| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- import { ZoomVideoSDKErrors } from './zoom_video_sdk_defines.js'
- import messages from './electron_zoomvideosdk_pb.js'
- export default (function () {
- var instance
- /**
- * Return an instance to manage screen sharing during a video SDK session.
- * @module zoom_video_sdk_share
- * @return {ZoomVideoSDKShare}
- */
- function init (opts) {
- const clientOpts = {...opts}
- // Private methods and variables
- if (!clientOpts.addon) {
- return null
- }
- const _addon = clientOpts.addon.GetShareHelper() || null
- return {
- // Public methods and variables
- /**
- * Share a window
- * @method startShareView
- * @param {String} handle the window handle that will to be share
- * @param {Boolean} isWithDeviceAudio true is share computer sound when share screen/window, otherwise not.
- * @param {Boolean} isOptimizeForSharedVideo true is optimize the frame rate when share screen/window, otherwise not.
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- startShareView: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const handle = clientOpts.handle
- const isWithDeviceAudio = clientOpts.isWithDeviceAudio || false
- const isOptimizeForSharedVideo = clientOpts.isOptimizeForSharedVideo || false
- const StartShareViewParams = new messages.StartShareViewParams()
- StartShareViewParams.setZnHandle(handle)
- StartShareViewParams.setIswithdeviceaudio(isWithDeviceAudio)
- StartShareViewParams.setIsoptimizeforsharedvideo(isOptimizeForSharedVideo)
- const bytes = StartShareViewParams.serializeBinary()
- return _addon.StartShareView(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Share a screen
- * @method startShareScreen
- * @param {String} monitorID the screen name that will to be share
- * @param {Boolean} isWithDeviceAudio true is share computer sound when share screen/window, otherwise not.
- * @param {Boolean} isOptimizeForSharedVideo true is optimize the frame rate when share screen/window, otherwise not.
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- startShareScreen: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const monitorID = clientOpts.monitorID
- const isWithDeviceAudio = clientOpts.isWithDeviceAudio || false
- const isOptimizeForSharedVideo = clientOpts.isOptimizeForSharedVideo || false
- const StartShareScreenParams = new messages.StartShareScreenParams()
- StartShareScreenParams.setZnMonitorid(monitorID)
- StartShareScreenParams.setIswithdeviceaudio(isWithDeviceAudio)
- StartShareScreenParams.setIsoptimizeforsharedvideo(isOptimizeForSharedVideo)
- const bytes = StartShareScreenParams.serializeBinary()
- return _addon.StartShareScreen(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Start sharing only the computer audio.
- * @method startShareComputerAudio
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- startShareComputerAudio: function () {
- if (_addon) {
- return _addon.StartShareComputerAudio()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Stop share
- * @method stopShare
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- stopShare: function () {
- if (_addon) {
- return _addon.StopShare()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Determine if myself is sharing
- * @method isSharingOut
- * @return {Boolean} true if myself is sharing. Otherwise returns false.
- */
- isSharingOut: function () {
- if (_addon) {
- return _addon.IsSharingOut()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Determine if myself is sharing screen
- * @method isScreenSharingOut
- * @return {Boolean} true if myself is sharing screen. Otherwise returns false.
- */
- isScreenSharingOut: function () {
- if (_addon) {
- return _addon.IsScreenSharingOut()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Determine if other user is sharing
- * @method isOtherSharing
- * @return {Boolean} true if other user is sharing screen. Otherwise returns false.
- */
- isOtherSharing: function () {
- if (_addon) {
- return _addon.IsOtherSharing()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Lock current share.(only host call)
- * @method lockShare
- * @param {Boolean} bLock
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- lockShare: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const bLock = clientOpts.bLock
- const LockShareParams = new messages.LockShareParams()
- LockShareParams.setZnBlock(bLock)
- const bytes = LockShareParams.serializeBinary()
- return _addon.LockShare(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Determine if share is locked
- * @method isShareLocked
- * @return {Boolean} true if share is locked. Otherwise returns false.
- */
- isShareLocked: function () {
- if (_addon) {
- return _addon.IsShareLocked()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Enable or disable the computer sound when sharing, if virtual speaker is enabled, don't support share audio.
- * @method enableShareDeviceAudio
- * @param {Boolean} bEnable, true indicates to enable. false disable.
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- enableShareDeviceAudio: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const bEnable = clientOpts.bEnable
- const EnableShareDeviceAudioParams = new messages.EnableShareDeviceAudioParams()
- EnableShareDeviceAudioParams.setEnable(bEnable)
- const bytes = EnableShareDeviceAudioParams.serializeBinary()
- return _addon.EnableShareDeviceAudio(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Determine if share computer sound is enabled.
- * @method isShareDeviceAudioEnabled
- * @return {Boolean} true if enabled. Otherwise returns false.
- */
- isShareDeviceAudioEnabled: function () {
- if (_addon) {
- return _addon.IsShareDeviceAudioEnabled()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Enable or disable the optimization of frame rate, you can enable it when there is video in shared content.
- * @method enableOptimizeForSharedVideo
- * @param {Boolean} bEnable, true indicates to enable. false disable.
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- enableOptimizeForSharedVideo: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const bEnable = clientOpts.bEnable
- const EnableOptimizeForSharedVideoParams = new messages.EnableOptimizeForSharedVideoParams()
- EnableOptimizeForSharedVideoParams.setEnable(bEnable)
- const bytes = EnableOptimizeForSharedVideoParams.serializeBinary()
- return _addon.EnableOptimizeForSharedVideo(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Determine if optimization for shared video is enabled.
- * @method isOptimizeForSharedVideoEnabled
- * @return {Boolean} true if enabled. otherwise returns false.
- */
- isOptimizeForSharedVideoEnabled: function () {
- if (_addon) {
- return _addon.IsOptimizeForSharedVideoEnabled()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Start sharing a camera feed specified by the cameraID as the second camera.
- * @method startShare2ndCamera
- * @param {String} cameraID, The camera ID.Warning: This must be a different camera than the one sending your primary video.
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- startShare2ndCamera: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const cameraID = clientOpts.cameraID
- const StartShare2ndCameraParams = new messages.StartShare2ndCameraParams()
- StartShare2ndCameraParams.setZnCameraid(cameraID)
- const bytes = StartShare2ndCameraParams.serializeBinary()
- return _addon.StartShare2ndCamera(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Subscribe to the raw data stream of the camera that is shared as the second camera.
- * @method subscribeMyShareCamera
- * @param {Number} recv_handle, Data handler.
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- subscribeMyShareCamera: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const recv_handle = clientOpts.recv_handle
- const SubscribeMyShareCameraParams = new messages.SubscribeMyShareCameraParams()
- SubscribeMyShareCameraParams.setZnRecvHandle(recv_handle)
- const bytes = SubscribeMyShareCameraParams.serializeBinary()
- return _addon.SubscribeMyShareCamera(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Unsubscribe to the raw data stream of the camera that is shared as the second camera.
- * @method unSubscribeMyShareCamera
- * @return {ZoomSDKError} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- unSubscribeMyShareCamera: function () {
- if (_addon) {
- return _addon.UnSubscribeMyShareCamera()
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- }
- }
- };
- return {
- getInstance: function (opts) {
- if (!instance) {
- instance = init(opts)
- }
- return instance
- }
- }
- })()
|