From d82c74ca2e845211c95b314134bf7d0ea80e45f7 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 20 八月 2021 18:03:06 +0800
Subject: [PATCH] 2021-08-20 1.增加IOS SDK相关接口对接

---
 HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs |  521 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 419 insertions(+), 102 deletions(-)

diff --git a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
index 6055281..bd931dc 100644
--- a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
+++ b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
@@ -5,6 +5,7 @@
 using HDL_ON;
 using HDL_ON.DAL.Server;
 using HDL_ON.Entity;
+
 #if __Android__
 using Android.App;
 using Android.Content;
@@ -13,18 +14,24 @@
 using Com.Hdl.Hdllinphonesdk;
 #else
 using Foundation;
+using UIKit;
+using Shared.IOS.HDLLinphoneSDK;
 #endif
 
 namespace Shared
 {
+    /// <summary>
+    /// 鐩墠鏄瘡涓綇瀹呭搴斾竴涓猄IP璐﹀彿锛屽垏鎹綇瀹呴渶瑕侀噸鏂拌幏鍙朣IP璐﹀彿
+    /// </summary>
     public class HDLLinphone
     {
+        /// <summary>
+        /// 
+        /// </summary>
         public HDLLinphone()
         {
-            //鍒ゆ柇鏈夋病鏈夊垵濮嬪寲SDK锛屾病鍒濆鍖栬繃鍒濆鍖栦竴娆�
-            InitLinphone();
+           
         }
-
         /// <summary>
         /// 
         /// </summary>
@@ -44,6 +51,30 @@
             }
         }
 
+     
+        /// <summary>
+        /// 褰撳墠浣忓畢鏄惁鏀寔鍙瀵硅
+        /// </summary>
+        public bool IsEnable = false;
+        /// <summary>
+        /// 鏄惁鑷姩璺宠浆鍛煎彨椤甸潰,
+        /// false锛氭敹鍒版帹閫佸苟涓斿凡缁忔敹鍒皊ip鍛煎彨鎵嶈烦杞懠鍙〉闈�
+        /// true锛氬師鐢熸敹鍒板懠鍙┈涓婅烦杞懠鍙〉闈紝涓嶇瓑寰呮帹閫佽繃鏉�
+        /// </summary>
+        bool IsAutoJumpCallView = false;
+        /// <summary>
+        /// 鏄惁鍒濆鍖栦簡SDK
+        /// </summary>
+        bool IsInitSdk;
+        /// <summary>
+        /// 褰撳墠鐧诲綍鐨凷ip璐﹀彿
+        /// </summary>
+        HDLSipInfo currentHDLSipInfo;
+        /// <summary>
+        /// 鍙瀵硅璁惧鍙傛暟
+        /// </summary>
+        HDLCallVideoInfo mHDLCallVideoInfo;
+
         #region 鈻�  --  鍒濆鍖朣DK_______________________________
         /// <summary>
         /// 鍒濆鍖朣DK
@@ -51,52 +82,142 @@
         void InitLinphone()
         {
             //闃叉閲嶅鍒濆鍖�
-            if (isInitSdk) return;
+            if (IsInitSdk) return;
 
-            isInitSdk = true;
+            IsInitSdk = true;
 
 #if __IOS__
 
             Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().InitalLinPhone();
+            //璁剧疆鏀跺埌鏉ョ數鍚庛�佹槸鍚﹂渶鑷姩璺宠浆鍛煎彨椤甸潰鏂规
+            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().IsAutoJumpCallView = IsAutoJumpCallView;
+            //璁剧疆Listener鐩戝惉
+            mOnHDLLinphoneCallDelegate = new OnHDLLinphoneCallDelegate(this);
+            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().HdlLinphoneCallDelegate = mOnHDLLinphoneCallDelegate;
 #else
-            Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.InitLinphone(Application.Activity);
+            HDLLinphoneKit.Instance.InitLinphone(Application.Activity);
+            //璁剧疆鏀跺埌鏉ョ數鍚庛�佹槸鍚﹂渶鑷姩璺宠浆鍛煎彨椤甸潰鏂规
+            HDLLinphoneKit.Instance.AutoJumpCallView = IsAutoJumpCallView;
+            //璁剧疆Listener鐩戝惉
             setOnHDLLinphoneCallListener();
 #endif
-
-
         }
 
