iOS

更新时间:
复制 MD 格式

The Real-time Communication (RTC) SDK provides device detection and management features. You can use these features to verify that your hardware devices are working correctly before you join a channel. This topic describes how to detect and manage devices.

Overview

RTC SDK allows you to call internal methods to detect and manage devices. For example, you can query the information about devices, detect whether the camera works as expected, detect whether the audio device can record and play audio files, switch between front and rear cameras, or change audio devices (microphone and speaker).

Implementation methods

The following are common methods for device detection and management. For more information, see the AliRtcEngine interface.

  • switchCamera: Switches between the front and rear cameras. The front camera is used by default. (iOS only).
    - (int)switchCamera;
    Return value

    0 indicates a successful call. Other values indicate a failed call.

  • setCameraZoom: Sets the camera zoom ratio. (iOS only).
    - (int)setCameraZoom:(float)zoom;
    Parameters
    NameTypeDescription
    zoomfloatThe zoom level. The default value is 1.0.
    Return value

    0 indicates a successful call. Other values indicate a failed call.

  • setCameraFlash: Enables or disables the camera flash. (iOS only).
    - (int)setCameraFlash:(BOOL)flash;
    Parameters
    NameTypeDescription
    flashBOOLYES: Enables the flash. NO: Disables the flash. The default value is NO.
    Return value

    0 indicates a successful call. Other values indicate a failed call.

  • setCameraAutoFocusFaceModeEnabled: Enables or disables face-based autofocus for the camera. (iOS only).
    - (BOOL)setCameraAutoFocusFaceModeEnabled:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLYES: Enables face-based autofocus. NO: Disables face-based autofocus. The default value is NO.
    Return value

    YES indicates a successful call. NO indicates a failed call.

  • isCameraOn: Checks if the camera is on.
    - (BOOL)isCameraOn;
    Return value

    YES indicates that the camera is on. NO indicates that the camera is off.

  • enableSpeakerphone: Switches the audio output between the earpiece and the speaker. (iOS only).
    - (int)enableSpeakerphone:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLYES: Enables speaker mode. NO: Enables earpiece mode. The default value is YES.
    Return value

    0 indicates a successful call. Other values indicate a failed call.