Android

更新时间:
复制 MD 格式

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.
    public abstract AliRTCCameraDirection getCurrentCameraDirection();
    Return value
    • 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.
    public abstract boolean isCameraOn();
    Return value

    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.
    public abstract int switchCamera();
    Return value

    0: The method call is successful. Other values indicate that the method call failed.

  • setCameraZoom: Sets the camera zoom ratio.
    public abstract int setCameraZoom(float zoom);
    Parameters
    ParameterTypeDescription
    zoomfloatThe zoom ratio. The default value is 1.0.
    Return value

    0: The method call is successful. Other values indicate that the method call failed.

  • setCameraFlash: Turns the camera flash on or off.
    public abstract int setCameraFlash(boolean flash);
    Parameters
    ParameterTypeDescription
    flashbooleanSpecifies whether to turn on the camera flash. Valid values:
    • true: Turn on.
    • false (default): Turn off.
    Return value

    0: The method call is successful. Other values indicate that the method call failed.

  • setCameraAutoFocusFaceModeEnabled: Enables or disables face auto-focus for the camera.
    public abstract boolean setCameraAutoFocusFaceModeEnabled(boolean enable);
    Parameters
    ParameterTypeDescription
    enablebooleanSpecifies whether to enable face auto-focus for the camera. Valid values:
    • true: Enable.
    • false (default): Disable.
    Return value

    Returns true if the operation is successful, or false if the operation failed.

  • isCameraAutoFocusFaceModeSupported: Checks whether the camera supports face auto-focus.
    public abstract boolean isCameraAutoFocusFaceModeSupported();
    Return value

    Returns true if supported, or false otherwise.

  • setCameraExposurePoint: Sets the camera exposure point.
    public abstract int setCameraExposurePoint(float pointX, float pointY);
    Parameters
    ParameterTypeDescription
    pointXfloatThe x-coordinate of the exposure point.
    pointYfloatThe y-coordinate of the exposure point.
    Return value

    0: The method call is successful. Other values indicate that the method call failed.

  • setCameraFocusPoint: Sets the manual focus point for the camera.
    public abstract int setCameraFocusPoint(float pointX, float pointY);
    Parameters
    ParameterTypeDescription
    pointXfloatThe x-coordinate of the focus point.
    pointYfloatThe y-coordinate of the focus point.
    Return value

    0: The method call is successful. Other values indicate that the method call failed.