The RTC software development kit (SDK) provides features for device detection and management. You can check whether your hardware devices are working correctly before you join a channel. This topic describes the methods used for device detection and management.
Feature description
The RTC SDK provides internal methods to detect and manage devices. For example, you can query device information, check if the camera is working correctly, test audio recording and playback, set the camera direction, or switch between audio devices such as the microphone and speaker.
Implementation
The following are common methods for device detection and management. For more information, see the AliRtcEngine interface.
- getCurrentCameraDirection: Returns the current camera direction.
Return valuepublic abstract AliRTCCameraDirection getCurrentCameraDirection();- CAMERA_REAR(0): The rear-facing camera.
- CAMERA_FRONT(1): The front-facing camera.
- CAMERA_INVALID(-1): Invalid.
Note Call this method after the camera is turned on. Otherwise, CAMERA_INVALID(-1) is returned. - isCameraOn: Checks if the camera is on.
Return valuepublic abstract boolean isCameraOn();true: The camera is on. false: The camera is off.
- isSpeakerOn: Checks whether the current audio output is the earpiece or the speaker.
Return valuepublic abstract boolean isSpeakerOn();true: The speaker. false: The earpiece.
- switchCamera: Switches between the front and rear cameras. The default camera is the front-facing camera.
Return valuepublic abstract int switchCamera();0: The method call is successful. Other values indicate that the method call failed.
- setCameraZoom: Sets the camera zoom ratio.
Parameter descriptionpublic abstract int setCameraZoom(float zoom);
Return valueParameter Type Description zoom float The zoom level. The default value is 1.0. 0: The method call is successful. Other values indicate that the method call failed.
- setCameraFlash: Sets whether to turn on the camera flash.
Parameter descriptionpublic abstract int setCameraFlash(boolean flash);
Return valueParameter Type Description flash boolean Specifies whether to turn on the camera flash. Valid values: - true: Enabled.
- false (default): shutdown.
0: The method call is successful. Other values indicate that the method call failed.
- setCameraAutoFocusFaceModeEnabled: Enables or disables face autofocus for the camera.
Parameter descriptionpublic abstract boolean setCameraAutoFocusFaceModeEnabled(boolean enable);
Return valueParameter Type Description enable boolean Specifies whether to enable face autofocus for the camera. Valid values: - true: Enabled.
- false (default): Disabled.
true: The method call was successful. false: The method call failed.
- enableSpeakerphone: Sets the audio output to the speaker or the earpiece.
Parameter descriptionpublic abstract int enableSpeakerphone(boolean enable);
Return valueParameter Type Description enable boolean Specifies whether to use the earpiece or the speaker for audio output. Valid values: - true (default): Speaker mode.
- false: Earpiece mode.
0: The method call is successful. Other values indicate that the method call failed.