| | |
| | | @property (nonatomic,strong) dispatch_source_t openDoorTimer; |
| | | @property (nonatomic, assign) int openDoorTimeout; |
| | | @property (nonatomic, assign) int callTimeout; |
| | | |
| | | @property (nonatomic, assign) BOOL isHangUpByRemote;//æ¯å¦å¯¹æ¹è¿ç¨ææ |
| | | |
| | | @end |
| | | |
| | | @implementation HDLLinphoneIntercomVC{ |
| | |
| | | NSString * callingStr; |
| | | NSString * hangUpStr; |
| | | NSString * endOfCallStr; |
| | | |
| | | |
| | | NSString * cancelStr; |
| | | NSString * tipMsgStr; |
| | | |
| | | // int openDoorTimeout; |
| | | //å
¨å±åé |
| | | SystemSoundID sound; |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | - (void)linphoneCallUpdate:(NSNotification *)notif { |
| | | int state = [[notif.userInfo objectForKey:@"state"] intValue]; |
| | | if ((state == LinphoneCallEnd || state == LinphoneCallError)) {//ææäº |
| | | if ((state == LinphoneCallEnd || state == LinphoneCallError)) {//ææäº(è½ç¶èªå·±ææä¹ä¼èµ°LinphoneCallUpdateéç¥ï¼ä½èªå·±ææçè¯é¡µé¢å·²éæ¯ï¼ä¸ä¼è§¦åè¯¥æ¹æ³) |
| | | NSLog(@"æææåºéäº"); |
| | | [self stopPlaySystemSound]; |
| | | self.isHangUpByRemote=YES; |
| | | [self showUIAlertViewWithBack:@"éè¯ç»æ"]; |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | unlockSuccessfullyStr = @"å¼éæå"; |
| | | callingStr = @"æ¥çµä¸..."; |
| | | endOfCallStr = @"éè¯ç»æ"; |
| | | cancelStr = @"åæ¶"; |
| | | tipMsgStr = @"ç¡®å®å¼éå?"; |
| | | }else{ |
| | | tipStr = @"Prompt"; |
| | | okStr = @"OK"; |
| | |
| | | unlockSuccessfullyStr = @"Unlock successfully"; |
| | | callingStr = @"Incoming call"; |
| | | endOfCallStr = @"End of call"; |
| | | cancelStr = @"Cancel"; |
| | | tipMsgStr = @"Are you sure to unlock?"; |
| | | |
| | | } |
| | | } |
| | |
| | | [_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; |
| | | |
| | | // æ¾ç¤ºå¼¹çª |
| | | [self presentViewController:alertController animated:YES completion:nil]; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | return _hangUpTextBtn; |
| | | } |
| | | |
| | | //æ¥å¬ 徿 æé® |
| | | - (UIButton *)answerImgBtn{ |
| | | if (_answerImgBtn == nil) { |
| | |
| | | [self stopPlaySystemSound]; |
| | | |
| | | // [[HDLCallManager instance] acceptCallByCallID:self.CallId hasVideo:self.hasVideo]; |
| | | [[HDLLinphoneManager instance] acceptCall]; |
| | | [HDLLinphoneManager.instance enableMicro:true]; |
| | | if (self.deviceType==HDLLPType_HDLSR) { |
| | | NSLog(@"åå¼"); |
| | | [HDLLinphoneManager.instance startCall:self.userName]; |
| | | }else{ |
| | | NSLog(@"æ¥å¬"); |
| | | [[HDLLinphoneManager instance] acceptCall]; |
| | | |
| | | } |
| | | /// å¼å¯å¯¹è®² |
| | | // [self startTalk]; |
| | | |
| | |
| | | /** å¼å¯åè®¡æ¶ */ |
| | | - (void)startCountdown { |
| | | |
| | | if (_callTimeout > 100) { |
| | | return; |
| | | } |
| | | // if (_callTimeout > 100) { |
| | | // return; |
| | | // } |
| | | _callTimeout = 0; |
| | | // GCD宿¶å¨ |
| | | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); |
| | |
| | | |
| | | dispatch_source_set_event_handler(_countdownTimer, ^{ |
| | | WEAKSELF_AT |
| | | if(weakSelf_AT.callTimeout >= 100 ){// 计æ¶ç»æ |
| | | // å
³é宿¶å¨ |
| | | dispatch_source_cancel(weakSelf_AT.countdownTimer); |
| | | |
| | | dispatch_async(dispatch_get_main_queue(), ^{ |
| | | NSLog(@"è¶
æ¶"); |
| | | [weakSelf_AT backAction]; |
| | | |
| | | }); |
| | | |
| | | }else{// 计æ¶ä¸ |
| | | // if(weakSelf_AT.callTimeout >= 100 ){// 计æ¶ç»æ |
| | | // // å
³é宿¶å¨ |
| | | // dispatch_source_cancel(weakSelf_AT.countdownTimer); |
| | | // |
| | | // dispatch_async(dispatch_get_main_queue(), ^{ |
| | | // NSLog(@"è¶
æ¶"); |
| | | // [weakSelf_AT backAction]; |
| | | // |
| | | // }); |
| | | // |
| | | // }else{// 计æ¶ä¸ |
| | | weakSelf_AT.callTimeout++; |
| | | dispatch_async(dispatch_get_main_queue(), ^{ |
| | | [weakSelf_AT ShowTime:weakSelf_AT.callTimeout]; |
| | | }); |
| | | |
| | | |
| | | } |
| | | // } |
| | | }); |
| | | |
| | | // å¼å¯å®æ¶å¨ |
| | |
| | | [self stopPlaySystemSound]; |
| | | //鲿¢ç¨æ·ä¸æææï¼æè
ä¸çæ¶å°å¯¹æ¹çææï¼ç¹å»è¿åæé®ã |
| | | //1.æåSDKç¸å
³ææ¾ |
| | | [self stopPlay]; |
| | | if (!self.isHangUpByRemote) { |
| | | [self stopPlay]; |
| | | } |
| | | //2.Delegateéæ¾ |
| | | self.hdlLinphoneCallDelegate = nil; |
| | | //3.宿¶å¨éæ¾ |
| | |
| | | } |
| | | |
| | | -(void)dealloc{ |
| | | NSLog(@"==============dealloc 1"); |
| | | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| | | NSLog(@"==============dealloc å¯¹è±¡éæ¯äº"); |
| | | // [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| | | } |
| | | - (void)willEnterForeground:(NSNotification*)notification{ |
| | | NSLog(@"willEnterForeground"); |