| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- import { ZoomVideoSDKErrors } from './zoom_video_sdk_defines.js'
- import messages from './electron_zoomvideosdk_pb.js'
- import { setUserInfo } from './zoom_video_sdk_user_util.js'
- function checkCameraCtrlRange(range) {
- if (range < 10) {
- return 10
- } else if (range > 100) {
- return 100
- } else {
- return range
- }
- }
- export default (function () {
- var instance
- /**
- * Get the helper class instance to access the remote camera control.
- * @module zoom_video_sdk_remote_camera_control
- * @return {ZoomVideoSDKRemoteCameraControl}
- */
- function init(opts) {
- const clientOpts = {...opts}
- // Private methods and variables
- if (!clientOpts.addon) {
- return null
- }
- const _addon = clientOpts.addon.GetRemoteCameraCtrlHelper()
- return {
- // Public methods and variables
- /**
- * Request to control remote camera.
- * @method requestControlRemoteCamera
- * @param {Object} user
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- requestControlRemoteCamera: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const user = setUserInfo(clientOpts.user)
- const RequestControlRemoteCameraParams = new messages.RequestControlRemoteCameraParams()
- RequestControlRemoteCameraParams.setUser(user)
- const bytes = RequestControlRemoteCameraParams.serializeBinary()
- return _addon.RequestControlRemoteCamera(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Give up control of the remote camera.
- * @method giveUpControlRemoteCamera
- * @param {Object} user
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
- */
- giveUpControlRemoteCamera: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const user = setUserInfo(clientOpts.user)
- const GiveUpControlRemoteCameraParams = new messages.GiveUpControlRemoteCameraParams()
- GiveUpControlRemoteCameraParams.setUser(user)
- const bytes = GiveUpControlRemoteCameraParams.serializeBinary()
- return _addon.GiveUpControlRemoteCamera(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Turn the camera to the left.
- * @method turnLeft
- * @param {Number} Rotation range, 10 <= range <= 100.
- * @param {Object} user
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- turnLeft: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- let range = checkCameraCtrlRange(clientOpts.range)
- const user = setUserInfo(clientOpts.user)
- const RemoteCameraCtrlTurnLeftParams = new messages.RemoteCameraCtrlTurnLeftParams()
- RemoteCameraCtrlTurnLeftParams.setRange(range)
- RemoteCameraCtrlTurnLeftParams.setUser(user)
- const bytes = RemoteCameraCtrlTurnLeftParams.serializeBinary()
- return _addon.TurnLeft(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Turn the camera to the right.
- * @method turnRight
- * @param {Number} Rotation range, 10 <= range <= 100.
- * @param {Object} user
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- turnRight: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const range = checkCameraCtrlRange(clientOpts.range)
- const user = setUserInfo(clientOpts.user)
- const RemoteCameraCtrlTurnRightParams = new messages.RemoteCameraCtrlTurnRightParams()
- RemoteCameraCtrlTurnRightParams.setRange(range)
- RemoteCameraCtrlTurnRightParams.setUser(user)
- const bytes = RemoteCameraCtrlTurnRightParams.serializeBinary()
- return _addon.TurnRight(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Turn the camera up.
- * @method turnUp
- * @param {Number} Rotation range, 10 <= range <= 100.
- * @param {Object} user
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- turnUp: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const range = checkCameraCtrlRange(clientOpts.range)
- const user = setUserInfo(clientOpts.user)
- const RemoteCameraCtrlTurnUpParams = new messages.RemoteCameraCtrlTurnUpParams()
- RemoteCameraCtrlTurnUpParams.setRange(range)
- RemoteCameraCtrlTurnUpParams.setUser(user)
- const bytes = RemoteCameraCtrlTurnUpParams.serializeBinary()
- return _addon.TurnUp(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Turn the camera down.
- * @method turnDown
- * @param {Number} Rotation range, 10 <= range <= 100.
- * @param {Object} user
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- turnDown: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const range = checkCameraCtrlRange(clientOpts.range)
- const user = setUserInfo(clientOpts.user)
- const RemoteCameraCtrlTurnDownParams = new messages.RemoteCameraCtrlTurnDownParams()
- RemoteCameraCtrlTurnDownParams.setRange(range)
- RemoteCameraCtrlTurnDownParams.setUser(user)
- const bytes = RemoteCameraCtrlTurnDownParams.serializeBinary()
- return _addon.TurnDown(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Zoom the camera in.
- * @method zoomIn
- * @param {Number} Zoom range, 10 <= range <= 100.
- * @param {Object} user
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- zoomIn: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const range = checkCameraCtrlRange(clientOpts.range)
- const user = setUserInfo(clientOpts.user)
- const RemoteCameraCtrlZoomInParams = new messages.RemoteCameraCtrlZoomInParams()
- RemoteCameraCtrlZoomInParams.setRange(range)
- RemoteCameraCtrlZoomInParams.setUser(user)
- const bytes = RemoteCameraCtrlZoomInParams.serializeBinary()
- return _addon.ZoomIn(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Zoom the camera out.
- * @method zoomOut
- * @param {Number} Zoom range, 10 <= range <= 100.
- * @param {Object} user
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- zoomOut: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const range = checkCameraCtrlRange(clientOpts.range)
- const user = setUserInfo(clientOpts.user)
- const RemoteCameraCtrlZoomOutParams = new messages.RemoteCameraCtrlZoomOutParams()
- RemoteCameraCtrlZoomOutParams.setRange(range)
- RemoteCameraCtrlZoomOutParams.setUser(user)
- const bytes = RemoteCameraCtrlZoomOutParams.serializeBinary()
- return _addon.ZoomOut(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- }
- }
- };
- return {
- getInstance: function (opts) {
- if (!instance) {
- instance = init(opts)
- }
- return instance
- }
- }
- })()
|