소스 검색

配合Flyinsonolite实现第二屏会诊状态处理

felix 1 년 전
부모
커밋
3925bcd5a7

+ 15 - 8
FISSDK/FISIMPL/ConsultationServiceForAndroid.cs

@@ -38,7 +38,7 @@ namespace FISIMPL
         private int _ultrasoundCameraHeight;
         private int _localImageWidth;
         private int _localImageHeight;
-        private bool _secondWindowIsOpened = false;
+
         internal void Update(IvCloudTerminal vcloudTerminal)
         {
             try
@@ -210,7 +210,6 @@ namespace FISIMPL
                         _ultrasoundCameraHeight = 0;
                         _ultrasoundImageWidth = 0;
                         _ultrasoundImageHeight = 0;
-                        _secondWindowIsOpened = false;
                     }
                 }
             }
@@ -224,11 +223,10 @@ namespace FISIMPL
         {
             try
             {
-                if(string.IsNullOrEmpty(e))
+                if (string.IsNullOrEmpty(e))
                 {
                     return;
                 }
-                _secondWindowIsOpened= true;
                 NotificationSender.SendNotification(new FISNotificationArgs
                 {
                     Params = e,
@@ -1150,7 +1148,6 @@ namespace FISIMPL
         {
             try
             {
-                _secondWindowIsOpened = false;
                 lock (_lock)
                 {
                     foreach (var userId in _remoteVideoFileWriterList.Keys)
@@ -1960,7 +1957,7 @@ namespace FISIMPL
                     Logger.WriteLineInfo($"SendFlutterLiveConsultationInfo Invoke,Args:{JsonSerializer.Serialize(fisFlutterLiveConsultationInfo)}");
                     if (FISIMPL.IsConnectWithOldServer)
                     {
-                        Logger.WriteLineError($"ConsultationServiceForAndroid doesn't support SendFlutterLiveConsultationInfo for old Server");
+                        Logger.WriteLineError($"ConsultationServiceForWindows doesn't support SendFlutterLiveConsultationInfo for old Server");
                         return new FISResultInfoDTO
                         {
                             IsSuccess = false,
@@ -1987,6 +1984,16 @@ namespace FISIMPL
                                 FailMessage = "Args is null",
                             };
                         }
+                        var accountId = _consultationV2.GetUserInfo(fisFlutterLiveConsultationInfo.Token);
+                        if (string.IsNullOrEmpty(accountId))
+                        {
+                            Logger.WriteLineError($"Consultation SendFlutterLiveConsultationInfo error: Account Id is null");
+                            return new FISResultInfoDTO
+                            {
+                                IsSuccess = false,
+                                FailMessage = "Account Id is null",
+                            };
+                        }
                         var flutterLiveConsultationInfo = FISConverter.ConvertFISFlutterLiveConsultationInfoToFlutterLiveConsultationInfo(fisFlutterLiveConsultationInfo);
                         var result = _consultationV2.SendFlutterLiveConsultationInfo(flutterLiveConsultationInfo);
                         return FISConverter.ConvertResultInfoToFISResultInfo(result);
@@ -1994,7 +2001,7 @@ namespace FISIMPL
                 }
                 catch (Exception ex)
                 {
-                    Logger.WriteLineError($"ConsultationServiceForAndroid SendFlutterLiveConsultationInfo Error:{ex}");
+                    Logger.WriteLineError($"ConsultationServiceForWindows SendFlutterLiveConsultationInfo Error:{ex}");
                     return new FISResultInfoDTO
                     {
                         IsSuccess = false,
@@ -2280,7 +2287,7 @@ namespace FISIMPL
                         }
                         return new FISSecondWindowStateDTO
                         {
-                            IsSecondWindowOpen = _secondWindowIsOpened,
+                            IsSecondWindowOpen = _consultationV2.CheckSecondWindowState(),
                         };
                     }
                 }

+ 11 - 1
FISSDK/FISIMPL/ConsultationServiceForWindows.cs

@@ -2049,6 +2049,16 @@ namespace FISIMPL
                                 FailMessage = "Args is null",
                             };
                         }
+                        var accountId = _consultationV2.GetUserInfo(fisFlutterLiveConsultationInfo.Token);
+                        if (string.IsNullOrEmpty(accountId))
+                        {
+                            Logger.WriteLineError($"Consultation SendFlutterLiveConsultationInfo error: Account Id is null");
+                            return new FISResultInfoDTO
+                            {
+                                IsSuccess = false,
+                                FailMessage = "Account Id is null",
+                            };
+                        }
                         var flutterLiveConsultationInfo = FISConverter.ConvertFISFlutterLiveConsultationInfoToFlutterLiveConsultationInfo(fisFlutterLiveConsultationInfo);
                         var result = _consultationV2.SendFlutterLiveConsultationInfo(flutterLiveConsultationInfo);
                         return FISConverter.ConvertResultInfoToFISResultInfo(result);
@@ -2342,7 +2352,7 @@ namespace FISIMPL
                         }
                         return new FISSecondWindowStateDTO
                         {
-                            IsSecondWindowOpen = _secondWindowIsOpened,
+                            IsSecondWindowOpen = _consultationV2.CheckSecondWindowState(),
                         };
                     }
                 }

