JLChen
2021-05-13 7f62f2d3bf626ac55d2d2de05ca1d71eaaabef39
iOS/Xamarin/LCOnDemo/LCOnDemo/LCSDK/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>
@@ -90,8 +92,11 @@
    //开始反呼
    [self StartReverseCall];
    [self ShowCalltimeBtn:callingStr];
    //暂时不支持开锁功能
    [self setUnlock:NO];
//    //暂时不支持开锁功能
//    [self setUnlock:NO];
    //注册开锁成功监听
    [self addOpenSuccessAction];
    // Do any additional setup after loading the view.
}
@@ -282,11 +287,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 +309,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 +354,7 @@
    [self stopPlaySystemSound];
    /// 开启对讲
    [self startTalk];
    _answerImgBtn.hidden = YES;
    _answerTextBtn.hidden = YES;
    
@@ -364,8 +368,8 @@
    [self startCountdown];
    isAnswer = YES;
    
    if(self.mESCallDelegate != NULL){
        [self.mESCallDelegate onAnswerAction];
    if(self.mLCCallDelegate != NULL){
        [self.mLCCallDelegate onAnswerAction];
    }
    
}
@@ -503,10 +507,7 @@
    _openDoorTimeout = 0;
    [self startOpenDoorCountdown];
    [self showUIAlertView:unlockSuccessfullyStr];
    // 开锁成功回调
    if(self.mESCallDelegate != NULL){
        [self.mESCallDelegate onUnlockAction];
    }
}
-(void)setUnlock:(BOOL)ISEnable{
@@ -653,7 +654,7 @@
- (void)startTalk {
    if (!isAnswer) {
        //对讲开启
//        [self.playWindow stopAudio];
        //        [self.playWindow stopAudio];
        
        if(self.talker == NULL) return;
        
@@ -726,13 +727,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 +765,31 @@
    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"开启对讲回调error = %@, 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;
        //        });
    });
}
@@ -1025,8 +1026,8 @@
    if (!error) {
        message = saveToTheAlbumsStr;
        // 截图成功回调
        if(self.mESCallDelegate != NULL){
            [self.mESCallDelegate onScreenshotSuccessfulAction:image];
        if(self.mLCCallDelegate != NULL){
            [self.mLCCallDelegate onScreenshotSuccessfulAction:image];
        }
    }
    else
@@ -1079,7 +1080,7 @@
//开始播放的时候调用
-(void)startPlaySystemSound{
    
//    return;
    //    return;
    //    //震动的提示文件名放到资源目录下
    //    NSString *path = [[NSBundle mainBundle] pathForResource:@"ring" ofType:@"wav"];
    //    AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &sound);
@@ -1092,7 +1093,7 @@
//手动停止播放的时候调用
- (void)stopPlaySystemSound{
//    return;
    //    return;
    NSLog(@"stop PlaySystemSound");
    stopRingAndVibration();
}
@@ -1119,8 +1120,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