zoom_video_sdk_video.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. import { ZoomVideoSDKErrors, ZoomVideoSDKVideoPreferenceMode } from './zoom_video_sdk_defines.js'
  2. import messages from './electron_zoomvideosdk_pb.js'
  3. function checkCameraCtrlRange(range) {
  4. if (!range || range < 10) {
  5. return 10
  6. } else if (range > 100) {
  7. return 100
  8. } else {
  9. return parseInt(range)
  10. }
  11. }
  12. function checkVideoPreferenceFrameRate(frame_rate) {
  13. if (frame_rate < 0) {
  14. return 0
  15. } else if (frame_rate > 30) {
  16. return 30
  17. } else {
  18. return parseInt(frame_rate)
  19. }
  20. }
  21. export default (function () {
  22. var instance
  23. /**
  24. * Return an instance to manage cameras and video during a video SDK session.
  25. * @module zoom_video_sdk_video
  26. * @return {ZoomVideoSDKVideo}
  27. */
  28. function init (opts) {
  29. const clientOpts = {...opts}
  30. // Private methods and variables
  31. if (!clientOpts.addon) {
  32. return null
  33. }
  34. const _addon = clientOpts.addon.GetVideoHelper()
  35. return {
  36. // Public methods and variables
  37. /**
  38. * Call this method to start sending local video data from the camera.
  39. * @method startVideo
  40. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  41. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  42. */
  43. startVideo: function () {
  44. if (_addon) {
  45. return _addon.StartVideo()
  46. }
  47. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  48. },
  49. /**
  50. * Call this method to stop sending local video data from the camera.
  51. * @method stopVideo
  52. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  53. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  54. */
  55. stopVideo: function () {
  56. if (_addon) {
  57. return _addon.StopVideo()
  58. }
  59. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  60. },
  61. /**
  62. * Call this method to rotate the video when the device is rotated.
  63. * @method rotateMyVideo
  64. * @param {Number} rotation
  65. * @return {Boolean} Return true if the rotation was successful, false otherwise.
  66. */
  67. rotateMyVideo: function (opts) {
  68. if (_addon) {
  69. const clientOpts = {...opts}
  70. const rotation = clientOpts.rotation
  71. try {
  72. const RotateMyVideoParams = new messages.RotateMyVideoParams()
  73. RotateMyVideoParams.setZnRotation(rotation)
  74. const bytes = RotateMyVideoParams.serializeBinary()
  75. return _addon.RotateMyVideo(bytes)
  76. } catch (error) {
  77. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  78. }
  79. }
  80. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  81. },
  82. /**
  83. * Switch to the next available camera
  84. * @method switchCamera
  85. * @return {Boolean} Return true if the switch to the next camera was successful, false otherwise.
  86. */
  87. switchCamera: function () {
  88. if (_addon) {
  89. return _addon.SwitchCamera()
  90. }
  91. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  92. },
  93. /**
  94. * Select camera with cameraDeviceID
  95. * @method selectCamera
  96. * @param {String} deviceID
  97. * @return {Boolean} true if success. Otherwise returns false.
  98. */
  99. selectCamera: function (opts) {
  100. if (_addon) {
  101. const clientOpts = {...opts}
  102. const deviceID = clientOpts.deviceID
  103. try {
  104. const SelectCameraParams = new messages.SelectCameraParams()
  105. SelectCameraParams.setZnDeviceid(deviceID)
  106. const bytes = SelectCameraParams.serializeBinary()
  107. return _addon.SelectCamera(bytes)
  108. } catch (error) {
  109. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  110. }
  111. }
  112. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  113. },
  114. /**
  115. * Return number of cameras available to share the video.
  116. * @method getNumberOfCameras
  117. * @return {Number} number of cameras.
  118. */
  119. getNumberOfCameras: function () {
  120. if (_addon) {
  121. return _addon.GetNumberOfCameras()
  122. }
  123. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  124. },
  125. /**
  126. * Get camera device list
  127. * @method getCameraList
  128. * @return {Array} camera devices list
  129. */
  130. getCameraList: function () {
  131. if (_addon) {
  132. const result = _addon.GetCameraList()
  133. const message = new messages.GetCameraList.deserializeBinary(result)
  134. const tempList = message.getCamerainfoList()
  135. let cameraList = []
  136. for (let val of tempList) {
  137. let obj = {
  138. deviceID: val.getDeviceid(),
  139. deviceName: val.getDevicename(),
  140. isSelectedDevice: val.getIsselecteddevice()
  141. }
  142. cameraList.push(obj)
  143. }
  144. return cameraList
  145. }
  146. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  147. },
  148. /**
  149. * Check whether the current user has permission to control the camera.
  150. * @method canControlCamera
  151. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  152. Otherwise failed. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
  153. */
  154. canControlCamera: function () {
  155. if (_addon) {
  156. return _addon.CanControlCamera()
  157. }
  158. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  159. },
  160. /**
  161. * Turn the camera to the left.
  162. * @method turnCameraLeft
  163. * @param {Number} Rotation range, 10 <= range <= 100.
  164. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  165. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  166. */
  167. turnCameraLeft: function (opts) {
  168. if (_addon) {
  169. const clientOpts = {...opts}
  170. try {
  171. const range = checkCameraCtrlRange(clientOpts.range)
  172. const LocalCameraCtrlTurnLeftParams = new messages.LocalCameraCtrlTurnLeftParams()
  173. LocalCameraCtrlTurnLeftParams.setRange(range)
  174. const bytes = LocalCameraCtrlTurnLeftParams.serializeBinary()
  175. return _addon.TurnCameraLeft(bytes)
  176. } catch (error) {
  177. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  178. }
  179. }
  180. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  181. },
  182. /**
  183. * Turn the camera to the right.
  184. * @method turnCameraRight
  185. * @param {Number} Rotation range, 10 <= range <= 100.
  186. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  187. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  188. */
  189. turnCameraRight: function (opts) {
  190. if (_addon) {
  191. const clientOpts = {...opts}
  192. try {
  193. const range = checkCameraCtrlRange(clientOpts.range)
  194. const LocalCameraCtrlTurnRightParams = new messages.LocalCameraCtrlTurnRightParams()
  195. LocalCameraCtrlTurnRightParams.setRange(range)
  196. const bytes = LocalCameraCtrlTurnRightParams.serializeBinary()
  197. return _addon.TurnCameraRight(bytes)
  198. } catch (error) {
  199. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  200. }
  201. }
  202. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  203. },
  204. /**
  205. * Turn the camera up.
  206. * @method turnCameraUp
  207. * @param {Number} Rotation range, 10 <= range <= 100.
  208. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  209. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  210. */
  211. turnCameraUp: function (opts) {
  212. if (_addon) {
  213. const clientOpts = {...opts}
  214. try {
  215. const range = checkCameraCtrlRange(clientOpts.range)
  216. const LocalCameraCtrlTurnUpParams = new messages.LocalCameraCtrlTurnUpParams()
  217. LocalCameraCtrlTurnUpParams.setRange(range)
  218. const bytes = LocalCameraCtrlTurnUpParams.serializeBinary()
  219. return _addon.TurnCameraUp(bytes)
  220. } catch (error) {
  221. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  222. }
  223. }
  224. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  225. },
  226. /**
  227. * Turn the camera down.
  228. * @method turnCameraDown
  229. * @param {Number} Rotation range, 10 <= range <= 100.
  230. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  231. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  232. */
  233. turnCameraDown: function (opts) {
  234. if (_addon) {
  235. const clientOpts = {...opts}
  236. try {
  237. const range = checkCameraCtrlRange(clientOpts.range)
  238. const LocalCameraCtrlTurnDownParams = new messages.LocalCameraCtrlTurnDownParams()
  239. LocalCameraCtrlTurnDownParams.setRange(range)
  240. const bytes = LocalCameraCtrlTurnDownParams.serializeBinary()
  241. return _addon.TurnCameraDown(bytes)
  242. } catch (error) {
  243. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  244. }
  245. }
  246. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  247. },
  248. /**
  249. * Zoom the camera in.
  250. * @method zoomCameraIn
  251. * @param {Number} Zoom range, 10 <= range <= 100.
  252. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  253. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  254. */
  255. zoomCameraIn: function (opts) {
  256. if (_addon) {
  257. const clientOpts = {...opts}
  258. try {
  259. const range = checkCameraCtrlRange(clientOpts.range)
  260. const LocalCameraCtrlZoomInParams = new messages.LocalCameraCtrlZoomInParams()
  261. LocalCameraCtrlZoomInParams.setRange(range)
  262. const bytes = LocalCameraCtrlZoomInParams.serializeBinary()
  263. return _addon.ZoomCameraIn(bytes)
  264. } catch (error) {
  265. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  266. }
  267. }
  268. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  269. },
  270. /**
  271. * Zoom the camera out.
  272. * @method zoomCameraOut
  273. * @param {Number} Zoom range, 10 <= range <= 100.
  274. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  275. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  276. */
  277. zoomCameraOut: function (opts) {
  278. if (_addon) {
  279. const clientOpts = {...opts}
  280. try {
  281. const range = checkCameraCtrlRange(clientOpts.range)
  282. const LocalCameraCtrlZoomOutParams = new messages.LocalCameraCtrlZoomOutParams()
  283. LocalCameraCtrlZoomOutParams.setRange(range)
  284. const bytes = LocalCameraCtrlZoomOutParams.serializeBinary()
  285. return _addon.ZoomCameraOut(bytes)
  286. } catch (error) {
  287. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  288. }
  289. }
  290. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  291. },
  292. /**
  293. * Automatically adjust user's video solution and frame-rate. When setting custom modes, the maximum and minimum frame rates are provided by the developer. If the current bandwidth cannot maintain the minimum frame rate, the video system will drop to the next lower resolution.
  294. * @method setVideoQualityPreference
  295. * @param {Number} mode, {@link ZoomVideoSDKVideoPreferenceMode} enum. When setting custom modes, the maximum and minimum frame rates are provided by the developer.
  296. * @param {Number} minimum_frame_rate, 0 for the default value,minimum_frame_rate should be less than maximum_frame_rate, range: from 0 to 30 .out of range for frame-rate will use default frame-rate of Zoom.
  297. * @param {Number} maximum_frame_rate, 0 for the default value,maximum_frame_rate should be less and equal than 30, range: from 0 to 30.out of range for frame-rate will use default frame-rate of Zoom.
  298. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  299. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  300. */
  301. setVideoQualityPreference: function (opts) {
  302. if (_addon) {
  303. const clientOpts = {...opts}
  304. try {
  305. const mode = clientOpts.mode || ZoomVideoSDKVideoPreferenceMode.ZoomVideoSDKVideoPreferenceMode_Balance
  306. const minimum_frame_rate = checkVideoPreferenceFrameRate(clientOpts.minimum_frame_rate == undefined ? 0 : clientOpts.minimum_frame_rate)
  307. const maximum_frame_rate = checkVideoPreferenceFrameRate(clientOpts.maximum_frame_rate == undefined ? 0 : clientOpts.maximum_frame_rate)
  308. const SetVideoQualityPreferenceParams = new messages.SetVideoQualityPreferenceParams()
  309. SetVideoQualityPreferenceParams.setMode(mode)
  310. SetVideoQualityPreferenceParams.setMinimumFrameRate(minimum_frame_rate)
  311. SetVideoQualityPreferenceParams.setMaximumFrameRate(maximum_frame_rate)
  312. const bytes = SetVideoQualityPreferenceParams.serializeBinary()
  313. return _addon.SetVideoQualityPreference(bytes)
  314. } catch (error) {
  315. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  316. }
  317. }
  318. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  319. },
  320. /**
  321. * Enable multiple stream video if you have multiple cameras and other participants can see multiple videos of you.
  322. * @method enableMultiStreamVideo
  323. * @param {String} deviceID the camera ID which you want to enable.
  324. * @return {Boolean} True if success. Otherwise returns false.
  325. */
  326. enableMultiStreamVideo: function (opts) {
  327. if (_addon) {
  328. const clientOpts = {...opts}
  329. try {
  330. const deviceID = clientOpts.deviceID
  331. const EnableMultiStreamVideoParams = new messages.EnableMultiStreamVideoParams()
  332. EnableMultiStreamVideoParams.setDeviceid(deviceID)
  333. const bytes = EnableMultiStreamVideoParams.serializeBinary()
  334. return _addon.EnableMultiStreamVideo(bytes)
  335. } catch (error) {
  336. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  337. }
  338. }
  339. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  340. },
  341. /**
  342. * Disable multiple stream video
  343. * @method disableMultiStreamVideo
  344. * @param {String} deviceID the camera id which you want to disable.
  345. * @return {Boolean} True if success. Otherwise returns false.
  346. */
  347. disableMultiStreamVideo: function (opts) {
  348. if (_addon) {
  349. const clientOpts = {...opts}
  350. try {
  351. const deviceID = clientOpts.deviceID
  352. const DisableMultiStreamVideoParams = new messages.DisableMultiStreamVideoParams()
  353. DisableMultiStreamVideoParams.setDeviceid(deviceID)
  354. const bytes = DisableMultiStreamVideoParams.serializeBinary()
  355. return _addon.DisableMultiStreamVideo(bytes)
  356. } catch (error) {
  357. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  358. }
  359. }
  360. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  361. },
  362. /**
  363. * Subscribe preview video raw data with a callback.
  364. * @method startVideoPreview
  365. * @param {Number} recv_handle
  366. * @param {String} cameraDeviceID
  367. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  368. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  369. */
  370. startVideoPreview: function (opts) {
  371. if (_addon) {
  372. const clientOpts = {...opts}
  373. try {
  374. const recv_handle = clientOpts.recv_handle
  375. const cameraDeviceID = clientOpts.cameraDeviceID
  376. const StartVideoPreviewParams = new messages.StartVideoPreviewParams()
  377. StartVideoPreviewParams.setZnRecvHandle(recv_handle)
  378. StartVideoPreviewParams.setCameradeviceid(cameraDeviceID)
  379. const bytes = StartVideoPreviewParams.serializeBinary()
  380. return _addon.StartVideoPreview(bytes)
  381. } catch (error) {
  382. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  383. }
  384. }
  385. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  386. },
  387. /**
  388. * UnSubscribe preview video raw data with the subscribed callback.
  389. * @method stopVideoPreview
  390. * @param {Number} recv_handle
  391. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  392. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  393. */
  394. stopVideoPreview: function (opts) {
  395. if (_addon) {
  396. const clientOpts = {...opts}
  397. try {
  398. const recv_handle = clientOpts.recv_handle
  399. const StopVideoPreviewParams = new messages.StopVideoPreviewParams()
  400. StopVideoPreviewParams.setZnRecvHandle(recv_handle)
  401. const bytes = StopVideoPreviewParams.serializeBinary()
  402. return _addon.StopVideoPreview(bytes)
  403. } catch (error) {
  404. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  405. }
  406. }
  407. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  408. },
  409. /**
  410. * add virtual background object.
  411. * @method addVirtualBackgroundItem
  412. * @param {String} imagePath setting using image path.
  413. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  414. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  415. */
  416. addVirtualBackgroundItem: function (opts) {
  417. if (_addon) {
  418. const clientOpts = {...opts}
  419. try {
  420. const imagePath = clientOpts.imagePath
  421. const AddVirtualBackgroundItemParams = new messages.AddVirtualBackgroundItemParams()
  422. AddVirtualBackgroundItemParams.setImagepath(imagePath)
  423. const bytes = AddVirtualBackgroundItemParams.serializeBinary()
  424. return _addon.AddVirtualBackgroundItem(bytes)
  425. } catch (error) {
  426. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  427. }
  428. }
  429. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  430. },
  431. /**
  432. * remove virtual background object.
  433. * @method removeVirtualBackgroundItem
  434. * @param {Number} vbItemHandle the choosing virtual background item handle.
  435. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  436. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  437. */
  438. removeVirtualBackgroundItem: function (opts) {
  439. if (_addon) {
  440. const clientOpts = {...opts}
  441. try {
  442. const vbItemHandle = clientOpts.vbItemHandle
  443. const RemoveVirtualBackgroundItemParams = new messages.RemoveVirtualBackgroundItemParams()
  444. RemoveVirtualBackgroundItemParams.setVbitemhandle(vbItemHandle)
  445. const bytes = RemoveVirtualBackgroundItemParams.serializeBinary()
  446. return _addon.RemoveVirtualBackgroundItem(bytes)
  447. } catch (error) {
  448. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  449. }
  450. }
  451. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  452. },
  453. /**
  454. * get virtual background item list, this function need to call first before create virtual background object to get background item last time.
  455. * @method getVirtualBackgroundItemList
  456. * @return {Array} If the function succeeds, the return value is VirtualBackgroundItem object Array. Otherwise failed. the return value is null.
  457. */
  458. getVirtualBackgroundItemList: function () {
  459. if (_addon) {
  460. const result = _addon.GetVirtualBackgroundItemList()
  461. const message = new messages.VBItemHandleList.deserializeBinary(result)
  462. return message.getVbitemhandleList()
  463. }
  464. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  465. },
  466. /**
  467. * set virtual background item.
  468. * @method setVirtualBackgroundItem
  469. * @param {Number} vbItemHandle the choosing virtual background item handle.
  470. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  471. Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
  472. */
  473. setVirtualBackgroundItem: function (opts) {
  474. if (_addon) {
  475. const clientOpts = {...opts}
  476. try {
  477. const vbItemHandle = clientOpts.vbItemHandle
  478. const SetVirtualBackgroundItemParams = new messages.SetVirtualBackgroundItemParams()
  479. SetVirtualBackgroundItemParams.setVbitemhandle(vbItemHandle)
  480. const bytes = SetVirtualBackgroundItemParams.serializeBinary()
  481. return _addon.SetVirtualBackgroundItem(bytes)
  482. } catch (error) {
  483. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  484. }
  485. }
  486. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  487. },
  488. /**
  489. * get virtual background handle which is been selected.
  490. * @method getSelectedVirtualBackgroundItem
  491. * @return {Number} If the function succeeds, the return value is virtual background handle. Otherwise failed. the return value is null.
  492. */
  493. getSelectedVirtualBackgroundItem: function () {
  494. if (_addon) {
  495. return _addon.GetSelectedVirtualBackgroundItem()
  496. }
  497. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  498. },
  499. /**
  500. * get the virtual background item information.
  501. * @method getVirtualBackgroundItemInfo
  502. * @param {Number} vbItemHandle the choosing virtual background item handle.
  503. * @return {Object} If the function succeeds, the return value is VirtualBackgroundItem object. Otherwise failed. the return value is null.
  504. */
  505. getVirtualBackgroundItemInfo: function (opts) {
  506. if (_addon) {
  507. const clientOpts = {...opts}
  508. try {
  509. const vbItemHandle = clientOpts.vbItemHandle
  510. const GetVirtualBackgroundItemInfoParams = new messages.GetVirtualBackgroundItemInfoParams()
  511. GetVirtualBackgroundItemInfoParams.setVbitemhandle(vbItemHandle)
  512. const bytes = GetVirtualBackgroundItemInfoParams.serializeBinary()
  513. let temp_info = _addon.GetVirtualBackgroundItemInfo(bytes)
  514. if (temp_info.err == ZoomVideoSDKErrors.ZoomVideoSDKErrors_Success) {
  515. let temp_obj = new messages.VBItemInfo.deserializeBinary(temp_info.vbItemInfo)
  516. temp_info.vbItemInfo = {
  517. imageFilePath: temp_obj.getImagefilepath(),
  518. imageName: temp_obj.getImagename(),
  519. vbType: temp_obj.getVbtype(),
  520. canBeDeleted: temp_obj.getCanbedeleted()
  521. }
  522. }
  523. const virtualBackgroundItemInfo = {...temp_info}
  524. return virtualBackgroundItemInfo
  525. } catch (error) {
  526. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
  527. }
  528. }
  529. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  530. }
  531. }
  532. };
  533. return {
  534. getInstance: function (opts) {
  535. if (!instance) {
  536. instance = init(opts)
  537. }
  538. return instance
  539. }
  540. }
  541. })()