From 30741caa02ed108fb0fbbaeda91eb6dd7c33fc9f Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期五, 27 八月 2021 11:48:35 +0800
Subject: [PATCH] Merge branch 'CJL-Linphone' into wxr7
---
HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs | 847 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 847 insertions(+), 0 deletions(-)
diff --git a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
new file mode 100644
index 0000000..68cec3c
--- /dev/null
+++ b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
@@ -0,0 +1,847 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Threading;
+
+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>
+ private static HDLLinphone m_Current = null;
+ /// <summary>
+ ///
+ /// </summary>
+ public static HDLLinphone Current
+ {
+ get
+ {
+ if (m_Current == null)
+ {
+ m_Current = new HDLLinphone();
+ }
+ return m_Current;
+ }
+ }
+
+
+ /// <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
+ /// </summary>
+ void InitLinphone()
+ {
+ //闃叉閲嶅鍒濆鍖�
+ if (IsInitSdk) return;
+
+ 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
+ HDLLinphoneKit.Instance.InitLinphone(Application.Activity);
+ //璁剧疆鏀跺埌鏉ョ數鍚庛�佹槸鍚﹂渶鑷姩璺宠浆鍛煎彨椤甸潰鏂规
+ HDLLinphoneKit.Instance.AutoJumpCallView = IsAutoJumpCallView;
+ //璁剧疆Listener鐩戝惉
+ setOnHDLLinphoneCallListener();
+#endif
+ }
+
+
+ /// <summary>
+ /// 璁剧疆sip鐧诲綍璐﹀彿
+ /// </summary>
+ /// <param name="mHDLSipInfo"></param>
+ public void SetAccountAndLogin(HDLSipInfo mHDLSipInfo)
+ {
+
+ this.currentHDLSipInfo = mHDLSipInfo;
+
+ if (mHDLSipInfo == null) return;
+
+#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);
+#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>
+ /// <param name="mHDLCallVideoInfo"></param>
+ /// <param name="mInterphoneType"></param>
+ void InitCallInfo(HDLCallVideoInfo mHDLCallVideoInfo)
+ {
+ this.mHDLCallVideoInfo = mHDLCallVideoInfo;
+ }
+
+ /// <summary>
+ /// 鍒ゆ柇callId鏄惁涓虹┖
+ /// </summary>
+ /// <returns></returns>
+ bool CheckmHDLCallVideoInfoIsNullOrEmpty()
+ {
+ return (mHDLCallVideoInfo == null || string.IsNullOrEmpty(mHDLCallVideoInfo.CallId));
+ }
+
+ /// <summary>
+ /// 鎴浘鎴愬姛 鏆傛椂搴熷純
+ /// </summary>
+ public void ScreenshotSuccessfulAction(byte[] dataBytes)
+ {
+ //Utlis.WriteLine("ScreenshotSuccessfulAction");
+
+ if (CheckmHDLCallVideoInfoIsNullOrEmpty()) return;
+
+ new Thread(() =>
+ {
+ //var imageName = Guid.NewGuid().ToString();
+ Dictionary<string, object> dic = new Dictionary<string, object>();
+ dic.Add("callId", mHDLCallVideoInfo.CallId);
+ dic.Add("images", dataBytes);
+#if __IOS__
+ dic.Add("imagesName", "_IOS.jpg");
+#else
+ dic.Add("imagesName", "_Android.jpg");
+#endif
+
+ var requestJson = HttpUtil.GetSignRequestJson(dic);
+ var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_FL_Screenshot, requestJson);
+ if (revertObj.Code == StateCode.SUCCESS)
+ {
+ //Utlis.WriteLine("POST 鎴浘涓婁紶鎴愬姛");
+ }
+ else
+ {
+ Utlis.WriteLine("POST 鎴浘涓婁紶澶辫触 code: " + revertObj.Code);
+ }
+
+ })
+ { IsBackground = false }.Start();
+
+ }
+
+ //DateTime UnlockDateTime = DateTime.MinValue;
+ #endregion
+
+ #region 鈻� -- 鏂版帴鍚拰寮�閿佹帴鍙______________________________
+ /// <summary>
+ /// 寮�閿�
+ /// </summary>
+ public void HDLUnlockAction()
+ {
+ //Utlis.WriteLine("UnlockAction");
+
+ if (mHDLCallVideoInfo == null) return;
+
+ new Thread(() =>
+ {
+ Dictionary<string, object> dic = new Dictionary<string, object>();
+ dic.Add("deviceId", mHDLCallVideoInfo.DeviceId);//璁惧id
+ 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);
+
+ Application.RunOnMainThread(() =>
+ {
+
+#if __IOS__
+ if (revertObj.Code == StateCode.SUCCESS)
+ {
+ //鍜屽師鐢熺洃鎺х晫闈氦浜掋�佸彂閫佸紑閿佹垚鍔熼�氱煡
+ NSNotificationCenter.DefaultCenter.PostNotificationName("lcCallDelegateOpenDoorSuccess", null);
+ }
+ else
+ {
+ Utlis.WriteLine("POST 寮�閿佸け璐� code: " + revertObj.Code);
+ }
+#else
+ if (revertObj.Code == StateCode.SUCCESS)
+ {
+ HDLLinphoneKit.Instance.OnOpenSuccess();
+ }
+ else
+ {
+ Utlis.WriteLine("POST 寮�閿佸け璐� code: " + revertObj.Code);
+ HDLLinphoneKit.Instance.OnOpenError(revertObj.message);
+ }
+#endif
+
+ });
+
+
+ })
+ { IsBackground = false }.Start();
+ }
+
+ /// <summary>
+ /// 鏇存敼閫氳瘽鐘舵��
+ /// </summary>
+ public void HDLUpdateCallStatus(CallStatusType callStatusType, InterphoneType interphoneType, int callDuration = 0)
+ {
+
+ if (CheckmHDLCallVideoInfoIsNullOrEmpty()) return;
+
+ new Thread(() =>
+ {
+ 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());
+ if (callStatusType == CallStatusType.RECEIVED && callDuration > 0)
+ {
+ dic.Add("callDuration", callDuration);//閫氳瘽鏃堕暱锛堢锛�
+ }
+
+ var requestJson = HttpUtil.GetSignRequestJson(dic);
+ var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_UpdateCallStatus, requestJson);
+ if (revertObj.Code == StateCode.SUCCESS)
+ {
+
+ }
+ else
+ {
+ Utlis.WriteLine("POST 鏇存柊鐘舵�佸け璐� code: " + revertObj.Code);
+ }
+
+ })
+ { IsBackground = false }.Start();
+
+ }
+ #endregion
+
+
+ #region 鈻� -- 璺宠浆鐩戞帶椤甸潰_______________________________
+ /// <summary>
+ /// 璺宠浆鐩戞帶椤甸潰
+ /// </summary>
+ /// <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;
+ mHDLCallVideoInfo.DeviceName = mESVideoInfo.DeviceName;
+ mHDLCallVideoInfo.InterphoneType = InterphoneType.HDL.ToString();
+ mHDLCallVideoInfo.DeviceSipAccount = mESVideoInfo.deviceSipAccount;//鐩戣涓诲姩鍛煎彨闂ㄥ彛鏈烘椂鐢ㄥ埌
+ 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);//浼犲叆璁惧鍚嶇О涓烘樉绀烘爣棰�
+ Shared.Application.Activity.StartActivity(intent);
+#endif
+
+ }
+ #endregion
+
+
+ #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;
+ mHDLCallVideoInfo.DeviceId = mESVideoInfo.Lc_DeviceId;
+ mHDLCallVideoInfo.DeviceName = mESVideoInfo.DeviceName;
+ mHDLCallVideoInfo.InterphoneType = InterphoneType.HDL.ToString();
+ 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
+ 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
+
+
+ #region 鈻� -- Android鐩稿叧鎿嶄綔_______________________________
+
+#if __Android__
+
+ /// <summary>
+ /// 鎺ュ惉銆佹寕鏂�佸紑閿佺瓑鍔ㄤ綔鐩戝惉澶勭悊
+ /// </summary>
+ private class HDLLinphoneCallListener : Java.Lang.Object, Com.Hdl.Hdllinphonesdk.Callback.IOnHDLLinphoneCallListener
+ {
+ [Weak] HDLLinphone hdlLinphone;
+
+ public HDLLinphoneCallListener(HDLLinphone mHDLLinphone)
+ {
+ hdlLinphone = mHDLLinphone;
+ }
+
+
+ //showToast
+ void showToast(string text)
+ {
+ Toast.MakeText(Application.Activity, text, ToastLength.Short).Show();
+ }
+ /// <summary>
+ /// 鎺ュ惉浜嬩欢
+ /// </summary>
+ public void OnAnswerAction()
+ {
+ //showToast("鎺ュ惉");
+ hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
+ }
+ /// <summary>
+ /// 鎸傛柇浜嬩欢
+ /// </summary>
+ /// <param name="callDuration"></param>
+ public void OnHangUpAction(int callDuration)
+ {
+
+ //showToast("鎸傛柇 閫氳瘽鏃堕暱锛�" + callDuration);
+ hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL, callDuration);
+ }
+
+ /// <summary>
+ /// 鎷掓帴浜嬩欢
+ /// </summary>
+ public void OnRejectCallAction()
+ {
+ //showToast("鎷掓帴");
+ hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
+ }
+
+ /// <summary>
+ /// 鎴浘鎴愬姛浜嬩欢
+ /// </summary>
+ /// <param name="p0"></param>
+ public void OnScreenshotSuccessfulAction(Bitmap imgBitmap)
+ {
+ //showToast("鎴浘鎴愬姛");
+ }
+
+ /// <summary>
+ /// 寮�閿佷簨浠�
+ /// </summary>
+ public void OnUnlockAction()
+ {
+ hdlLinphone.HDLUnlockAction();
+ }
+
+ /// <summary>
+ /// 鏉ョ數浜嬩欢
+ /// </summary>
+ /// <param name="userName"></param>
+ public void OnIncomingCall(string userName)
+ {
+ Utlis.WriteLine("OnIncomingCall :" + userName);
+ }
+ }
+
+ /// <summary>
+ /// 璁剧疆鍘熺敓鐨凩istener鐩戝惉
+ /// </summary>
+ void setOnHDLLinphoneCallListener()
+ {
+ 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>
+ /// SIP鍙瀵硅鍙傛暟
+ /// </summary>
+ public class HDLCallVideoInfo
+ {
+ /// <summary>
+ /// 璁惧搴忓垪鍙凤紝閫氳蹇呰瀛楁
+ /// </summary>
+ public string DeviceId = string.Empty;
+ /// <summary>
+ /// 璁惧鍚嶇О
+ /// </summary>
+ public string DeviceName = string.Empty;
+ /// <summary>
+ /// 璁惧Sip璐﹀彿
+ /// </summary>
+ public string DeviceSipAccount = string.Empty;
+ /// <summary>
+ /// 鍛煎彨璁板綍Id
+ /// </summary>
+ public string CallId = string.Empty;
+ /// <summary>
+ /// 浣忓畢Id
+ /// </summary>
+ public string HomeId = string.Empty;
+ /// <summary>
+ /// 绫诲瀷
+ /// </summary>
+ public string InterphoneType;
+
+ }
+
+ /// <summary>
+ /// SIP璐﹀彿鐩稿叧淇℃伅
+ /// </summary>
+ public class HDLSipInfo
+ {
+ /// <summary>
+ /// Sip鏈嶅姟鍣�
+ /// </summary>
+ public string proxy { get; set; }
+ /// <summary>
+ /// 璁惧鍩�
+ /// </summary>
+ public string realm { get; set; }
+ /// <summary>
+ /// sip璐﹀彿
+ /// </summary>
+ public string sipAccount { get; set; }
+ /// <summary>
+ /// sipPasswd sip瀵嗙爜
+ /// </summary>
+ public string sipPasswd { get; set; }
+ /// <summary>
+ /// 浣忓畢ID
+ /// </summary>
+ public string homeId;
+ }
+
+
+}
--
Gitblit v1.8.0