wxr
2024-05-20 efcffde735fa65ae34bae0bcc86313b74ed0e36c
HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
@@ -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;
@@ -124,9 +124,8 @@
            //登录sip服务器
#if __IOS__
            //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login("1003", "123456", "192.168.31.194: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
            if (mInterphoneType == InterphoneType.FREEVIEW.ToString())
@@ -134,7 +133,8 @@
                HDLLinphoneKit.Instance.SetAccountAndLogin(
                    mHDLSipInfo.sipAccount,
                    mHDLSipInfo.sipPasswd,
                    "139.159.157.75:46000",
                    mHDLSipInfo.realm,
                    //"sip:139.159.157.75:47000;transport=udp",
                    HDLLinphoneKit.InterPhoneTypeFreeview
                    );
            }
@@ -144,6 +144,8 @@
                   mHDLSipInfo.sipAccount,
                   mHDLSipInfo.sipPasswd,
                   mHDLSipInfo.realm,
                   //mHDLSipInfo.proxy+ ";transport=udp",
                   //"sip:139.159.157.75:47000;transport=udp",
                   HDLLinphoneKit.InterPhoneTypeHdl
                   );
            }
@@ -161,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
        }
@@ -174,7 +183,7 @@
        {
#if __IOS__
            HDLLinPhoneSDK.Instance().ClearAllConfigs();
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().ClearAllConfigs();
#else
            HDLLinphoneKit.Instance.ClearProxyConfig();
#endif
@@ -225,7 +234,7 @@
                //先清空呼叫和监视设备信息
                if (clearCallInfo)
                {
                    InitCallInfo(null);
                    //InitCallInfo(null);//造成接收呼叫时开锁开锁异常
                }
                HDLSipInfo mHDLSipInfo = GetHDLSipInfo(mHDLCallVideoInfo.HomeId);
@@ -233,15 +242,31 @@
                {
                    Application.RunOnMainThread(() =>
                    {
                        InitLinphone();
                        try
                        {
                            InitLinphone();
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"InitLinphone exception : {ex.Message}");
                        }
                        mHDLSipInfo.homeId = mHDLCallVideoInfo.HomeId;
                        SetAccountAndLogin(mHDLSipInfo, mHDLCallVideoInfo.InterphoneType);
                        try {
                            SetAccountAndLogin(mHDLSipInfo, mHDLCallVideoInfo.InterphoneType);
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"SetAccountAndLogin exception : {ex.Message}");
                        }
                        Utlis.WriteLine("CALL 获取SIP账号成功:" + mHDLSipInfo.sipAccount);
                    });
                }
                else
                {
                    new Alert("", $"获取Sip账号信息失败.", "确定").Show();
                    //Application.RunOnMainThread(() =>
                    //{
                    //    new Alert("", $"获取Sip账号信息失败.", "确定").Show();
                    //});
                }
            }
            catch { }
@@ -313,7 +338,7 @@
        #region ■  --  新接听和开锁接口_______________________________
        /// <summary>
        /// 开锁
        /// 可视对讲开锁
        /// </summary>
        public void HDLUnlockAction()
        {
@@ -333,6 +358,10 @@
                Application.RunOnMainThread(() =>
                {
                    if(revertObj == null)
                    {
                        return;
                    }
#if __IOS__
                    if (revertObj.Code == StateCode.SUCCESS)
@@ -425,7 +454,13 @@
#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.先呼叫设备
@@ -493,7 +528,7 @@
            {
#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)
@@ -511,7 +546,7 @@
                if (IsAutoJumpCallView) return;
                //先结束掉之前的线程
                EndCheckIncomingCallThread();
                //检测是否来电了如果是直接调整呼叫页面如果不是则开启线程等待判断
                //检测是否来电了如果是直接调整呼叫页面如果不是则开启线程等待判断(Shared.IOS.HDLLinphoneSDK)
                if (IsIncomingReceivedCallState())
                {
                    Utlis.WriteLine("CALL 已经来电了。。。打开呼叫页面");
@@ -528,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
@@ -546,7 +582,7 @@
#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));
@@ -595,7 +631,7 @@
                                threadTime--;
                                Utlis.WriteLine("CALL 检测中...." + threadTime);
                                Thread.Sleep(1000);
                                //来电了,跳转呼叫页面
                                //来电了,跳转呼叫页面(Shared.IOS.HDLLinphoneSDK)
                                if (IsIncomingReceivedCallState())
                                {
                                    Utlis.WriteLine("CALL 来电了。。。打开呼叫页面");
@@ -647,10 +683,10 @@
            return checkIncomingCallThread == null || checkIncomingCallThread.ThreadState != ThreadState.Running;
        }
#endregion
        #endregion
#region ■  --  Android相关操作_______________________________
        #region ■  --  Android相关操作_______________________________
#if __Android__
@@ -745,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)
@@ -797,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>
            /// 开锁成功
@@ -823,15 +859,13 @@
            {
                Utlis.WriteLine("OnIncomingCall :" + userName);
            }
        }
#endregion
        #endregion
#endif
#endregion
        #endregion
    }