wxr
2024-09-30 dc9a1b15bb69227e19afc070adf58156a362d2a2
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;
@@ -126,7 +127,17 @@
            //登录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())
            {
@@ -135,7 +146,8 @@
                    mHDLSipInfo.sipPasswd,
                    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
@@ -510,8 +523,23 @@
        /// 收到推送,后判断呼叫住宅是否为当前住宅,不是的话重新获取SIP账号并登录
        /// </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();
@@ -558,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)
@@ -567,6 +595,7 @@
                    intent.PutExtra("lpTitleName", mHDLCallVideoInfo.DeviceName);
                    intent.PutExtra("lpSipAccount", mHDLCallVideoInfo.DeviceSipAccount);
                }
                MainPage.Log("启动自研可视对讲界面");
                Shared.Application.Activity.StartActivity(intent);
#endif
            }
@@ -599,7 +628,7 @@
        bool IsIncomingReceivedCallState()
        {
#if __IOS__
            return Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
            return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
#else
            return HDLLinphoneKit.Instance.IsIncomingReceivedCallState;
#endif
@@ -612,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));
@@ -744,6 +774,14 @@
            public void OnAnswerAction()
            {
                //showToast("接听");
                try
                {
                    HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
                }
                catch (Exception ex)
                {
                    MainPage.Log("铃声关闭异常:" + ex.StackTrace);
                }
                hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
            }
            /// <summary>
@@ -763,10 +801,23 @@
            public void OnRejectCallAction()
            {
                //showToast("拒接");
                hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
                hdlLinphone.HDLRejectCallIn();
                try
                {
                    HDLLinphoneKit.Instance.SetMediaPlayerLooping(false);
                }
                catch (Exception ex)
                {
                    MainPage.Log("铃声关闭异常:" + ex.StackTrace);
                }
                try
                {
                    hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
                }
                catch (Exception ex)
                {
                    MainPage.Log("OnRejectCallAction异常:" + ex.StackTrace);
                }
            }
            /// <summary>
            /// 截图成功事件
            /// </summary>
@@ -791,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("铃声关闭异常:" + 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("铃声关闭异常:" + ex.StackTrace);
                }
                try
                {
                    hdlLinphone.HDLUpdateCallStatus(CallStatusType.MISSED, InterphoneType.HDL);
                }
                catch (Exception ex)
                {
                    MainPage.Log("OnMissedCallsAction异常:" + ex.StackTrace);
                }
            }
        }
@@ -841,6 +937,7 @@
            /// </summary>
            public override void OnAnswerAction()
            {
                Other.SoundPlayer.Ins.StopSound();
                hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
            }
@@ -858,6 +955,8 @@
            /// </summary>
            public override void OnRejectCallAction()
            {
                MainPage.Log("iOS 全部拒接");
                Other.SoundPlayer.Ins.StopSound();
                hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
            }
@@ -865,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();
@@ -891,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