From adc150efb13a0506f45a3c344c3ee2ef2dba8e90 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 01 七月 2021 15:19:13 +0800
Subject: [PATCH] 合并嘉乐lc代码

---
 HDL_ON/DAL/ThirdPartySdk/ESOnVideo.cs |  364 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 335 insertions(+), 29 deletions(-)

diff --git a/HDL_ON/DAL/ThirdPartySdk/ESOnVideo.cs b/HDL_ON/DAL/ThirdPartySdk/ESOnVideo.cs
index 9758f95..d1be072 100644
--- a/HDL_ON/DAL/ThirdPartySdk/ESOnVideo.cs
+++ b/HDL_ON/DAL/ThirdPartySdk/ESOnVideo.cs
@@ -3,9 +3,11 @@
 using HDL_ON.DAL.Server;
 using System.Threading;
 using System.Collections.Generic;
+using HDL_ON.UI.UI2.PersonalCenter.PirDevice;
 
 #if __IOS__
 using Shared.IOS.ESVideoOnSDK;
+using Shared.IOS.LCVideoOnSDK;
 using UIKit;
 using Foundation;
 #else
@@ -56,12 +58,18 @@
         /// <summary>
         /// 鐩戞帶椤甸潰
         /// </summary>
+<<<<<<< HEAD
         /// <param name="mESVideoInfo">涓版灄鐩戣鎵�闇�鐩稿叧鍙傛暟</param>
         public void ShowESVideoMonitor(ESVideoInfo mESVideoInfo)
+=======
+        /// <param name="mESVideoInfo"></param>
+        public void ShowESVideoMonitor(ESVideoInfo mESVideoInfo, string interphoneType)
+>>>>>>> origin/CJL-LC
         {
-#if __IOS__
-             int roomID = 0;
+            this.esVideoInfo = mESVideoInfo;
+            int roomID = 0;
             int.TryParse(mESVideoInfo.roomno, out roomID);
+<<<<<<< HEAD
             ESOnMonitorViewController vc = new ESOnMonitorViewController();
             vc.MESVideoID = mESVideoInfo.ESVideoUUID;
             vc.MESRoomID =roomID;
@@ -71,62 +79,152 @@
             mOnESCallDelegate = new OnESCallDelegate(this);
             vc.MESCallDelegate = mOnESCallDelegate;
             Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
-#else
+=======
 
-            Intent intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity));
+#if __IOS__
+            if (interphoneType == "IMOUVISIAL")
+            {
+                //涔愭鍙瀵硅
+                //1.鍒濆鍖朙COpenSDK_Api
+                LCApiKit.SharedInstance().InitSDKOpenApi(mESVideoInfo.Lc_AccessToken);
+                LCApiKit.SharedInstance().CurrentDevicePlayToken = mESVideoInfo.Lc_PlayToken;
+                LCApiKit.SharedInstance().CurrentDeviceId = mESVideoInfo.Lc_DeviceId;
+                LCApiKit.SharedInstance().CurrentDeviceName = mESVideoInfo.DeviceName;
+                LCApiKit.SharedInstance().CurrentPsk = mESVideoInfo.Lc_DeviceId;
+                //2.璋冩暣鐩戣椤甸潰
+                LCOnMonitorViewController vc = new LCOnMonitorViewController();
+                mOnLCCallDelegate = new OnLCCallDelegate(this);
+                vc.MLCCallDelegate = mOnLCCallDelegate;
+                //vc.MLCCallDelegate = new OnLCCallDelegate(this);
+                Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
+            }
+            else
+            {
+
+                ESOnMonitorViewController vc = new ESOnMonitorViewController();
+                vc.MESVideoID = mESVideoInfo.ESVideoUUID;
+                vc.MESRoomID = roomID;
+                vc.DeviceName = mESVideoInfo.DeviceName;
+                //vc.RoomName = mESVideoInfo.RoomName;
+                //vc.MESCallDelegate = new OnESCallDelegate(this);
+                Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
+            }
+>>>>>>> origin/CJL-LC
+#else
+            Intent intent = null;
+            if (interphoneType == "IMOUVISIAL")
+            {
+                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.LeChengVideoActivity));
+            }
+            else
+            {
+                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity));
+            }
+
             intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);
             intent.PutExtra("uuid", mESVideoInfo.uuid);
             intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);
             intent.PutExtra("cmtID", mESVideoInfo.cmtID);
             intent.PutExtra("roomno", mESVideoInfo.roomno);
             intent.PutExtra("unitno", mESVideoInfo.unitno);
