wei
2021-08-27 eda3fb873e59544ff36301b51e05aef64f87b0f9
HDL_ON/DAL/ThirdPartySdk/ESOnVideo.cs
@@ -4,6 +4,7 @@
using System.Threading;
using System.Collections.Generic;
using HDL_ON.UI.UI2.PersonalCenter.PirDevice;
using HDL_ON.Entity;
#if __IOS__
using Shared.IOS.ESVideoOnSDK;
@@ -66,10 +67,11 @@
            int.TryParse(mESVideoInfo.roomno, out roomID);
#if __IOS__
            if (interphoneType == "IMOUVISIAL")
            if (interphoneType == InterphoneType.IMOUVISIAL.ToString())
            {
                //乐橙可视对讲
                //1.初始化LCOpenSDK_Api
                LCApiKit.SharedInstance().IsChinaMainland = OnAppConfig.Instance.RequestHttpsHost.Contains("china");//如果域名包含china,则SDK 使用乐橙的中国大陆(正式)域名
                LCApiKit.SharedInstance().InitSDKOpenApi(mESVideoInfo.Lc_AccessToken);
                LCApiKit.SharedInstance().CurrentDevicePlayToken = mESVideoInfo.Lc_PlayToken;
                LCApiKit.SharedInstance().CurrentDeviceId = mESVideoInfo.Lc_DeviceId;
@@ -82,7 +84,7 @@
                //vc.MLCCallDelegate = new OnLCCallDelegate(this);
                Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
            }
            else
            else if(interphoneType == InterphoneType.FLVI.ToString())
            {
                ESOnMonitorViewController vc = new ESOnMonitorViewController();
@@ -92,36 +94,73 @@
                //vc.RoomName = mESVideoInfo.RoomName;
                //vc.MESCallDelegate = new OnESCallDelegate(this);
                Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
            }
#else
            Intent intent = null;
            if (interphoneType == "IMOUVISIAL")
            }else if (interphoneType == InterphoneType.HDL.ToString())
            {
                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.LeChengVideoActivity));
                //HDLLinphone 狄耐克
                HDLLinphone.Current.ShowESVideoMonitor(mESVideoInfo);
            }
            else
            {
                HDLUtils.WriteLine("未对接,不支持监视");
            }
#else
            Intent intent = null;
            if (interphoneType == InterphoneType.IMOUVISIAL.ToString())
            {
                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.LeChengVideoActivity));
                intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);
                intent.PutExtra("uuid", mESVideoInfo.uuid);
                intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);
                intent.PutExtra("cmtID", mESVideoInfo.cmtID);
                intent.PutExtra("roomno", mESVideoInfo.roomno);
                intent.PutExtra("unitno", mESVideoInfo.unitno);
                intent.PutExtra("HomeID", PirSend.HomeId);
                intent.PutExtra("callId", mESVideoInfo.callId);
                intent.PutExtra("Type", 0);
                //=========乐橙==========
                intent.PutExtra("AccessToken", mESVideoInfo.Lc_AccessToken);
                intent.PutExtra("DeviceId", mESVideoInfo.Lc_DeviceId);
                intent.PutExtra("Location", OnAppConfig.Instance.RequestHttpsHost.Contains("china") ? 0 : 1);//如果域名包含china,则是国内账号);
                intent.PutExtra("PlayToken", mESVideoInfo.Lc_PlayToken);
                intent.PutExtra("Psk", mESVideoInfo.Lc_Psk);
                Shared.Application.Activity.StartActivity(intent);
            }
            else if (interphoneType == InterphoneType.FLVI.ToString())
            {
                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity));
                intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);
                intent.PutExtra("uuid", mESVideoInfo.uuid);
                intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);
                intent.PutExtra("cmtID", mESVideoInfo.cmtID);
                intent.PutExtra("roomno", mESVideoInfo.roomno);
                intent.PutExtra("unitno", mESVideoInfo.unitno);
                intent.PutExtra("HomeID", PirSend.HomeId);
                intent.PutExtra("callId", mESVideoInfo.callId);
                intent.PutExtra("Type", 0);
                //=========乐橙==========
                intent.PutExtra("AccessToken", mESVideoInfo.Lc_AccessToken);
                intent.PutExtra("DeviceId", mESVideoInfo.Lc_DeviceId);
                intent.PutExtra("Location", OnAppConfig.Instance.RequestHttpsHost.Contains("china") ? 0 : 1);//如果域名包含china,则是国内账号);
                intent.PutExtra("PlayToken", mESVideoInfo.Lc_PlayToken);
                intent.PutExtra("Psk", mESVideoInfo.Lc_Psk);
                Shared.Application.Activity.StartActivity(intent);
            }
            else if (interphoneType == InterphoneType.HDL.ToString())
            {
                //HDLLinphone 狄耐克
                HDLLinphone.Current.ShowESVideoMonitor(mESVideoInfo);
            }
            else
            {
                HDLUtils.WriteLine("未对接,不支持监视");
            }
            intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);
            intent.PutExtra("uuid", mESVideoInfo.uuid);
            intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);
            intent.PutExtra("cmtID", mESVideoInfo.cmtID);
            intent.PutExtra("roomno", mESVideoInfo.roomno);
            intent.PutExtra("unitno", mESVideoInfo.unitno);
            intent.PutExtra("HomeID", PirSend.HomeId);
            intent.PutExtra("callId", mESVideoInfo.callId);
            intent.PutExtra("Type", 0);
            //=========乐橙==========
            intent.PutExtra("AccessToken", mESVideoInfo.Lc_AccessToken);
            intent.PutExtra("DeviceId", mESVideoInfo.Lc_DeviceId);
            intent.PutExtra("Location", OnAppConfig.Instance.RequestHttpsHost.Contains("China") ? 0 : 1);//如果域名包含china,则是国内账号);
            intent.PutExtra("PlayToken", mESVideoInfo.Lc_PlayToken);
            intent.PutExtra("Psk", mESVideoInfo.Lc_Psk);
            Shared.Application.Activity.StartActivity(intent);
