Camera controls

The Video SDK for iOS lets you control the local user's camera during a session: switch, mirror, rotate, and set the aspect ratio. These per-device operations run through ZoomVideoSDKVideoHelper. For using two cameras at the same time, see Multiple camera support.

Get the camera list

To enumerate the cameras available on the device, call getCameraDeviceList on the ZoomVideoSDKVideoHelper. Each entry carries the deviceId you'll need for switchCamera and the multi-camera APIs, along with deviceName, isSelectDevice, isSelectedAsMultiCamera, and isRunningAsMultiCamera.

if let cameraList = ZoomVideoSDK.shareInstance()?.getVideoHelper()?.getCameraDeviceList() {
    for camera in cameraList {
        // Each device exposes deviceId, deviceName, isSelectDevice, and more.
    }
}
NSArray<ZoomVideoSDKCameraDevice *> *cameraList = [[[ZoomVideoSDK shareInstance] getVideoHelper] getCameraDeviceList];
for (ZoomVideoSDKCameraDevice *camera in cameraList) {
    // Each device exposes deviceId, deviceName, isSelectDevice, and more.
}

To read the currently selected camera, use getSelectedCamera.

Switch camera

Call switchCamera with no arguments to cycle to the next available camera. On most devices this toggles between the front and back camera.

ZoomVideoSDK.shareInstance()?.getVideoHelper()?.switchCamera()
[[[ZoomVideoSDK shareInstance] getVideoHelper] switchCamera];

To switch to a specific camera, pass a deviceId from getCameraDeviceList.

let didSwitch = ZoomVideoSDK.shareInstance()?.getVideoHelper()?.switchCamera("cameraDeviceID")
BOOL didSwitch = [[[ZoomVideoSDK shareInstance] getVideoHelper] switchCamera:@"cameraDeviceID"];

Mirror the local video

Mirroring is a common convention for the front-facing camera, so the user sees themselves the way they would in a mirror. Use mirrorMyVideo(true) to enable and mirrorMyVideo(false) to disable. Use isMyVideoMirrored to read the current state.

let videoHelper = ZoomVideoSDK.shareInstance()?.getVideoHelper()
videoHelper?.mirrorMyVideo(true)
let isMirrored = videoHelper?.isMyVideoMirrored()
ZoomVideoSDKVideoHelper *videoHelper = [[ZoomVideoSDK shareInstance] getVideoHelper];
[videoHelper mirrorMyVideo:YES];
BOOL isMirrored = [videoHelper isMyVideoMirrored];

Rotate the local video

When the device orientation changes, call rotateMyVideo with the new UIDeviceOrientation to update the orientation of the locally captured video.

ZoomVideoSDK.shareInstance()?.getVideoHelper()?.rotateMyVideo(UIDevice.current.orientation)
[[[ZoomVideoSDK shareInstance] getVideoHelper] rotateMyVideo:[UIDevice currentDevice].orientation];

A common pattern is to observe UIDevice.orientationDidChangeNotification and call rotateMyVideo with the new value.

Aspect ratio of the local video

By default, the SDK renders video at the source aspect ratio. To force the original aspect ratio, use enableOriginalAspectRatio. Check the current setting with isOriginalAspectRatioEnabled.

ZoomVideoSDK.shareInstance()?.getVideoHelper()?.enableOriginalAspectRatio(true)
[[[ZoomVideoSDK shareInstance] getVideoHelper] enableOriginalAspectRatio:YES];

Alpha channel mode

Alpha channel mode lets the SDK render video with a transparent background, useful for compositing a user's video over other UI content (for example, a presenter video overlaid on a slide deck). Both the device hardware and the current session state gate this feature, so capability-check before enabling.

  • isDeviceSupportAlphaChannelMode: does the device hardware support it? Check once.
  • canEnableAlphaChannelMode: can the mode be toggled in the current session state? Check before each enable call.
  • enableAlphaChannelMode: turn the mode on or off.
  • isAlphaChannelModeEnabled: read the current state.
let videoHelper = ZoomVideoSDK.shareInstance()?.getVideoHelper()
if videoHelper?.isDeviceSupportAlphaChannelMode() == true,
   videoHelper?.canEnableAlphaChannelMode() == true {
    videoHelper?.enableAlphaChannelMode(true)
}
let isOn = videoHelper?.isAlphaChannelModeEnabled()
ZoomVideoSDKVideoHelper *videoHelper = [[ZoomVideoSDK shareInstance] getVideoHelper];
if ([videoHelper isDeviceSupportAlphaChannelMode] && [videoHelper canEnableAlphaChannelMode]) {
    [videoHelper enableAlphaChannelMode:YES];
}
BOOL isOn = [videoHelper isAlphaChannelModeEnabled];

The SDK fires onVideoAlphaChannelStatusChanged whenever the mode is toggled. To read the per-pixel alpha mask from the raw video pipeline, see Raw video with alpha channel.