-            //intent.PutExtra("HomeID", mESVideoInfo.HomeID);
+            intent.PutExtra("HomeID", PirSend.HomeId);
             intent.PutExtra("callId", mESVideoInfo.callId);
             intent.PutExtra("Type", 0);
+
+            //=========涔愭==========
+            intent.PutExtra("AccessToken", mESVideoInfo.Lc_AccessToken);
+            intent.PutExtra("DeviceId", mESVideoInfo.Lc_DeviceId);
+            intent.PutExtra("Location", OnAppConfig.Instance.RequestHttpsHost.Contains("China") ? 0 : 1);//濡傛灉鍩熷悕鍖呭惈china锛屽垯鏄浗鍐呰处鍙�);
+            intent.PutExtra("PlayToken", mESVideoInfo.Lc_PlayToken);
+            intent.PutExtra("Psk", mESVideoInfo.Lc_Psk);
+
             Shared.Application.Activity.StartActivity(intent);
 
 #endif
         }
-
-
 
         /// <summary>
         /// 琚懠鍙〉闈�
         /// </summary>
+<<<<<<< HEAD
         /// <param name="mESVideoInfo">涓版灄鍛煎彨鍔熻兘鎵�闇�鐩稿叧鍙傛暟</param>
         public void ShowESvideoVideoIntercom(ESVideoInfo mESVideoInfo)
+=======
+        /// <param name="mESVideoInfo"></param>
+        public void ShowESvideoVideoIntercom(ESVideoInfo mESVideoInfo, string interphoneType)
+>>>>>>> origin/CJL-LC
         {
             this.esVideoInfo = mESVideoInfo;
-#if __IOS__
             int roomID = 0;
             int.TryParse(mESVideoInfo.roomno, out roomID);
-            ESOnIntercomViewController vc = new ESOnIntercomViewController();
-            vc.MESVideoID = mESVideoInfo.ESVideoUUID;
-            vc.MESRoomID = roomID;
-            vc.DeviceName = mESVideoInfo.DeviceName;
-            //vc.RoomName = mESVideoInfo.RoomName;
-            //vc.MESCallDelegate = new OnESCallDelegate(this);
-            mOnESCallDelegate = new OnESCallDelegate(this);
-            vc.MESCallDelegate = mOnESCallDelegate;
-            Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
-#else
+#if __IOS__
+            if (interphoneType == "IMOUVISIAL")
+            {
+                //涔愭鍙瀵硅
+                //1.鍒濆鍖朙COpenSDK_Api
+                LCApiKit.SharedInstance().InitSDKOpenApi(mESVideoInfo.Lc_AccessToken);
+                //2021-05-18 鐩墠鎺ㄩ�佺殑PlayToken;鏈夐棶棰樹細瀵艰嚧SDK宕╂簝锛屾殏鏃朵笉浼�
+                //LCApiKit.SharedInstance().CurrentDevicePlayToken = mESVideoInfo.Lc_PlayToken;
+                LCApiKit.SharedInstance().CurrentDeviceId = mESVideoInfo.Lc_DeviceId;
+                LCApiKit.SharedInstance().CurrentDeviceName = mESVideoInfo.DeviceName;
+                LCApiKit.SharedInstance().CurrentPsk = mESVideoInfo.Lc_DeviceId;
+                //2.璺宠浆涔愭鍛煎彨椤甸潰
+                LCOnIntercomViewController vc = new LCOnIntercomViewController();
+                mOnLCCallDelegate = new OnLCCallDelegate(this);
+                vc.MLCCallDelegate = mOnLCCallDelegate;
+                //vc.MLCCallDelegate = new OnLCCallDelegate(this);
+                Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
+            }
+            else
+            {
 
-            Intent intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity));
+                ESOnIntercomViewController vc = new ESOnIntercomViewController();
+                vc.MESVideoID = mESVideoInfo.ESVideoUUID;
+                vc.MESRoomID = roomID;
+                vc.DeviceName = mESVideoInfo.DeviceName;
+                //vc.RoomName = mESVideoInfo.RoomName;
+                //vc.MESCallDelegate = new OnESCallDelegate(this);
+                mOnESCallDelegate = new OnESCallDelegate(this);
+                vc.MESCallDelegate = mOnESCallDelegate;
+                Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
+            }
+#else
+            #region
+
+            Intent intent = null;
+            if (interphoneType == "IMOUVISIAL")
+            {
+                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.LeChengVideoActivity));
+            }
+            else
+            {
+                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity));
+            }
+
             intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);
             intent.PutExtra("uuid", mESVideoInfo.uuid);
             intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);
             intent.PutExtra("cmtID", mESVideoInfo.cmtID);
             intent.PutExtra("roomno", mESVideoInfo.roomno);
             intent.PutExtra("unitno", mESVideoInfo.unitno);
