From cb9232b3ab413fae7bcc2b94abd70f18ca02b263 Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期二, 03 十二月 2024 11:20:32 +0800 Subject: [PATCH] 增加铃声;增加TCP/UDP连接选择 --- HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneIntercomVC.m | 63 +++++++++++++++++++++++++++---- 1 files changed, 54 insertions(+), 9 deletions(-) diff --git a/HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneIntercomVC.m b/HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneIntercomVC.m index 136009d..33682da 100644 --- a/HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneIntercomVC.m +++ b/HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneIntercomVC.m @@ -50,6 +50,10 @@ NSString * callingStr; NSString * hangUpStr; NSString * endOfCallStr; + + NSString * cancelStr; + NSString * tipMsgStr; + // int openDoorTimeout; //鍏ㄥ眬鍙橀噺 SystemSoundID sound; @@ -67,7 +71,7 @@ [self initCentetView]; [self initData]; [self initESVideo]; - //寮�濮嬪弽鍛� + //寮�濮嬮渿鍔� [self StartReverseCall]; [self ShowCalltimeBtn:callingStr]; //娉ㄥ唽寮�閿佹垚鍔熺洃鍚� @@ -77,8 +81,22 @@ self.titleUILabel.text=self.titleName; } // self.titleUILabel.text=self.titleName; + + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(registrationUpdate:) + name:@"LinphoneRegistrationUpdate" + object:nil]; + } +- (void)registrationUpdate:(NSNotification *)notif { + int state = [[notif.userInfo objectForKey:@"state"] intValue]; + if(state==11){//鎸傛柇浜� + NSLog(@"鎸傛柇鎴栧嚭閿欎簡"); + [self showUIAlertViewWithBack:@"閫氳瘽缁撴潫"]; + + } +} -(void)initLlanguage{ NSString *languageName = [[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] objectAtIndex:0]; @@ -95,6 +113,8 @@ unlockSuccessfullyStr = @"寮�閿佹垚鍔�"; callingStr = @"鏉ョ數涓�..."; endOfCallStr = @"閫氳瘽缁撴潫"; + cancelStr = @"鍙栨秷"; + tipMsgStr = @"纭畾寮�閿佸悧?"; }else{ tipStr = @"Prompt"; okStr = @"OK"; @@ -106,6 +126,8 @@ unlockSuccessfullyStr = @"Unlock successfully"; callingStr = @"Incoming call"; endOfCallStr = @"End of call"; + cancelStr = @"Cancel"; + tipMsgStr = @"Are you sure to unlock?"; } } @@ -238,6 +260,7 @@ [_screenshotImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_on_takephoto_unselect"] forState:UIControlStateNormal]; //鎴浘 + [HDLLinphoneManager.instance snapShotWithView:self.videoView]; } @@ -264,7 +287,26 @@ [_unlockImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_on_unlock_unselect"] forState:UIControlStateNormal]; //寮�閿� if(self.hdlLinphoneCallDelegate != NULL){ - [self.hdlLinphoneCallDelegate onUnlockAction]; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:tipStr message:tipMsgStr preferredStyle:UIAlertControllerStyleAlert]; + + // 娣诲姞鍙栨秷鎸夐挳 + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelStr style:UIAlertActionStyleCancel handler:nil]; + [alertController addAction:cancelAction]; + + // 娣诲姞纭鎸夐挳 + WEAKSELF_AT + UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:okStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + + [weakSelf_AT.hdlLinphoneCallDelegate onUnlockAction]; + }]; + [alertController addAction:confirmAction]; + + // 鑾峰彇褰撳墠瑙嗗浘鎺у埗鍣� + UIViewController *currentViewController = [UIApplication sharedApplication].keyWindow.rootViewController; + + // 鏄剧ず寮圭獥 + [currentViewController presentViewController:alertController animated:YES completion:nil]; + } } @@ -332,7 +374,7 @@ // [[HDLCallManager instance] acceptCallByCallID:self.CallId hasVideo:self.hasVideo]; [[HDLLinphoneManager instance] acceptCall]; /// 寮�鍚璁� - [self startTalk]; +// [self startTalk]; _answerImgBtn.hidden = YES; _answerTextBtn.hidden = YES; @@ -505,7 +547,7 @@ /** 寮�鍚�掕鏃� */ - (void)startOpenDoorCountdown { - if (_openDoorTimeout > 20) { + if (_openDoorTimeout > 10) { return; } @@ -520,7 +562,7 @@ dispatch_source_set_event_handler(_openDoorTimer, ^{ WEAKSELF_AT - if(weakSelf_AT.openDoorTimeout >= 20 ){// 璁℃椂缁撴潫 + if(weakSelf_AT.openDoorTimeout >= 10 ){// 璁℃椂缁撴潫 // 鍏抽棴瀹氭椂鍣� dispatch_source_cancel(weakSelf_AT.openDoorTimer); @@ -629,6 +671,7 @@ } -(void)viewWillDisappear:(BOOL)animated{ + NSLog(@"viewWillDisappear"); [super viewWillDisappear:animated]; [self stopPlaySystemSound]; //闃叉鐢ㄦ埛涓嶆寜鎸傛柇锛屾垨鑰呬笉绛夋敹鍒板鏂圭殑鎸傛柇锛岀偣鍑昏繑鍥炴寜閽�� @@ -646,6 +689,8 @@ _countdownTimer = nil; // OK } + + [[NSNotificationCenter defaultCenter] removeObserver:self]; } @@ -711,7 +756,7 @@ #pragma 闇囧姩瀹炵幇璨屼技鍜孲DK鍐茬獊 涓嶈兘瀹炵幇闇囧姩 //寮�濮嬫挱鏀剧殑鏃跺�欒皟鐢� -(void)startPlaySystemSound{ - return; +// return; // //闇囧姩鐨勬彁绀烘枃浠跺悕鏀惧埌璧勬簮鐩綍涓� // NSString *path = [[NSBundle mainBundle] pathForResource:@"ring" ofType:@"wav"]; // AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &sound); @@ -724,13 +769,13 @@ //鎵嬪姩鍋滄鎾斁鐨勬椂鍊欒皟鐢� - (void)stopPlaySystemSound{ - return; +// return; NSLog(@"stop PlaySystemSound"); - stopRingAndVibration(); + HDLLPStopRingAndVibration(); } //鍋滄鍝嶉搩鍜岄渿鍔紝绉婚櫎鍥炶皟骞跺鐞嗘帀閾冨0鍜岄渿鍔� -void stopRingAndVibration() { +void HDLLPStopRingAndVibration() { AudioServicesRemoveSystemSoundCompletion(kSystemSoundID_Vibrate); // AudioServicesRemoveSystemSoundCompletion(sound); AudioServicesDisposeSystemSoundID(kSystemSoundID_Vibrate); -- Gitblit v1.8.0