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.

  • switchCamera (iOS only): Switch the front and rear cameras.

    - (int)switchCamera;

    Return result

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

  • setCameraZoom (available for iOS only): Set camera parameters.

     - (int)setCameraZoom:(float)zoom flash:(BOOL)flash autoFocus:(BOOL)autoFocus;
    Parameter description
    Parameter Type Description
    zoom float The level of zoom. Valid values:-3.0 to 3.0. Default value: 1.0.
    flash BOOL Specifies whether to turn on the flash. YES is to turn on the flash, NO is not to turn on the flash. The flash is not turned on by default.
    autoFocus BOOL Specifies whether to turn on autofocus. YES is to turn on autofocus, NO is not to turn on autofocus. Auto focus is not turned on by default.

    Return result

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

  • isCameraOn (iOS only available): Check if the camera is on.

    - (BOOL)isCameraOn;

    Return result

    YES indicates that the camera is turned on, and NO indicates that the camera is not turned on.

  • isCameraFocusPointSupported (available for iOS only): Whether the camera supports manual focus.

    - (BOOL)isCameraFocusPointSupported;

    Return result

    YES indicates that manual focus is supported. NO indicates that manual focus is not supported.

  • isCameraExposurePointSupported (available for iOS only): Whether the camera supports manual exposure.

    - (BOOL)isCameraExposurePointSupported;

    Return result

    YES indicates that manual exposure is supported. NO indicates that manual exposure is not supported.

  • 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.

  • setCameraExposurePoint (available for iOS only): Sets the coordinate point for manual exposure.

    - (int)setCameraExposurePoint:(CGPoint)point;
    Parameter description
    Parameter Type Description
    point CGPoint The coordinates of the exposure point.

    Return result

    0 indicates success, others indicate failure.