+ 2 - 0
FISSDK/FISIMPL/FISConverter.cs

@@ -601,6 +601,8 @@ namespace FISIMPL
             {
                 IsStartLiveConsultation = fisFlutterLiveConsultationInfo.IsStartLiveConsultation,
                 LiveConsultationFlutterUrl = fisFlutterLiveConsultationInfo.LiveConsultationFlutterUrl,
+                ConsulationId = fisFlutterLiveConsultationInfo.ConsultationCode,
+                Token = fisFlutterLiveConsultationInfo.Token,
             };
         }
 

+ 4 - 0
FISSDK/FISSDK/Consultation/FISFlutterLiveConsultationInfo.cs

@@ -11,5 +11,9 @@
         /// Is Start Live Consultation or Exit
         /// </summary>
         public bool IsStartLiveConsultation { get; set; }
+
+        public string Token { get; set; }
+
+        public string ConsultationCode { get; set; }
     }
 }

+ 38 - 3
FISSDK/FISSDKDemoV2/MainWindow.xaml.cs

@@ -25,16 +25,51 @@ namespace FISSDKDemoV2
         {
             InitializeComponent();
             var settings = new CefSettings();
+            settings.IgnoreCertificateErrors = true;
             settings.BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CefSharp/x64", "CefSharp.BrowserSubprocess.exe");
-            settings.CefCommandLineArgs.Add("no-proxy-server", "1");
-            //此配置可以允许摄像头打开摄像
+            if (!settings.CefCommandLineArgs.ContainsKey("disable-features"))
+            {
+                settings.CefCommandLineArgs.Add("disable-features", "TabHoverCards");
+            }
+            else
+            {
+                var existingFeatures = settings.CefCommandLineArgs["disable-features"];
+                settings.CefCommandLineArgs["disable-features"] = existingFeatures + ",TabHoverCards";
+            }
+            //允许媒体自动播放,而无需用户交互。
+            settings.CefCommandLineArgs.Add("autoplay-policy", "no-user-gesture-required");
+            //启用打印预览功能
+            settings.CefCommandLineArgs.Add("--enable-print-preview", "1");
+            //允许使用媒体流(例如麦克风和摄像头)。
             settings.CefCommandLineArgs.Add("enable-media-stream", "1");
+            //允许屏幕捕捉,这通常用于屏幕共享或录制。
+            settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing", "1");
+            //允许语音输入
+            settings.CefCommandLineArgs.Add("enable-speech-input", "1");
+            //禁用Web安全策略,允许跨源请求,但这可能会带来安全风险
+            settings.CefCommandLineArgs.Add("--disable-web-security", "1");
+            //允许HTTP屏幕捕获
+            settings.CefCommandLineArgs.Add("allow-http-screen-capture", "1");
+            //自动选择桌面捕捉源为整个屏幕
+            settings.CefCommandLineArgs.Add("--auto-select-desktop-capture-source", "Entire screen");
+            //使用假的UI来请求媒体流(例如摄像头和麦克风),而不显示真实的权限请求对话框
+            settings.CefCommandLineArgs.Add("--use-fake-ui-for-media-stream", "1");
+            //启用专有编解码器,这可以支持更多的视频格式
+            settings.CefCommandLineArgs.Add("proprietary_codecs", "1");
+            //启用剪贴板访问
+            settings.CefCommandLineArgs.Add("--enable-clipboard", "1");
+            //使用Chrome版本的FFmpeg,这可以支持更多的媒体格式
+            settings.CefCommandLineArgs.Add("ffmpeg_branding", "Chrome");
+            // 允许CEF访问剪贴板
+            settings.CefCommandLineArgs.Add("allow-cef-access-to-clipboard", "1");
+            //允许从文件访问文件,通常用于本地HTML页面可以读取其他本地文件。
+            settings.CefCommandLineArgs.Add("allow-file-access-from-files", "1");
             CefSharpSettings.LegacyJavascriptBindingEnabled = true;
             CefSharpSettings.ShutdownOnExit = false;
 #if DEBUG
             settings.RemoteDebuggingPort = 8088;
 #endif
-            Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
+            Cef.Initialize(settings);
             PageManager.Instance.MainWindow = this;
             _gcController = new GcController();
             RenderTextBlock();

+ 23 - 11
Vinno.vCloud.Common.FIS/Consultation/ConsultationClientV2.cs

@@ -32,6 +32,8 @@ namespace Vinno.vCloud.Common.FIS.Consultation
         protected int count = 0;
         protected ConsultationLiveVideoProviderV2 VideoProvider { get; }
 
+        public bool IsSecondViewMode { get; protected set; }
+
         /// <summary>
         /// Gets or sets the current live status
         /// </summary>
@@ -153,7 +155,7 @@ namespace Vinno.vCloud.Common.FIS.Consultation
             }
         }
 