-            //intent.PutExtra("HomeID", mESVideoInfo.HomeID);
+            intent.PutExtra("HomeID", PirSend.HomeId);
             intent.PutExtra("callId", mESVideoInfo.callId);
             intent.PutExtra("Type", 1);
+
+            //=========涔愭==========
+            intent.PutExtra("AccessToken", mESVideoInfo.Lc_AccessToken);
+            intent.PutExtra("DeviceId", mESVideoInfo.Lc_DeviceId);
+            intent.PutExtra("Location", OnAppConfig.Instance.RequestHttpsHost.Contains("China") ? 0 : 1);//濡傛灉鍩熷悕鍖呭惈china锛屽垯鏄浗鍐呰处鍙�);
+            intent.PutExtra("PlayToken", mESVideoInfo.Lc_PlayToken);
+            intent.PutExtra("Psk", mESVideoInfo.Lc_Psk);
+
             Shared.Application.Activity.StartActivity(intent);
 
+            #endregion
 #endif
         }
 
-        #region 鍔ㄤ綔鍥炶皟锛屾彁浜よ褰曞埌浜戠
+        #region 鍔ㄤ綔鍥炶皟鍜屽師鐢熶氦浜掞紝鎻愪氦璁板綍鍒颁簯绔�
 
         /// <summary>
         /// 鍒ゆ柇callId鏄惁涓虹┖
@@ -188,7 +286,7 @@
                 }
                 else
                 {
-                    Utlis.WriteLine("POST 鎸傛柇澶辫触 code: "+ revertObj.Code);
+                    Utlis.WriteLine("POST 鎸傛柇澶辫触 code: " + revertObj.Code);
                 }
 
             })
@@ -262,6 +360,7 @@
         }
 
         DateTime UnlockDateTime = DateTime.MinValue;
+
         /// <summary>
         /// 寮�閿佹垚鍔�
         /// </summary>
@@ -272,9 +371,9 @@
             if (CheckESVideoInfoIsNullOrEmpty()) return;
 
             //3S鍐呬笉鍏佽瑙﹀彂绗簩娆�
-            if(UnlockDateTime.AddSeconds(3) > DateTime.Now)
+            if (UnlockDateTime.AddSeconds(3) > DateTime.Now)
             {
-               
+
                 Utlis.WriteLine("3S鍐呬笉鍏佽瑙﹀彂绗簩娆�");
                 //涓版灄SDKbug锛屽懠鍙殑鏃跺�欏紑閿佹垚鍔熶細鏈�2娆″洖璋冿紝
                 return;
@@ -303,6 +402,80 @@
         }
 
         #endregion
