The Real-time Communication (RTC) SDK provides device detection and management features. You can use these features to verify that your hardware devices are working correctly before you join a channel. This topic describes how to detect and manage devices.
Overview
RTC SDK allows you to call internal methods to detect and manage devices. For example, you can query the information about devices, detect whether the camera works as expected, detect whether the audio device can record and play audio files, switch between front and rear cameras, or change audio devices (microphone and speaker).
Implementation methods
The following are common methods for device detection and management. For more information, see the AliRtcEngine interface.
- switchCamera: Switches between the front and rear cameras. The front camera is used by default. (iOS only).
Return value- (int)switchCamera;0 indicates a successful call. Other values indicate a failed call.
- setCameraZoom: Sets the camera zoom ratio. (iOS only).
Parameters- (int)setCameraZoom:(float)zoom;
Return valueName Type Description zoom float The zoom level. The default value is 1.0. 0 indicates a successful call. Other values indicate a failed call.
- setCameraFlash: Enables or disables the camera flash. (iOS only).
Parameters- (int)setCameraFlash:(BOOL)flash;
Return valueName Type Description flash BOOL YES: Enables the flash. NO: Disables the flash. The default value is NO. 0 indicates a successful call. Other values indicate a failed call.
- setCameraAutoFocusFaceModeEnabled: Enables or disables face-based autofocus for the camera. (iOS only).
Parameters- (BOOL)setCameraAutoFocusFaceModeEnabled:(BOOL)enable;
Return valueName Type Description enable BOOL YES: Enables face-based autofocus. NO: Disables face-based autofocus. The default value is NO. YES indicates a successful call. NO indicates a failed call.
- isCameraOn: Checks if the camera is on.
Return value- (BOOL)isCameraOn;YES indicates that the camera is on. NO indicates that the camera is off.
- enableSpeakerphone: Switches the audio output between the earpiece and the speaker. (iOS only).
Parameters- (int)enableSpeakerphone:(BOOL)enable;
Return valueName Type Description enable BOOL YES: Enables speaker mode. NO: Enables earpiece mode. The default value is YES. 0 indicates a successful call. Other values indicate a failed call.