From fac61655d3d255468491d0829c8814c0cf0a62dd Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期四, 02 七月 2020 13:50:41 +0800
Subject: [PATCH] 2020-07-02 1.更新最新SDK。 2.参试封装工具类,只初始化一次SDK方案,暂时解决SDK无法释放问题。

---
 xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m |   57 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m b/xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m
index 63df999..bf1c7be 100644
--- a/xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m
+++ b/xamarin/ESVideoPhoneSDKXamarin/ESVideoPhoneSDKXamarin/ESvideoVideoIntercomViewController.m
@@ -14,7 +14,7 @@
 #import "AudioSessionHelper.h"
 #import <Photos/Photos.h>
 #import <AudioToolbox/AudioToolbox.h>
-
+#import "ESVideo.h"
 
 
 
@@ -80,6 +80,8 @@
     NSString * refuseStr;
     NSString * answerStr;
     NSString * unlockSuccessfullyStr;
+    NSString * callingStr;
+    NSString * hangUpStr;
     //    int openDoorTimeout;
     //鍏ㄥ眬鍙橀噺
     SystemSoundID sound;
@@ -92,11 +94,11 @@
     [self initTopBarView];
     [self initCentetView];
     [self initData];
-//    [self setAnswerBtnEnable:NO];
+    //    [self setAnswerBtnEnable:NO];
     [self initESVideo];
     //寮�濮嬪弽鍛�
     [self StartReverseCall];
-    [self ShowCalltimeBtn:@"瀹ゅ鏈烘潵鐢典腑..."];
+    [self ShowCalltimeBtn:callingStr];
     // Do any additional setup after loading the view.
 }
 
@@ -112,7 +114,9 @@
         operationFailedStr = @"鎿嶄綔澶辫触";
         refuseStr = @"鎷掔粷";
         answerStr = @"鎺ュ惉";
+        hangUpStr = @"鎸傛柇";
         unlockSuccessfullyStr = @"寮�閿佹垚鍔�";
+        callingStr = @"鏉ョ數涓�...";
     }else{
         tipStr = @"Prompt";
         okStr = @"OK";
@@ -120,7 +124,10 @@
         operationFailedStr = @"Operation failed.";
         refuseStr = @"Refuse";
         answerStr = @"Answer";
+        hangUpStr = @"Hang up";
         unlockSuccessfullyStr = @"Unlock successfully";
+        callingStr = @"Incoming call";
+        
     }
 }
 
@@ -152,8 +159,8 @@
 
 -(void)backAction{
     [self.navigationController popViewControllerAnimated:true];
-//    [self dismissViewControllerAnimated:YES completion:NULL];
- 
+    //    [self dismissViewControllerAnimated:YES completion:NULL];
+    
 }
 
 - (UIButton *)moreButton{
@@ -174,7 +181,7 @@
 
 - (void)initCentetView {
     [self.view addSubview:self.centerView];
-    [self.centerView addSubview:self.collectButton];
+    //    [self.centerView addSubview:self.collectButton];
     [self.centerView addSubview:self.homeView];
     [self.centerView addSubview:self.unlockView];
     [self.unlockView addSubview:self.screenshotImgBtn];
@@ -384,7 +391,7 @@
     //鎸傛柇鎸夐挳绉诲姩涓棿
     _hangUpImgBtn.frame = CGRectMake(159, 448, 58, 58);
     _hangUpTextBtn.frame = CGRectMake(138, 514, 100, 21);
-    
+    [_hangUpTextBtn setTitle:hangUpStr forState:UIControlStateNormal];
     //寮�濮嬭鏃�
     _callTimeout = 0;
     [self startCountdown];
@@ -437,9 +444,9 @@
 
 -(void)ShowCalltimeBtn:(NSString*) mesStr  {
     if(_calltimeBtn.hidden) _calltimeBtn.hidden = NO;
-
+    
     [self setCalltimeButtonText:mesStr isTime:NO];
-
+    
     
 }
 
@@ -450,9 +457,9 @@
 {
     [_calltimeBtn setTitle:mesStr forState:UIControlStateNormal];
     if(isTime){
-        _calltimeBtn.frame = CGRectMake(0, 0, 100, 30);
+        _calltimeBtn.frame = CGRectMake(0, 0, 80, 30);
     }else{
-        _calltimeBtn.frame = CGRectMake(0, 0, 150, 30);
+        _calltimeBtn.frame = CGRectMake(0, 0, 115, 30);
     }
     _calltimeBtn.center = CGPointMake(APP_SCREEN_WIDTH/2, 397);
 }
@@ -575,7 +582,10 @@
 
 #pragma SDK鍙瀵硅 鍔熻兘閮ㄥ垎
 -(void)initESVideo{
+    _es = ESVideo.shareInstance.es;
     //鍒濆鍖栦腑鏂紝杩涘叆鍚庡彴鐨則ag
+    
+    
     _playing = NO;
     _isSpeaking = NO;
     self.isInterrupt = NO;
@@ -593,13 +603,15 @@
             });
         };
         //闂ㄥ彛鏈轰細鏈夎棰戠殑闀垮楂橈紝鏄浐瀹氱殑锛堟殏鏃惰繕涓嶇‘瀹氾級
