From c00da77d00a479fa5d022346a6d9075f90a5c087 Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期六, 14 九月 2024 10:05:34 +0800
Subject: [PATCH] 退出登录时间调整,新风,音乐

---
 HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs |  208 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 164 insertions(+), 44 deletions(-)

diff --git a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
index 07f7fc6..4898a28 100644
--- a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
+++ b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
@@ -13,6 +13,7 @@
 using Android.Widget;
 using Com.Hdl.Hdllinphonesdk;
 #else
+using Other;
 using Foundation;
 using UIKit;
 using Shared.IOS.HDLLinphoneSDK;
@@ -95,7 +96,7 @@
             Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().InitalLinPhone();
             //璁剧疆鏀跺埌鏉ョ數鍚庛�佹槸鍚﹂渶鑷姩璺宠浆鍛煎彨椤甸潰鏂规
             Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().IsAutoJumpCallView = IsAutoJumpCallView;
-            //璁剧疆Listener鐩戝惉
+            //璁剧疆Listener鐩戝惉(Shared.IOS.HDLLinphoneSDK)
             mOnHDLLinphoneCallDelegate = new OnHDLLinphoneCallDelegate(this);
             Console.WriteLine(UserInfo.Current.ID);
             Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().HdlLinphoneCallDelegate = mOnHDLLinphoneCallDelegate;
@@ -117,20 +118,26 @@
 
             this.currentHDLSipInfo = mHDLSipInfo;
 
-            if (mHDLSipInfo == null) return;
+            if (mHDLSipInfo == null) {
+                //new alert
+                return;
+            }
 
+
+
+            //鐧诲綍sip鏈嶅姟鍣�
 #if __IOS__
-            //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login("1003", "123456", "192.168.31.194:5060");
-            //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login("6666", "85521566", "116.62.26.215:5060");
-            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm);
+            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm,"UDP");
 #else
             if (mInterphoneType == InterphoneType.FREEVIEW.ToString())
             {
                 HDLLinphoneKit.Instance.SetAccountAndLogin(
                     mHDLSipInfo.sipAccount,
                     mHDLSipInfo.sipPasswd,
-                    "139.159.157.75:46000",
-                    HDLLinphoneKit.InterPhoneTypeFreeview
+                    mHDLSipInfo.realm,
+                    //"sip:139.159.157.75:47000;transport=udp",
+                    HDLLinphoneKit.InterPhoneTypeFreeview,
+                    DB_ResidenceData.Instance.linphoneConnectType.ToString()
                     );
             }
             else
@@ -139,7 +146,10 @@
                    mHDLSipInfo.sipAccount,
                    mHDLSipInfo.sipPasswd,
                    mHDLSipInfo.realm,
-                   HDLLinphoneKit.InterPhoneTypeHdl
+                   //mHDLSipInfo.proxy+ ";transport=udp",
+                   //"sip:139.159.157.75:47000;transport=udp",
+                   HDLLinphoneKit.InterPhoneTypeHdl,
+                    DB_ResidenceData.Instance.linphoneConnectType.ToString()
                    );
             }
 #endif
@@ -156,9 +166,16 @@
             this.mHDLCallVideoInfo = null;
 #if __IOS__
 
-            HDLLinPhoneSDK.Instance().LogoutAllLinphoneUser();
+            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().LogoutAllLinphoneUser();
 #else
-            HDLLinphoneKit.Instance.Logout();
+            if (HDLLinphoneKit.Instance != null)
+            {
+                HDLLinphoneKit.Instance.Logout();
+            }
+            else
+            {
+
+            }
 #endif
         }
 
