Tencent Cloud Device Management Module
Module: audio/video device management module Description: manages audio/video devices such as camera, mic, and speaker.
Properties | |
TXMediaDeviceType | type |
NSString * | deviceId |
NSString * | deviceName |
Type definitions of audio/video devices | |
enum | TXSystemVolumeType : NSInteger |
enum | TXAudioRoute : NSInteger |
enum | TXMediaDeviceType : NSInteger |
class TXMediaDeviceInfo |
Properties | |
TXMediaDeviceType | type |
NSString * | deviceId |
NSString * | deviceName |
class TXDeviceManager |
Device APIs for mobile OS | |
(BOOL) | - isFrontCamera |
(NSInteger) | - switchCamera |
(BOOL) | - isCameraZoomSupported |
(CGFloat) | - getCameraZoomMaxRatio |
(NSInteger) | - setCameraZoomRatio |
(BOOL) | - isAutoFocusEnabled |
(NSInteger) | - enableCameraAutoFocus |
(NSInteger) | - setCameraFocusPosition |
(BOOL) | - isCameraTorchSupported |
(NSInteger) | - enableCameraTorch |
(NSInteger) | - setAudioRoute |
(NSInteger) | - setSystemVolumeType |
Device APIs for desktop OS | |
(NSArray< TXMediaDeviceInfo * > *_Nullable) | - getDevicesList |
(NSInteger) | - setCurrentDevice:deviceId |
(TXMediaDeviceInfo *_Nullable) | - getCurrentDevice |
(NSInteger) | - setCurrentDeviceVolume:deviceType |
(NSInteger) | - getCurrentDeviceVolume |
(NSInteger) | - setCurrentDeviceMute:deviceType |
(BOOL) | - getCurrentDeviceMute |
(NSInteger) | - startCameraDeviceTest |
(NSInteger) | - stopCameraDeviceTest |
(NSInteger) | - startMicDeviceTest:testEcho |
(NSInteger) | - stopMicDeviceTest |
(NSInteger) | - startSpeakerDeviceTest:onVolumeChanged |
(NSInteger) | - stopSpeakerDeviceTest |
- (BOOL) isFrontCamera |
Querying whether the front camera is being used
- (NSInteger) switchCamera: | (BOOL) | frontCamera |
Switching to the front/rear camera (for mobile OS)
- (BOOL) isCameraZoomSupported |
Querying whether the current camera supports zooming (for mobile OS)
- (CGFloat) getCameraZoomMaxRatio |
Getting the maximum zoom ratio of the camera (for mobile OS)
- (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). |
- (BOOL) isAutoFocusEnabled |
Querying whether automatic face detection is supported (for mobile OS)
- (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) 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. |
- (BOOL) isCameraTorchSupported |
Querying whether flash is supported (for mobile OS)
- (NSInteger) enableCameraTorch: | (BOOL) | enabled |
Enabling/Disabling flash, i.e., the torch mode (for mobile OS)
- (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) setSystemVolumeType: | (TXSystemVolumeType) | type |
Setting the system volume type (for mobile OS)
- (NSArray<TXMediaDeviceInfo *> * _Nullable) getDevicesList: | (TXMediaDeviceType) | type |
Getting the device list (for desktop OS)
- (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. |
- (TXMediaDeviceInfo * _Nullable) getCurrentDevice: | (TXMediaDeviceType) | type |
Getting the device currently in use (for desktop OS)
- (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 |
- (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.
- (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.
- (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) startCameraDeviceTest: | (NSView *) | view |
Starting camera testing (for desktop OS)
- (NSInteger) stopCameraDeviceTest |
Ending 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) stopMicDeviceTest |
Ending mic testing (for desktop OS)
- (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) stopSpeakerDeviceTest |
Ending speaker testing (for desktop OS)
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.
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 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 |
|
readwritenonatomicassign |
device type
|
readwritenonatomiccopy |
device id
|
readwritenonatomiccopy |
device name