JLChen
2021-08-20 d82c74ca2e845211c95b314134bf7d0ea80e45f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
using System;
using System.Collections.Generic;
using System.Threading;
 
using HDL_ON;
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
 
#if __Android__
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.Widget;
using Com.Hdl.Hdllinphonesdk;
#else
using Foundation;
using UIKit;
using Shared.IOS.HDLLinphoneSDK;
#endif
 
namespace Shared
{
    /// <summary>
    /// 目前是每个住宅对应一个SIP账号,切换住宅需要重新获取SIP账号
    /// </summary>
    public class HDLLinphone
    {
        /// <summary>
        /// 
        /// </summary>
        public HDLLinphone()
        {
           
        }
        /// <summary>
        /// 
        /// </summary>
        private static HDLLinphone m_Current = null;
        /// <summary>
        /// 
        /// </summary>
        public static HDLLinphone Current
        {
            get
            {
                if (m_Current == null)
                {
                    m_Current = new HDLLinphone();
                }
                return m_Current;
            }
        }
 
     
        /// <summary>
        /// 当前住宅是否支持可视对讲
        /// </summary>
        public bool IsEnable = false;
        /// <summary>
        /// 是否自动跳转呼叫页面,
        /// false:收到推送并且已经收到sip呼叫才跳转呼叫页面
        /// true:原生收到呼叫马上跳转呼叫页面,不等待推送过来
        /// </summary>
        bool IsAutoJumpCallView = false;
        /// <summary>
        /// 是否初始化了SDK
        /// </summary>
        bool IsInitSdk;
        /// <summary>
        /// 当前登录的Sip账号
        /// </summary>
        HDLSipInfo currentHDLSipInfo;
        /// <summary>
        /// 可视对讲设备参数
        /// </summary>
        HDLCallVideoInfo mHDLCallVideoInfo;
 
        #region ■  --  初始化SDK_______________________________
        /// <summary>
        /// 初始化SDK
        /// </summary>
        void InitLinphone()
        {
            //防止重复初始化
            if (IsInitSdk) return;
 
            IsInitSdk = true;
 
#if __IOS__
 
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().InitalLinPhone();
            //设置收到来电后、是否需自动跳转呼叫页面方案
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().IsAutoJumpCallView = IsAutoJumpCallView;
            //设置Listener监听
            mOnHDLLinphoneCallDelegate = new OnHDLLinphoneCallDelegate(this);
            Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().HdlLinphoneCallDelegate = mOnHDLLinphoneCallDelegate;
#else
            HDLLinphoneKit.Instance.InitLinphone(Application.Activity);
            //设置收到来电后、是否需自动跳转呼叫页面方案
            HDLLinphoneKit.Instance.AutoJumpCallView = IsAutoJumpCallView;
            //设置Listener监听
            setOnHDLLinphoneCallListener();
#endif
        }
 
       
        /// <summary>
        /// 设置sip登录账号
        /// </summary>
        /// <param name="mHDLSipInfo"></param>
        public void SetAccountAndLogin(HDLSipInfo mHDLSipInfo)
        {
 
            this.currentHDLSipInfo = mHDLSipInfo;
 
            if (mHDLSipInfo == null) return;
 
#if __IOS__
            //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
            HDLLinphoneKit.Instance.SetAccountAndLogin(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm);
#endif
 
        }
 
        /// <summary>
        /// 注销所有账号
        /// </summary>
        public void LogoutAllAccount() {
            //没初始化过则返回
            if (!IsInitSdk) return;
 
            this.currentHDLSipInfo = null;
            this.mHDLCallVideoInfo = null;
#if __IOS__
 
            HDLLinPhoneSDK.Instance().LogoutAllLinphoneUser();
#else
            HDLLinphoneKit.Instance.Logout();
#endif
        }
 
