LiveVideoServiceForWindows.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. using FISLib;
  2. using FISLib.LiveVideo;
  3. using FISLib.Notification;
  4. using System;
  5. using System.Collections.Concurrent;
  6. using System.Collections.Generic;
  7. using System.Runtime.InteropServices;
  8. using System.Threading;
  9. using Vinno.FIS.TRTCClient.Common.Enum;
  10. using Vinno.IUS.Common.Log;
  11. using Vinno.vCloud.Common.FIS;
  12. using Vinno.vCloud.Common.FIS.LiveVideos;
  13. using Vinno.vCloud.FIS.CrossPlatform.Common.LiveVideo;
  14. namespace FISIMPL
  15. {
  16. internal class LiveVideoServiceForWindows : ILiveVideoService, IDisposable
  17. {
  18. private readonly ConcurrentStack<byte[]> _byteImageCache = new ConcurrentStack<byte[]>();
  19. private ILiveVideo _liveVideo;
  20. private ILiveVideoV2 _liveVideoV2;
  21. private PipeClient _pipeClient;
  22. private PipeServer _pipeServer;
  23. private FISImageFrameData _imageFrameData;
  24. /// <summary>
  25. /// Raised when local camera live execute
  26. /// </summary>
  27. public event EventHandler<FISImageFrameData> PreviewCameraCaptured;
  28. /// <summary>
  29. /// Raised when capture image generated.(only for new server)
  30. /// </summary>
  31. public event EventHandler<string> CaptureImageGenerated;
  32. /// <summary>
  33. /// Raised when record video generated.(only for new server)
  34. /// </summary>
  35. public event EventHandler<string> RecordVideoGenerated;
  36. internal void Update(IvCloudTerminal vcloudTerminal)
  37. {
  38. try
  39. {
  40. var newLiveVideo = vcloudTerminal?.GetFeature<ILiveVideo>(TerminalFeatureType.LiveVideo);
  41. if (newLiveVideo != _liveVideo)
  42. {
  43. if (_liveVideo != null)
  44. {
  45. _liveVideo.PreviewCameraCaptured -= OnPreviewCameraCaptured;
  46. _liveVideo.CameraPreviewImageSizeChanged -= OnCameraPreviewImageSizeChanged;
  47. _liveVideo.LiveNotification -= OnLiveNotification;
  48. _liveVideo.Dispose();
  49. _liveVideo = null;
  50. if (FISIMPL.IsRunningJsonRpcMode)
  51. {
  52. _pipeClient.Dispose();
  53. _pipeClient.LogMsgThrow -= OnLogMsgThrow;
  54. _pipeClient = null;
  55. _pipeServer.DataReceived -= OnDataReceived;
  56. _pipeServer.Dispose();
  57. _pipeServer.LogMsgThrow -= OnLogMsgThrow;
  58. _pipeServer = null;
  59. }
  60. }
  61. _liveVideo = newLiveVideo;
  62. if (_liveVideo != null)
  63. {
  64. _liveVideo.PreviewCameraCaptured += OnPreviewCameraCaptured;
  65. _liveVideo.CameraPreviewImageSizeChanged += OnCameraPreviewImageSizeChanged;
  66. _liveVideo.LiveNotification += OnLiveNotification;
  67. if (FISIMPL.IsRunningJsonRpcMode)
  68. {
  69. _pipeClient = new PipeClient(FISConsts.PipeForLiveVideoCameraPreviewImage);
  70. _pipeClient.LogMsgThrow += OnLogMsgThrow;
  71. _pipeClient.Start();
  72. _pipeServer = new PipeServer(FISConsts.PipeForLiveVideoUltrasoundImage);
  73. _pipeServer.LogMsgThrow += OnLogMsgThrow;
  74. _pipeServer.DataReceived += OnDataReceived;
  75. _pipeServer.StartAndReceive();
  76. }
  77. }
  78. }
  79. }
  80. catch (Exception ex)
  81. {
  82. Logger.WriteLineError($"LiveVideoServiceForWindows Update Error:{ex}");
  83. }
  84. }
  85. internal void UpdateV2(IvCloudTerminalV2 vcloudTerminalV2)
  86. {
  87. try
  88. {
  89. var newLiveVideo = vcloudTerminalV2?.GetFeature<ILiveVideoV2>(TerminalFeatureType.LiveVideo);
  90. if (newLiveVideo != _liveVideoV2)
  91. {
  92. if (_liveVideoV2 != null)
  93. {
  94. _liveVideoV2.PreviewCameraCaptured -= OnPreviewCameraCaptured;
  95. _liveVideoV2.CameraPreviewImageSizeChanged -= OnCameraPreviewImageSizeChanged;
  96. _liveVideoV2.LiveNotification -= OnLiveNotification;
  97. _liveVideoV2.CaptureImageGenerated -= OnCaptureImageGenerated;
  98. _liveVideoV2.RecordVideoGenerated -= OnRecordVideoGenerated;
  99. _liveVideoV2.Dispose();
  100. _liveVideoV2 = null;
  101. if (FISIMPL.IsRunningJsonRpcMode)
  102. {
  103. _pipeClient.Dispose();
  104. _pipeClient.LogMsgThrow -= OnLogMsgThrow;
  105. _pipeClient = null;
  106. _pipeServer.DataReceived -= OnDataReceived;
  107. _pipeServer.Dispose();
  108. _pipeServer.LogMsgThrow -= OnLogMsgThrow;
  109. _pipeServer = null;
  110. }
  111. }
  112. _liveVideoV2 = newLiveVideo;
  113. if (_liveVideoV2 != null)
  114. {
  115. _liveVideoV2.PreviewCameraCaptured += OnPreviewCameraCaptured;
  116. _liveVideoV2.CameraPreviewImageSizeChanged += OnCameraPreviewImageSizeChanged;
  117. _liveVideoV2.LiveNotification += OnLiveNotification;
  118. _liveVideoV2.CaptureImageGenerated += OnCaptureImageGenerated;
  119. _liveVideoV2.RecordVideoGenerated += OnRecordVideoGenerated;
  120. if (FISIMPL.IsRunningJsonRpcMode)
  121. {
  122. _pipeClient = new PipeClient(FISConsts.PipeForLiveVideoCameraPreviewImage);
  123. _pipeClient.LogMsgThrow += OnLogMsgThrow;
  124. _pipeClient.Start();
  125. _pipeServer = new PipeServer(FISConsts.PipeForLiveVideoUltrasoundImage);
  126. _pipeServer.LogMsgThrow += OnLogMsgThrow;
  127. _pipeServer.DataReceived += OnDataReceived;
  128. _pipeServer.StartAndReceive();
  129. }
  130. }
  131. }
  132. }
  133. catch (Exception ex)
  134. {
  135. Logger.WriteLineError($"LiveVideoServiceForWindows UpdateV2 Error:{ex}");
  136. }
  137. }
  138. private void OnCaptureImageGenerated(object sender, string e)
  139. {
  140. CaptureImageGenerated?.Invoke(this, e);
  141. }
  142. private void OnRecordVideoGenerated(object sender, string e)
  143. {
  144. RecordVideoGenerated?.Invoke(this, e);
  145. }
  146. private void OnDataReceived(object sender, byte[] e)
  147. {
  148. _byteImageCache.Push(e);
  149. }
  150. /// <summary>
  151. /// Change camera settings.
  152. /// </summary>
  153. /// <param name="cameraSetting"></param>
  154. public void ChangeCameraSetting(CameraSetting cameraSetting)
  155. {
  156. try
  157. {
  158. if (cameraSetting == null)
  159. {
  160. Logger.WriteLineError($"ChangeCameraSetting error: cameraSetting is null");
  161. return;
  162. }
  163. if (FISIMPL.IsConnectWithOldServer)
  164. {
  165. if (_liveVideo == null)
  166. {
  167. Logger.WriteLineError($"ChangeCameraSetting error: live video feature is null");
  168. return;
  169. }
  170. _liveVideo.ChangeCameraSettings(cameraSetting.CameraLiveEnabled && cameraSetting.LiveVideoEnabled, cameraSetting.CameraSource?.Id, cameraSetting.MicSource?.Id, cameraSetting.CameraPreviewEnabled, cameraSetting.LiveVideoEnabled, cameraSetting.IsMute);
  171. }
  172. else
  173. {
  174. if (_liveVideoV2 == null)
  175. {
  176. Logger.WriteLineError($"ChangeCameraSetting error: live video v2 feature is null");
  177. return;
  178. }
  179. _liveVideoV2.ChangeCameraSettings(cameraSetting.CameraLiveEnabled && cameraSetting.LiveVideoEnabled, cameraSetting.CameraSource?.Id, cameraSetting.MicSource?.Id, cameraSetting.CameraPreviewEnabled, cameraSetting.LiveVideoEnabled, cameraSetting.IsMute);
  180. }
  181. }
  182. catch (Exception ex)
  183. {
  184. Logger.WriteLineError($"LiveVideoServiceForWindows ChangeCameraSetting Error:{ex}");
  185. }
  186. }
  187. /// <summary>
  188. /// Change camera settings for sonopost
  189. /// </summary>
  190. /// <param name="cameraSetting"></param>
  191. public void ChangeCameraSettingForSonopost(CameraSettingForSonopost cameraSetting)
  192. {
  193. try
  194. {
  195. if (cameraSetting == null)
  196. {
  197. Logger.WriteLineError($"ChangeCameraSetting error: cameraSetting is null");
  198. return;
  199. }
  200. var currentLiveChannelCategory = (EnumLiveChannelCategory)cameraSetting.CurrentLiveChannelCategory;
  201. var videoDeviceInfoList = new List<CPVideoDeviceInfo>();
  202. if (cameraSetting.VideoDeviceInfoList != null)
  203. {
  204. foreach (var fisVideoDeviceInfo in cameraSetting.VideoDeviceInfoList)
  205. {
  206. var videoDeviceInfo = FISConverter.ConvertFISVideoDeviceInfoToCPVideoDeviceInfo(fisVideoDeviceInfo);
  207. videoDeviceInfoList.Add(videoDeviceInfo);
  208. }
  209. }
  210. string micId = null;
  211. bool isMute = true;
  212. if (cameraSetting.MicDeviceInfo != null)
  213. {
  214. micId = cameraSetting.MicDeviceInfo.Id;
  215. isMute = !cameraSetting.MicDeviceInfo.IsEnable;
  216. }
  217. var rainbowImageDetectConfig = FISConverter.ConvertFISRainbowImageDetectConfigToRainbowImageDetectConfig(cameraSetting.RainbowImageDetectConfig);
  218. if (FISIMPL.IsConnectWithOldServer)
  219. {
  220. if (_liveVideo == null)
  221. {
  222. Logger.WriteLineError($"ChangeCameraSetting error: live video feature is null");
  223. return;
  224. }
  225. _liveVideo.ChangeCameraSettingsForSonopost(cameraSetting.CameraPreviewEnabled, currentLiveChannelCategory, videoDeviceInfoList, rainbowImageDetectConfig, micId, isMute);
  226. }
  227. else
  228. {
  229. if (_liveVideoV2 == null)
  230. {
  231. Logger.WriteLineError($"ChangeCameraSetting error: live videoV2 feature is null");
  232. return;
  233. }
  234. _liveVideoV2.ChangeCameraSettingsForSonopost(cameraSetting.CameraPreviewEnabled, currentLiveChannelCategory, videoDeviceInfoList, micId, isMute, rainbowImageDetectConfig);
  235. }
  236. }
  237. catch (Exception ex)
  238. {
  239. Logger.WriteLineError($"LiveVideoServiceForWindows ChangeCameraSettingForSonopost Error:{ex}");
  240. }
  241. }
  242. /// <summary>
  243. /// Speed live test network and auto select good network to server
  244. /// </summary>
  245. /// <returns></returns>
  246. public bool StartSpeedTest()
  247. {
  248. try
  249. {
  250. if (FISIMPL.IsConnectWithOldServer)
  251. {
  252. if (_liveVideo == null)
  253. {
  254. Logger.WriteLineError($"ChangeCameraSetting error: live video feature is null");
  255. return false;
  256. }
  257. return _liveVideo.StartSpeedTest();
  258. }
  259. else
  260. {
  261. if (_liveVideoV2 == null)
  262. {
  263. Logger.WriteLineError($"ChangeCameraSetting error: live video v2 feature is null");
  264. return false;
  265. }
  266. return _liveVideoV2.StartSpeedTest();
  267. }
  268. }
  269. catch (Exception ex)
  270. {
  271. Logger.WriteLineError($"LiveVideoServiceForWindows StartSpeedTest Error:{ex}");
  272. return false;
  273. }
  274. }
  275. /// <summary>
  276. /// Capture ultrasound machie image data.
  277. /// </summary>
  278. /// <param name="length">image data length</param>
  279. /// <param name="width">image width</param>
  280. /// <param name="height">image height</param>
  281. public void CapturedUSImageData(int length, int width, int height)
  282. {
  283. try
  284. {
  285. byte[] byteImage = null;
  286. int retryCount = 0;
  287. while (!_byteImageCache.TryPop(out byteImage) && retryCount < 50)
  288. {
  289. Thread.Sleep(10);
  290. retryCount++;
  291. }
  292. if (byteImage == null)
  293. {
  294. Logger.WriteLineError($"LiveVideoServiceForWindows-CapturedUSImageData Get Image Cache Fail");
  295. return;
  296. }
  297. if (byteImage == null)
  298. {
  299. return;
  300. }
  301. var imageCaptureDataInfo = new CaptureDataInfo
  302. {
  303. Width = width,
  304. Height = height,
  305. Data = byteImage,
  306. };
  307. ImageDataCapturer.RaiseImdageDataCaptured(imageCaptureDataInfo);
  308. }
  309. catch (Exception ex)
  310. {
  311. Logger.WriteLineError($"LiveVideoServiceForWindows CapturedUSImageData Error:{ex}");
  312. }
  313. }
  314. /// <summary>
  315. /// Capture ultrasound machie image data.
  316. /// </summary>
  317. /// <param name="fisVideoFrameData">image data</param>
  318. public void CapturedUSImageData_2(FISVideoFrameData fisVideoFrameData)
  319. {
  320. try
  321. {
  322. var imageCaptureDataInfo = new CaptureDataInfo
  323. {
  324. Width = fisVideoFrameData.Width,
  325. Height = fisVideoFrameData.Height,
  326. Data = fisVideoFrameData.Data,
  327. };
  328. ImageDataCapturer.RaiseImdageDataCaptured(imageCaptureDataInfo);
  329. }
  330. catch (Exception ex)
  331. {
  332. Logger.WriteLineError($"LiveVideoServiceForWindows CapturedUSImageData Error:{ex}");
  333. }
  334. }
  335. /// <summary>
  336. /// 获取品牌列表
  337. /// </summary>
  338. /// <returns></returns>
  339. public List<string> GetBrandList()
  340. {
  341. try
  342. {
  343. if (FISIMPL.IsConnectWithOldServer)
  344. {
  345. if (_liveVideo == null)
  346. {
  347. Logger.WriteLineError($"GetBrandList error: live video feature is null");
  348. return new List<string>();
  349. }
  350. return _liveVideo.GetBrandList();
  351. }
  352. else
  353. {
  354. if (_liveVideoV2 == null)
  355. {
  356. Logger.WriteLineError($"GetBrandList error: live videoV2 feature is null");
  357. return new List<string>();
  358. }
  359. return _liveVideoV2.GetBrandList();
  360. }
  361. }
  362. catch (Exception ex)
  363. {
  364. Logger.WriteLineError($"LiveVideoServiceForWindows GetBrandList Error:{ex}");
  365. return new List<string>();
  366. }
  367. }
  368. /// <summary>
  369. /// 获取型号列表
  370. /// </summary>
  371. /// <param name="brand"></param>
  372. /// <param name="model"></param>
  373. /// <returns></returns>
  374. public List<string> GetModelList(string brand)
  375. {
  376. try
  377. {
  378. if (FISIMPL.IsConnectWithOldServer)
  379. {
  380. if (_liveVideo == null)
  381. {
  382. Logger.WriteLineError($"GetModelList error: live video feature is null");
  383. return new List<string>();
  384. }
  385. return _liveVideo.GetModelList(brand);
  386. }
  387. else
  388. {
  389. if (_liveVideoV2 == null)
  390. {
  391. Logger.WriteLineError($"GetModelList error: live videoV2 feature is null");
  392. return new List<string>();
  393. }
  394. return _liveVideoV2.GetModelList(brand);
  395. }
  396. }
  397. catch (Exception ex)
  398. {
  399. Logger.WriteLineError($"LiveVideoServiceForWindows GetModelList Error:{ex}");
  400. return new List<string>();
  401. }
  402. }
  403. /// <summary>
  404. /// 获取推荐分辨率
  405. /// </summary>
  406. /// <param name="brand"></param>
  407. /// <param name="model"></param>
  408. /// <returns></returns>
  409. public FISDeviceRecommandResolution GetRecommandResolution(string brand, string model)
  410. {
  411. try
  412. {
  413. if (FISIMPL.IsConnectWithOldServer)
  414. {
  415. if (_liveVideo == null)
  416. {
  417. Logger.WriteLineError($"GetRecommandResolution error: live video feature is null");
  418. return null;
  419. }
  420. var result = _liveVideo.GetRecommandResolution(brand, model);
  421. return FISConverter.ConvertDeviceRecommandResolutionToFISDeviceRecommandResolution(result);
  422. }
  423. else
  424. {
  425. if (_liveVideoV2 == null)
  426. {
  427. Logger.WriteLineError($"GetRecommandResolution error: live videoV2 feature is null");
  428. return null;
  429. }
  430. var result = _liveVideoV2.GetRecommandResolution(brand, model);
  431. return FISConverter.ConvertDeviceRecommandResolutionToFISDeviceRecommandResolution(result);
  432. }
  433. }
  434. catch (Exception ex)
  435. {
  436. Logger.WriteLineError($"LiveVideoServiceForWindows GetRecommandResolution Error:{ex}");
  437. return null;
  438. }
  439. }
  440. /// <summary>
  441. /// Dispose
  442. /// </summary>
  443. public void Dispose()
  444. {
  445. try
  446. {
  447. Update(null);
  448. UpdateV2(null);
  449. }
  450. catch (Exception ex)
  451. {
  452. Logger.WriteLineError($"LiveVideoServiceForWindows Dispose Error:{ex}");
  453. }
  454. }
  455. private void OnPreviewCameraCaptured(object sender, byte[] e)
  456. {
  457. try
  458. {
  459. if (FISIMPL.IsRunningJsonRpcMode)
  460. {
  461. _pipeClient?.SendBytes(e);
  462. }
  463. else
  464. {
  465. if (_imageFrameData == null || _imageFrameData.Size != e.Length)
  466. {
  467. return;
  468. }
  469. Marshal.Copy(e, 0, _imageFrameData.Data, e.Length);
  470. PreviewCameraCaptured?.Invoke(this, _imageFrameData);
  471. }
  472. }
  473. catch (Exception ex)
  474. {
  475. Logger.WriteLineError($"LiveVideoServiceForWindows OnPreviewCameraCaptured Error:{ex}");
  476. }
  477. }
  478. private void OnCameraPreviewImageSizeChanged(object sender, ImageSize e)
  479. {
  480. try
  481. {
  482. if (FISIMPL.IsRunningJsonRpcMode)
  483. {
  484. var fisImageSize = new FISImageSize(e.Width, e.Height);
  485. NotificationSender.SendNotification(new FISNotificationArgs
  486. {
  487. NotificationType = FISNotificationType.FISLiveVideoCameraImageSizeChange,
  488. Params = fisImageSize
  489. });
  490. }
  491. else
  492. {
  493. if (_imageFrameData == null)
  494. {
  495. _imageFrameData = new FISImageFrameData(e.Width, e.Height);
  496. }
  497. else if (_imageFrameData.Width != e.Width || _imageFrameData.Height != e.Height)
  498. {
  499. _imageFrameData.Resize(e.Width, e.Height);
  500. }
  501. }
  502. }
  503. catch (Exception ex)
  504. {
  505. Logger.WriteLineError($"LiveVideoServiceForWindows OnCameraPreviewImageSizeChanged Error:{ex}");
  506. }
  507. }
  508. private void OnLiveNotification(object sender, LiveNotificationArgs e)
  509. {
  510. try
  511. {
  512. var fisLiveNotificationArgs = new FISLiveNotificationArgs(e.IsLive, e.LiveWidth, e.LiveHeight);
  513. if (FISIMPL.IsRunningJsonRpcMode)
  514. {
  515. NotificationSender.SendNotification(new FISNotificationArgs
  516. {
  517. Params = fisLiveNotificationArgs,
  518. NotificationType = FISNotificationType.FISLiveVideoLiveNotification
  519. });
  520. }
  521. }
  522. catch (Exception ex)
  523. {
  524. Logger.WriteLineError($"LiveVideoServiceForWindows OnLiveNotification Error:{ex}");
  525. }
  526. }
  527. private void OnLogMsgThrow(object sender, FISLogEventArgs e)
  528. {
  529. if (e == null)
  530. {
  531. return;
  532. }
  533. switch (e.LogType)
  534. {
  535. case FISDeviceLogCategory.Error:
  536. Logger.WriteLineError(e.Msg);
  537. break;
  538. case FISDeviceLogCategory.Warn:
  539. Logger.WriteLineWarn(e.Msg);
  540. break;
  541. case FISDeviceLogCategory.Verb:
  542. Logger.WriteLineVerbose(e.Msg);
  543. break;
  544. case FISDeviceLogCategory.Info:
  545. default:
  546. Logger.WriteLineInfo(e.Msg);
  547. break;
  548. }
  549. }
  550. public void ChangeRealTimeCaptureSetting(bool isStart)
  551. {
  552. try
  553. {
  554. if (FISIMPL.IsConnectWithOldServer)
  555. {
  556. Logger.WriteLineError($"ChangeRealTimeCaptureSetting error: old Server doesn't support");
  557. return;
  558. }
  559. else
  560. {
  561. if (_liveVideoV2 == null)
  562. {
  563. Logger.WriteLineError($"ChangeRealTimeCaptureSetting error: live videoV2 feature is null");
  564. return;
  565. }
  566. _liveVideoV2.ChangeRealTimeCaptureSetting(isStart);
  567. }
  568. }
  569. catch (Exception ex)
  570. {
  571. Logger.WriteLineError($"LiveVideoServiceForWindows ChangeRealTimeCaptureSetting Error:{ex}");
  572. }
  573. }
  574. /// <summary>
  575. /// Capture current Image
  576. /// </summary>
  577. public void CaptureCurrentImage()
  578. {
  579. try
  580. {
  581. if (FISIMPL.IsConnectWithOldServer)
  582. {
  583. Logger.WriteLineError($"CaptureCurrentImage error: old Server doesn't support");
  584. return;
  585. }
  586. else
  587. {
  588. if (_liveVideoV2 == null)
  589. {
  590. Logger.WriteLineError($"CaptureCurrentImage error: live videoV2 feature is null");
  591. return;
  592. }
  593. _liveVideoV2.CaptureCurrentImage();
  594. }
  595. }
  596. catch (Exception ex)
  597. {
  598. Logger.WriteLineError($"LiveVideoServiceForWindows CaptureCurrentImage Error:{ex}");
  599. }
  600. }
  601. /// <summary>
  602. /// Start Record Video
  603. /// </summary>
  604. public void StartRecordVideo()
  605. {
  606. try
  607. {
  608. if (FISIMPL.IsConnectWithOldServer)
  609. {
  610. Logger.WriteLineError($"StartRecordVideo error: old Server doesn't support");
  611. return;
  612. }
  613. else
  614. {
  615. if (_liveVideoV2 == null)
  616. {
  617. Logger.WriteLineError($"StartRecordVideo error: live videoV2 feature is null");
  618. return;
  619. }
  620. _liveVideoV2.StartRecordVideo();
  621. }
  622. }
  623. catch (Exception ex)
  624. {
  625. Logger.WriteLineError($"LiveVideoServiceForWindows StartRecordVideo Error:{ex}");
  626. }
  627. }
  628. /// <summary>
  629. /// Stop Record Video
  630. /// </summary>
  631. public void StopRecordVideo(bool isTimeOut)
  632. {
  633. try
  634. {
  635. if (FISIMPL.IsConnectWithOldServer)
  636. {
  637. Logger.WriteLineError($"StopRecordVideo error: old Server doesn't support");
  638. return;
  639. }
  640. else
  641. {
  642. if (_liveVideoV2 == null)
  643. {
  644. Logger.WriteLineError($"StopRecordVideo error: live videoV2 feature is null");
  645. return;
  646. }
  647. _liveVideoV2.StopRecordVideo(isTimeOut);
  648. }
  649. }
  650. catch (Exception ex)
  651. {
  652. Logger.WriteLineError($"LiveVideoServiceForWindows StopRecordVideo Error:{ex}");
  653. }
  654. }
  655. public void ReUploadRestVid()
  656. {
  657. try
  658. {
  659. if (FISIMPL.IsConnectWithOldServer)
  660. {
  661. Logger.WriteLineError($"ReUploadRestVid error: old Server doesn't support");
  662. return;
  663. }
  664. else
  665. {
  666. if (_liveVideoV2 == null)
  667. {
  668. Logger.WriteLineError($"ReUploadRestVid error: live videoV2 feature is null");
  669. }
  670. _liveVideoV2.ReUploadRestVid();
  671. }
  672. }
  673. catch (Exception ex)
  674. {
  675. Logger.WriteLineError($"LiveVideoServiceForWindows StopRecordVideo Error:{ex}");
  676. }
  677. }
  678. }
  679. }