Data Structures | |
class | TXMediaDeviceInfo |
protocol | <TXDeviceObserver> |
class | TXDeviceManager |
Type definitions of audio/video devices | |
enum | TXSystemVolumeType : NSInteger |
enum | TXAudioRoute : NSInteger |
enum | TXMediaDeviceType : NSInteger |
enum | TXMediaDeviceState : NSInteger |
Tencent Cloud Device Management Module.
Module: audio/video device management module Description: manages audio/video devices such as camera, mic, and speaker.
class TXMediaDeviceInfo |
Audio/Video device information (for desktop OS)
This structure describes key information (such as device ID and device name) of an audio/video device, so that users can choose on the UI the device to use.
Properties | |
TXMediaDeviceType | type |
NSString * | deviceId |
NSString * | deviceName |
NSString * | deviceProperties |
|
readwritenonatomiccopy |
device id
|
readwritenonatomiccopy |
device name
|
readwritenonatomiccopy |
device properties
|
readwritenonatomicassign |
device type
protocol TXDeviceObserver-p |
The status of a local device changed (for desktop OS only)
The SDK returns this callback when a local device (camera, mic, or speaker) is connected or disconnected.
deviceId | Device ID |
type | Device type |
state | Device status. 0 : connected; 1 : disconnected; 2 : started |
Instance Methods | |
(void) | - onDeviceChanged:type:state: |
- (void) onDeviceChanged: | (NSString *) | deviceId | |
type: | (TXMediaDeviceType) | mediaType | |
state: | (TXMediaDeviceState) | mediaState | |
class TXDeviceManager |
- (NSInteger) enableCameraAutoFocus: | (BOOL) | enabled |
Enabling auto focus (for mobile OS)
After auto focus is enabled, the camera will automatically detect and always focus on faces.
- (NSInteger) enableCameraTorch: | (BOOL) | enabled |
Enabling/Disabling flash, i.e., the torch mode (for mobile OS)
- (CGFloat) getCameraZoomMaxRatio |
Getting the maximum zoom ratio of the camera (for mobile OS)
- (TXMediaDeviceInfo *_Nullable) getCurrentDevice: | (TXMediaDeviceType) | type |
Getting the device currently in use (for desktop OS)
- (BOOL) getCurrentDeviceMute: | (TXMediaDeviceType) | type |
Querying whether the current device is muted (for desktop OS)
This API is used to query whether the mic or speaker is muted. Camera muting is not supported.
- (NSInteger) getCurrentDeviceVolume: | (TXMediaDeviceType) | type |
Getting the volume of the current device (for desktop OS)
This API is used to get the capturing volume of the mic or playback volume of the speaker, but not the volume of the camera.
- (NSArray<TXMediaDeviceInfo *> *_Nullable) getDevicesList: | (TXMediaDeviceType) | type |
Getting the device list (for desktop OS)
type | Device type. Set it to the type of device you want to get. For details, please see the definition of TXMediaDeviceType . |
ITXDeviceCollection
object, after using this API, please call the release
method to release the resources.delete
to release the Collection object returned as deleting the ITXDeviceCollection* pointer will cause crash.type
are TXMediaDeviceTypeMic
, TXMediaDeviceTypeSpeaker
, and TXMediaDeviceTypeCamera
.- (BOOL) isAutoFocusEnabled |
Querying whether automatic face detection is supported (for mobile OS)
- (BOOL) isCameraTorchSupported |
Querying whether flash is supported (for mobile OS)
- (BOOL) isCameraZoomSupported |
Querying whether the current camera supports zooming (for mobile OS)
- (BOOL) isFrontCamera |
Querying whether the front camera is being used
- (NSInteger) setAudioRoute: | (TXAudioRoute) | route |
Setting the audio route (for mobile OS)
A mobile phone has two audio playback devices: the receiver at the top and the speaker at the bottom. If the audio route is set to the receiver, the volume is relatively low, and audio can be heard only when the phone is put near the ear. This mode has a high level of privacy and is suitable for answering calls. If the audio route is set to the speaker, the volume is relatively high, and there is no need to put the phone near the ear. This mode enables the "hands-free" feature.
- (NSInteger) setCameraFocusPosition: | (CGPoint) | position |
Adjusting the focus (for mobile OS)
This API can be used to achieve the following:
position | The spot to focus on. Pass in the coordinates of the spot you want to focus on. |
- (NSInteger) setCameraZoomRatio: | (CGFloat) | zoomRatio |
Setting the camera zoom ratio (for mobile OS)
zoomRatio | Value range: 1-5. 1 indicates the widest angle of view (original), and 5 the narrowest angle of view (zoomed in). |
- (NSInteger) setCurrentDevice: | (TXMediaDeviceType) | type | |
deviceId: | (NSString *) | deviceId | |
Setting the device to use (for desktop OS)
type | Device type. For details, please see the definition of TXMediaDeviceType . |
deviceId | Device ID. You can get the ID of a device using the getDevicesList API. |
- (NSInteger) setCurrentDeviceMute: | (BOOL) | mute | |
deviceType: | (TXMediaDeviceType) | type | |
Muting the current device (for desktop OS)
This API is used to mute the mic or speaker, but not the camera.
- (NSInteger) setCurrentDeviceVolume: | (NSInteger) | volume | |
deviceType: | (TXMediaDeviceType) | type | |
Setting the volume of the current device (for desktop OS)
This API is used to set the capturing volume of the mic or playback volume of the speaker, but not the volume of the camera.
volume | Volume. Value range: 0-100; default: 100 |
- (void) setObserver: | (nullable id< TXDeviceObserver >) | observer |
set onDeviceChanged callback (for Mac)
- (NSInteger) setSystemVolumeType: | (TXSystemVolumeType) | type |
Setting the system volume type (for mobile OS)
startLocalAudio(quality)
API in TRTCCloud instead, which param quality
is used to decide audio quality. - (NSInteger) startCameraDeviceTest: | (NSView *) | view |
Starting camera testing (for desktop OS)
- (NSInteger) startMicDeviceTest: | (NSInteger) | interval | |
testEcho: | (void(^)(NSInteger volume)) | testEcho | |
Starting mic testing (for desktop OS)
This API is used to test whether the mic functions properly. The mic volume detected (value range: 0-100) is returned via a callback.
interval | Interval of volume callbacks |
- (NSInteger) startSpeakerDeviceTest: | (NSString *) | audioFilePath | |
onVolumeChanged: | (void(^)(NSInteger volume, BOOL isLastFrame)) | volumeBlock | |
Starting speaker testing (for desktop OS)
This API is used to test whether the audio playback device functions properly by playing a specified audio file. If users can hear audio during testing, the device functions properly.
filePath | Path of the audio file |
- (NSInteger) stopCameraDeviceTest |
Ending camera testing (for desktop OS)
- (NSInteger) stopMicDeviceTest |
Ending mic testing (for desktop OS)
- (NSInteger) stopSpeakerDeviceTest |
Ending speaker testing (for desktop OS)
- (NSInteger) switchCamera: | (BOOL) | frontCamera |
Switching to the front/rear camera (for mobile OS)
enum TXAudioRoute : NSInteger |
Audio route (the route via which audio is played)
Audio route is the route (speaker or receiver) via which audio is played. It applies only to mobile devices such as mobile phones. A mobile phone has two speakers: one at the top (receiver) and the other the bottom.
enum TXMediaDeviceState : NSInteger |
Device operation
This enumerated value is used to notify the status change of the local device onDeviceChanged.
Enumerator | |
---|---|
TXMediaDeviceStateAdd | The device has been plugged in. |
TXMediaDeviceStateRemove | The device has been removed. |
TXMediaDeviceStateActive | The device has been enabled. |
enum TXMediaDeviceType : NSInteger |
Device type (for desktop OS)
This enumerated type defines three types of audio/video devices, namely camera, mic and speaker, so that you can use the same device management API to manage three types of devices.
Enumerator | |
---|---|
TXMediaDeviceTypeUnknown | undefined device type |
TXMediaDeviceTypeAudioInput | microphone |
TXMediaDeviceTypeAudioOutput | speaker or earpiece |
TXMediaDeviceTypeVideoCamera | camera |
enum TXSystemVolumeType : NSInteger |
System volume type (for mobile devices only)
Smartphones usually have two types of system volume: call volume and media volume.
The SDK offers three system volume control modes: auto, call volume, and media volume.
Enumerator | |
---|---|
TXSystemVolumeTypeAuto | Auto. |
TXSystemVolumeTypeMedia | Media volume. |
TXSystemVolumeTypeVOIP | Call volume. |