        /// <summary>
        /// 清除配置表
        /// </summary>
        public void ClearProxyConfig()
        {
#if __IOS__
 
            HDLLinPhoneSDK.Instance().ClearAllConfigs();
#else
            HDLLinphoneKit.Instance.ClearProxyConfig();
#endif
        }
 
        #endregion
 
        #region ■  --  获取sip账号_______________________________
        /// <summary>
        /// 获取当前住宅的SIP账号
        /// </summary>
        public HDLSipInfo GetHDLSipInfo(string homeId)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", homeId);
 
            var requestJson = HttpUtil.GetSignRequestJson(d);
            var resultObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_GetSipAccount, requestJson);
 
            if (resultObj.Code == StateCode.SUCCESS)
            {
                if (string.IsNullOrEmpty(resultObj.Data.ToString()))
                {
                    //控的话代表当前住宅不支持
                    return null;
                }
                else
                {
                    var info = Newtonsoft.Json.JsonConvert.DeserializeObject<HDLSipInfo>(resultObj.Data.ToString());
                    return info;
                }
            }
            else
            {
                return null;
            }
 
        }
 
        /// <summary>
        /// 请求服务器获取当前住宅Sip账号信息并初始化LinphoneSDK和登录
        /// </summary>
        /// <param name="homeId"></param>
        public void GetHDLSipInfoAndInitSDK(string homeId)
        {
            try
            {
                //先清空呼叫和监视设备信息
                InitCallInfo(null);
                HDLSipInfo mHDLSipInfo = GetHDLSipInfo(homeId);
                if (mHDLSipInfo != null)
                {
                    Application.RunOnMainThread(() =>
                    {
                        InitLinphone();
                        mHDLSipInfo.homeId = homeId;
                        SetAccountAndLogin(mHDLSipInfo);
                        Utlis.WriteLine("CALL 获取SIP账号成功:" + mHDLSipInfo.sipAccount);
                    });
                }
            }
            catch { }
 
        }
        #endregion
 
 
        #region ■  -- 动作回调和原生交互,提交记录到云端_______________________________
       
        /// <summary>
        /// 初始化呼叫参数
        /// </summary>
        /// <param name="mHDLCallVideoInfo"></param>
        /// <param name="mInterphoneType"></param>
        public void InitCallInfo(HDLCallVideoInfo mHDLCallVideoInfo)
        {
            this.mHDLCallVideoInfo = mHDLCallVideoInfo;
        }
 
        /// <summary>
        /// 判断callId是否为空
        /// </summary>
        /// <returns></returns>
        bool CheckmHDLCallVideoInfoIsNullOrEmpty()
        {
            return (mHDLCallVideoInfo == null || string.IsNullOrEmpty(mHDLCallVideoInfo.CallId));
        }
 
        /// <summary>
        /// 截图成功 暂时废弃
        /// </summary>
        public void ScreenshotSuccessfulAction(byte[] dataBytes)
        {
            //Utlis.WriteLine("ScreenshotSuccessfulAction");
 
            if (CheckmHDLCallVideoInfoIsNullOrEmpty()) return;
 
            new Thread(() =>
            {
                //var imageName = Guid.NewGuid().ToString();
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("callId", mHDLCallVideoInfo.CallId);
                dic.Add("images", dataBytes);
#if __IOS__
                dic.Add("imagesName", "_IOS.jpg");
#else
                dic.Add("imagesName", "_Android.jpg");
#endif
 
                var requestJson = HttpUtil.GetSignRequestJson(dic);
                var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_FL_Screenshot, requestJson);
                if (revertObj.Code == StateCode.SUCCESS)
                {
                    //Utlis.WriteLine("POST 截图上传成功");
                }
                else
                {
                    Utlis.WriteLine("POST 截图上传失败 code: " + revertObj.Code);
                }
 
            })
            { IsBackground = false }.Start();
 
        }
 
        //DateTime UnlockDateTime = DateTime.MinValue;
        #endregion
 
        #region ■  --  新接听和开锁接口_______________________________
        /// <summary>
        /// 开锁
        /// </summary>
        public void HDLUnlockAction()
        {
            //Utlis.WriteLine("UnlockAction");
 
            if (mHDLCallVideoInfo == null) return;
 
            new Thread(() =>
            {
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("deviceId", mHDLCallVideoInfo.DeviceId);//设备id
                dic.Add("callId", mHDLCallVideoInfo.CallId);//当前呼叫id
                dic.Add("interphoneType", mHDLCallVideoInfo.InterphoneType);//可视对讲厂家类型
                dic.Add("homeId", mHDLCallVideoInfo.HomeId);//住宅ID
                var requestJson = HttpUtil.GetSignRequestJson(dic);
                var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_OpenDoorbell, requestJson);
 
                Application.RunOnMainThread(() =>
                {
 
#if __IOS__
                    if (revertObj.Code == StateCode.SUCCESS)
                    {
                        //和原生监控界面交互、发送开锁成功通知
                        NSNotificationCenter.DefaultCenter.PostNotificationName("lcCallDelegateOpenDoorSuccess", null);
                    }
                    else
                    {
                        Utlis.WriteLine("POST 开锁失败 code: " + revertObj.Code);
                    }
#else
                    if (revertObj.Code == StateCode.SUCCESS)
                    {
                        HDLLinphoneKit.Instance.OnOpenSuccess();
                    }
                    else
                    {
                        Utlis.WriteLine("POST 开锁失败 code: " + revertObj.Code);
                        HDLLinphoneKit.Instance.OnOpenError(revertObj.message);
                    }
#endif
 
                });
 
 
            })
            { IsBackground = false }.Start();
        }
 
        /// <summary>
        /// 更改通话状态
        /// </summary>
        public void HDLUpdateCallStatus(CallStatusType callStatusType, InterphoneType interphoneType, int callDuration = 0)
        {
 
            if (CheckmHDLCallVideoInfoIsNullOrEmpty()) return;
 
            new Thread(() =>
            {
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("callId", mHDLCallVideoInfo.CallId);//呼叫id
                dic.Add("callStatus", callStatusType.ToString());//可用值:MISSED,RECEIVED,REJECT
                dic.Add("interphoneTypeEnum", interphoneType.ToString());
                if (callStatusType == CallStatusType.RECEIVED && callDuration > 0)
                {
                    dic.Add("callDuration", callDuration);//通话时长(秒)
                }
 
                var requestJson = HttpUtil.GetSignRequestJson(dic);
                var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_VideoDevice_UpdateCallStatus, requestJson);
                if (revertObj.Code == StateCode.SUCCESS)
                {
 
                }
                else
                {
                    Utlis.WriteLine("POST 更新状态失败 code: " + revertObj.Code);
                }
 
            })
            { IsBackground = false }.Start();
 
        }
        #endregion
 
     
        #region ■  --  跳转监控页面_______________________________
        /// <summary>
        /// 跳转监控页面
        /// </summary>
        /// <param name="mESVideoInfo"></param>
        public void ShowESVideoMonitor(ESVideoInfo mESVideoInfo)
        {
            InitLinphone();
            //sip账号为空
            if (string.IsNullOrEmpty(mESVideoInfo.deviceSipAccount))
            {
 
                HDLCommon.Current.ShowAlert(Language.StringByID(StringId.shebeibucunzai));
                return;
            }
            HDLCallVideoInfo mHDLCallVideoInfo = new HDLCallVideoInfo();
            mHDLCallVideoInfo.HomeId = mESVideoInfo.HomeId;
            mHDLCallVideoInfo.DeviceId = mESVideoInfo.Lc_DeviceId;
            mHDLCallVideoInfo.DeviceName = mESVideoInfo.DeviceName;
            mHDLCallVideoInfo.InterphoneType = InterphoneType.HDL.ToString();
            mHDLCallVideoInfo.DeviceSipAccount = mESVideoInfo.deviceSipAccount;//监视主动呼叫门口机时用到
            InitCallInfo(mHDLCallVideoInfo);
 
#if __IOS__
 
            HDLLinPhoneSDK.Instance().CallWithUserName(mHDLCallVideoInfo.DeviceSipAccount, mHDLCallVideoInfo.DeviceName);
 
#else
            //1.先呼叫设备
            Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.CallTo(mHDLCallVideoInfo.DeviceSipAccount, true);
            //2.跳转打开监控页面
            var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneMonitorActivity)); ;
            intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.DeviceName);//传入设备名称为显示标题
            Shared.Application.Activity.StartActivity(intent);