-        /// <summary>
-        /// 褰撳墠鐧诲綍鐨凷ip璐﹀彿
-        /// </summary>
-        HDLSipInfo currentHDLSipInfo;
+       
         /// <summary>
         /// 璁剧疆sip鐧诲綍璐﹀彿
         /// </summary>
         /// <param name="mHDLSipInfo"></param>
-        public void SetAccountAndLogin(HDLSipInfo mHDLSipInfo) {
+        public void SetAccountAndLogin(HDLSipInfo mHDLSipInfo)
+        {
 
             this.currentHDLSipInfo = mHDLSipInfo;
 
             if (mHDLSipInfo == null) return;
-          
+
 #if __IOS__
-            //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login("3333", "85521566", "116.62.26.215: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);
 #else
-            Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.SetAccountAndLogin(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm);
-            //Com.Hdl.Hdllinphonesdk.Core.EasyLinphone.SetAccountAndLogin("61723164995710", "8ec02ce0", "47.94.42.230:25060");
+            HDLLinphoneKit.Instance.SetAccountAndLogin(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm);
 #endif
+
+        }
+
+        /// <summary>
+        /// 娉ㄩ攢鎵�鏈夎处鍙�
+        /// </summary>
+        public void LogoutAllAccount() {
+            //娌″垵濮嬪寲杩囧垯杩斿洖
+            if (!IsInitSdk) return;
+
+            this.currentHDLSipInfo = null;
+            this.mHDLCallVideoInfo = null;
+#if __IOS__
+
+            HDLLinPhoneSDK.Instance().LogoutAllLinphoneUser();
+#else
+            HDLLinphoneKit.Instance.Logout();
+#endif
+        }
+
+        /// <summary>
+        /// 娓呴櫎閰嶇疆琛�
+        /// </summary>
+        public void ClearProxyConfig()
+        {
+#if __IOS__
+
+            HDLLinPhoneSDK.Instance().ClearAllConfigs();
+#else
+            HDLLinphoneKit.Instance.ClearProxyConfig();
+#endif
+        }
+
+        #endregion
+
+        #region 鈻�  --  鑾峰彇sip璐﹀彿_______________________________
+        /// <summary>
+        /// 鑾峰彇褰撳墠浣忓畢鐨凷IP璐﹀彿
+        /// </summary>
+        public HDLSipInfo GetHDLSipInfo(string homeId)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", homeId);
+
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            var resultObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_GetSipAccount, requestJson);
+
+            if (resultObj.Code == StateCode.SUCCESS)
+            {
+                if (string.IsNullOrEmpty(resultObj.Data.ToString()))
+                {
+                    //鎺х殑璇濅唬琛ㄥ綋鍓嶄綇瀹呬笉鏀寔
+                    return null;
+                }
+                else
+                {
+                    var info = Newtonsoft.Json.JsonConvert.DeserializeObject<HDLSipInfo>(resultObj.Data.ToString());
+                    return info;
+                }
+            }
+            else
+            {
+                return null;
+            }
+
+        }
+
+        /// <summary>
+        /// 璇锋眰鏈嶅姟鍣ㄨ幏鍙栧綋鍓嶄綇瀹匰ip璐﹀彿淇℃伅骞跺垵濮嬪寲LinphoneSDK鍜岀櫥褰�
+        /// </summary>
+        /// <param name="homeId"></param>
+        public void GetHDLSipInfoAndInitSDK(string homeId)
+        {
+            try
+            {
+                //鍏堟竻绌哄懠鍙拰鐩戣璁惧淇℃伅
+                InitCallInfo(null);
+                HDLSipInfo mHDLSipInfo = GetHDLSipInfo(homeId);
+                if (mHDLSipInfo != null)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        InitLinphone();
+                        mHDLSipInfo.homeId = homeId;
+                        SetAccountAndLogin(mHDLSipInfo);
+                        Utlis.WriteLine("CALL 鑾峰彇SIP璐﹀彿鎴愬姛锛�" + mHDLSipInfo.sipAccount);
+                    });
+                }
+            }
+            catch { }
 
         }
         #endregion
 