#endif
        }
@@ -136,10 +175,11 @@
            int roomID = 0;
            int.TryParse(mESVideoInfo.roomno, out roomID);
#if __IOS__
            if (interphoneType == "IMOUVISIAL")
            if (interphoneType == InterphoneType.IMOUVISIAL.ToString())
            {
                //乐橙可视对讲
                //1.初始化LCOpenSDK_Api
                LCApiKit.SharedInstance().IsChinaMainland = OnAppConfig.Instance.RequestHttpsHost.Contains("china");//如果域名包含china,则SDK 使用乐橙的中国大陆(正式)域名
                LCApiKit.SharedInstance().InitSDKOpenApi(mESVideoInfo.Lc_AccessToken);
                //2021-05-18 目前推送的PlayToken;有问题会导致SDK崩溃,暂时不传
                //LCApiKit.SharedInstance().CurrentDevicePlayToken = mESVideoInfo.Lc_PlayToken;
@@ -153,7 +193,28 @@
                //vc.MLCCallDelegate = new OnLCCallDelegate(this);
                Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
            }
            else
            else if (interphoneType == InterphoneType.EZVIZ.ToString())
            {
                //萤石猫眼呼叫
                //初始化萤石云SDK,中文国内key、英文海外key 开发者账号使用应用包名申请的APPKEY,不同包名应用需配置不同的APPKEY
                EZSDK.IOS.EZSDK.SharedInstance().InitLibWithAppKey("1aa98a90489b4838b966b57018b4b04b", "1aa98a90489b4838b966b57018b4b04b");
                //1.设置所需河东的AccessToken和RefreshToken、域名地址
                EZSDK.IOS.EZSDK.SharedInstance().SetHDlAccessToken(UserInfo.Current.LoginTokenString, UserInfo.Current.RefreshToken);
                EZSDK.IOS.EZSDK.SharedInstance().SetRequestHttpsHostAndPlatform(OnAppConfig.Instance.RequestHttpsHost, 1, mESVideoInfo.HomeId);
                //2.设置萤石子账号的AccessToken到SDK
                EZSDK.IOS.EZSDK.SharedInstance().SetEZAccessToken(mESVideoInfo.Lc_AccessToken);
                //3.打开视频播放页面
                EZSDK.IOS.EZSDK.SharedInstance().PlayWithDeviceSerial(mESVideoInfo.DeviceSerial);
            }
            else if (interphoneType == InterphoneType.HDL.ToString())
            {
                //HDL Linphone 狄耐克
            }
            else if (interphoneType == InterphoneType.FLVI.ToString())
            {
                ESOnIntercomViewController vc = new ESOnIntercomViewController();
@@ -165,38 +226,100 @@
                mOnESCallDelegate = new OnESCallDelegate(this);
                vc.MESCallDelegate = mOnESCallDelegate;
                Shared.Application.currentVC.NavigationController.PushViewController(vc, true);
            }else{
                HDLUtils.WriteLine("未支持的可视对讲类型");
            }
