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无法释放问题。

---
 ESVideoPhoneSDKZigbee/ESVideoPhoneSDKDemo/ZigBee/ESvideoVideoIntercomViewController.m |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/ESVideoPhoneSDKZigbee/ESVideoPhoneSDKDemo/ZigBee/ESvideoVideoIntercomViewController.m b/ESVideoPhoneSDKZigbee/ESVideoPhoneSDKDemo/ZigBee/ESvideoVideoIntercomViewController.m
index 7bdb545..bf1c7be 100644
--- a/ESVideoPhoneSDKZigbee/ESVideoPhoneSDKDemo/ZigBee/ESvideoVideoIntercomViewController.m
+++ b/ESVideoPhoneSDKZigbee/ESVideoPhoneSDKDemo/ZigBee/ESvideoVideoIntercomViewController.m
@@ -14,7 +14,7 @@
 #import "AudioSessionHelper.h"
 #import <Photos/Photos.h>
 #import <AudioToolbox/AudioToolbox.h>
-
+#import "ESVideo.h"
 
 
 
@@ -81,6 +81,7 @@
     NSString * answerStr;
     NSString * unlockSuccessfullyStr;
     NSString * callingStr;
+    NSString * hangUpStr;
     //    int openDoorTimeout;
     //鍏ㄥ眬鍙橀噺
     SystemSoundID sound;
@@ -113,6 +114,7 @@
         operationFailedStr = @"鎿嶄綔澶辫触";
         refuseStr = @"鎷掔粷";
         answerStr = @"鎺ュ惉";
+        hangUpStr = @"鎸傛柇";
         unlockSuccessfullyStr = @"寮�閿佹垚鍔�";
         callingStr = @"鏉ョ數涓�...";
     }else{
@@ -122,6 +124,7 @@
         operationFailedStr = @"Operation failed.";
         refuseStr = @"Refuse";
         answerStr = @"Answer";
+        hangUpStr = @"Hang up";
         unlockSuccessfullyStr = @"Unlock successfully";
         callingStr = @"Incoming call";
         
@@ -388,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];
@@ -579,7 +582,10 @@
 
 #pragma SDK鍙瀵硅 鍔熻兘閮ㄥ垎
 -(void)initESVideo{
+    _es = ESVideo.shareInstance.es;
     //鍒濆鍖栦腑鏂紝杩涘叆鍚庡彴鐨則ag
+    
+    
     _playing = NO;
     _isSpeaking = NO;
     self.isInterrupt = NO;
@@ -597,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 鍒濆鍖栧け璐�");
@@ -689,6 +697,16 @@
     
 }
 
+-(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];
+}
+
 
 #pragma viewDidAppear
 -(void)viewDidAppear:(BOOL)animated{
@@ -715,11 +733,11 @@
         [_es stopTalk];
         
         _es.delegate = nil;
-        
+        ESVideo.shareInstance.snapImageCallback = nil;
         
         
     }
-    [_es freeSubClass];
+//    [_es freeSubClass];
 }
 -(void)dealloc{
     [[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -748,6 +766,7 @@
     NSString *phoneEventStr = eventArray.lastObject;
     
     if([phoneEventStr isEqual:@"EVT_Ringing"]){
+        _es.showView.hidden = NO;
         //鍙嶅懠鎴愬姛 鍏佽鎺ュ惉  鐪嬮渶姹傛槸鍚﹂渶瑕佹挱鏀鹃搩澹板拰闇囧姩
         [self setAnswerBtnEnable:YES];
         
@@ -757,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