@@ -169,7 +186,7 @@
         {
 #if __IOS__
 
-            HDLLinPhoneSDK.Instance().ClearAllConfigs();
+            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().ClearAllConfigs();
 #else
             HDLLinphoneKit.Instance.ClearProxyConfig();
 #endif
@@ -220,7 +237,7 @@
                 //鍏堟竻绌哄懠鍙拰鐩戣璁惧淇℃伅
                 if (clearCallInfo)
                 {
-                    InitCallInfo(null);
+                    //InitCallInfo(null);//閫犳垚鎺ユ敹鍛煎彨鏃跺紑閿佸紑閿佸紓甯�
                 }
 
                 HDLSipInfo mHDLSipInfo = GetHDLSipInfo(mHDLCallVideoInfo.HomeId);
@@ -228,11 +245,31 @@
                 {
                     Application.RunOnMainThread(() =>
                     {
-                        InitLinphone();
+                        try
+                        {
+                            InitLinphone();
+                        }
+                        catch (Exception ex)
+                        {
+                            MainPage.Log($"InitLinphone exception : {ex.Message}");
+                        }
                         mHDLSipInfo.homeId = mHDLCallVideoInfo.HomeId;
-                        SetAccountAndLogin(mHDLSipInfo, mHDLCallVideoInfo.InterphoneType);
+                        try { 
+                            SetAccountAndLogin(mHDLSipInfo, mHDLCallVideoInfo.InterphoneType);
+                        }
+                        catch (Exception ex)
+                        {
+                            MainPage.Log($"SetAccountAndLogin exception : {ex.Message}");
+                        }
                         Utlis.WriteLine("CALL 鑾峰彇SIP璐﹀彿鎴愬姛锛�" + mHDLSipInfo.sipAccount);
                     });
+                }
+                else
+                {
+                    //Application.RunOnMainThread(() =>
+                    //{
+                    //    new Alert("", $"鑾峰彇Sip璐﹀彿淇℃伅澶辫触.", "纭畾").Show();
+                    //});
                 }
             }
             catch { }
@@ -304,7 +341,7 @@
 
         #region 鈻�  --  鏂版帴鍚拰寮�閿佹帴鍙______________________________
         /// <summary>
-        /// 寮�閿�
+        /// 鍙瀵硅寮�閿�
         /// </summary>
         public void HDLUnlockAction()
         {
@@ -324,6 +361,10 @@
 
                 Application.RunOnMainThread(() =>
                 {
+                    if(revertObj == null)
+                    {
+                        return;
+                    }
 
 #if __IOS__
                     if (revertObj.Code == StateCode.SUCCESS)
@@ -388,9 +429,39 @@
             { IsBackground = false }.Start();
 
         }
+        /// <summary>
+        /// 鎷掓帴锛堟寕娈垫墍鏈夊懠鍙級
+        /// </summary>
+        public void HDLRejectCallIn() {
+
+            if (CheckmHDLCallVideoInfoIsNullOrEmpty()) return;
+
+            new Thread(() =>
+            {
+                Dictionary<string, object> dic = new Dictionary<string, object>();
+                dic.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+                dic.Add("deviceId", mHDLCallVideoInfo.DeviceId);
+                dic.Add("interphoneType", "HDL");
+                dic.Add("callId", mHDLCallVideoInfo.CallId);//鍛煎彨id
+
+                var requestJson = HttpUtil.GetSignRequestJson(dic);
+                var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_RejectCallIn, requestJson);
+                if (revertObj.Code == StateCode.SUCCESS)
+                {
+
+                }
+                else
+                {
+                    Utlis.WriteLine("POST 鏇存柊鐘舵�佸け璐� code: " + revertObj.Code);
+                }
+
+            })
+            { IsBackground = false }.Start();
+        }
+
         #endregion
 
-     
+
         #region 鈻�  --  璺宠浆鐩戞帶椤甸潰_______________________________
         /// <summary>
         /// 璺宠浆鐩戞帶椤甸潰
@@ -416,7 +487,13 @@
 
 #if __IOS__
 
-            HDLLinPhoneSDK.Instance().CallWithUserName(mHDLCallVideoInfo.DeviceSipAccount, mHDLCallVideoInfo.DeviceName);
+            if (mHDLCallVideoInfo.spk == "door.gate")
+            {
+                Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().CallHDLSRWithUserName(mHDLCallVideoInfo.DeviceSipAccount, mHDLCallVideoInfo.DeviceName);   
+            }else{
+                Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().CallWithUserName(mHDLCallVideoInfo.DeviceSipAccount, mHDLCallVideoInfo.DeviceName);
+            }
+            
 
 #else
             //1.鍏堝懠鍙澶�
@@ -438,6 +515,14 @@
         /// <param name="mESVideoInfo"></param>
         public void ShowESVideoIntercom(ESVideoInfo mESVideoInfo,string mInterphoneType)
         {
+            if(this.mHDLCallVideoInfo != null)
+            {
+                if(this.mHDLCallVideoInfo.CallId == mESVideoInfo.callId)
+                {
+                    return;
+                }
+            }
+
             InitLinphone();
 
             HDLCallVideoInfo mHDLCallVideoInfo = new HDLCallVideoInfo();
@@ -484,7 +569,7 @@
             {
 #if __IOS__
                 //鑷爺鍙瀵硅
-                HDLLinPhoneSDK.Instance().GotoHDLSRLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName,mHDLCallVideoInfo.DeviceSipAccount);
+                HDLLinPhoneSDK.Instance().GotoHDLSRLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName, mHDLCallVideoInfo.DeviceSipAccount);
 #else
                 var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneReverseCallActivity));  
                 if (mHDLCallVideoInfo != null)
