Multiple camera support
Users can use both the front and back cameras of their iOS mobile devices simultaneously using the methods provided by the Video SDK. Multiple cameras can also be used while screen sharing. Fore more information, see ZoomVideoSDKVideoHelper Class Reference.
Support multiple cameras
Check if the user's device has multiple cameras and that other users in the session can see multiple video streams.
```swift
if let videoHelper = ZoomVideoSDK.shareInstance()?.getVideoHelper(), videoHelper.isMultiStreamSupported() {
}
```
```objectivec
BOOL isMultiStreamSupported = [[[ZoomVideoSDK shareInstance] getVideoHelper] isMultiStreamSupported];
if (isMultiStreamSupported) {
}
```
Get the device's available camera list and important information about each camera, including the
deviceIddeviceNameisSelectDeviceisSelectedAsMultiCameraisRunningAsMultiCamera
if let cameraList = videoHelper.getCameraDeviceList() {
for camera in cameraList {
// Each device contains deviceId, deviceName, isSelectDevice, isSelectedAsMultiCamera, isRunningAsMultiCamera and more.
}
}
NSArray *cameraList = [[[ZoomVideoSDK shareInstance] getVideoHelper] getCameraDeviceList];
for (ZoomVideoSDKCameraDevice *device in cameraList) {
// Each device contains deviceId, deviceName, isSelectDevice, isSelectedAsMultiCamera, isRunningAsMultiCamera and more.
}
With the available camera list, the user can then use the deviceId to choose which camera they want to enable, disable, unmute (turn on), or mute (turn off). These methods will trigger the onMultiCameraStreamStatusChanged callbacks with different parameters under the ZoomVideoSDKDelegate.
// To enable/disable multi video stream for a camera given its deviceID
let enableBOOLResult = videoHelper.enableMultiStreamVideo("cameraDeviceID", customDeviceName: nil)
let disableBOOLResult = videoHelper.disableMultiStreamVideo("cameraDeviceID")
// Enable/Disable will trigger the 2 onMultiCameraStreamStatusChanged callback under ZoomVideoSDKDelegate
func onMultiCameraStreamStatusChanged(_ status: ZoomVideoSDKMultiCameraStreamStatus, parentUser user: ZoomVideoSDKUser?, videoPipe: ZoomVideoSDKRawDataPipe?) {
// Getting ZoomVideoSDKRawDataPipe
}
func onMultiCameraStreamStatusChanged(_ status: ZoomVideoSDKMultiCameraStreamStatus, parentUser user: ZoomVideoSDKUser?, videoCanvas: ZoomVideoSDKVideoCanvas?) {
// Getting ZoomVideoSDKVideoCanvas
}
// To mute (turn off) / unmute (turn on) the multi video stream given its deviceID
let muteBOOLResult = videoHelper.muteMultiStreamVideo("cameraDeviceID")
let unmuteBOOLResult = videoHelper.unmuteMultiStreamVideo("cameraDeviceID")
// To enable/disable multi video stream for a camera given its deviceID
BOOL enableBOOLResult = [[[ZoomVideoSDK shareInstance] getVideoHelper] enableMultiStreamVideo:@"deviceID" customDeviceName:nil];
BOOL disableBOOLResult = [[[ZoomVideoSDK shareInstance] getVideoHelper] disableMultiStreamVideo:@"deviceID"];
// Enable/Disable will trigger the 2 onMultiCameraStreamStatusChanged callback under ZoomVideoSDKDelegate
- (void)onMultiCameraStreamStatusChanged:(ZoomVideoSDKMultiCameraStreamStatus)status parentUser:(ZoomVideoSDKUser *)user videoPipe:(ZoomVideoSDKRawDataPipe *)videoPipe
{
// Getting ZoomVideoSDKRawDataPipe
}
- (void)onMultiCameraStreamStatusChanged:(ZoomVideoSDKMultiCameraStreamStatus)status parentUser:(ZoomVideoSDKUser *)user videoCanvas:(ZoomVideoSDKVideoCanvas *)videoCanvas
{
// Getting ZoomVideoSDKVideoCanvas
}
// To mute (turn off) / unmute (turn on) the multi video stream given its deviceID
BOOL muteBOOLResult = [[[ZoomVideoSDK shareInstance] getVideoHelper] muteMultiStreamVideo:@"deviceID"];
BOOL unmuteBOOLResult = [[[ZoomVideoSDK shareInstance] getVideoHelper] unmuteMultiStreamVideo:@"deviceID"];
To find the deviceId in the raw data of the multi camera pipe or canvas, use the getDeviceIDByMyPipe or getDeviceIDByMyCanvas methods. For more information about handling raw data, see Raw data.
if let localUser = ZoomVideoSDK.shareInstance()?.getSession()?.getMySelf() {
// Get the user's multi camera stream - ZoomVideoSDKRawDataPipe
if let pipeList = localUser.getMultiCameraStreamList() {
for pipe in pipeList {
let deviceID = videoHelper.getDeviceID(byMyPipe: pipe)
}
}
// Get the user's multi camera canvas - ZoomVideoSDKVideoCanvas
if let canvasList = localUser.getMultiCameraCanvasList() {
for canvas in canvasList {
let deviceID = videoHelper.getDeviceID(byMyCanvas: canvas)
}
}
}
ZoomVideoSDKUser *localUser = [[[ZoomVideoSDK shareInstance] getSession] getMySelf];
// Get the user's multi camera stream - ZoomVideoSDKRawDataPipe
NSArray <ZoomVideoSDKRawDataPipe *> *pipeList = localUser.getMultiCameraStreamList;
for (ZoomVideoSDKRawDataPipe *pipe in pipeList) {
NSString *deviceID = [[[ZoomVideoSDK shareInstance] getVideoHelper] getDeviceIDByMyPipe:pipe];
}
// Get the user's multi camera canvas - ZoomVideoSDKVideoCanvas
NSArray <ZoomVideoSDKVideoCanvas *> *canvasList = localUser.getMultiCameraCanvasList;
for (ZoomVideoSDKVideoCanvas *canvas in canvasList) {
NSString *deviceId = [[[ZoomVideoSDK shareInstance] getVideoHelper] getDeviceIDByMyCanvas:canvas];
}