#else
            #region
            #region Android 处理
            Intent intent = null;
            if (interphoneType == "IMOUVISIAL")
            if (interphoneType == InterphoneType.IMOUVISIAL.ToString())
            {
                //待删减不必要参数
                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.LeChengVideoActivity));
                intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);
                intent.PutExtra("uuid", mESVideoInfo.uuid);
                intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);
                intent.PutExtra("cmtID", mESVideoInfo.cmtID);
                intent.PutExtra("roomno", mESVideoInfo.roomno);
                intent.PutExtra("unitno", mESVideoInfo.unitno);
                intent.PutExtra("HomeID", PirSend.HomeId);
                intent.PutExtra("callId", mESVideoInfo.callId);
                intent.PutExtra("Type", 1);
                //=========乐橙==========
                intent.PutExtra("AccessToken", mESVideoInfo.Lc_AccessToken);
                intent.PutExtra("DeviceId", mESVideoInfo.Lc_DeviceId);
                intent.PutExtra("Location", OnAppConfig.Instance.RequestHttpsHost.Contains("china") ? 0 : 1);//如果域名包含china,则是国内账号);
                intent.PutExtra("PlayToken", mESVideoInfo.Lc_PlayToken);
                intent.PutExtra("Psk", mESVideoInfo.Lc_Psk);
                Shared.Application.Activity.StartActivity(intent);
            }
            else if (interphoneType == InterphoneType.EZVIZ.ToString())
            {
                ((BaseActivity)Shared.Application.Activity).SetCamera(b =>
                {
                    if (b)
                    {
                        intent = new Android.Content.Intent();
                        var bundle = new Android.OS.Bundle();
                        //传递name参数为tinyphp
                        bundle.PutString("EzChildAccessToken", mESVideoInfo.Lc_AccessToken);
                        bundle.PutString("HdlToken", UserInfo.Current.LoginTokenString);
                        bundle.PutString("Url", OnAppConfig.Instance.RequestHttpsHost);
                        bundle.PutString("EzvizAppKey", "1aa98a90489b4838b966b57018b4b04b");
                        bundle.PutInt("Platform", 1);
                        bundle.PutString("HomeId", mESVideoInfo.HomeId);
                        bundle.PutString("DeviceSerial", mESVideoInfo.DeviceSerial);
                        intent.PutExtras(bundle);
                        intent.SetComponent(new Android.Content.ComponentName(Shared.Application.Activity, "com.videogo.MainActivity"));
                        Shared.Application.Activity.StartActivity(intent);
                    }
                });
                return;
            }
            else if (interphoneType == InterphoneType.HDL.ToString())
            {
                //HDL Linphone 狄耐克
            }
            else if (interphoneType == InterphoneType.FLVI.ToString())
            {
                //待删减不必要参数
                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity));
                intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);
                intent.PutExtra("uuid", mESVideoInfo.uuid);
                intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);
                intent.PutExtra("cmtID", mESVideoInfo.cmtID);
                intent.PutExtra("roomno", mESVideoInfo.roomno);
                intent.PutExtra("unitno", mESVideoInfo.unitno);
                intent.PutExtra("HomeID", PirSend.HomeId);
                intent.PutExtra("callId", mESVideoInfo.callId);
                intent.PutExtra("Type", 1);
                //=========乐橙==========
                intent.PutExtra("AccessToken", mESVideoInfo.Lc_AccessToken);
                intent.PutExtra("DeviceId", mESVideoInfo.Lc_DeviceId);
                intent.PutExtra("Location", OnAppConfig.Instance.RequestHttpsHost.Contains("china") ? 0 : 1);//如果域名包含china,则是国内账号);
                intent.PutExtra("PlayToken", mESVideoInfo.Lc_PlayToken);
                intent.PutExtra("Psk", mESVideoInfo.Lc_Psk);
                Shared.Application.Activity.StartActivity(intent);
            }
            else
            {
                intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity));
                HDLUtils.WriteLine("未支持的可视对讲类型");
            }
            intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID);
            intent.PutExtra("uuid", mESVideoInfo.uuid);
            intent.PutExtra("DeviceName", mESVideoInfo.DeviceName);
            intent.PutExtra("cmtID", mESVideoInfo.cmtID);
            intent.PutExtra("roomno", mESVideoInfo.roomno);
            intent.PutExtra("unitno", mESVideoInfo.unitno);
            intent.PutExtra("HomeID", PirSend.HomeId);
            intent.PutExtra("callId", mESVideoInfo.callId);
            intent.PutExtra("Type", 1);
            //=========乐橙==========
            intent.PutExtra("AccessToken", mESVideoInfo.Lc_AccessToken);
            intent.PutExtra("DeviceId", mESVideoInfo.Lc_DeviceId);
            intent.PutExtra("Location", OnAppConfig.Instance.RequestHttpsHost.Contains("China") ? 0 : 1);//如果域名包含china,则是国内账号);
            intent.PutExtra("PlayToken", mESVideoInfo.Lc_PlayToken);
            intent.PutExtra("Psk", mESVideoInfo.Lc_Psk);
            Shared.Application.Activity.StartActivity(intent);
            #endregion
