chenqiyang
2023-05-25 b897bf1e118e69764da20ef6668ef5d9ec1653e8
HDLLinPhoneSDK£¨OC£©/HDLLinPhoneSDK/HDLLinphoneIntercomVC.m
@@ -35,6 +35,9 @@
@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{
@@ -90,11 +93,15 @@
}
- (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:@"通话结束"];
        
    }
}
@@ -331,6 +338,7 @@
    }
    return _hangUpTextBtn;
}
//接听 å›¾æ ‡æŒ‰é’®
- (UIButton *)answerImgBtn{
    if (_answerImgBtn == nil) {
@@ -349,7 +357,15 @@
    [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];
    
@@ -467,9 +483,9 @@
/** å¼€å¯å€’计时 */
- (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);
@@ -480,24 +496,24 @@
    
    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];
            });
            
            
        }
//        }
    });
    
    // å¼€å¯å®šæ—¶å™¨
@@ -653,7 +669,9 @@
    [self stopPlaySystemSound];
    //防止用户不按挂断,或者不等收到对方的挂断,点击返回按钮。
    //1.暂停SDK相关播放
    [self stopPlay];
    if (!self.isHangUpByRemote) {
        [self stopPlay];
    }
    //2.Delegate释放
    self.hdlLinphoneCallDelegate = nil;
    //3.定时器释放
@@ -672,8 +690,8 @@
}
-(void)dealloc{
    NSLog(@"==============dealloc  1");
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    NSLog(@"==============dealloc å¯¹è±¡é”€æ¯äº†");
//    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)willEnterForeground:(NSNotification*)notification{
    NSLog(@"willEnterForeground");