-        public ResultInfoDTO Hangup()
+        public ResultInfoDTO Hangup(bool isFakeHangup = false)
         {
             try
             {
@@ -167,22 +169,31 @@ namespace Vinno.vCloud.Common.FIS.Consultation
                         FailMessage = "ConsultationHangup Fail: Current is not Consultating"
                     };
                 }
-                if (!IsOnlyForRtmpPushing)
+                if (isFakeHangup)
                 {
-                    var leaveLiveConsultationRequest = new LeaveLiveConsultationRequest
+                    lock (ConsultationInfoLocker)
                     {
-                        ConsultationCode = ConsultationInfo?.ConsultationId,
-                        Token = AccountToken,
-                    };
-                    var leaveResult = JsonRpcHelper.LeaveLiveConsultation(LiveConsultationService, leaveLiveConsultationRequest);
-                    if (leaveResult != null && leaveResult.ConsultationCode == ConsultationInfo?.ConsultationId)
+                        ConsultationInfo = null;
+                        _muteVideoUserList.Clear();
+                    }
+                    lock (_interactiveBoardLocker)
                     {
-                        result = LiveStates.OK;
+                        StrokeDict.Clear();
                     }
+                    return new ResultInfoDTO
+                    {
+                        IsSuccess = true,
+                    };
                 }
-                else
+                var leaveLiveConsultationRequest = new LeaveLiveConsultationRequest
+                {
+                    ConsultationCode = ConsultationInfo?.ConsultationId,
+                    Token = AccountToken,
+                };
+                var leaveResult = JsonRpcHelper.LeaveLiveConsultation(LiveConsultationService, leaveLiveConsultationRequest);
+                if (leaveResult == null || leaveResult.ConsultationCode != ConsultationInfo?.ConsultationId)
                 {
-                    result = LiveStates.OK;
+                    Logger.WriteLineError($"Hangup Fail, leaveResult.ConsultationCode is {leaveResult?.ConsultationCode}");
                 }
                 lock (ConsultationInfoLocker)
                 {
@@ -213,6 +224,7 @@ namespace Vinno.vCloud.Common.FIS.Consultation
             finally
             {
                 IsOnlyForRtmpPushing = false;
+                IsSecondViewMode = false;
             }
         }
 

+ 68 - 4
Vinno.vCloud.Common.FIS/Consultation/ConsultationRecipientV2.cs

@@ -21,6 +21,11 @@ namespace Vinno.vCloud.Common.FIS.Consultation
         /// </summary>
         public event EventHandler<ConsultationInfo> ConsultationRequestArrived;
 