-        #region 鈻�  -- 鍔ㄤ綔鍥炶皟鍜屽師鐢熶氦浜掞紝鎻愪氦璁板綍鍒颁簯绔痏______________________________
-        /// <summary>
-        /// 鍙瀵硅璁惧鍙傛暟
-        /// </summary>
-        public HDLCallVideoInfo mHDLCallVideoInfo;
 
+        #region 鈻�  -- 鍔ㄤ綔鍥炶皟鍜屽師鐢熶氦浜掞紝鎻愪氦璁板綍鍒颁簯绔痏______________________________
+       
         /// <summary>
         /// 鍒濆鍖栧懠鍙弬鏁�
         /// </summary>
@@ -153,7 +274,7 @@
 
         }
 
-        DateTime UnlockDateTime = DateTime.MinValue;
+        //DateTime UnlockDateTime = DateTime.MinValue;
         #endregion
 
         #region 鈻�  --  鏂版帴鍚拰寮�閿佹帴鍙______________________________
@@ -244,72 +365,7 @@
         }
         #endregion
 
-        #region 鈻�  --  鑾峰彇sip璐﹀彿_______________________________
-        /// <summary>
-        /// 鏄惁鍒濆鍖栦簡SDK
-        /// </summary>
-        public bool isInitSdk;
-        /// <summary>
-        /// 鑾峰彇褰撳墠浣忓畢鐨凷IP璐﹀彿
-        /// </summary>
-        public HDLSipInfo GetHDLSipInfo(string homeId)
-        {
-            Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", homeId);
-
-            var requestJson = HttpUtil.GetSignRequestJson(d);
-            var resultObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_GetSipAccount, requestJson);
-
-            if (resultObj.Code == StateCode.SUCCESS)
-            {
-                if (string.IsNullOrEmpty(resultObj.Data.ToString()))
-                {
-                    //鎺х殑璇濅唬琛ㄥ綋鍓嶄綇瀹呬笉鏀寔
-                    return null;
-                }
-                else
-                {
-                    var info = Newtonsoft.Json.JsonConvert.DeserializeObject<HDLSipInfo>(resultObj.Data.ToString());
-                    return info;
-                }
-            }
-            else
-            {
-                return null;
-            }
-
-        }
-
-        /// <summary>
-        /// 鑾峰彇褰撳墠浣忓畢Sip璐﹀彿淇℃伅骞跺垵濮嬪寲LinphoneSDK鍜岀櫥褰�
-        /// </summary>
-        /// <param name="homeId"></param>
-        public void getHDLSipInfoAndInitSDK(string homeId)
-        {
-            try
-            {
-                //鍏堟竻绌哄懠鍙拰鐩戣璁惧淇℃伅
-                InitCallInfo(null);
-                HDLSipInfo mHDLSipInfo = GetHDLSipInfo(homeId);
-                if (mHDLSipInfo != null)
-                {
-                    InitLinphone();
-                    mHDLSipInfo.homeId = homeId;
-                    SetAccountAndLogin(mHDLSipInfo);
-                    //Application.RunOnMainThread(() =>
-                    //{
-                    //    InitLinphone();
-                    //    SetAccountAndLogin(mHDLSipInfo);
-                    //});
-                }
-            }
-            catch
-            {
-
-            }
-        }
-        #endregion
-
+     
         #region 鈻�  --  璺宠浆鐩戞帶椤甸潰_______________________________
         /// <summary>
         /// 璺宠浆鐩戞帶椤甸潰
