From efcffde735fa65ae34bae0bcc86313b74ed0e36c Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期一, 20 五月 2024 13:47:38 +0800 Subject: [PATCH] 优化离线数据 --- HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs | 177 ++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 122 insertions(+), 55 deletions(-) diff --git a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs index 04910cd..d26ebf5 100644 --- a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs +++ b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs @@ -65,7 +65,7 @@ /// false锛氭敹鍒版帹閫佸苟涓斿凡缁忔敹鍒皊ip鍛煎彨鎵嶈烦杞懠鍙〉闈� /// true锛氬師鐢熸敹鍒板懠鍙┈涓婅烦杞懠鍙〉闈紝涓嶇瓑寰呮帹閫佽繃鏉� /// </summary> - bool IsAutoJumpCallView = false; + bool IsAutoJumpCallView = true; /// <summary> /// 鏄惁鍒濆鍖栦簡SDK /// </summary> @@ -95,7 +95,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; @@ -108,25 +108,48 @@ #endif } - /// <summary> /// 璁剧疆sip鐧诲綍璐﹀彿 /// </summary> /// <param name="mHDLSipInfo"></param> - public void SetAccountAndLogin(HDLSipInfo mHDLSipInfo) + public void SetAccountAndLogin(HDLSipInfo mHDLSipInfo, string mInterphoneType) { this.currentHDLSipInfo = mHDLSipInfo; - if (mHDLSipInfo == null) return; + if (mHDLSipInfo == null) { + //new alert + return; + } + + + //鐧诲綍sip鏈嶅姟鍣� #if __IOS__ - //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 - HDLLinphoneKit.Instance.SetAccountAndLogin(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm); + if (mInterphoneType == InterphoneType.FREEVIEW.ToString()) + { + HDLLinphoneKit.Instance.SetAccountAndLogin( + mHDLSipInfo.sipAccount, + mHDLSipInfo.sipPasswd, + mHDLSipInfo.realm, + //"sip:139.159.157.75:47000;transport=udp", + HDLLinphoneKit.InterPhoneTypeFreeview + ); + } + else + { + HDLLinphoneKit.Instance.SetAccountAndLogin( + mHDLSipInfo.sipAccount, + mHDLSipInfo.sipPasswd, + mHDLSipInfo.realm, + //mHDLSipInfo.proxy+ ";transport=udp", + //"sip:139.159.157.75:47000;transport=udp", + HDLLinphoneKit.InterPhoneTypeHdl + ); + } #endif - } /// <summary> @@ -140,9 +163,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 } @@ -153,7 +183,7 @@ { #if __IOS__ - HDLLinPhoneSDK.Instance().ClearAllConfigs(); + Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().ClearAllConfigs(); #else HDLLinphoneKit.Instance.ClearProxyConfig(); #endif @@ -197,28 +227,46 @@ /// 璇锋眰鏈嶅姟鍣ㄨ幏鍙栧綋鍓嶄綇瀹匰ip璐﹀彿淇℃伅骞跺垵濮嬪寲LinphoneSDK鍜岀櫥褰� /// </summary> /// <param name="homeId"></param> - public void GetHDLSipInfoAndInitSDK(string homeId, bool clearCallInfo = true) + public void GetHDLSipInfoAndInitSDK(HDLCallVideoInfo mHDLCallVideoInfo, bool clearCallInfo = true) { try { - - //鍏堟竻绌哄懠鍙拰鐩戣璁惧淇℃伅 if (clearCallInfo) { - InitCallInfo(null); + //InitCallInfo(null);//閫犳垚鎺ユ敹鍛煎彨鏃跺紑閿佸紑閿佸紓甯� } - HDLSipInfo mHDLSipInfo = GetHDLSipInfo(homeId); + HDLSipInfo mHDLSipInfo = GetHDLSipInfo(mHDLCallVideoInfo.HomeId); if (mHDLSipInfo != null) { Application.RunOnMainThread(() => { - InitLinphone(); - mHDLSipInfo.homeId = homeId; - SetAccountAndLogin(mHDLSipInfo); + try + { + InitLinphone(); + } + catch (Exception ex) + { + MainPage.Log($"InitLinphone exception : {ex.Message}"); + } + mHDLSipInfo.homeId = mHDLCallVideoInfo.HomeId; + 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 { } @@ -290,7 +338,7 @@ #region 鈻� -- 鏂版帴鍚拰寮�閿佹帴鍙______________________________ /// <summary> - /// 寮�閿� + /// 鍙瀵硅寮�閿� /// </summary> public void HDLUnlockAction() { @@ -310,6 +358,10 @@ Application.RunOnMainThread(() => { + if(revertObj == null) + { + return; + } #if __IOS__ if (revertObj.Code == StateCode.SUCCESS) @@ -382,7 +434,7 @@ /// 璺宠浆鐩戞帶椤甸潰 /// </summary> /// <param name="mESVideoInfo"></param> - public void ShowESVideoMonitor(ESVideoInfo mESVideoInfo) + public void ShowESVideoMonitor(ESVideoInfo mESVideoInfo,string mInterphoneType) { InitLinphone(); //sip璐﹀彿涓虹┖ @@ -396,13 +448,19 @@ mHDLCallVideoInfo.HomeId = mESVideoInfo.HomeId; mHDLCallVideoInfo.DeviceId = mESVideoInfo.Lc_DeviceId; mHDLCallVideoInfo.DeviceName = mESVideoInfo.DeviceName; - mHDLCallVideoInfo.InterphoneType = InterphoneType.HDL.ToString(); + mHDLCallVideoInfo.InterphoneType = mInterphoneType; mHDLCallVideoInfo.DeviceSipAccount = mESVideoInfo.deviceSipAccount;//鐩戣涓诲姩鍛煎彨闂ㄥ彛鏈烘椂鐢ㄥ埌 InitCallInfo(mHDLCallVideoInfo); #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.鍏堝懠鍙澶� @@ -422,7 +480,7 @@ /// 鏀跺埌鎺ㄩ�侊紝鍚庡垽鏂懠鍙綇瀹呮槸鍚︿负褰撳墠浣忓畢锛屼笉鏄殑璇濋噸鏂拌幏鍙朣IP璐﹀彿骞剁櫥褰� /// </summary> /// <param name="mESVideoInfo"></param> - public void ShowESVideoIntercom(ESVideoInfo mESVideoInfo) + public void ShowESVideoIntercom(ESVideoInfo mESVideoInfo,string mInterphoneType) { InitLinphone(); @@ -431,7 +489,7 @@ mHDLCallVideoInfo.HomeId = mESVideoInfo.HomeId; mHDLCallVideoInfo.DeviceId = mESVideoInfo.Lc_DeviceId; mHDLCallVideoInfo.DeviceName = mESVideoInfo.DeviceName; - mHDLCallVideoInfo.InterphoneType = InterphoneType.HDL.ToString(); + mHDLCallVideoInfo.InterphoneType = mInterphoneType; mHDLCallVideoInfo.DeviceSipAccount = mESVideoInfo.deviceSipAccount; mHDLCallVideoInfo.spk = mESVideoInfo.spk; InitCallInfo(mHDLCallVideoInfo); @@ -449,7 +507,7 @@ Utlis.WriteLine("CALL 鏀跺埌鎺ㄩ�� 鍏朵粬浣忓畢锛岄噸鏂拌幏鍙栧懠鍙綇瀹呯殑SIP璐﹀彿骞剁櫥褰�"); new Thread(() => { - GetHDLSipInfoAndInitSDK(mESVideoInfo.HomeId, false); + GetHDLSipInfoAndInitSDK(mHDLCallVideoInfo, false); }) { IsBackground = false }.Start(); @@ -470,7 +528,16 @@ { #if __IOS__ //鑷爺鍙瀵硅 - HDLLinPhoneSDK.Instance().GotoHDLSRLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName,mHDLCallVideoInfo.DeviceSipAccount); + Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().GotoHDLSRLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName, mHDLCallVideoInfo.DeviceSipAccount); +#else + var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneReverseCallActivity)); + if (mHDLCallVideoInfo != null) + { + //intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.DeviceName); + intent.PutExtra("lpTitleName", mHDLCallVideoInfo.DeviceName); + intent.PutExtra("lpSipAccount", mHDLCallVideoInfo.DeviceSipAccount); + } + Shared.Application.Activity.StartActivity(intent); #endif } else { @@ -479,7 +546,7 @@ if (IsAutoJumpCallView) return; //鍏堢粨鏉熸帀涔嬪墠鐨勭嚎绋� EndCheckIncomingCallThread(); - //妫�娴嬫槸鍚︽潵鐢典簡濡傛灉鏄洿鎺ヨ皟鏁村懠鍙〉闈㈠鏋滀笉鏄垯寮�鍚嚎绋嬬瓑寰呭垽鏂� + //妫�娴嬫槸鍚︽潵鐢典簡濡傛灉鏄洿鎺ヨ皟鏁村懠鍙〉闈㈠鏋滀笉鏄垯寮�鍚嚎绋嬬瓑寰呭垽鏂�(Shared.IOS.HDLLinphoneSDK) if (IsIncomingReceivedCallState()) { Utlis.WriteLine("CALL 宸茬粡鏉ョ數浜嗐�傘�傘�傛墦寮�鍛煎彨椤甸潰"); @@ -496,12 +563,13 @@ } /// <summary> - /// 鏄惁鏉ョ數鐘舵�� + /// 鏄惁鏉ョ數鐘舵��(Shared.IOS.HDLLinphoneSDK) /// </summary> /// <returns></returns> - bool IsIncomingReceivedCallState() { + bool IsIncomingReceivedCallState() + { #if __IOS__ - return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState; + return Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState; #else return HDLLinphoneKit.Instance.IsIncomingReceivedCallState; #endif @@ -514,13 +582,14 @@ #if __IOS__ - HDLLinPhoneSDK.Instance().GotoHDLLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName); + Shared.IOS.HDLLinphoneSDK.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 @@ -562,7 +631,7 @@ threadTime--; Utlis.WriteLine("CALL 妫�娴嬩腑...." + threadTime); Thread.Sleep(1000); - //鏉ョ數浜嗭紝璺宠浆鍛煎彨椤甸潰 + //鏉ョ數浜嗭紝璺宠浆鍛煎彨椤甸潰(Shared.IOS.HDLLinphoneSDK) if (IsIncomingReceivedCallState()) { Utlis.WriteLine("CALL 鏉ョ數浜嗐�傘�傘�傛墦寮�鍛煎彨椤甸潰"); @@ -614,10 +683,10 @@ return checkIncomingCallThread == null || checkIncomingCallThread.ThreadState != ThreadState.Running; } -#endregion + #endregion -#region 鈻� -- Android鐩稿叧鎿嶄綔_______________________________ + #region 鈻� -- Android鐩稿叧鎿嶄綔_______________________________ #if __Android__ @@ -712,23 +781,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,16 +833,16 @@ /// <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 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> /// 寮�閿佹垚鍔� @@ -790,15 +859,13 @@ { Utlis.WriteLine("OnIncomingCall :" + userName); } - - } -#endregion + #endregion #endif -#endregion + #endregion } -- Gitblit v1.8.0