+        /// <summary>
+        /// 当开始Web会诊时
+        /// </summary>
+        public event EventHandler<string> StartWebConsultationEvent;
+
         public ConsultationRecipientV2(ConsultationLiveVideoProviderV2 videoProvider, string deviceId, ILiveConsultationService liveConsultationService, IUserService userService, IDeviceService deviceService) : base(videoProvider, liveConsultationService, userService, deviceService)
         {
             _deviceId = deviceId;
@@ -30,13 +35,66 @@ namespace Vinno.vCloud.Common.FIS.Consultation
         /// Send a join Rtc Consultation Live  request
         /// </summary>
         /// <returns></returns>
-        public ResultInfoDTO StartLiveConsultation(LiveConsultationRequestDTO liveConsultationRequestDTO, string cameraHardwareId, string micHardwareId, string speakerHardwareId)
+        public ResultInfoDTO StartWebConsultation(FlutterLiveConsultationInfo flutterLiveConsultationInfo)
         {
             try
             {
                 if (CurrentLiveStatus == LiveStates.RecipientAcceptting || CurrentLiveStatus == LiveStates.RecipientAcceptted)
                 {
                     Logger.WriteLineInfo($"Consultation Live-- accept Consultation failed due to CurrentLiveStatus is {CurrentLiveStatus}");
+                    return new ResultInfoDTO
+                    {
+                        IsSuccess = false,
+                        FailMessage = $"StartWebConsultation Fail,Consultation is busy.",
+                        ErrorCode = 861,
+                    };
+                }
+                if (string.IsNullOrEmpty(flutterLiveConsultationInfo.ConsulationId))
+                {
+                    return new ResultInfoDTO
+                    {
+                        IsSuccess = false,
+                        FailMessage = $"StartWebConsultation Fail,Consultation id is null.",
+                    };
+                }
+                IsSecondViewMode = true;
+                ConsultationInfo consultationInfo = new ConsultationInfo(ChatRole.Recipient)
+                {
+                    ConsultationId = flutterLiveConsultationInfo.ConsulationId,
+                };
+                lock (ConsultationInfoLocker)
+                {
+                    ConsultationInfo = consultationInfo;
+                }
+                StartWebConsultationEvent?.Invoke(this, flutterLiveConsultationInfo.LiveConsultationFlutterUrl);
+                return new ResultInfoDTO
+                {
+                    IsSuccess = true,
+                };
+            }
+            catch (Exception ex)
+            {
+                Logger.WriteLineError($"Exception happened when StartWebConsultation {ex}");
+                Hangup(true);
+                return new ResultInfoDTO
+                {
+                    IsSuccess = false,
+                    FailMessage = $"StartWebConsultation Error:{ex}",
+                };
+            }
+        }
+
+        /// <summary>
+        /// Send a join Rtc Consultation Live  request
+        /// </summary>
+        /// <returns></returns>
+        public ResultInfoDTO StartLiveConsultation(LiveConsultationRequestDTO liveConsultationRequestDTO, string cameraHardwareId, string micHardwareId, string speakerHardwareId)
+        {
+            try
+            {
+                if (CurrentLiveStatus == LiveStates.RecipientAcceptting || CurrentLiveStatus == LiveStates.RecipientAcceptted || IsSecondViewMode)
+                {
+                    Logger.WriteLineInfo($"Consultation Live-- accept Consultation failed due to CurrentLiveStatus is {CurrentLiveStatus},IsSecondViewMode:{IsSecondViewMode}");
                     if (liveConsultationRequestDTO.IsInvite)
                     {
                         return new ResultInfoDTO
@@ -73,7 +131,7 @@ namespace Vinno.vCloud.Common.FIS.Consultation
                     var initiateLiveConsultationRequest = new InitiateLiveConsultationRequest
                     {
                         ConsultationCode = liveConsultationRequestDTO.ConsultationCode,
-                        Token = liveConsultationRequestDTO.Token,
+                        Token = AccountToken,
                         CheckOnly = false,
                     };
                     var initiateLiveConsultationResult = JsonRpcHelper.InitiateLiveConsultation(LiveConsultationService, initiateLiveConsultationRequest, out var errorCode);
@@ -94,7 +152,7 @@ namespace Vinno.vCloud.Common.FIS.Consultation
                     var joinLiveConsultationRequest = new JoinLiveConsultationRequest
                     {
                         ConsultationCode = liveConsultationRequestDTO.ConsultationCode,
-                        Token = liveConsultationRequestDTO.Token,
+                        Token = AccountToken,
                         CheckOnly = false,
                     };
                     var joinLiveConsultationResult = JsonRpcHelper.JoinInLiveConsultation(LiveConsultationService, joinLiveConsultationRequest, out var errorCode);
@@ -218,7 +276,6 @@ namespace Vinno.vCloud.Common.FIS.Consultation
                         },
                     },
                 };
-
                 lock (ConsultationInfoLocker)
                 {
                     ConsultationInfo = consultationInfo;
@@ -258,6 +315,13 @@ namespace Vinno.vCloud.Common.FIS.Consultation
                     };
                 }
                 ConsultationInfo.ConsultationId = changeLiveConsultation0RequestDTO.ConsultationCode;
+                if (IsSecondViewMode && !IsOnlyForRtmpPushing)//第二屏且不是rtmp推流的情况下
+                {
+                    return new ResultInfoDTO
+                    {
+                        IsSuccess = true,
+                    };
+                }
                 VideoProvider.ChangeConsultationCodeForConsultationConnectionKeeper(changeLiveConsultation0RequestDTO.ConsultationCode);
                 if (IsOnlyForRtmpPushing)
                 {

+ 21 - 4
Vinno.vCloud.Common.FIS/Consultation/ConsultationV2.cs

@@ -19,7 +19,6 @@ namespace Vinno.vCloud.Common.FIS.Consultation
         private readonly JsonRpcClient _client;
         private readonly string _deviceToken;
         private bool _disposed;
-
         public string ConsultationUrl { get; private set; }
 
         /// <summary>
@@ -120,10 +119,16 @@ namespace Vinno.vCloud.Common.FIS.Consultation
             ConsultationRecipient.InteractiveBoardInfoArrived += OnInteractiveBoardInfoArrived;
             ConsultationRecipient.ClearInteractiveBoardArrived += OnClearInteractiveBoardArrived;
             ConsultationRecipient.MuteVideoUserListNotifyArrived += OnMuteVideoUserListNotifyArrived;
+            ConsultationRecipient.StartWebConsultationEvent += OnStartWebConsultationEvent;
             ConsultationManager = new ConsultationManagerV2(liveConsultationService);
             ConsultationManager.SwitchToLocalPatientEvent += OnSwitchToLocalPatientEvent;
         }
 
+        private void OnStartWebConsultationEvent(object sender, string e)
+        {
+            StartWebConsultationEvent?.Invoke(this, e);
+        }
+
         private void OnSwitchToLocalPatientEvent(object sender, vCloudExamInfo e)
         {
             SwitchToLocalPatientEvent?.Invoke(this, e);
@@ -187,6 +192,7 @@ namespace Vinno.vCloud.Common.FIS.Consultation
                 ConsultationRecipient.InteractiveBoardInfoArrived -= OnInteractiveBoardInfoArrived;
                 ConsultationRecipient.ClearInteractiveBoardArrived -= OnClearInteractiveBoardArrived;
                 ConsultationRecipient.MuteVideoUserListNotifyArrived -= OnMuteVideoUserListNotifyArrived;
+                ConsultationRecipient.StartWebConsultationEvent -= OnStartWebConsultationEvent;
                 ConsultationRecipient.Dispose();
                 ConsultationManager.SwitchToLocalPatientEvent -= OnSwitchToLocalPatientEvent;
                 ConsultationManager.Dispose();
@@ -333,6 +339,7 @@ namespace Vinno.vCloud.Common.FIS.Consultation
             }
             if (!flutterLiveConsultationInfo.IsStartLiveConsultation)
             {
+                ConsultationRecipient.Hangup(true);
                 OnConsultationDisconnected(this, ConsultationDisconnectedType.HangUpBySelf);
                 return new ResultInfoDTO
                 {
@@ -350,14 +357,19 @@ namespace Vinno.vCloud.Common.FIS.Consultation
                         FailMessage = "Url is null",
                     };
                 }
-                else
+                if (string.IsNullOrEmpty(flutterLiveConsultationInfo.ConsulationId))
                 {
-                    StartWebConsultationEvent?.Invoke(this, flutterLiveConsultationInfo.LiveConsultationFlutterUrl);
+                    Logger.WriteLineError($"SendFlutterLiveConsultationInfo Error:consultationId is null");
                     return new ResultInfoDTO
                     {
-                        IsSuccess = true,
+                        IsSuccess = false,
+                        FailMessage = "consultationId is null",
                     };
                 }
+                else
+                {
+                    return ConsultationRecipient.StartWebConsultation(flutterLiveConsultationInfo);
+                }
             }
         }
 