-        _es = [[ESVideoPhone alloc]initESVideoPhoneWithFrame:CGRectMake(0, 57, APP_SCREEN_WIDTH, 211) delegate:self imagecallBack:snapImageCallback];
+//        _es = [[ESVideoPhone alloc]initESVideoPhoneWithFrame:CGRectMake(0, 57, APP_SCREEN_WIDTH, 211) delegate:self imagecallBack:snapImageCallback];
         if (_es) {
             //鍒ゆ柇瑙嗛娓叉煋鏄惁鍒濆鍖栨垚鍔燂紝濡傛灉澶辫触浼氳蛋ESVideoPhoneDelegate鏂规硶
             if (_es.showView) {
+                ESVideo.shareInstance.snapImageCallback = snapImageCallback;
                 _es.delegate = self;
                 _es.showView.backgroundColor = [UIColor whiteColor];
                 [self.centerView addSubview:_es.showView];
+                _es.showView.hidden = YES;
             }
         }else{
             NSLog(@"ESVideoPhone 鍒濆鍖栧け璐�");
@@ -680,9 +692,19 @@
     [alertController addAction:[UIAlertAction actionWithTitle:okStr style:UIAlertActionStyleCancel handler:nil]];
     [self presentViewController:alertController animated:YES completion:nil];
     
-//    UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:tipStr message:mes delegate:self cancelButtonTitle:okStr otherButtonTitles:nil, nil];
-//    [alertView1 show];
+    //    UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:tipStr message:mes delegate:self cancelButtonTitle:okStr otherButtonTitles:nil, nil];
+    //    [alertView1 show];
     
+}
+
+-(void)showUIAlertViewWithBack:(NSString *)mes
+{
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:tipStr message:mes preferredStyle:UIAlertControllerStyleAlert];
+    [alertController addAction:[UIAlertAction actionWithTitle:okStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        [self backAction];
+    }]];
+    
+    [self presentViewController:alertController animated:YES completion:nil];
 }
 
 
@@ -711,11 +733,11 @@
         [_es stopTalk];
         
         _es.delegate = nil;
-        
+        ESVideo.shareInstance.snapImageCallback = nil;
         
         
     }
-    [_es freeSubClass];
+//    [_es freeSubClass];
 }
 -(void)dealloc{
     [[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -744,6 +766,7 @@
     NSString *phoneEventStr = eventArray.lastObject;
     
     if([phoneEventStr isEqual:@"EVT_Ringing"]){
+        _es.showView.hidden = NO;
         //鍙嶅懠鎴愬姛 鍏佽鎺ュ惉  鐪嬮渶姹傛槸鍚﹂渶瑕佹挱鏀鹃搩澹板拰闇囧姩
         [self setAnswerBtnEnable:YES];
         
@@ -753,8 +776,10 @@
     } else if([phoneEventStr isEqual:@"EVT_StopStream"]){
         //           [_mCallOrAccept setTitle:@"鍙嶅懠" forState:UIControlStateNormal];
     }else if([phoneEventStr isEqual:@"EVT_Connected"]){
+        
         //           [_mCallOrAccept setTitle:@"閫氳瘽涓�..." forState:UIControlStateNormal];
     }else if([phoneEventStr  isEqual:@"EVT_HangUp"]){
+         [self showUIAlertViewWithBack:@"宸叉寕鏂�"];
         //           [_mCallOrAccept setTitle:@"鍙嶅懠" forState:UIControlStateNormal];
     }else if([phoneEventStr  isEqual:@"EVT_P2POnlineStatusChanged"]){
         //EVT_P2PStarted(p2p鍒濆鍖朞K锛屽彲浠ヨ繛鎺�),EVT_P2POnlineStatusChangedonline=1

--
Gitblit v1.8.0