The RTC SDK provides you with an interface method for camera management. You can manage the camera before audio and video calls to ensure that the device is working properly. By reading this article, you can learn how to manage cameras.

Overview

Alibaba Cloud RTC provides a series of camera management methods, including switching the front and rear cameras, zooming the lens, exposure settings, and focusing functions. You can set them before joining a channel to help you make the imaging clearer and the size and brightness more appropriate during a call.

Implementation method

The following table describes commonly used camera management methods. For more information, see AliRtcEngine interface.

  • getCurrentCameraType: obtains the current camera type.

    Returns the camera type AliRTCCameraType.

    public abstract AliRTCCameraType getCurrentCameraType()                   
  • isCameraOn: Check whether the camera is turned on.

    public abstract boolean isCameraOn()                   

    Return result

    true indicates that the camera is turned on. false indicates that the camera is not turned on.

  • setPreCameraType: preset camera direction.

    public abstract void setPreCameraType(int faceTo)                    
    Parameter description
    Parameter Type Description
    faceTo int 0 indicates the rear position, and 1 indicates the front position (the default value is 1).
  • getPreCameraType: obtains the preset camera direction.

    public abstract int getPreCameraType()                  

    Return result

    0 indicates the rear camera, and 1 indicates the front camera.

  • setCameraZoom: sets camera parameters.

    public abstract int setCameraZoom(float zoom, boolean flash, boolean autoFocus)                  
    Parameter description
    Parameter Type Description
    zoom float The zoom level (default value: 1.0).
    flash boolean true indicates that the flash is turned on. false indicates that the flash is not turned on. The flash is not turned on by default.
    autoFocus boolean true indicates that autofocus is turned on. false indicates that autofocus is not turned on. Auto focus is not turned on by default.

    Return result

    0 indicates that the setting is successful. Others indicate that the setting fails.

  • isCameraSupportExposurePoint: Whether the camera supports manual exposure.

    public abstract boolean isCameraSupportExposurePoint();

    Return result

    The value true indicates that the alert group can subscribe to weekly reports. The value false indicates that the alert group cannot subscribe to weekly reports.

  • isCameraSupportFocusPoint: Whether the camera supports manual focus.

    public abstract boolean isCameraSupportFocusPoint();

    Return result

    The value true indicates that the alert group can subscribe to weekly reports. The value false indicates that the alert group cannot subscribe to weekly reports.

  • setCameraExposurePoint: Sets the coordinate point for manual exposure.

    public abstract int setCameraExposurePoint(float x, float y);
    Parameter description
    Parameter Type Description
    x float The x coordinate.
    y float y coordinate.

    Return result

    0 indicates that the setting is successful. Others indicate that the setting fails.

  • setCameraFocusPoint: Sets the coordinate point for manual focus.

    public abstract int setCameraFocusPoint(float x, float y);
    Parameter description
    Parameter Type Description
    x float The x coordinate.
    y float y coordinate.

    Return result

    0 indicates that the setting is successful. Others indicate that the setting fails.

  • isCameraFlash: Check whether the camera flash is on.

    public abstract boolean isCameraFlash();

    Return result

    true indicates that it is enabled. false indicates that it is not enabled.

  • getCameraZoom: Gets the camera zoom value.

    public abstract float getCameraZoom();

    Return result

    Return value range: 0.0 to 1.0. 0 indicates the minimum value supported by the camera, and 1 indicates the maximum value supported by the camera.