From dc9a1b15bb69227e19afc070adf58156a362d2a2 Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期一, 30 九月 2024 17:07:58 +0800
Subject: [PATCH] 安卓可视对讲响铃,

---
 HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs |  184 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 168 insertions(+), 16 deletions(-)

diff --git a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
index 8badede..b8c70e9 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;
@@ -124,18 +125,29 @@
 
 
 
+            //鐧诲綍sip鏈嶅姟鍣�
 #if __IOS__
-
-            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm);
+            string systemVersion = UIKit.UIDevice.CurrentDevice.SystemVersion;
+            System.Version currentVersion = new System.Version(systemVersion);
+            System.Version version17 = new System.Version(17, 0);
+            if (currentVersion.CompareTo(version17) > 0)
+            {
+                HDLLinPhoneSDK.Instance().Login(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm, "udp");
+            }
+            else
+            {
+                HDLLinPhoneSDK.Instance().Login(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm, DB_ResidenceData.Instance.linphoneConnectType.ToString());
+            }
 #else
             if (mInterphoneType == InterphoneType.FREEVIEW.ToString())
             {
                 HDLLinphoneKit.Instance.SetAccountAndLogin(
                     mHDLSipInfo.sipAccount,
                     mHDLSipInfo.sipPasswd,
-                    "139.159.157.75:47000",//mHDLSipInfo.realm,
+                    mHDLSipInfo.realm,
                     //"sip:139.159.157.75:47000;transport=udp",
-                    HDLLinphoneKit.InterPhoneTypeFreeview
+                    HDLLinphoneKit.InterPhoneTypeFreeview,
+                    DB_ResidenceData.Instance.linphoneConnectType.ToString()
                     );
             }
             else
@@ -146,7 +158,8 @@
                    mHDLSipInfo.realm,
                    //mHDLSipInfo.proxy+ ";transport=udp",
                    //"sip:139.159.157.75:47000;transport=udp",
-                   HDLLinphoneKit.InterPhoneTypeHdl
+                   HDLLinphoneKit.InterPhoneTypeHdl,
+                    DB_ResidenceData.Instance.linphoneConnectType.ToString()
                    );
             }
 #endif
@@ -234,7 +247,7 @@
                 //鍏堟竻绌哄懠鍙拰鐩戣璁惧淇℃伅
                 if (clearCallInfo)
                 {
-                    InitCallInfo(null);
+                    //InitCallInfo(null);//閫犳垚鎺ユ敹鍛煎彨鏃跺紑閿佸紑閿佸紓甯�
                 }
 
                 HDLSipInfo mHDLSipInfo = GetHDLSipInfo(mHDLCallVideoInfo.HomeId);
@@ -338,7 +351,7 @@
 
         #region 鈻�  --  鏂版帴鍚拰寮�閿佹帴鍙______________________________
         /// <summary>