#endif
 
        }
        #endregion
 
 
        #region ■  --  跳转呼叫页面_______________________________
        /// <summary>
        /// 收到推送,后判断呼叫住宅是否为当前住宅,不是的话重新获取SIP账号并登录
        /// </summary>
        /// <param name="mESVideoInfo"></param>
        public void ShowESVideoIntercom(ESVideoInfo mESVideoInfo)
        {
            InitLinphone();
 
            HDLCallVideoInfo mHDLCallVideoInfo = new HDLCallVideoInfo();
            mHDLCallVideoInfo.CallId = mESVideoInfo.callId;
            mHDLCallVideoInfo.HomeId = mESVideoInfo.HomeId;
            mHDLCallVideoInfo.DeviceId = mESVideoInfo.Lc_DeviceId;
            mHDLCallVideoInfo.DeviceName = mESVideoInfo.DeviceName;
            mHDLCallVideoInfo.InterphoneType = InterphoneType.HDL.ToString();
            mHDLCallVideoInfo.DeviceSipAccount = mESVideoInfo.deviceSipAccount;
            InitCallInfo(mHDLCallVideoInfo);
 
            //当前呼叫来电的住宅和之前注册登录的住宅一致的情况下
            if (currentHDLSipInfo != null && currentHDLSipInfo.homeId == mESVideoInfo.HomeId)
            {
                Utlis.WriteLine("CALL 收到推送 推送住宅和之前注册登录的住宅一致");
                CheckCallStateAndGotoPage();
            }
            else
            {
                //注意:之前没登录SIP账号或者住宅不一致的情况下需要重新获取SIP账号
                //获取呼叫住宅的SIP账号并登录
                Utlis.WriteLine("CALL 收到推送 其他住宅,重新获取呼叫住宅的SIP账号并登录");
                new Thread(() =>
                {
                    GetHDLSipInfoAndInitSDK(mESVideoInfo.HomeId);
                })
                { IsBackground = false }.Start();
 
                //
                CheckCallStateAndGotoPage();
 
            }
 
        }
 
        /// <summary>
        /// 检测来电状态,判断是否马上打开呼叫页面,如果还没来电则开启线程检测等待
        /// </summary>
        /// <param name="mESVideoInfo"></param>
        public void CheckCallStateAndGotoPage()
        {
            //如果开启了自动跳转方案,则无需继续下面处理、无需手动跳转
            if (IsAutoJumpCallView) return;
 
            //检测是否来电了如果是直接调整呼叫页面如果不是则开启线程等待判断
            if (IsIncomingReceivedCallState()) {
                Utlis.WriteLine("CALL 已经来电了。。。打开呼叫页面");
                GoToHDLLinphoneIntercomActivity();
            }
            else
            {
                //如果还没来电 开启线程检测
                StartCheckIncomingCallThread();
            }
 
        }
 
        /// <summary>
        /// 是否来电状态
        /// </summary>
        /// <returns></returns>
        bool IsIncomingReceivedCallState() {
#if __IOS__
             return HDLLinPhoneSDK.Instance().IsIncomingReceivedCallState;
#else
            return HDLLinphoneKit.Instance.IsIncomingReceivedCallState;
#endif
        }
 
        /// <summary>
        /// 跳转打开原生的呼叫页面
        /// </summary>
        void GoToHDLLinphoneIntercomActivity() {
 
#if __IOS__
 
            HDLLinPhoneSDK.Instance().GotoHDLLinphoneIntercomVC(mHDLCallVideoInfo.DeviceName);
 
#else
            var intent = new Intent(Shared.Application.Activity, typeof(Com.Hdl.Hdllinphonesdk.Activity.HDLLinphoneIntercomActivity));
            if (mHDLCallVideoInfo != null)
            {
                intent.PutExtra(HDLLinphoneKit.KeyTitleName, mHDLCallVideoInfo.DeviceName);
            }
            Shared.Application.Activity.StartActivity(intent);
#endif
 
        }
 
 
        /// <summary>
        /// 检测来电线程
        /// </summary>
        Thread checkIncomingCallThread = null;
        /// <summary>
        /// 线程结束
        /// </summary>
        int threadTime = 15;
        /// <summary>
        /// 开启检测来电线程
        /// </summary>
        void StartCheckIncomingCallThread()
        {
            try
            {
                Utlis.WriteLine("CALL 还没来电,开启线程");
                threadTime = 15;
                //结束之前的线程
                EndCheckIncomingCallThread();
                //新建线程
                checkIncomingCallThread = new Thread(() =>
                    {
                        try
                        {
                            //15S后自动结束线程
                            while (threadTime > 0)
                            {
                                threadTime--;
                                Utlis.WriteLine("CALL 检测中...." + threadTime);
                                Thread.Sleep(1000);
                                //来电了,跳转呼叫页面
                                if (IsIncomingReceivedCallState())
                                {
                                    Utlis.WriteLine("CALL 来电了。。。打开呼叫页面");
                                    threadTime = 0;//跳出循环,关闭线程
                                    Application.RunOnMainThread(() =>
                                    {
                                        GoToHDLLinphoneIntercomActivity();
                                    });
                                }
                            }
                          
                          
                        }
                        catch { }
                    });
                //开启线程
                checkIncomingCallThread.Start();
            }
            catch { }
        }
 
        /// <summary>
        /// 结束线程
        /// </summary>
        void EndCheckIncomingCallThread()
        {
            if (checkIncomingCallThread != null)
            {
                try
                {
                    checkIncomingCallThread.Interrupt();
                }
                catch { }
                checkIncomingCallThread = null;
            }
        }
 
        #endregion
 
 
        #region ■  --  Android相关操作_______________________________
 
