From eda3fb873e59544ff36301b51e05aef64f87b0f9 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期五, 27 八月 2021 13:21:21 +0800 Subject: [PATCH] Merge branch 'newBranch1' of http://172.16.1.23:6688/r/~wxr/HDL_APP_Project into newBranch1 --- HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs | 581 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 461 insertions(+), 120 deletions(-) diff --git a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs index 347ddd6..68cec3c 100644 --- a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs +++ b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs @@ -5,23 +5,33 @@ using HDL_ON; using HDL_ON.DAL.Server; using HDL_ON.Entity; + #if __Android__ +using Android.App; using Android.Content; using Android.Graphics; using Android.Widget; 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() { + } - /// <summary> /// /// </summary> @@ -41,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 @@ -48,58 +82,154 @@ 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, bool clearCallInfo = true) + { + try + { + + + //鍏堟竻绌哄懠鍙拰鐩戣璁惧淇℃伅 + if (clearCallInfo) + { + 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> /// <param name="mHDLCallVideoInfo"></param> /// <param name="mInterphoneType"></param> - public void InitCallInfo(HDLCallVideoInfo mHDLCallVideoInfo) + void InitCallInfo(HDLCallVideoInfo mHDLCallVideoInfo) { this.mHDLCallVideoInfo = mHDLCallVideoInfo; } @@ -110,12 +240,11 @@ /// <returns></returns> bool CheckmHDLCallVideoInfoIsNullOrEmpty() { - //return false; return (mHDLCallVideoInfo == null || string.IsNullOrEmpty(mHDLCallVideoInfo.CallId)); } /// <summary> - /// 鎴浘鎴愬姛 + /// 鎴浘鎴愬姛 鏆傛椂搴熷純 /// </summary> public void ScreenshotSuccessfulAction(byte[] dataBytes) { @@ -151,7 +280,7 @@ } - DateTime UnlockDateTime = DateTime.MinValue; + //DateTime UnlockDateTime = DateTime.MinValue; #endregion #region 鈻� -- 鏂版帴鍚拰寮�閿佹帴鍙______________________________ @@ -168,9 +297,9 @@ { Dictionary<string, object> dic = new Dictionary<string, object>(); dic.Add("deviceId", mHDLCallVideoInfo.DeviceId);//璁惧id - dic.Add("callId", mHDLCallVideoInfo.CallId); - dic.Add("interphoneType", mHDLCallVideoInfo.InterphoneType); - dic.Add("homeId", mHDLCallVideoInfo.HomeId); + dic.Add("callId", mHDLCallVideoInfo.CallId);//褰撳墠鍛煎彨id + dic.Add("interphoneType", mHDLCallVideoInfo.InterphoneType);//鍙瀵硅鍘傚绫诲瀷 + dic.Add("homeId", mHDLCallVideoInfo.HomeId);//浣忓畢ID var requestJson = HttpUtil.GetSignRequestJson(dic); var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_OpenDoorbell, requestJson); @@ -199,7 +328,6 @@ } #endif - }); @@ -220,7 +348,7 @@ Dictionary<string, object> dic = new Dictionary<string, object>(); dic.Add("callId", mHDLCallVideoInfo.CallId);//鍛煎彨id dic.Add("callStatus", callStatusType.ToString());//鍙敤鍊�:MISSED,RECEIVED,REJECT - dic.Add("interphoneTypeEnum", interphoneType.ToString());//鍙敤鍊�:FLVI,IMOUVISIAL + dic.Add("interphoneTypeEnum", interphoneType.ToString()); if (callStatusType == CallStatusType.RECEIVED && callDuration > 0) { dic.Add("callDuration", callDuration);//閫氳瘽鏃堕暱锛堢锛� @@ -243,72 +371,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> /// 璺宠浆鐩戞帶椤甸潰 @@ -316,6 +379,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; @@ -325,11 +396,15 @@ InitCallInfo(mHDLCallVideoInfo); #if __IOS__ - + + HDLLinPhoneSDK.Instance().CallWithUserName(mHDLCallVideoInfo.DeviceSipAccount, mHDLCallVideoInfo.DeviceName); + #else + //1.鍏堝懠鍙澶� Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.CallTo(mHDLCallVideoInfo.DeviceSipAccount, true); + //2.璺宠浆鎵撳紑鐩戞帶椤甸潰 var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneMonitorActivity)); ; - intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.DeviceName); + intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.DeviceName);//浼犲叆璁惧鍚嶇О涓烘樉绀烘爣棰� Shared.Application.Activity.StartActivity(intent); #endif @@ -339,11 +414,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; @@ -353,15 +430,172 @@ 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, false); + }) + { IsBackground = false }.Start(); + + // + CheckCallStateAndGotoPage(); + + } + + } + + /// <summary> + /// 妫�娴嬫潵鐢电姸鎬侊紝鍒ゆ柇鏄惁椹笂鎵撳紑鍛煎彨椤甸潰锛屽鏋滆繕娌℃潵鐢靛垯寮�鍚嚎绋嬫娴嬬瓑寰� + /// </summary> + /// <param name="mESVideoInfo"></param> + public void CheckCallStateAndGotoPage() + { + //濡傛灉寮�鍚簡鑷姩璺宠浆鏂规锛屽垯鏃犻渶缁х画涓嬮潰澶勭悊銆佹棤闇�鎵嬪姩璺宠浆 + if (IsAutoJumpCallView) return; + //鍏堢粨鏉熸帀涔嬪墠鐨勭嚎绋� + EndCheckIncomingCallThread(); + //妫�娴嬫槸鍚︽潵鐢典簡濡傛灉鏄洿鎺ヨ皟鏁村懠鍙〉闈㈠鏋滀笉鏄垯寮�鍚嚎绋嬬瓑寰呭垽鏂� + 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> + const int MAX_THREAD_TIME = 30; + /// <summary> + /// 绾跨▼缁撴潫 + /// </summary> + int threadTime = MAX_THREAD_TIME; + /// <summary> + /// 寮�鍚娴嬫潵鐢电嚎绋� + /// </summary> + void StartCheckIncomingCallThread() + { + try + { + Utlis.WriteLine("CALL 杩樻病鏉ョ數锛屽紑鍚嚎绋�"); + threadTime = MAX_THREAD_TIME; + //缁撴潫涔嬪墠鐨勭嚎绋� + 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; + Utlis.WriteLine("CALL 鍏堢粨鏉熺嚎绋�"); + } + } + + /// <summary> + /// 鍒ゆ柇绾跨▼鏄惁鍚姩浜� + /// </summary> + /// <returns></returns> + public bool CheckIncomingCallThreadIsNull() + { + return checkIncomingCallThread == null || checkIncomingCallThread.ThreadState != ThreadState.Running; + } + #endregion @@ -387,36 +621,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> @@ -427,8 +684,104 @@ HDLLinphoneKit.Instance.OnHDLLinphoneCallListener = new HDLLinphoneCallListener(this); } + /// <summary> + /// 娓呮閫氱煡鏍忔墍鏈夐�氱煡 + /// </summary> + 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> @@ -456,18 +809,6 @@ /// 浣忓畢Id /// </summary> public string HomeId = string.Empty; - /// <summary> - /// 璐﹀彿 - /// </summary> - public string Username = string.Empty; - /// <summary> - /// 瀵嗙爜 - /// </summary> - public string Password = string.Empty; - /// <summary> - /// Domain - /// </summary> - public string Domain = string.Empty; /// <summary> /// 绫诲瀷 /// </summary> -- Gitblit v1.8.0