#endif
@@ -598,31 +721,33 @@
        }
        #endregion
#endif
        /// <summary>
        /// 测试方法
        /// </summary>
        /// <param name="isMonitor"></param>
        public void Test(bool isMonitor = true)
        {
            ESVideoInfo eSVideoInfo = new ESVideoInfo()
            {
                DeviceName = "室外机88",
                ESVideoUUID = "JJY000019VPLLF",
        ///// <summary>
        ///// 测试方法
        ///// </summary>
        ///// <param name="isMonitor"></param>
        //public void Test(bool isMonitor = true)
        //{
        //    ESVideoInfo eSVideoInfo = new ESVideoInfo()
        //    {
        //        DeviceName = "室外机88",
        //        ESVideoUUID = "JJY000019VPLLF",
            };
            if (isMonitor)
            {
                ShowESVideoMonitor(eSVideoInfo, "");
            }
            else
            {
                eSVideoInfo.callId = "88888";
                ShowESvideoVideoIntercom(eSVideoInfo, "");
            }
        //    };
        //    if (isMonitor)
        //    {
        //        ShowESVideoMonitor(eSVideoInfo, "");
        //    }
        //    else
        //    {
        //        eSVideoInfo.callId = "88888";
        //        ShowESvideoVideoIntercom(eSVideoInfo, "");
        //    }
        }
        //}
    }
    /// <summary>
@@ -667,9 +792,9 @@
        //========================大华==========================
        /// <summary>
        /// 账号accessToken
        /// 萤石子账号Token也共用这个字段
        /// </summary>
        public string Lc_AccessToken = string.Empty;
@@ -693,6 +818,20 @@
        /// </summary>
        public int Lc_Location = 0;
        //========================萤石云猫眼==========================
        /// <summary>
        /// 住宅Id
        /// </summary>
        public string HomeId = string.Empty;
        /// <summary>
        /// 设备序列号
        /// </summary>
        public string DeviceSerial = string.Empty;
        //========================HDL SIP==========================
        /// <summary>
        /// 设备sip账号 interphoneType是HDL时才会有值
        /// </summary>
        public string deviceSipAccount;
    }
@@ -728,5 +867,15 @@
        /// 大华可视对讲平台
        /// </summary>
        IMOUVISIAL,
        /// <summary>
        /// 萤石猫眼呼叫
        /// </summary>
        EZVIZ,
        /// <summary>
        /// 狄耐克 HDL Linphone
        /// </summary>
        HDL,
    }
}