#if __Android__
 
        /// <summary>
        /// 接听、挂断、开锁等动作监听处理
        /// </summary>
        private class HDLLinphoneCallListener : Java.Lang.Object, Com.Hdl.Hdllinphonesdk.Callback.IOnHDLLinphoneCallListener
        {
            [Weak] HDLLinphone hdlLinphone;
 
            public HDLLinphoneCallListener(HDLLinphone mHDLLinphone)
            {
                hdlLinphone = mHDLLinphone;
            }
 
 
            //showToast
            void showToast(string text)
            {
                Toast.MakeText(Application.Activity, text, ToastLength.Short).Show();
            }
            /// <summary>
            /// 接听事件
            /// </summary>
            public void OnAnswerAction()
            {
                //showToast("接听");
                hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL);
            }
            /// <summary>
            /// 挂断事件
            /// </summary>
            /// <param name="callDuration"></param>
            public void OnHangUpAction(int callDuration)
            {
 
                //showToast("挂断 通话时长:" + callDuration);
                hdlLinphone.HDLUpdateCallStatus(CallStatusType.RECEIVED, InterphoneType.HDL, callDuration);
            }
 
            /// <summary>
            /// 拒接事件
            /// </summary>
            public void OnRejectCallAction()
            {
                //showToast("拒接");
                hdlLinphone.HDLUpdateCallStatus(CallStatusType.REJECT, InterphoneType.HDL);
            }
 
            /// <summary>
            /// 截图成功事件
            /// </summary>
            /// <param name="p0"></param>
            public void OnScreenshotSuccessfulAction(Bitmap imgBitmap)
            {
                //showToast("截图成功");
            }
 
            /// <summary>
            /// 开锁事件
            /// </summary>
            public void OnUnlockAction()
            {
                hdlLinphone.HDLUnlockAction();
            }
 
            /// <summary>
            /// 来电事件
            /// </summary>
            /// <param name="userName"></param>
            public void OnIncomingCall(string userName)
            {
                Utlis.WriteLine("OnIncomingCall :" + userName);
            }
        }
 
        /// <summary>
        /// 设置原生的Listener监听
        /// </summary>
        void setOnHDLLinphoneCallListener()
        {
            HDLLinphoneKit.Instance.OnHDLLinphoneCallListener = new HDLLinphoneCallListener(this);
        }
 
        /// <summary>
        /// 清楚通知栏所有通知
        /// </summary>
        void CancelAllNotification()
        {
            NotificationManager nMgr = (NotificationManager)Application.Activity.GetSystemService(Context.NotificationService);
            nMgr.CancelAll();
        }
 