@@ -502,7 +587,7 @@
                 if (IsAutoJumpCallView) return;
                 //鍏堢粨鏉熸帀涔嬪墠鐨勭嚎绋�
                 EndCheckIncomingCallThread();
-                //妫�娴嬫槸鍚︽潵鐢典簡濡傛灉鏄洿鎺ヨ皟鏁村懠鍙〉闈㈠鏋滀笉鏄垯寮�鍚嚎绋嬬瓑寰呭垽鏂�
+                //妫�娴嬫槸鍚︽潵鐢典簡濡傛灉鏄洿鎺ヨ皟鏁村懠鍙〉闈㈠鏋滀笉鏄垯寮�鍚嚎绋嬬瓑寰呭垽鏂�(Shared.IOS.HDLLinphoneSDK)
                 if (IsIncomingReceivedCallState())
                 {
                     Utlis.WriteLine("CALL 宸茬粡鏉ョ數浜嗐�傘�傘�傛墦寮�鍛煎彨椤甸潰");
@@ -519,12 +604,13 @@
         }
 
         /// <summary>
-        /// 鏄惁鏉ョ數鐘舵��
+        /// 鏄惁鏉ョ數鐘舵��(Shared.IOS.HDLLinphoneSDK)
         /// </summary>
         /// <returns></returns>
-        bool IsIncomingReceivedCallState() {
+        bool IsIncomingReceivedCallState()
+        {
 #if __IOS__
-             return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
+            return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
 #else
             return HDLLinphoneKit.Instance.IsIncomingReceivedCallState;
 #endif
@@ -537,13 +623,15 @@
 
 #if __IOS__
 
+            
             HDLLinPhoneSDK.Instance().GotoHDLLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName);
 
 #else
             var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneIntercomActivity));
             if (mHDLCallVideoInfo != null)
             {
-                intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.DeviceName);
+                //intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.DeviceName);
+                intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.CallId);
             }
             Shared.Application.Activity.StartActivity(intent);
 #endif
@@ -585,7 +673,7 @@
                                 threadTime--;
                                 Utlis.WriteLine("CALL 妫�娴嬩腑...." + threadTime);
                                 Thread.Sleep(1000);
