wxr
2024-05-20 efcffde735fa65ae34bae0bcc86313b74ed0e36c
HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
@@ -15,7 +15,7 @@
#else
using Foundation;
using UIKit;
//using Shared.IOS.HDLLinphoneSDK;
using Shared.IOS.HDLLinphoneSDK;
#endif
namespace Shared
@@ -124,8 +124,8 @@
            //登录sip服务器
#if __IOS__
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm);
#else
            if (mInterphoneType == InterphoneType.FREEVIEW.ToString())
@@ -133,8 +133,8 @@
                HDLLinphoneKit.Instance.SetAccountAndLogin(
                    mHDLSipInfo.sipAccount,
                    mHDLSipInfo.sipPasswd,
                    "139.159.157.75:47000",//mHDLSipInfo.realm,
                    "sip:139.159.157.75:47000;transport=udp",
                    mHDLSipInfo.realm,
                    //"sip:139.159.157.75:47000;transport=udp",
                    HDLLinphoneKit.InterPhoneTypeFreeview
                    );
            }
@@ -144,7 +144,8 @@
                   mHDLSipInfo.sipAccount,
                   mHDLSipInfo.sipPasswd,
                   mHDLSipInfo.realm,
                   "sip:139.159.157.75:47000;transport=udp",
                   //mHDLSipInfo.proxy+ ";transport=udp",
                   //"sip:139.159.157.75:47000;transport=udp",
                   HDLLinphoneKit.InterPhoneTypeHdl
                   );
            }
@@ -164,7 +165,14 @@
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().LogoutAllLinphoneUser();
#else
            HDLLinphoneKit.Instance.Logout();
            if (HDLLinphoneKit.Instance != null)
            {
                HDLLinphoneKit.Instance.Logout();
            }
            else
            {
            }
#endif
        }
@@ -226,7 +234,7 @@
                //先清空呼叫和监视设备信息
                if (clearCallInfo)
                {
                    InitCallInfo(null);
                    //InitCallInfo(null);//造成接收呼叫时开锁开锁异常
                }
                HDLSipInfo mHDLSipInfo = GetHDLSipInfo(mHDLCallVideoInfo.HomeId);
@@ -234,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 { }
@@ -314,7 +338,7 @@
        #region ■  --  新接听和开锁接口_______________________________
        /// <summary>
        /// 开锁
        /// 可视对讲开锁
        /// </summary>
        public void HDLUnlockAction()
        {
@@ -334,6 +358,10 @@
                Application.RunOnMainThread(() =>
                {
                    if(revertObj == null)
                    {
                        return;
                    }
#if __IOS__
                    if (revertObj.Code == StateCode.SUCCESS)
@@ -426,7 +454,13 @@
#if __IOS__
            Shared.IOS.HDLLinphoneSDK.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.先呼叫设备
@@ -766,57 +800,57 @@
        {
            [Weak] HDLLinphone hdlLinphone;
        //    public OnHDLLinphoneCallDelegate(HDLLinphone mHDLLinphone)
        //    {
        //        this.hdlLinphone = mHDLLinphone;
        //    }
            public OnHDLLinphoneCallDelegate(HDLLinphone mHDLLinphone)
            {
                this.hdlLinphone = mHDLLinphone;
            }
        //    /// <summary>
        //    /// 接听
        //    /// </summary>
        //    public override void OnAnswerAction()
        //    {
        //        hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
        //    }
            /// <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>
            /// <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>
            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);
            //}
            /// <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>
        //    /// 开锁成功
        //    /// </summary>
        //    public override void OnUnlockAction()
        //    {
        //        hdlLinphone.HDLUnlockAction();
        //    }
            /// <summary>
            /// 开锁成功
            /// </summary>
            public override void OnUnlockAction()
            {
                hdlLinphone.HDLUnlockAction();
            }
            /// <summary>
            /// 来电中...
@@ -826,9 +860,7 @@
                Utlis.WriteLine("OnIncomingCall :" + userName);
            }
        //}
        }
        #endregion
#endif