@@ -317,6 +373,14 @@
         /// <param name="mESVideoInfo"></param>
         public void ShowESVideoMonitor(ESVideoInfo mESVideoInfo)
         {
+            InitLinphone();
+            //sip璐﹀彿涓虹┖
+            if (string.IsNullOrEmpty(mESVideoInfo.deviceSipAccount))
+            {
+
+                HDLCommon.Current.ShowAlert(Language.StringByID(StringId.shebeibucunzai));
+                return;
+            }
             HDLCallVideoInfo mHDLCallVideoInfo = new HDLCallVideoInfo();
             mHDLCallVideoInfo.HomeId = mESVideoInfo.HomeId;
             mHDLCallVideoInfo.DeviceId = mESVideoInfo.Lc_DeviceId;
@@ -326,7 +390,9 @@
             InitCallInfo(mHDLCallVideoInfo);
 
 #if __IOS__
-               
+
+            HDLLinPhoneSDK.Instance().CallWithUserName(mHDLCallVideoInfo.DeviceSipAccount, mHDLCallVideoInfo.DeviceName);
+
 #else
             //1.鍏堝懠鍙澶�
             Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.CallTo(mHDLCallVideoInfo.DeviceSipAccount, true);
@@ -342,11 +408,13 @@
 
         #region 鈻�  --  璺宠浆鍛煎彨椤甸潰_______________________________
         /// <summary>
-        /// 璺宠浆鍛煎彨椤甸潰
+        /// 鏀跺埌鎺ㄩ�侊紝鍚庡垽鏂懠鍙綇瀹呮槸鍚︿负褰撳墠浣忓畢锛屼笉鏄殑璇濋噸鏂拌幏鍙朣IP璐﹀彿骞剁櫥褰�
         /// </summary>
         /// <param name="mESVideoInfo"></param>
         public void ShowESVideoIntercom(ESVideoInfo mESVideoInfo)
         {
+            InitLinphone();
+
             HDLCallVideoInfo mHDLCallVideoInfo = new HDLCallVideoInfo();
             mHDLCallVideoInfo.CallId = mESVideoInfo.callId;
             mHDLCallVideoInfo.HomeId = mESVideoInfo.HomeId;
@@ -356,15 +424,153 @@
             mHDLCallVideoInfo.DeviceSipAccount = mESVideoInfo.deviceSipAccount;
             InitCallInfo(mHDLCallVideoInfo);
 
+            //褰撳墠鍛煎彨鏉ョ數鐨勪綇瀹呭拰涔嬪墠娉ㄥ唽鐧诲綍鐨勪綇瀹呬竴鑷寸殑鎯呭喌涓�
+            if (currentHDLSipInfo != null && currentHDLSipInfo.homeId == mESVideoInfo.HomeId)
+            {
+                Utlis.WriteLine("CALL 鏀跺埌鎺ㄩ�� 鎺ㄩ�佷綇瀹呭拰涔嬪墠娉ㄥ唽鐧诲綍鐨勪綇瀹呬竴鑷�");
+                CheckCallStateAndGotoPage();
+            }
+            else
+            {
+                //娉ㄦ剰锛氫箣鍓嶆病鐧诲綍SIP璐﹀彿鎴栬�呬綇瀹呬笉涓�鑷寸殑鎯呭喌涓嬮渶瑕侀噸鏂拌幏鍙朣IP璐﹀彿
+                //鑾峰彇鍛煎彨浣忓畢鐨凷IP璐﹀彿骞剁櫥褰�
+                Utlis.WriteLine("CALL 鏀跺埌鎺ㄩ�� 鍏朵粬浣忓畢锛岄噸鏂拌幏鍙栧懠鍙綇瀹呯殑SIP璐﹀彿骞剁櫥褰�");
+                new Thread(() =>
+                {
+                    GetHDLSipInfoAndInitSDK(mESVideoInfo.HomeId);
+                })
+                { IsBackground = false }.Start();
+
+                //
+                CheckCallStateAndGotoPage();
+
+            }
+
+        }
+
+        /// <summary>
+        /// 妫�娴嬫潵鐢电姸鎬侊紝鍒ゆ柇鏄惁椹笂鎵撳紑鍛煎彨椤甸潰锛屽鏋滆繕娌℃潵鐢靛垯寮�鍚嚎绋嬫娴嬬瓑寰�
+        /// </summary>
+        /// <param name="mESVideoInfo"></param>
+        public void CheckCallStateAndGotoPage()
+        {
+            //濡傛灉寮�鍚簡鑷姩璺宠浆鏂规锛屽垯鏃犻渶缁х画涓嬮潰澶勭悊銆佹棤闇�鎵嬪姩璺宠浆
+            if (IsAutoJumpCallView) return;
+
+            //妫�娴嬫槸鍚︽潵鐢典簡濡傛灉鏄洿鎺ヨ皟鏁村懠鍙〉闈㈠鏋滀笉鏄垯寮�鍚嚎绋嬬瓑寰呭垽鏂�
+            if (IsIncomingReceivedCallState()) {
+                Utlis.WriteLine("CALL 宸茬粡鏉ョ數浜嗐�傘�傘�傛墦寮�鍛煎彨椤甸潰");
+                GoToHDLLinphoneIntercomActivity();
+            }
+            else
+            {
+                //濡傛灉杩樻病鏉ョ數 寮�鍚嚎绋嬫娴�
+                StartCheckIncomingCallThread();
+            }
+
+        }
+
+        /// <summary>
+        /// 鏄惁鏉ョ數鐘舵��
+        /// </summary>
+        /// <returns></returns>
+        bool IsIncomingReceivedCallState() {
 #if __IOS__
-               
+             return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
 #else
-            var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneIntercomActivity)); ;
-            intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.DeviceName);
+            return HDLLinphoneKit.Instance.IsIncomingReceivedCallState;
+#endif
+        }
+
+        /// <summary>
+        /// 璺宠浆鎵撳紑鍘熺敓鐨勫懠鍙〉闈�
+        /// </summary>
+        void GoToHDLLinphoneIntercomActivity() {
+
+#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);
+            }
             Shared.Application.Activity.StartActivity(intent);
 #endif
 
         }
