wjc
2023-03-28 f46be160caed45c67e8980173d29ed48d525a4d3
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
@@ -92,13 +92,13 @@
#if __IOS__
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().InitalLinPhone();
            //设置收到来电后、是否需自动跳转呼叫页面方案
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().IsAutoJumpCallView = IsAutoJumpCallView;
            //设置Listener监听
            mOnHDLLinphoneCallDelegate = new OnHDLLinphoneCallDelegate(this);
            Console.WriteLine(UserInfo.Current.ID);
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().HdlLinphoneCallDelegate = mOnHDLLinphoneCallDelegate;
            //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().InitalLinPhone();
            ////设置收到来电后、是否需自动跳转呼叫页面方案
            //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().IsAutoJumpCallView = IsAutoJumpCallView;
            ////设置Listener监听
            //mOnHDLLinphoneCallDelegate = new OnHDLLinphoneCallDelegate(this);
            //Console.WriteLine(UserInfo.Current.ID);
            //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().HdlLinphoneCallDelegate = mOnHDLLinphoneCallDelegate;
#else
            HDLLinphoneKit.Instance.InitLinphone(Application.Activity);
            //设置收到来电后、是否需自动跳转呼叫页面方案
@@ -117,19 +117,25 @@
            this.currentHDLSipInfo = mHDLSipInfo;
            if (mHDLSipInfo == null) return;
            if (mHDLSipInfo == null) {
                //new alert
                return;
            }
#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);
            //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm);
#else
            if (mInterphoneType == InterphoneType.FREEVIEW.ToString())
            {
                HDLLinphoneKit.Instance.SetAccountAndLogin(
                    mHDLSipInfo.sipAccount,
                    mHDLSipInfo.sipPasswd,
                    "139.159.157.75:46000",
                    "139.159.157.75:47000",//mHDLSipInfo.realm,
                    "sip:139.159.157.75:47000;transport=udp",
                    HDLLinphoneKit.InterPhoneTypeFreeview
                    );
            }
@@ -139,6 +145,7 @@
                   mHDLSipInfo.sipAccount,
                   mHDLSipInfo.sipPasswd,
                   mHDLSipInfo.realm,
                   "sip:139.159.157.75:47000;transport=udp",
                   HDLLinphoneKit.InterPhoneTypeHdl
                   );
            }
@@ -156,7 +163,7 @@
            this.mHDLCallVideoInfo = null;
#if __IOS__
            HDLLinPhoneSDK.Instance().LogoutAllLinphoneUser();
            //HDLLinPhoneSDK.Instance().LogoutAllLinphoneUser();
#else
            HDLLinphoneKit.Instance.Logout();
#endif
@@ -169,7 +176,7 @@
        {
#if __IOS__
            HDLLinPhoneSDK.Instance().ClearAllConfigs();
            //HDLLinPhoneSDK.Instance().ClearAllConfigs();
#else
            HDLLinphoneKit.Instance.ClearProxyConfig();
#endif
@@ -233,6 +240,10 @@
                        SetAccountAndLogin(mHDLSipInfo, mHDLCallVideoInfo.InterphoneType);
                        Utlis.WriteLine("CALL 获取SIP账号成功:" + mHDLSipInfo.sipAccount);
                    });
                }
                else
                {
                    new Alert("", $"获取Sip账号信息失败.", "确定").Show();
                }
            }
            catch { }
@@ -416,7 +427,7 @@
#if __IOS__
            HDLLinPhoneSDK.Instance().CallWithUserName(mHDLCallVideoInfo.DeviceSipAccount, mHDLCallVideoInfo.DeviceName);
            //HDLLinPhoneSDK.Instance().CallWithUserName(mHDLCallVideoInfo.DeviceSipAccount, mHDLCallVideoInfo.DeviceName);
#else
            //1.先呼叫设备
@@ -484,7 +495,7 @@
            {
#if __IOS__
                //自研可视对讲
                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)
@@ -524,7 +535,8 @@
        /// <returns></returns>
        bool IsIncomingReceivedCallState() {
#if __IOS__
             return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
            //return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
            return true;
#else
            return HDLLinphoneKit.Instance.IsIncomingReceivedCallState;
#endif
@@ -537,7 +549,7 @@
#if __IOS__
            HDLLinPhoneSDK.Instance().GotoHDLLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName);
            //HDLLinPhoneSDK.Instance().GotoHDLLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName);
#else
            var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneIntercomActivity));
@@ -743,81 +755,81 @@
#if __IOS__
#region OnHDLLinphoneCallDelegate
        /// <summary>
        ///
        /// </summary>
        OnHDLLinphoneCallDelegate mOnHDLLinphoneCallDelegate;
        ///// <summary>
        /////
        ///// </summary>
        //OnHDLLinphoneCallDelegate mOnHDLLinphoneCallDelegate;
     
        /// <summary>
        ///
        /// </summary>
        public class OnHDLLinphoneCallDelegate : HDLLinphoneCallDelegate
        {
            [Weak] HDLLinphone hdlLinphone;
        ///// <summary>
        /////
        ///// </summary>
        //public class OnHDLLinphoneCallDelegate : HDLLinphoneCallDelegate
        //{
        //    [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);
            //}
        //    /// <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 OnUnlockAction()
        //    {
        //        hdlLinphone.HDLUnlockAction();
        //    }
            /// <summary>
            /// 来电中...
            /// </summary>
            public override void OnIncomingCall(string userName)
            {
                Utlis.WriteLine("OnIncomingCall :" + userName);
            }
        //    /// <summary>
        //    /// 来电中...
        //    /// </summary>
        //    public override void OnIncomingCall(string userName)
        //    {
        //        Utlis.WriteLine("OnIncomingCall :" + userName);
        //    }
            
        }
        //}
#endregion
#endif