import { NativeModules } from 'react-native'; import type { Errors } from '../native/ZoomVideoSdk'; const { RNZoomVideoSdkVideoHelper } = NativeModules; export enum VideoPreferenceMode { Balance = 'ZoomVideoSDKVideoPreferenceMode_Balance', Sharpness = 'ZoomVideoSDKVideoPreferenceMode_Sharpness', Smoothness = 'ZoomVideoSDKVideoPreferenceMode_Smoothness', Custom = 'ZoomVideoSDKVideoPreferenceMode_Custom', } export type VideoPreferenceSetting = { mode?: VideoPreferenceMode; maximumFrameRate?: number; minimumFrameRate?: number; }; export type ZoomVideoSdkCameraDeviceType = { deviceId: string; deviceName: string; isSelectedDevice: boolean; }; /** * An interface to control video and manage cameras during a video session. */ export type ZoomVideoSdkVideoHelperType = { /** * Call this method to start sending local video data from the camera. */ startVideo: () => Promise; /** * Call this method to stop sending local video data from the camera. */ stopVideo: () => Promise; /** * Switch to the next available camera. */ switchCamera: (deviceId?: string) => Promise; /** * Call this method to rotate the video when the device is rotated. */ rotateMyVideo: (rotation: number) => Promise; /** * Get the list of camera devices. */ getCameraList: () => Promise; /** * Get the number of cameras available to share the video. */ getNumberOfCameras: () => Promise; /** * Determine whether current aspect ratio is the original aspect ratio of video. */ isOriginalAspectRatioEnabled: () => Promise; /** * This function is used to set the aspect ratio of the video sent out. */ enableOriginalAspectRatio: (enable: boolean) => Promise; /** * Determine whether my video is mirrored. */ isMyVideoMirrored: () => Promise; /** * Call this method to mirror my video. */ mirrorMyVideo: (enable: boolean) => Promise; /** * Turn on or off the flashlight (Only support Android platform). */ turnOnOrOffFlashlight: (enable: boolean) => Promise; /** * Return true if support to control the flashlight (Only support Android platform). */ isSupportFlashlight: () => Promise; /** * Return true if the flashlight is on. Otherwise, it'll return false (Only support Android platform). */ isFlashlightOn: () => Promise; }; export class ZoomVideoSdkVideoHelper implements ZoomVideoSdkVideoHelperType { async startVideo() { return await RNZoomVideoSdkVideoHelper.startVideo(); } async stopVideo() { return await RNZoomVideoSdkVideoHelper.stopVideo(); } async switchCamera(deviceId?: string) { return await RNZoomVideoSdkVideoHelper.switchCamera(deviceId); } async rotateMyVideo(rotation: number) { return await RNZoomVideoSdkVideoHelper.rotateMyVideo(rotation); } async getCameraList(): Promise { return await RNZoomVideoSdkVideoHelper.getCameraList(); } async getNumberOfCameras() { return await RNZoomVideoSdkVideoHelper.getNumberOfCameras(); } async isOriginalAspectRatioEnabled() { return await RNZoomVideoSdkVideoHelper.isOriginalAspectRatioEnabled(); } async enableOriginalAspectRatio(enable: boolean) { return await RNZoomVideoSdkVideoHelper.enableOriginalAspectRatio(enable); } async isMyVideoMirrored() { return await RNZoomVideoSdkVideoHelper.isMyVideoMirrored(); } async mirrorMyVideo(enable: boolean) { return await RNZoomVideoSdkVideoHelper.mirrorMyVideo(enable); } /** * Turn on or off the flashlight (Only support Android platform). * @param {boolean} enable - True means to turn it on. False is to turn it off. */ async turnOnOrOffFlashlight(enable: boolean) { return await RNZoomVideoSdkVideoHelper.turnOnOrOffFlashlight(enable); } /** * Return true if support to control the flashlight (Only support Android platform). */ async isSupportFlashlight() { return await RNZoomVideoSdkVideoHelper.isSupportFlashlight(); } /** * Return true if the flashlight is on. Otherwise, it'll return false (Only support Android platform). */ async isFlashlightOn() { return await RNZoomVideoSdkVideoHelper.isFlashlightOn(); } }