The Real-time Communication (RTC) SDK provides API methods to manage the camera. Before an audio or video call, you can use these methods to ensure that the device works properly. This topic describes the available camera management methods.
Feature overview
Alibaba Cloud RTC provides several camera management methods. These include switching between front and rear cameras, zooming, exposure settings, and focus. You can configure these settings before you join a channel to obtain clearer images with the correct size and brightness during a call.
Methods
The following are common camera management methods. For more information, see the AliRtcEngine interface.
- getCurrentCameraDirection: Retrieves the current camera direction.
Return valuepublic abstract AliRTCCameraDirection getCurrentCameraDirection();- Returns CAMERA_REAR(0) for the rear camera.
- Returns CAMERA_FRONT(1) for the front camera.
- Returns CAMERA_INVALID(-1) if the camera is invalid.
Note Call this method after the camera is turned on. Otherwise, the method returns CAMERA_INVALID(-1). - isCameraOn: Checks whether the camera is on.
Return valuepublic abstract boolean isCameraOn();Returns true if the camera is on, or false otherwise.
- switchCamera: Switches between the front and rear cameras. The front camera is used by default.
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.
Parameterspublic abstract int setCameraZoom(float zoom);
Return valueParameter Type Description zoom float The zoom ratio. The default value is 1.0. 0: The method call is successful. Other values indicate that the method call failed.
- setCameraFlash: Turns the camera flash on or off.
Parameterspublic abstract int setCameraFlash(boolean flash);
Return valueParameter Type Description flash boolean Specifies whether to turn on the camera flash. Valid values: - true: Turn on.
- false (default): Turn off.
0: The method call is successful. Other values indicate that the method call failed.
- setCameraAutoFocusFaceModeEnabled: Enables or disables face auto-focus for the camera.
Parameterspublic abstract boolean setCameraAutoFocusFaceModeEnabled(boolean enable);
Return valueParameter Type Description enable boolean Specifies whether to enable face auto-focus for the camera. Valid values: - true: Enable.
- false (default): Disable.
Returns true if the operation is successful, or false if the operation failed.
- isCameraAutoFocusFaceModeSupported: Checks whether the camera supports face auto-focus.
Return valuepublic abstract boolean isCameraAutoFocusFaceModeSupported();Returns true if supported, or false otherwise.
- setCameraExposurePoint: Sets the camera exposure point.
Parameterspublic abstract int setCameraExposurePoint(float pointX, float pointY);
Return valueParameter Type Description pointX float The x-coordinate of the exposure point. pointY float The y-coordinate of the exposure point. 0: The method call is successful. Other values indicate that the method call failed.
- setCameraFocusPoint: Sets the manual focus point for the camera.
Parameterspublic abstract int setCameraFocusPoint(float pointX, float pointY);
Return valueParameter Type Description pointX float The x-coordinate of the focus point. pointY float The y-coordinate of the focus point. 0: The method call is successful. Other values indicate that the method call failed.