#endif
        #endregion
 
        #region ■  --  iOS相关操作_______________________________
 
#if __IOS__
 
        #region OnHDLLinphoneCallDelegate
        /// <summary>
        /// 
        /// </summary>
        OnHDLLinphoneCallDelegate mOnHDLLinphoneCallDelegate;
     
        /// <summary>
        /// 
        /// </summary>
        public class OnHDLLinphoneCallDelegate : HDLLinphoneCallDelegate
        { 
            [Weak] HDLLinphone hdlLinphone;
 
            public OnHDLLinphoneCallDelegate(HDLLinphone mHDLLinphone)
            {
                this.hdlLinphone = mHDLLinphone;
            }
 
            /// <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>
            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>
            public override void OnUnlockAction()
            {
                hdlLinphone.HDLUnlockAction();
            }
 
            /// <summary>
            /// 来电中...
            /// </summary>
            public override void OnIncomingCall(string userName)
            {
                Utlis.WriteLine("OnIncomingCall :" + userName);
            }
            
 
 
        }
 
        #endregion
#endif
 
        #endregion
 
    }
 
    /// <summary>
    /// SIP可视对讲参数
    /// </summary>
    public class HDLCallVideoInfo
    {
        /// <summary>
        /// 设备序列号,通讯必要字段
        /// </summary>
        public string DeviceId = string.Empty;
        /// <summary>
        /// 设备名称
        /// </summary>
        public string DeviceName = string.Empty;
        /// <summary>
        /// 设备Sip账号
        /// </summary>
        public string DeviceSipAccount = string.Empty;
        /// <summary>
        /// 呼叫记录Id
        /// </summary>
        public string CallId = string.Empty;
        /// <summary>
        /// 住宅Id
        /// </summary>
        public string HomeId = string.Empty;
        /// <summary>
        /// 账号
        /// </summary>
        public string Username = string.Empty;
        /// <summary>
        /// 密码
        /// </summary>
        public string Password = string.Empty;
        /// <summary>
        /// Domain
        /// </summary>
        public string Domain = string.Empty;
        /// <summary>
        /// 类型
        /// </summary>
        public string InterphoneType;
 
    }
 
    /// <summary>
    /// SIP账号相关信息
    /// </summary>
    public class HDLSipInfo
    {
        /// <summary>
        /// Sip服务器
        /// </summary>
        public string proxy { get; set; }
        /// <summary>
        /// 设备域
        /// </summary>
        public string realm { get; set; }
        /// <summary>
        /// sip账号
        /// </summary>
        public string sipAccount { get; set; }
        /// <summary>
        /// sipPasswd    sip密码
        /// </summary>
        public string sipPasswd { get; set; }
        /// <summary>
        /// 住宅ID
        /// </summary>
        public string homeId;
    }
 
 
}