+<<<<<<< HEAD
+=======
+
+        #region 鐜嬭耽鏂版帴鍚拰寮�閿佹帴鍙�
+        /// <summary>
+        /// 寮�閿�
+        /// </summary>
+        void HDLUnlockAction()
+        {
+            //Utlis.WriteLine("UnlockAction");
+
+            if (esVideoInfo == null) return;
+
+            new Thread(() =>
+            {
+                Dictionary<string, object> dic = new Dictionary<string, object>();
+                dic.Add("deviceId", esVideoInfo.Lc_DeviceId);//璁惧id
+                dic.Add("callId", esVideoInfo.callId);
+                var requestJson = HttpUtil.GetSignRequestJson(dic);
+                var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_OpenDoorbell, requestJson);
+                if (revertObj.Code == StateCode.SUCCESS)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+#if __IOS__
+                        //鍜屽師鐢熺洃鎺х晫闈氦浜掋�佸彂閫佸紑閿佹垚鍔熼�氱煡
+                        NSNotificationCenter.DefaultCenter.PostNotificationName("lcCallDelegateOpenDoorSuccess", null);
+#endif
+                    });
+                }
+                else
+                {
+                    Utlis.WriteLine("POST 寮�閿佸け璐� code: " + revertObj.Code);
+                }
+
+            })
+            { IsBackground = false }.Start();
+        }
+
+        /// <summary>
+        /// 鏇存敼閫氳瘽鐘舵��
+        /// </summary>
+        void HDLUpdateCallStatus(CallStatusType callStatusType, InterphoneType interphoneType, int callDuration = 0) {
+
+            if (CheckESVideoInfoIsNullOrEmpty()) return;
+
+            new Thread(() =>
+            {
+                Dictionary<string, object> dic = new Dictionary<string, object>();
+                dic.Add("callId", esVideoInfo.callId);//鍛煎彨id
+                dic.Add("callStatus", callStatusType.ToString());//鍙敤鍊�:MISSED,RECEIVED,REJECT
+                dic.Add("interphoneTypeEnum", interphoneType.ToString());//鍙敤鍊�:FLVI,IMOUVISIAL
+                if (callStatusType == CallStatusType.RECEIVED && callDuration > 0)
+                {
+                    dic.Add("callDuration", callDuration);//閫氳瘽鏃堕暱锛堢锛�
+                }
+
+                var requestJson = HttpUtil.GetSignRequestJson(dic);
+                var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_UpdateCallStatus, requestJson);
+                if (revertObj.Code == StateCode.SUCCESS)
+                {
+
+                }
+                else
+                {
+                    Utlis.WriteLine("POST 鏇存柊鐘舵�佸け璐� code: " + revertObj.Code);
+                }
+
+            })
+            { IsBackground = false }.Start();
+
+        }
+        #endregion
+>>>>>>> origin/CJL-LC
 
 #if __IOS__
         #region OnESCallDelegate
@@ -379,7 +552,77 @@
 
         }
 
-#endregion
+        #endregion
+
+        #region OnLCCallDelegate
+        /////// <summary>
+        /////// OnLCCallDelegate 缁ф壙鍝嶅簲浜嬩欢
+        /////// </summary>
+        OnLCCallDelegate mOnLCCallDelegate;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public class OnLCCallDelegate : LCCallDelegate
+        {
+
+            [Weak] ESOnVideo _ESOnVideo;
+
+            public OnLCCallDelegate(ESOnVideo mESOnVideo)
+            {
+                _ESOnVideo = mESOnVideo;
+            }
+
+            /// <summary>
+            /// 鎺ュ惉
+            /// </summary>
+            public override void OnAnswerAction()
+            {
+                _ESOnVideo.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.IMOUVISIAL);
+            }
+
+            /// <summary>
+            /// 鎸傛柇
+            /// </summary>
+            /// <param name="callDuration"></param>
+            public override void OnHangUpAction(int callDuration)
+            {
+                _ESOnVideo.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.IMOUVISIAL, callDuration);
+            }
+
+            /// <summary>
+            /// 鎷掓帴
+            /// </summary>
+            public override void OnRejectCallAction()
+            {
+                _ESOnVideo.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.IMOUVISIAL);
+            }
+
+            /// <summary>
+            /// 鎴浘鎴愬姛
+            /// </summary>
+            /// <param name="image"></param>
+            public override void OnScreenshotSuccessfulAction(UIImage image)
+            {
+                ////NSData imageData = UIImagePNGRepresentation(image); UIImage
+                //NSData imageData = image.AsPNG();
+                //byte[] dataBytes = new byte[imageData.Length];
+                //System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, dataBytes, 0, Convert.ToInt32(imageData.Length));
+                ////image.g
+                ////_ESOnVideo.ScreenshotSuccessfulAction(dataBytes);
+            }
+
+            /// <summary>
+            /// 寮�閿佹垚鍔�
+            /// </summary>
+            public override void OnUnlockAction()
+            {
+                _ESOnVideo.HDLUnlockAction();
+            }
+
+        }
+
+        #endregion
 #endif
 
         /// <summary>