+
+
+        /// <summary>
+        /// 妫�娴嬫潵鐢电嚎绋�
+        /// </summary>
+        Thread checkIncomingCallThread = null;
+        /// <summary>
+        /// 绾跨▼缁撴潫
+        /// </summary>
+        int threadTime = 15;
+        /// <summary>
+        /// 寮�鍚娴嬫潵鐢电嚎绋�
+        /// </summary>
+        void StartCheckIncomingCallThread()
+        {
+            try
+            {
+                Utlis.WriteLine("CALL 杩樻病鏉ョ數锛屽紑鍚嚎绋�");
+                threadTime = 15;
+                //缁撴潫涔嬪墠鐨勭嚎绋�
+                EndCheckIncomingCallThread();
+                //鏂板缓绾跨▼
+                checkIncomingCallThread = new Thread(() =>
+                    {
+                        try
+                        {
+                            //15S鍚庤嚜鍔ㄧ粨鏉熺嚎绋�
+                            while (threadTime > 0)
+                            {
+                                threadTime--;
+                                Utlis.WriteLine("CALL 妫�娴嬩腑...." + threadTime);
+                                Thread.Sleep(1000);
+                                //鏉ョ數浜嗭紝璺宠浆鍛煎彨椤甸潰
+                                if (IsIncomingReceivedCallState())
+                                {
+                                    Utlis.WriteLine("CALL 鏉ョ數浜嗐�傘�傘�傛墦寮�鍛煎彨椤甸潰");
+                                    threadTime = 0;//璺冲嚭寰幆锛屽叧闂嚎绋�
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        GoToHDLLinphoneIntercomActivity();
+                                    });
+                                }
+                            }
+                          
+                          
+                        }
+                        catch { }
+                    });
+                //寮�鍚嚎绋�
+                checkIncomingCallThread.Start();
+            }
+            catch { }
+        }
+
+        /// <summary>
+        /// 缁撴潫绾跨▼
+        /// </summary>
+        void EndCheckIncomingCallThread()
+        {
+            if (checkIncomingCallThread != null)
+            {
+                try
+                {
+                    checkIncomingCallThread.Interrupt();
+                }
+                catch { }
+                checkIncomingCallThread = null;
+            }
+        }
+
         #endregion
 
 
@@ -390,36 +596,59 @@
             {
                 Toast.MakeText(Application.Activity, text, ToastLength.Short).Show();
             }