-                                //鏉ョ數浜嗭紝璺宠浆鍛煎彨椤甸潰
+                                //鏉ョ數浜嗭紝璺宠浆鍛煎彨椤甸潰(Shared.IOS.HDLLinphoneSDK)
                                 if (IsIncomingReceivedCallState())
                                 {
                                     Utlis.WriteLine("CALL 鏉ョ數浜嗐�傘�傘�傛墦寮�鍛煎彨椤甸潰");
@@ -637,10 +725,10 @@
             return checkIncomingCallThread == null || checkIncomingCallThread.ThreadState != ThreadState.Running;
         }
 
-#endregion
+        #endregion
 
 
-#region 鈻�  --  Android鐩稿叧鎿嶄綔_______________________________
+        #region 鈻�  --  Android鐩稿叧鎿嶄綔_______________________________
 
 #if __Android__
 
@@ -668,6 +756,7 @@
             public void OnAnswerAction()
             {
                 //showToast("鎺ュ惉");
+                HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
             }
             /// <summary>
@@ -687,6 +776,7 @@
             public void OnRejectCallAction()
             {
                 //showToast("鎷掓帴");
+                HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
             }
 
@@ -715,6 +805,23 @@
             {
                 Utlis.WriteLine("OnIncomingCall :" + userName);
             }
+
+            /// <summary>
+            /// 鎷掓帴浜嬩欢
+            /// 鍏ㄩ儴鎸傛柇
+            /// </summary>
+            public void OnCallAllRejection()
+            {
+                HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
+                hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
+                hdlLinphone.HDLRejectCallIn();
+            }
+
+            public void OnMissedCallsAction()
+            {
+                HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
+                hdlLinphone.HDLUpdateCallStatus(CallStatusType.MISSED, InterphoneType.HDL);
+            }
         }
 
         /// <summary>
@@ -735,23 +842,23 @@
         }
 
 #endif
-#endregion
+        #endregion
 
-#region 鈻�  --  iOS鐩稿叧鎿嶄綔_______________________________
+        #region 鈻�  --  iOS鐩稿叧鎿嶄綔_______________________________
 
 #if __IOS__
 
-#region OnHDLLinphoneCallDelegate
+        #region OnHDLLinphoneCallDelegate
         /// <summary>
         /// 
         /// </summary>
         OnHDLLinphoneCallDelegate mOnHDLLinphoneCallDelegate;
-     
+
         /// <summary>
         /// 
         /// </summary>
         public class OnHDLLinphoneCallDelegate : HDLLinphoneCallDelegate
-        { 
+        {
             [Weak] HDLLinphone hdlLinphone;
 
             public OnHDLLinphoneCallDelegate(HDLLinphone mHDLLinphone)
@@ -764,6 +871,7 @@
             /// </summary>
             public override void OnAnswerAction()
             {
+                Other.SoundPlayer.Ins.StopSound();
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
             }
 
@@ -781,22 +889,24 @@
             /// </summary>
             public override void OnRejectCallAction()
             {
+                MainPage.Log("iOS 鍏ㄩ儴鎷掓帴");
+                Other.SoundPlayer.Ins.StopSound();
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
             }
 
             /// <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
-                ////hdlLinphone.ScreenshotSuccessfulAction(dataBytes);
-            //}
+            /// <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
+                //hdlLinphone.ScreenshotSuccessfulAction(dataBytes);
+            }
 
             /// <summary>
             /// 寮�閿佹垚鍔�
@@ -813,15 +923,25 @@
             {
                 Utlis.WriteLine("OnIncomingCall :" + userName);
             }
-            
 
+            public override void OnRejectAllCallAction()
+            {
+                MainPage.Log("iOS 鍏ㄩ儴鎷掓帴");
+                Other.SoundPlayer.Ins.StopSound();
+                hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
+                hdlLinphone.HDLRejectCallIn();
+            }
 
+            //public override void OnScreenshotSuccessfulAction(UIImage image)
+            //{
+            //    throw new NotImplementedException();
+            //}
         }
 
-#endregion
+        #endregion
 #endif
 
-#endregion
+        #endregion
 
     }
 

--
Gitblit v1.8.0