-        /// 寮�閿�
+        /// 鍙瀵硅寮�閿�
         /// </summary>
         public void HDLUnlockAction()
         {
@@ -358,6 +371,10 @@
 
                 Application.RunOnMainThread(() =>
                 {
+                    if(revertObj == null)
+                    {
+                        return;
+                    }
 
 #if __IOS__
                     if (revertObj.Code == StateCode.SUCCESS)
@@ -422,9 +439,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>
         /// 璺宠浆鐩戞帶椤甸潰
@@ -450,7 +497,13 @@
 
 #if __IOS__
 
-            Shared.IOS.HDLLinphoneSDK.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.鍏堝懠鍙澶�
@@ -470,8 +523,23 @@
         /// 鏀跺埌鎺ㄩ�侊紝鍚庡垽鏂懠鍙綇瀹呮槸鍚︿负褰撳墠浣忓畢锛屼笉鏄殑璇濋噸鏂拌幏鍙朣IP璐﹀彿骞剁櫥褰�
         /// </summary>
         /// <param name="mESVideoInfo"></param>
-        public void ShowESVideoIntercom(ESVideoInfo mESVideoInfo,string mInterphoneType)
+        public void ShowESVideoIntercom(ESVideoInfo mESVideoInfo,string mInterphoneType, bool  isNotificationGoing = false)
         {
+#if __ANDROID__
+            //isNotificationGoing鍙傛暟鏄笓闂ㄧ粰瀹夊崜浣跨敤鐨勶紝鍥犱负瀹夊崜鍦ㄥ悗闈㈢殑鏃跺�欏凡缁忓惎鍔ㄤ簡鎺ュ惉鐨勭晫闈簡锛屼粠閫氱煡鏍忚繘鏉ョ殑鏃跺�欙紝callid宸茬粡琚娇鐢ㄤ簡锛屾墍浠ヨ閲嶇疆鎺夎繖涓睘鎬�
+            if (isNotificationGoing)
+            {
+                this.mHDLCallVideoInfo.CallId = "";
+            }
+#endif
+            if (this.mHDLCallVideoInfo != null)
+            {
+                if(this.mHDLCallVideoInfo.CallId == mESVideoInfo.callId)
+                {
+                    return;
+                }
+            }
+
             InitLinphone();
 
             HDLCallVideoInfo mHDLCallVideoInfo = new HDLCallVideoInfo();
@@ -518,7 +586,7 @@
             {
 #if __IOS__
                 //鑷爺鍙瀵硅
-                Shared.IOS.HDLLinphoneSDK.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)
@@ -527,6 +595,7 @@
                     intent.PutExtra("lpTitleName", mHDLCallVideoInfo.DeviceName);
                     intent.PutExtra("lpSipAccount", mHDLCallVideoInfo.DeviceSipAccount);
                 }
+                MainPage.Log("鍚姩鑷爺鍙瀵硅鐣岄潰");
                 Shared.Application.Activity.StartActivity(intent);
 #endif
             }
@@ -559,7 +628,7 @@
         bool IsIncomingReceivedCallState()
         {
 #if __IOS__
-            return Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
+            return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
 #else
             return HDLLinphoneKit.Instance.IsIncomingReceivedCallState;
 #endif
@@ -572,7 +641,8 @@
 
 #if __IOS__
 
-            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().GotoHDLLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName);
+            
+            HDLLinPhoneSDK.Instance().GotoHDLLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName);
 
 #else
             var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneIntercomActivity));
@@ -704,6 +774,14 @@
             public void OnAnswerAction()
             {
                 //showToast("鎺ュ惉");
+                try
+                {
+                    HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("閾冨0鍏抽棴寮傚父:" + ex.StackTrace);
+                }
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
             }
             /// <summary>
@@ -723,9 +801,23 @@
             public void OnRejectCallAction()
             {
                 //showToast("鎷掓帴");
-                hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
+                try
+                {
+                    HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("閾冨0鍏抽棴寮傚父:" + ex.StackTrace);
+                }
+                try
+                {
+                    hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("OnRejectCallAction寮傚父:" + ex.StackTrace);
+                }
             }
-
             /// <summary>
             /// 鎴浘鎴愬姛浜嬩欢
             /// </summary>
@@ -750,6 +842,51 @@
             public void OnIncomingCall(string userName)
             {
                 Utlis.WriteLine("OnIncomingCall :" + userName);
+            }
+
+            /// <summary>
+            /// 鎷掓帴浜嬩欢
+            /// 鍏ㄩ儴鎸傛柇
+            /// </summary>
+            public void OnCallAllRejection()
+            {
+                try
+                {
+                    HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("閾冨0鍏抽棴寮傚父:" + ex.StackTrace);
+                }
+                try
+                {
+                    hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
+                    hdlLinphone.HDLRejectCallIn();
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("鍏ㄩ儴鎸傛柇寮傚父:" + ex.StackTrace);
+                }
+            }
+
+            public void OnMissedCallsAction()
+            {
+                try
+                {
+                    HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("閾冨0鍏抽棴寮傚父:" + ex.StackTrace);
+                }
+                try
+                {
+                    hdlLinphone.HDLUpdateCallStatus(CallStatusType.MISSED, InterphoneType.HDL);
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("OnMissedCallsAction寮傚父:" + ex.StackTrace);
+                }
             }
         }
 
@@ -800,6 +937,7 @@
             /// </summary>
             public override void OnAnswerAction()
             {
+                Other.SoundPlayer.Ins.StopSound();
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
             }
 
@@ -817,6 +955,8 @@
             /// </summary>
             public override void OnRejectCallAction()
             {
+                MainPage.Log("iOS 鍏ㄩ儴鎷掓帴");
+                Other.SoundPlayer.Ins.StopSound();
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
             }
 
@@ -824,7 +964,7 @@
             /// 鎴浘鎴愬姛
             /// </summary>
             /// <param name = "image" ></ param >
-            public  void OnScreenshotSuccessfulAction(UIImage image)
+            public override void OnScreenshotSuccessfulAction(UIImage image)
             {
                 //NSData imageData = UIImagePNGRepresentation(image); UIImage
                 NSData imageData = image.AsPNG();
@@ -850,6 +990,18 @@
                 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

--
Gitblit v1.8.0