@@ -392,23 +635,27 @@
             {
                 DeviceName = "瀹ゅ鏈�88",
                 ESVideoUUID = "JJY000019VPLLF",
-                 
+
             };
             if (isMonitor)
             {
-                ShowESVideoMonitor(eSVideoInfo);
+                ShowESVideoMonitor(eSVideoInfo, "");
             }
             else
             {
                 eSVideoInfo.callId = "88888";
-                ShowESvideoVideoIntercom(eSVideoInfo);
+                ShowESvideoVideoIntercom(eSVideoInfo, "");
             }
 
         }
     }
 
     /// <summary>
+<<<<<<< HEAD
     /// 涓版灄鐩戣鍜屽懠鍙姛鑳芥墍闇�鐩稿叧鍙傛暟
+=======
+    /// 鍙瀵硅鍙傛暟瀵硅薄锛堜粎鍦ㄦ渶鍚庝竴姝ヨ烦杞埌activity鏃舵墠璋冪敤,涓轰簡鍋氬吋瀹硅繖閲岄兘鏁版嵁鏈夌偣涔憋紝浠ュ悗鏈夋椂闂村啀鐞嗛『鎬濊矾浼樺寲锛�
+>>>>>>> origin/CJL-LC
     /// </summary>
     public class ESVideoInfo
     {
@@ -447,9 +694,68 @@
         /// </summary>
         public string callId = string.Empty;
 
+
+        //========================澶у崕==========================
+
+        /// <summary>
+        /// 璐﹀彿accessToken
+        /// </summary>
+        public string Lc_AccessToken = string.Empty;
+
+        /// <summary>
+        /// 璁惧搴忓垪鍙凤紝閫氳蹇呰瀛楁
+        /// </summary>
+        public string Lc_DeviceId = string.Empty;
+
+        /// <summary>
+        /// 澶囨敞锛燂紵锛�
+        /// </summary>
+        public string Lc_Psk = string.Empty;
+
+        /// <summary>
+        /// 棰勮鐢婚潰蹇呴』浣跨敤
+        /// </summary>
+        public string Lc_PlayToken = string.Empty;
+
+        /// <summary>
+        /// 璐﹀彿鏍囪锛�0鍥藉唴锛�1鍥藉锛涘浗鍐呭浗澶栬闂兘鍦板潃涓嶄竴鏍�
+        /// </summary>
+        public int Lc_Location = 0;
+
     }
 
-    
 
+    /// <summary>
+    /// 閫氳瘽鐘舵�佺被鍨�
+    /// </summary>
+    public enum CallStatusType
+    {
+        /// <summary>
+        /// 鏈帴
+        /// </summary>
+        MISSED,
+        /// <summary>
+        /// 宸叉帴鍚�
+        /// </summary>
+        RECEIVED,
+        /// <summary>
+        /// 鎷掓帴
+        /// </summary>
+        REJECT,
+    }
 
+    /// <summary>
+    /// 鍙瀵硅璁惧骞冲彴绫诲瀷
+    /// </summary>
+    public enum InterphoneType
+    {
+        /// <summary>
+        /// 涓版灄骞冲彴
+        /// </summary>
+        FLVI,
+        /// <summary>
+        /// 澶у崕鍙瀵硅骞冲彴
+        /// </summary>
+        IMOUVISIAL,
+    }
 }

--
Gitblit v1.8.0