zoom_video_sdk_node_addon.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. #include "zoom_video_sdk_node_addon.h"
  2. #include "zoom_video_sdk_v8_to_c.h"
  3. #include "zoom_video_sdk_node_session_info_ctrl.h"
  4. #include "zoom_video_sdk_node_audio_helper.h"
  5. #include "zoom_video_sdk_node_video_helper.h"
  6. #include "zoom_video_sdk_node_share_helper.h"
  7. #include "zoom_video_sdk_node_chat_helper.h"
  8. #include "zoom_video_sdk_node_livestream_helper.h"
  9. #include "zoom_video_sdk_node_user_helper.h"
  10. #include "zoom_video_sdk_node_video_raw_data.h"
  11. #include "zoom_video_sdk_node_rawdata_server_mgr.h"
  12. #include "zoom_video_sdk_node_cmd_channel_helper.h"
  13. #include "zoom_video_sdk_node_phone_helper.h"
  14. #include "zoom_video_sdk_node_recording_helper.h"
  15. #include "zoom_video_sdk_node_remote_camera_control_helper.h"
  16. #include "zoom_video_sdk_node_audio_setting.h"
  17. #include "zoom_video_sdk_node_live_transcription_helper.h"
  18. #include "zoom_video_sdk_napi_util_exporter.h"
  19. ZNativeVideoSDKWrap _g_native_wrap;
  20. extern ZoomVideoNodePipeServerMgr _g_video_pipe_server;
  21. extern ZoomVideoNodePipeServerMgr _g_share_pipe_server;
  22. extern ZoomVideoNodePipeServerMgr _g_audio_pipe_server;
  23. static void CreateVideoSDKNodeObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
  24. VideoNodeAddonData* data =
  25. reinterpret_cast<VideoNodeAddonData*>(args.Data().As<v8::External>()->Value());
  26. data->zoomNodeWrapInstance = ZoomVideoNodeWrap::GetNewInstance(args);
  27. args.GetReturnValue().Set(data->zoomNodeWrapInstance);
  28. }
  29. NODE_MODULE_INIT(/* exports, module, context */) {
  30. v8::Isolate* isolate = context->GetIsolate();
  31. ZoomVideoNodeWrap::Init(exports->GetIsolate());
  32. ZoomVideoNodeSessionInfoCtrlWrap::Init(exports->GetIsolate());
  33. ZoomVideoNodeAudioHelperWrap::Init(exports->GetIsolate());
  34. ZoomVideoNodeVideoHelperWrap::Init(exports->GetIsolate());
  35. ZoomVideoNodeShareHelperWrap::Init(exports->GetIsolate());
  36. ZoomVideoNodeChatHelperWrap::Init(exports->GetIsolate());
  37. ZoomVideoNodeLiveStreamHelperWrap::Init(exports->GetIsolate());
  38. ZoomVideoNodeUserHelperWrap::Init(exports->GetIsolate());
  39. ZoomVideoNodeSDKVideoRenderWrap::Init(exports->GetIsolate());
  40. ZoomVideoNodeSDKRawdataServerMgrWrap::Init(exports->GetIsolate());
  41. ZoomVideoNodeCmdChannelHelperWrap::Init(exports->GetIsolate());
  42. ZoomVideoNodePhoneHelperWrap::Init(exports->GetIsolate());
  43. ZoomVideoNodeRecordingHelperWrap::Init(exports->GetIsolate());
  44. ZoomVideoNodeRemoteCameraControlHelperWrap::Init(exports->GetIsolate());
  45. ZoomVideoNodeCameraControlRequestHandlerWrap::Init(exports->GetIsolate());
  46. ZoomVideoNodeAudioSettingWrap::Init(exports->GetIsolate());
  47. ZoomVideoNodeTestAudioDeviceWrap::Init(exports->GetIsolate());
  48. ZoomVideoNodeLiveTranscriptionHelperWrap::Init(exports->GetIsolate());
  49. VideoNodeAddonData* data = new VideoNodeAddonData(isolate);
  50. v8::Local<v8::External> external = v8::External::New(isolate, data);
  51. exports->Set(context,
  52. v8::String::NewFromUtf8(isolate, "exports", v8::NewStringType::kNormal)
  53. .ToLocalChecked(),
  54. v8::FunctionTemplate::New(isolate, CreateVideoSDKNodeObject, external)
  55. ->GetFunction(context).ToLocalChecked()).FromJust();
  56. }
  57. v8::Persistent<v8::Function> ZoomVideoNodeWrap::constructor;
  58. v8::Persistent<v8::Function> ZoomVideoNodeSessionInfoCtrlWrap::constructor;
  59. v8::Persistent<v8::Function> ZoomVideoNodeAudioHelperWrap::constructor;
  60. v8::Persistent<v8::Function> ZoomVideoNodeVideoHelperWrap::constructor;
  61. v8::Persistent<v8::Function> ZoomVideoNodeShareHelperWrap::constructor;
  62. v8::Persistent<v8::Function> ZoomVideoNodeChatHelperWrap::constructor;
  63. v8::Persistent<v8::Function> ZoomVideoNodeLiveStreamHelperWrap::constructor;
  64. v8::Persistent<v8::Function> ZoomVideoNodeUserHelperWrap::constructor;
  65. v8::Persistent<v8::Function> ZoomVideoNodeSDKVideoRenderWrap::constructor;
  66. v8::Persistent<v8::Function> ZoomVideoNodeSDKRawdataServerMgrWrap::constructor;
  67. v8::Persistent<v8::Function> ZoomVideoNodeCmdChannelHelperWrap::constructor;
  68. v8::Persistent<v8::Function> ZoomVideoNodePhoneHelperWrap::constructor;
  69. v8::Persistent<v8::Function> ZoomVideoNodeRecordingHelperWrap::constructor;
  70. v8::Persistent<v8::Function> ZoomVideoNodeRemoteCameraControlHelperWrap::constructor;
  71. v8::Persistent<v8::Function> ZoomVideoNodeCameraControlRequestHandlerWrap::constructor;
  72. v8::Persistent<v8::Function> ZoomVideoNodeAudioSettingWrap::constructor;
  73. v8::Persistent<v8::Function> ZoomVideoNodeTestAudioDeviceWrap::constructor;
  74. v8::Persistent<v8::Function> ZoomVideoNodeLiveTranscriptionHelperWrap::constructor;
  75. ///////////////////////////////////////////////////////////////////////////
  76. ////////////////////////////////////////////////////////////////////////////
  77. ZoomVideoNodeWrap::ZoomVideoNodeWrap()
  78. {
  79. _g_native_wrap.SetSink(&ZoomVideoNodeSinkWrapMgr::GetInst().m_ZoomVideoSDKSink);
  80. }
  81. ZoomVideoNodeWrap::~ZoomVideoNodeWrap()
  82. {
  83. _g_native_wrap.SetSink(NULL);
  84. }
  85. void ZoomVideoNodeWrap::CreateZoomVideoSDKObj(const v8::FunctionCallbackInfo<v8::Value>& args) {
  86. v8::Isolate* isolate = args.GetIsolate();
  87. ZNZoomVideoSDKErrors err = ZNZoomVideoSDKErrors_Success;
  88. do
  89. {
  90. bool zn_bret = ZoomNodeAPIUtilHelper::GetInst().ExportNAPIUtilFunc();
  91. if (!zn_bret)
  92. {
  93. err = ZNZoomVideoSDKErrors_Internal_Error;
  94. break;
  95. }
  96. com::electron::zoomvideo::sdk::proto::CreateVideoSDKObjParam proto_param;
  97. if (!SetProtoParam<com::electron::zoomvideo::sdk::proto::CreateVideoSDKObjParam >(args, proto_param))
  98. {
  99. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  100. break;
  101. }
  102. if (!proto_param.has_path())
  103. {
  104. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  105. break;
  106. }
  107. ZoomSTRING path;
  108. path = s2zs(proto_param.path());
  109. err = _g_native_wrap.CreateZoomVideoSDKObj(path);
  110. } while (false);
  111. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  112. args.GetReturnValue().Set(bret);
  113. }
  114. void ZoomVideoNodeWrap::DestroyZoomVideoSDKObj(const v8::FunctionCallbackInfo<v8::Value>& args) {
  115. _g_video_pipe_server._uv_ipc_server.StopPipeServer();
  116. _g_share_pipe_server._uv_ipc_server.StopPipeServer();
  117. _g_audio_pipe_server._uv_ipc_server.StopPipeServer();
  118. v8::Isolate* isolate = args.GetIsolate();
  119. ZNZoomVideoSDKErrors err = _g_native_wrap.DestroyZoomVideoSDKObj();
  120. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  121. args.GetReturnValue().Set(bret);
  122. }
  123. void ZoomVideoNodeWrap::Initialize(const v8::FunctionCallbackInfo<v8::Value>& args){
  124. v8::Isolate* isolate = args.GetIsolate();
  125. ZNZoomVideoSDKErrors err = ZNZoomVideoSDKErrors_Success;
  126. do
  127. {
  128. com::electron::zoomvideo::sdk::proto::VideoSDKInitParams proto_param;
  129. if (!SetProtoParam<com::electron::zoomvideo::sdk::proto::VideoSDKInitParams >(args, proto_param))
  130. {
  131. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  132. break;
  133. }
  134. if (!proto_param.has_domain() ||
  135. !proto_param.has_logfileprefix()
  136. )
  137. {
  138. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  139. break;
  140. }
  141. ZNZoomVideoSDKInitParams param;
  142. param.domain = s2zs(proto_param.domain());
  143. param.logFilePrefix = s2zs(proto_param.logfileprefix());
  144. if (proto_param.has_enablelog())
  145. {
  146. convertBool(proto_param.enablelog(), param.enableLog);
  147. }
  148. if (proto_param.has_audiorawdatamemorymode())
  149. {
  150. int zn_audioRawDataMemoryMode = (int)proto_param.audiorawdatamemorymode();
  151. param.audioRawDataMemoryMode = (ZNZoomVideoSDKRawDataMemoryMode)zn_audioRawDataMemoryMode;
  152. }
  153. if (proto_param.has_zn_videorawdatamemorymode())
  154. {
  155. int zn_videoRawDataMemoryMode = (int)proto_param.zn_videorawdatamemorymode();
  156. param.videoRawDataMemoryMode = (ZNZoomVideoSDKRawDataMemoryMode)zn_videoRawDataMemoryMode;
  157. }
  158. if (proto_param.has_zn_sharerawdatamemorymode())
  159. {
  160. int zn_shareRawDataMemoryMode = (int)proto_param.zn_sharerawdatamemorymode();
  161. param.shareRawDataMemoryMode = (ZNZoomVideoSDKRawDataMemoryMode)zn_shareRawDataMemoryMode;
  162. }
  163. if (proto_param.has_speakertestfilepath())
  164. {
  165. param.extendParam.speakerTestFilePath = s2zs(proto_param.speakertestfilepath());
  166. }
  167. err = _g_native_wrap.Initialize(param);
  168. bool bsucc_video_pipe = false;
  169. bsucc_video_pipe = _g_video_pipe_server._uv_ipc_server.StartPipeServer(VIDEO_PIPE_NAME, &_g_video_pipe_server);
  170. bool bsucc_share_pipe = false;
  171. bsucc_share_pipe = _g_share_pipe_server._uv_ipc_server.StartPipeServer(SHARE_PIPE_NAME, &_g_share_pipe_server);
  172. if (!bsucc_video_pipe ||
  173. !bsucc_share_pipe
  174. )
  175. {
  176. err = ZNZoomVideoSDKErrors_Internal_Error;
  177. }
  178. } while (false);
  179. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  180. args.GetReturnValue().Set(bret);
  181. }
  182. void ZoomVideoNodeWrap::CleanUp(const v8::FunctionCallbackInfo<v8::Value>& args) {
  183. v8::Isolate* isolate = args.GetIsolate();
  184. ZoomNodeVideoSinkHelper::GetInst().Reset();
  185. ZoomVideoNodeSDKDelayGC::GetInst().StopTimer();
  186. ZNZoomVideoSDKErrors err = _g_native_wrap.CleanUp();
  187. bool bsucc_video_pipe = false;
  188. bsucc_video_pipe = _g_video_pipe_server._uv_ipc_server.StopPipeServer();
  189. bool bsucc_share_pipe = false;
  190. bsucc_share_pipe = _g_share_pipe_server._uv_ipc_server.StopPipeServer();
  191. if (!bsucc_video_pipe ||
  192. !bsucc_share_pipe
  193. )
  194. {
  195. err = ZNZoomVideoSDKErrors_Internal_Error;
  196. }
  197. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  198. args.GetReturnValue().Set(bret);
  199. }
  200. void ZoomVideoNodeWrap::JoinSession(const v8::FunctionCallbackInfo<v8::Value>& args) {
  201. v8::Isolate* isolate = args.GetIsolate();
  202. ZNZoomVideoSDKErrors err = ZNZoomVideoSDKErrors_Success;
  203. do
  204. {
  205. com::electron::zoomvideo::sdk::proto::VideoSDKSessionContext proto_param;
  206. if (!SetProtoParam<com::electron::zoomvideo::sdk::proto::VideoSDKSessionContext >(args, proto_param))
  207. {
  208. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  209. break;
  210. }
  211. if (!proto_param.has_sessionname() ||
  212. !proto_param.has_token() ||
  213. !proto_param.has_username())
  214. {
  215. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  216. break;
  217. }
  218. ZNZoomVideoSDKSessionContext zn_sessionContext;
  219. zn_sessionContext.sessionName = s2zs(proto_param.sessionname());
  220. zn_sessionContext.token = s2zs(proto_param.token());
  221. zn_sessionContext.userName = s2zs(proto_param.username());
  222. if (proto_param.has_sessionpassword())
  223. {
  224. zn_sessionContext.sessionPassword = s2zs(proto_param.sessionpassword());
  225. }
  226. if (proto_param.has_localvideoon())
  227. {
  228. convertBool(proto_param.localvideoon(), zn_sessionContext.videoOption.localVideoOn);
  229. }
  230. if (proto_param.has_connect())
  231. {
  232. convertBool(proto_param.connect(), zn_sessionContext.audioOption.connect);
  233. }
  234. if (proto_param.has_mute())
  235. {
  236. convertBool(proto_param.mute(), zn_sessionContext.audioOption.mute);
  237. }
  238. if (proto_param.has_preprocessor())
  239. {
  240. convertBool(proto_param.preprocessor(), zn_sessionContext.preProcessor);
  241. }
  242. if (proto_param.has_externalvideosource())
  243. {
  244. convertBool(proto_param.externalvideosource(), zn_sessionContext.externalVideoSource);
  245. }
  246. if (proto_param.has_sessionidletimeoutmins())
  247. {
  248. zn_sessionContext.sessionIdleTimeoutMins = proto_param.sessionidletimeoutmins();
  249. }
  250. err = _g_native_wrap.JoinSession(zn_sessionContext);
  251. } while (false);
  252. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  253. args.GetReturnValue().Set(bret);
  254. }
  255. void ZoomVideoNodeWrap::LeaveSession(const v8::FunctionCallbackInfo<v8::Value>& args) {
  256. v8::Isolate* isolate = args.GetIsolate();
  257. ZNZoomVideoSDKErrors err = ZNZoomVideoSDKErrors_Success;
  258. do
  259. {
  260. com::electron::zoomvideo::sdk::proto::LeaveSessionParams proto_param;
  261. if (!SetProtoParam<com::electron::zoomvideo::sdk::proto::LeaveSessionParams >(args, proto_param))
  262. {
  263. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  264. break;
  265. }
  266. if (!proto_param.has_zn_bend())
  267. {
  268. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  269. break;
  270. }
  271. bool zn_bEnd = false;
  272. convertBool(proto_param.zn_bend(), zn_bEnd);
  273. err = _g_native_wrap.LeaveSession(zn_bEnd);
  274. } while (false);
  275. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  276. args.GetReturnValue().Set(bret);
  277. }
  278. void ZoomVideoNodeWrap::IsInSession(const v8::FunctionCallbackInfo<v8::Value>& args)
  279. {
  280. v8::Isolate* isolate = args.GetIsolate();
  281. bool zn_bIsInSession = _g_native_wrap.IsInSession();
  282. v8::Local<v8::Boolean> bret = v8::Boolean::New(isolate, zn_bIsInSession);
  283. args.GetReturnValue().Set(bret);
  284. }
  285. void ZoomVideoNodeWrap::GetSDKVersion(const v8::FunctionCallbackInfo<v8::Value>& args)
  286. {
  287. v8::Isolate* isolate = args.GetIsolate();
  288. ZoomSTRING sdkVersion = _g_native_wrap.GetSDKVersion();
  289. v8::Local<v8::String> bret = v8::String::NewFromUtf8(isolate, zs2s(sdkVersion).c_str(), v8::NewStringType::kInternalized).ToLocalChecked();
  290. args.GetReturnValue().Set(bret);
  291. }
  292. void ZoomVideoNodeWrap::InputSessionPassword(const v8::FunctionCallbackInfo<v8::Value>& args) {
  293. v8::Isolate* isolate = args.GetIsolate();
  294. ZNZoomVideoSDKErrors err = ZNZoomVideoSDKErrors_Success;
  295. do
  296. {
  297. com::electron::zoomvideo::sdk::proto::SessionPasswordParams proto_param;
  298. if (!SetProtoParam<com::electron::zoomvideo::sdk::proto::SessionPasswordParams >(args, proto_param))
  299. {
  300. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  301. break;
  302. }
  303. if (!proto_param.has_zn_password())
  304. {
  305. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  306. break;
  307. }
  308. ZoomSTRING zn_password;
  309. zn_password = s2zs(proto_param.zn_password());
  310. err = _g_native_wrap.InputSessionPassword(zn_password);
  311. } while (false);
  312. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  313. args.GetReturnValue().Set(bret);
  314. }
  315. void ZoomVideoNodeWrap::LeaveSessionIgnorePassword(const v8::FunctionCallbackInfo<v8::Value>& args)
  316. {
  317. v8::Isolate* isolate = args.GetIsolate();
  318. ZNZoomVideoSDKErrors err = _g_native_wrap.LeaveSessionIgnorePassword();
  319. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  320. args.GetReturnValue().Set(bret);
  321. }
  322. void ZoomVideoNodeWrap::GetSessionInfoCtrl(const v8::FunctionCallbackInfo<v8::Value>& args)
  323. {
  324. ZoomVideoNodeSessionInfoCtrlWrap::NewInstance(args);
  325. }
  326. void ZoomVideoNodeWrap::GetAudioHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  327. {
  328. ZoomVideoNodeAudioHelperWrap::NewInstance(args);
  329. }
  330. void ZoomVideoNodeWrap::GetVideoHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  331. {
  332. ZoomVideoNodeVideoHelperWrap::NewInstance(args);
  333. }
  334. void ZoomVideoNodeWrap::GetShareHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  335. {
  336. ZoomVideoNodeShareHelperWrap::NewInstance(args);
  337. }
  338. void ZoomVideoNodeWrap::GetUserHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  339. {
  340. ZoomVideoNodeUserHelperWrap::NewInstance(args);
  341. }
  342. void ZoomVideoNodeWrap::GetVideoSDKRender(const v8::FunctionCallbackInfo<v8::Value>& args)
  343. {
  344. ZoomVideoNodeSDKVideoRenderWrap::NewInstance(args);
  345. }
  346. void ZoomVideoNodeWrap::GetVideoSDKRawDataServerMgr(const v8::FunctionCallbackInfo<v8::Value>& args)
  347. {
  348. ZoomVideoNodeSDKRawdataServerMgrWrap::NewInstance(args);
  349. }
  350. void ZoomVideoNodeWrap::GetChatHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  351. {
  352. ZoomVideoNodeChatHelperWrap::NewInstance(args);
  353. }
  354. void ZoomVideoNodeWrap::GetLiveStreamHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  355. {
  356. ZoomVideoNodeLiveStreamHelperWrap::NewInstance(args);
  357. }
  358. void ZoomVideoNodeWrap::GetCmdChannel(const v8::FunctionCallbackInfo<v8::Value>& args)
  359. {
  360. ZoomVideoNodeCmdChannelHelperWrap::NewInstance(args);
  361. }
  362. void ZoomVideoNodeWrap::GetPhoneHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  363. {
  364. ZoomVideoNodePhoneHelperWrap::NewInstance(args);
  365. }
  366. void ZoomVideoNodeWrap::GetRemoteCameraCtrlHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  367. {
  368. ZoomVideoNodeRemoteCameraControlHelperWrap::NewInstance(args);
  369. }
  370. void ZoomVideoNodeWrap::GetCameraControlRequestHandler(const v8::FunctionCallbackInfo<v8::Value>& args)
  371. {
  372. ZoomVideoNodeCameraControlRequestHandlerWrap::NewInstance(args);
  373. }
  374. void ZoomVideoNodeWrap::GetRecordingHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  375. {
  376. ZoomVideoNodeRecordingHelperWrap::NewInstance(args);
  377. }
  378. void ZoomVideoNodeWrap::GetAudioSetting(const v8::FunctionCallbackInfo<v8::Value>& args)
  379. {
  380. ZoomVideoNodeAudioSettingWrap::NewInstance(args);
  381. }
  382. void ZoomVideoNodeWrap::GetTestAudioDevice(const v8::FunctionCallbackInfo<v8::Value>& args)
  383. {
  384. ZoomVideoNodeTestAudioDeviceWrap::NewInstance(args);
  385. }
  386. void ZoomVideoNodeWrap::GetLiveTranscriptionHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
  387. {
  388. ZoomVideoNodeLiveTranscriptionHelperWrap::NewInstance(args);
  389. }
  390. void ZoomVideoNodeWrap::SetNodeAddonCallbacks(const v8::FunctionCallbackInfo<v8::Value>& args)
  391. {
  392. v8::Isolate* isolate = args.GetIsolate();
  393. ZNZoomVideoSDKErrors err = ZNZoomVideoSDKErrors_Success;
  394. do
  395. {
  396. if (args.Length() < 1)
  397. {
  398. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  399. break;
  400. }
  401. if (args[0]->IsNull())
  402. {
  403. ZoomNodeVideoSinkHelper::GetInst().onNodeAddonCallbacks.Clear();
  404. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  405. break;
  406. }
  407. if (!args[0]->IsFunction())
  408. {
  409. err = ZNZoomVideoSDKErrors_Invalid_Parameter;
  410. break;
  411. }
  412. v8::Local<v8::Function> cbfunc = v8::Local<v8::Function>::Cast(args[0]);
  413. v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function> > cb(isolate, cbfunc);
  414. ZoomNodeVideoSinkHelper::GetInst().onNodeAddonCallbacks = cb;
  415. } while (false);
  416. v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  417. args.GetReturnValue().Set(bret);
  418. }
  419. //void ZoomVideoNodeWrap::SendVideoFrame(const v8::FunctionCallbackInfo<v8::Value>& args)
  420. //{
  421. // v8::Isolate* isolate = args.GetIsolate();
  422. // com::electron::zoomvideo::sdk::proto::sendVideoFrameParams proto_param;
  423. // if (!SetProtoParam<com::electron::zoomvideo::sdk::proto::sendVideoFrameParams >(args, proto_param))
  424. // {
  425. // return;
  426. // }
  427. //
  428. // char* p_frameBuffer = NULL;
  429. // int width = 0;
  430. // int height = 0;
  431. // int frameLength = 0;
  432. // int rotation = 0;
  433. // if (proto_param.has_framebuffer())
  434. // {
  435. // p_frameBuffer = const_cast<char*>(proto_param.framebuffer().c_str());
  436. // }
  437. // if (proto_param.has_framelength())
  438. // {
  439. // frameLength = proto_param.framelength();
  440. // }
  441. // if (proto_param.has_height())
  442. // {
  443. // height = proto_param.height();
  444. // }
  445. // if (proto_param.has_rotaion())
  446. // {
  447. // rotation = proto_param.rotaion();
  448. // }
  449. // if (proto_param.has_width())
  450. // {
  451. // width = proto_param.width();
  452. // }
  453. //
  454. // ZNZoomVideoSDKErrors err = ZNZoomVideoSDKErrors_Success;
  455. //
  456. // _g_native_wrap.SendVideoFrame(p_frameBuffer, width, height, frameLength, rotation);
  457. // v8::Local<v8::Integer> bret = v8::Integer::New(isolate, (int32_t)err);
  458. // args.GetReturnValue().Set(bret);
  459. //}