From 1443556e9ccb1a19ed8e6710c16c8adc4d4f4fb3 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 04 十一月 2021 14:19:55 +0800 Subject: [PATCH] 2021-11-04 1.更新SDK --- iOS/Xamarin/LCSDKOnXamarin/LCSDKOnXamarin/LCOnIntercomViewController.m | 182 +++++++++++++++++++++++---------------------- 1 files changed, 92 insertions(+), 90 deletions(-) diff --git a/iOS/Xamarin/LCSDKOnXamarin/LCSDKOnXamarin/LCOnIntercomViewController.m b/iOS/Xamarin/LCSDKOnXamarin/LCSDKOnXamarin/LCOnIntercomViewController.m index 6ef9962..efa1afe 100644 --- a/iOS/Xamarin/LCSDKOnXamarin/LCSDKOnXamarin/LCOnIntercomViewController.m +++ b/iOS/Xamarin/LCSDKOnXamarin/LCSDKOnXamarin/LCOnIntercomViewController.m @@ -9,7 +9,9 @@ #import <AVFoundation/AVFoundation.h> #import <Photos/Photos.h> #import <AudioToolbox/AudioToolbox.h> -#import "LCKit.h" +#import "LCUtlis.h" +#import "LCApiKit.h" +#import <LCOpenSDKDynamic/LCOpenSDKDynamic.h> @interface LCOnIntercomViewController ()<LCOpenSDK_EventListener, LCOpenSDK_TalkerListener> @@ -51,11 +53,8 @@ @implementation LCOnIntercomViewController{ - BOOL isAccessAudio; - BOOL isAccessVideo; + BOOL isBackGround; - BOOL iSVideoNotDetermined; - BOOL iSAudioNotDetermined; BOOL isAnswer;//鏄惁宸茬粡鐐瑰嚮鎺ュ惉杩囦簡 NSString * tipStr; @@ -90,8 +89,10 @@ //寮�濮嬪弽鍛� [self StartReverseCall]; [self ShowCalltimeBtn:callingStr]; - //鏆傛椂涓嶆敮鎸佸紑閿佸姛鑳� - [self setUnlock:NO]; + + //娉ㄥ唽寮�閿佹垚鍔熺洃鍚� + [self addOpenSuccessAction]; + // Do any additional setup after loading the view. } @@ -126,8 +127,6 @@ } } - - - (void)initTopBarView { UIView *TopView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, APP_TOP_BAR_HEIGHT)]; TopView.backgroundColor = HEXCOLORA(0xF7F7F7,1.0); @@ -138,7 +137,6 @@ TopView.layer.shadowOffset = CGSizeMake(0,0.5); TopView.layer.shadowOpacity = 1; TopView.layer.shadowRadius = 0; - } - (UIButton *)backButton{ @@ -282,11 +280,10 @@ -(void)unlockAction{ [_unlockImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_on_unlock_unselect"] forState:UIControlStateNormal]; - // //寮�閿� - // if(_es){ - // [_es openTheDoorWithRoomid:_mESRoomID]; - // } - + //寮�閿� + if(self.mLCCallDelegate != NULL){ + [self.mLCCallDelegate onUnlockAction]; + } } #pragma 鎸傛柇鍜屽紑閿� @@ -305,13 +302,13 @@ //鎸傛柇鎸夐挳浜嬩欢 -(void)hangUpAction{ //1.鍥炶皟浜嬩欢 - if(self.mESCallDelegate != NULL){ + if(self.mLCCallDelegate != NULL){ if(isAnswer){ //濡傛灉涔嬪墠宸茬粡鎺ュ惉浜嗭紝鍥炶皟鏄寕鏂� - [self.mESCallDelegate onHangUpAction:_callTimeout]; + [self.mLCCallDelegate onHangUpAction:_callTimeout]; }else{ //濡傛灉涔嬪墠娌℃帴鍚簡锛屽洖璋冩槸鎷掓帴 - [self.mESCallDelegate onRejectCallAction]; + [self.mLCCallDelegate onRejectCallAction]; } } //2.椤甸潰鍏抽棴 @@ -350,7 +347,7 @@ [self stopPlaySystemSound]; /// 寮�鍚璁� [self startTalk]; - + _answerImgBtn.hidden = YES; _answerTextBtn.hidden = YES; @@ -364,8 +361,8 @@ [self startCountdown]; isAnswer = YES; - if(self.mESCallDelegate != NULL){ - [self.mESCallDelegate onAnswerAction]; + if(self.mLCCallDelegate != NULL){ + [self.mLCCallDelegate onAnswerAction]; } } @@ -446,13 +443,13 @@ } -- (int *)getTextWidth:(UIButton*) btn -{ - int textWidth = 0; - // 聽 CGSize size = [btn.titleLabel.textsizeWithFont:[UIFontboldSystemFontOfSize:15]constrainedToSize:contentMaxSizes lineBreakMode:UILineBreakModeCharacterWrap]; - // textWidth = (int)fontSize.Width; - return textWidth; -} +//- (int *)getTextWidth:(UIButton*) btn +//{ +// int textWidth = 0; +// // 聽 CGSize size = [btn.titleLabel.textsizeWithFont:[UIFontboldSystemFontOfSize:15]constrainedToSize:contentMaxSizes lineBreakMode:UILineBreakModeCharacterWrap]; +// // textWidth = (int)fontSize.Width; +// return textWidth; +//} @@ -503,10 +500,7 @@ _openDoorTimeout = 0; [self startOpenDoorCountdown]; [self showUIAlertView:unlockSuccessfullyStr]; - // 寮�閿佹垚鍔熷洖璋� - if(self.mESCallDelegate != NULL){ - [self.mESCallDelegate onUnlockAction]; - } + } -(void)setUnlock:(BOOL)ISEnable{ @@ -653,7 +647,7 @@ - (void)startTalk { if (!isAnswer) { //瀵硅寮�鍚� -// [self.playWindow stopAudio]; + // [self.playWindow stopAudio]; if(self.talker == NULL) return; @@ -671,7 +665,8 @@ param.psk = [[LCApiKit sharedInstance] currentPsk]; /** 7. 璁剧疆鎾斁瀵嗛挜锛岄潪蹇呬紶锛屼紶浜嗕細鎻愬崌鎷夋祦閫熷害 */ param.playToken = [[LCApiKit sharedInstance] currentDevicePlayToken];; - + /** 8. 瀵硅璇锋眰绫诲瀷锛宑all鍛煎彨锛屽鏋滀笉浼狅紝榛樿涓簍alk */ + param.talkType = @"call";//2021-10-28 鏂板 NSInteger result = [self.talker playTalk:param]; if (result != 0) { //閿欒澶勭悊 @@ -701,7 +696,7 @@ - (void)onPlayerResult:(NSString*)code Type:(NSInteger)type Index:(NSInteger)index { // play WEAKSELF_AT(self); - NSLog(@"LIVE_PLAY-CODE:%@,TYPE:%ld", code, type); + NSLog(@"LIVE_PLAY-CODE:%@,TYPE:%ld", code, (long)type); //鏄惁宸茬粡寮圭獥杩� if(isShowErrorAlert) return;; @@ -726,13 +721,13 @@ if (type == 0) { if ([RTSP_Result_String(STATE_RTSP_DESCRIBE_READY) isEqualToString:code]) { -// dispatch_async(dispatch_get_main_queue(), ^{ -// }); + // dispatch_async(dispatch_get_main_queue(), ^{ + // }); return; } if ([RTSP_Result_String(STATE_RTSP_PLAY_READY) isEqualToString:code]) { -// dispatch_async(dispatch_get_main_queue(), ^{ -// }); + // dispatch_async(dispatch_get_main_queue(), ^{ + // }); return; } //鎻愮ず澶辫触 @@ -764,31 +759,31 @@ dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"寮�鍚璁插洖璋僥rror = %@, type = %ld", error, (long)type); WEAKSELF_AT(self); -// [LCProgressHUD hideAllHuds:nil]; -// if (99 == type) { //缃戠粶璇锋眰澶辫触 -//// dispatch_async(dispatch_get_main_queue(), ^{ -//// weakself.videoManager.isOpenAudioTalk = NO; -//// [LCProgressHUD showMsg:@"play_module_video_preview_talk_failed".lc_T]; -//// }); -// return; -// } -// if (nil != error && [RTSP_Result_String(STATE_RTSP_DESCRIBE_READY) isEqualToString:error]) { -// dispatch_async(dispatch_get_main_queue(), ^{ -// }); -// return; -// } -// if (nil != error && [RTSP_Result_String(STATE_RTSP_PLAY_READY) isEqualToString:error]) { -// dispatch_async(dispatch_get_main_queue(), ^{ -// //瀵硅杩炴帴鎴愬姛寤虹珛 -// self.videoManager.isOpenAudioTalk = YES; -// [LCProgressHUD showMsg:@"device_mid_open_talk_success".lc_T]; -// }); -// return; -// } -// dispatch_async(dispatch_get_main_queue(), ^{ -// [LCProgressHUD showMsg:@"play_module_video_preview_talk_failed".lc_T]; -// weakself.videoManager.isOpenAudioTalk = NO; -// }); + // [LCProgressHUD hideAllHuds:nil]; + // if (99 == type) { //缃戠粶璇锋眰澶辫触 + //// dispatch_async(dispatch_get_main_queue(), ^{ + //// weakself.videoManager.isOpenAudioTalk = NO; + //// [LCProgressHUD showMsg:@"play_module_video_preview_talk_failed".lc_T]; + //// }); + // return; + // } + // if (nil != error && [RTSP_Result_String(STATE_RTSP_DESCRIBE_READY) isEqualToString:error]) { + // dispatch_async(dispatch_get_main_queue(), ^{ + // }); + // return; + // } + // if (nil != error && [RTSP_Result_String(STATE_RTSP_PLAY_READY) isEqualToString:error]) { + // dispatch_async(dispatch_get_main_queue(), ^{ + // //瀵硅杩炴帴鎴愬姛寤虹珛 + // self.videoManager.isOpenAudioTalk = YES; + // [LCProgressHUD showMsg:@"device_mid_open_talk_success".lc_T]; + // }); + // return; + // } + // dispatch_async(dispatch_get_main_queue(), ^{ + // [LCProgressHUD showMsg:@"play_module_video_preview_talk_failed".lc_T]; + // weakself.videoManager.isOpenAudioTalk = NO; + // }); }); } @@ -858,24 +853,11 @@ [super viewWillDisappear:animated]; [self stopPlaySystemSound]; //闃叉鐢ㄦ埛涓嶆寜鎸傛柇锛屾垨鑰呬笉绛夋敹鍒板鏂圭殑鎸傛柇锛岀偣鍑昏繑鍥炴寜閽�� + //1.鏆傚仠SDK鐩稿叧鎾斁 [self stopPlay]; - - // if(_es){ - // [_es onHangup]; - // [_es onStopCapture]; - // [_es stopTalk]; - // - // _es.delegate = nil; - // ESVideo.shareInstance.snapImageCallback = nil; - // - // - // } - // [_es freeSubClass]; -} --(void)dealloc{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; - // [_es freeSubClass]; - + //2.Delegate閲婃斁 + self.mLCCallDelegate = nil; + //3.瀹氭椂鍣ㄩ噴鏀� if(_openDoorTimer){ dispatch_source_cancel(_openDoorTimer); _openDoorTimer = nil; // OK @@ -885,9 +867,12 @@ _countdownTimer = nil; // OK } - NSLog(@"==============dealloc"); - - + +} + +-(void)dealloc{ + NSLog(@"==============dealloc 1"); + [[NSNotificationCenter defaultCenter] removeObserver:self]; } //#pragma mark ESVideoPhoneDelegate @@ -1025,8 +1010,8 @@ if (!error) { message = saveToTheAlbumsStr; // 鎴浘鎴愬姛鍥炶皟 - if(self.mESCallDelegate != NULL){ - [self.mESCallDelegate onScreenshotSuccessfulAction:image]; + if(self.mLCCallDelegate != NULL){ + [self.mLCCallDelegate onScreenshotSuccessfulAction:image]; } } else @@ -1079,7 +1064,7 @@ //寮�濮嬫挱鏀剧殑鏃跺�欒皟鐢� -(void)startPlaySystemSound{ -// return; + // return; // //闇囧姩鐨勬彁绀烘枃浠跺悕鏀惧埌璧勬簮鐩綍涓� // NSString *path = [[NSBundle mainBundle] pathForResource:@"ring" ofType:@"wav"]; // AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &sound); @@ -1092,13 +1077,13 @@ //鎵嬪姩鍋滄鎾斁鐨勬椂鍊欒皟鐢� - (void)stopPlaySystemSound{ -// return; + // return; NSLog(@"stop PlaySystemSound"); - stopRingAndVibration(); + LCStopRingAndVibration(); } //鍋滄鍝嶉搩鍜岄渿鍔紝绉婚櫎鍥炶皟骞跺鐞嗘帀閾冨0鍜岄渿鍔� -void stopRingAndVibration() { +void LCStopRingAndVibration() { AudioServicesRemoveSystemSoundCompletion(kSystemSoundID_Vibrate); // AudioServicesRemoveSystemSoundCompletion(sound); AudioServicesDisposeSystemSoundID(kSystemSoundID_Vibrate); @@ -1119,8 +1104,25 @@ //} +/// +- (void)addOpenSuccessAction { + [[NSNotificationCenter defaultCenter] removeObserver:self + name:LCCallDelegateOpenDoorSuccess + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(setOpenDoorSuccess) + name:LCCallDelegateOpenDoorSuccess + object:nil]; +} + +- (void)removeOpenSuccessAction { + + [[NSNotificationCenter defaultCenter] removeObserver:self + name:LCCallDelegateOpenDoorSuccess + object:nil]; +} @end -- Gitblit v1.8.0