-
+            /// <summary>
+            /// 鎺ュ惉浜嬩欢
+            /// </summary>
             public void OnAnswerAction()
             {
-                showToast("鎺ュ惉");
+                //showToast("鎺ュ惉");
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
             }
-
+            /// <summary>
+            /// 鎸傛柇浜嬩欢
+            /// </summary>
+            /// <param name="callDuration"></param>
             public void OnHangUpAction(int callDuration)
             {
 
-                showToast("鎸傛柇 閫氳瘽鏃堕暱锛�" + callDuration);
+                //showToast("鎸傛柇 閫氳瘽鏃堕暱锛�" + callDuration);
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL, callDuration);
             }
 
+            /// <summary>
+            /// 鎷掓帴浜嬩欢
+            /// </summary>
             public void OnRejectCallAction()
             {
-                showToast("鎷掓帴");
+                //showToast("鎷掓帴");
                 hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
             }
 
-            public void OnScreenshotSuccessfulAction(Bitmap p0)
+            /// <summary>
+            /// 鎴浘鎴愬姛浜嬩欢
+            /// </summary>
+            /// <param name="p0"></param>
+            public void OnScreenshotSuccessfulAction(Bitmap imgBitmap)
             {
-                showToast("鎴浘鎴愬姛");
+                //showToast("鎴浘鎴愬姛");
             }
 
+            /// <summary>
+            /// 寮�閿佷簨浠�
+            /// </summary>
             public void OnUnlockAction()
             {
                 hdlLinphone.HDLUnlockAction();
             }
 
+            /// <summary>
+            /// 鏉ョ數浜嬩欢
+            /// </summary>
+            /// <param name="userName"></param>
+            public void OnIncomingCall(string userName)
+            {
+                Utlis.WriteLine("OnIncomingCall :" + userName);
+            }
         }
 
         /// <summary>
@@ -433,13 +662,101 @@
         /// <summary>
         /// 娓呮閫氱煡鏍忔墍鏈夐�氱煡
         /// </summary>
-        void CancelAllNotification() {
+        void CancelAllNotification()
+        {
             NotificationManager nMgr = (NotificationManager)Application.Activity.GetSystemService(Context.NotificationService);
             nMgr.CancelAll();
         }
 
 #endif
         #endregion
+
+        #region 鈻�  --  iOS鐩稿叧鎿嶄綔_______________________________
+
+#if __IOS__
+
+        #region OnHDLLinphoneCallDelegate
+        /// <summary>
+        /// 
+        /// </summary>
+        OnHDLLinphoneCallDelegate mOnHDLLinphoneCallDelegate;
+     
+        /// <summary>
+        /// 
+        /// </summary>
+        public class OnHDLLinphoneCallDelegate : HDLLinphoneCallDelegate
+        { 
+            [Weak] HDLLinphone hdlLinphone;
+
+            public OnHDLLinphoneCallDelegate(HDLLinphone mHDLLinphone)
+            {
+                this.hdlLinphone = mHDLLinphone;
+            }
+
+            /// <summary>
+            /// 鎺ュ惉
+            /// </summary>
+            public override void OnAnswerAction()
+            {
+                hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
+            }
+
+            /// <summary>
+            /// 鎸傛柇
+            /// </summary>
+            /// <param name="callDuration"></param>
+            public override void OnHangUpAction(int callDuration)
+            {
+                hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL, callDuration);
+            }
+
+            /// <summary>
+            /// 鎷掓帴
+            /// </summary>
+            public override void OnRejectCallAction()
+            {
+                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);
+            //}
+
+            /// <summary>
+            /// 寮�閿佹垚鍔�
+            /// </summary>
+            public override void OnUnlockAction()
+            {
+                hdlLinphone.HDLUnlockAction();
+            }
+
+            /// <summary>
+            /// 鏉ョ數涓�...
+            /// </summary>
+            public override void OnIncomingCall(string userName)
+            {
+                Utlis.WriteLine("OnIncomingCall :" + userName);
+            }
+            
+
+
+        }
+
+        #endregion
+#endif
+
+        #endregion
+
     }
 
     /// <summary>

--
Gitblit v1.8.0