@@ -373,5 +385,10 @@ namespace Vinno.vCloud.Common.FIS.Consultation
             }
             return ConsultationRecipient.SwitchVideoPlay(userId, isVideoOpen);
         }
+
+        public bool CheckSecondWindowState()
+        {
+            return ConsultationRecipient.IsSecondViewMode;
+        }
     }
 }

+ 4 - 0
Vinno.vCloud.Common.FIS/Consultation/FlutterLiveConsultationInfo.cs

@@ -11,5 +11,9 @@
         /// Is Start Live Consultation or Exit
         /// </summary>
         public bool IsStartLiveConsultation { get; set; }
+
+        public string Token { get; set; }
+
+        public string ConsulationId { get; set; }
     }
 }

+ 6 - 0
Vinno.vCloud.Common.FIS/Consultation/IConsultationV2.cs

@@ -146,6 +146,12 @@ namespace Vinno.vCloud.Common.FIS.Consultation
         /// <returns></returns>
         ResultInfoDTO SwitchVideoPlayFromFlutter(string userId, bool isVideoOpen);
 
+        /// <summary>
+        /// 检查第二窗口的状态,如果第二窗口关闭,则关闭fispanel
+        /// </summary>
+        /// <returns></returns>
+        bool CheckSecondWindowState();
+
         /// <summary>
         /// 当开始Web会诊时
         /// </summary>