| | |
| | | #import "AudioSessionHelper.h" |
| | | #import <Photos/Photos.h> |
| | | #import <AudioToolbox/AudioToolbox.h> |
| | | |
| | | #import "ESVideo.h" |
| | | |
| | | |
| | | |
| | |
| | | NSString * refuseStr; |
| | | NSString * answerStr; |
| | | NSString * unlockSuccessfullyStr; |
| | | NSString * callingStr; |
| | | NSString * hangUpStr; |
| | | // int openDoorTimeout; |
| | | //全局变量 |
| | | SystemSoundID sound; |
| | |
| | | [self initTopBarView]; |
| | | [self initCentetView]; |
| | | [self initData]; |
| | | // [self setAnswerBtnEnable:NO]; |
| | | // [self setAnswerBtnEnable:NO]; |
| | | [self initESVideo]; |
| | | //开始反呼 |
| | | [self StartReverseCall]; |
| | | [self ShowCalltimeBtn:@"室外机来电中..."]; |
| | | [self ShowCalltimeBtn:callingStr]; |
| | | // Do any additional setup after loading the view. |
| | | } |
| | | |
| | |
| | | operationFailedStr = @"操作失败"; |
| | | refuseStr = @"拒绝"; |
| | | answerStr = @"接听"; |
| | | hangUpStr = @"挂断"; |
| | | unlockSuccessfullyStr = @"开锁成功"; |
| | | callingStr = @"来电中..."; |
| | | }else{ |
| | | tipStr = @"Prompt"; |
| | | okStr = @"OK"; |
| | |
| | | operationFailedStr = @"Operation failed."; |
| | | refuseStr = @"Refuse"; |
| | | answerStr = @"Answer"; |
| | | hangUpStr = @"Hang up"; |
| | | unlockSuccessfullyStr = @"Unlock successfully"; |
| | | callingStr = @"Incoming call"; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | -(void)backAction{ |
| | | [self.navigationController popViewControllerAnimated:true]; |
| | | // [self dismissViewControllerAnimated:YES completion:NULL]; |
| | | |
| | | // [self dismissViewControllerAnimated:YES completion:NULL]; |
| | | |
| | | } |
| | | |
| | | - (UIButton *)moreButton{ |
| | |
| | | |
| | | - (void)initCentetView { |
| | | [self.view addSubview:self.centerView]; |
| | | [self.centerView addSubview:self.collectButton]; |
| | | // [self.centerView addSubview:self.collectButton]; |
| | | [self.centerView addSubview:self.homeView]; |
| | | [self.centerView addSubview:self.unlockView]; |
| | | [self.unlockView addSubview:self.screenshotImgBtn]; |
| | |
| | | //挂断按钮移动中间 |
| | | _hangUpImgBtn.frame = CGRectMake(159, 448, 58, 58); |
| | | _hangUpTextBtn.frame = CGRectMake(138, 514, 100, 21); |
| | | |
| | | [_hangUpTextBtn setTitle:hangUpStr forState:UIControlStateNormal]; |
| | | //开始计时 |
| | | _callTimeout = 0; |
| | | [self startCountdown]; |
| | |
| | | |
| | | -(void)ShowCalltimeBtn:(NSString*) mesStr { |
| | | if(_calltimeBtn.hidden) _calltimeBtn.hidden = NO; |
| | | |
| | | |
| | | [self setCalltimeButtonText:mesStr isTime:NO]; |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | { |
| | | [_calltimeBtn setTitle:mesStr forState:UIControlStateNormal]; |
| | | if(isTime){ |
| | | _calltimeBtn.frame = CGRectMake(0, 0, 100, 30); |
| | | _calltimeBtn.frame = CGRectMake(0, 0, 80, 30); |
| | | }else{ |
| | | _calltimeBtn.frame = CGRectMake(0, 0, 150, 30); |
| | | _calltimeBtn.frame = CGRectMake(0, 0, 115, 30); |
| | | } |
| | | _calltimeBtn.center = CGPointMake(APP_SCREEN_WIDTH/2, 397); |
| | | } |
| | |
| | | |
| | | #pragma SDK可视对讲 功能部分 |
| | | -(void)initESVideo{ |
| | | _es = ESVideo.shareInstance.es; |
| | | //初始化中断,进入后台的tag |
| | | |
| | | |
| | | _playing = NO; |
| | | _isSpeaking = NO; |
| | | self.isInterrupt = NO; |
| | |
| | | }); |
| | | }; |
| | | //门口机会有视频的长宽高,是固定的(暂时还不确定) |
| | | _es = [[ESVideoPhone alloc]initESVideoPhoneWithFrame:CGRectMake(0, 57, APP_SCREEN_WIDTH, 211) delegate:self imagecallBack:snapImageCallback]; |
| | | // _es = [[ESVideoPhone alloc]initESVideoPhoneWithFrame:CGRectMake(0, 57, APP_SCREEN_WIDTH, 211) delegate:self imagecallBack:snapImageCallback]; |
| | | if (_es) { |
| | | //判断视频渲染是否初始化成功,如果失败会走ESVideoPhoneDelegate方法 |
| | | if (_es.showView) { |
| | | ESVideo.shareInstance.snapImageCallback = snapImageCallback; |
| | | _es.delegate = self; |
| | | _es.showView.backgroundColor = [UIColor whiteColor]; |
| | | [self.centerView addSubview:_es.showView]; |
| | | _es.showView.hidden = YES; |
| | | } |
| | | }else{ |
| | | NSLog(@"ESVideoPhone 初始化失败"); |
| | |
| | | [alertController addAction:[UIAlertAction actionWithTitle:okStr style:UIAlertActionStyleCancel handler:nil]]; |
| | | [self presentViewController:alertController animated:YES completion:nil]; |
| | | |
| | | // UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:tipStr message:mes delegate:self cancelButtonTitle:okStr otherButtonTitles:nil, nil]; |
| | | // [alertView1 show]; |
| | | // UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:tipStr message:mes delegate:self cancelButtonTitle:okStr otherButtonTitles:nil, nil]; |
| | | // [alertView1 show]; |
| | | |
| | | } |
| | | |
| | | -(void)showUIAlertViewWithBack:(NSString *)mes |
| | | { |
| | | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:tipStr message:mes preferredStyle:UIAlertControllerStyleAlert]; |
| | | [alertController addAction:[UIAlertAction actionWithTitle:okStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { |
| | | [self backAction]; |
| | | }]]; |
| | | |
| | | [self presentViewController:alertController animated:YES completion:nil]; |
| | | } |
| | | |
| | | |
| | |
| | | [_es stopTalk]; |
| | | |
| | | _es.delegate = nil; |
| | | |
| | | ESVideo.shareInstance.snapImageCallback = nil; |
| | | |
| | | |
| | | } |
| | | [_es freeSubClass]; |
| | | // [_es freeSubClass]; |
| | | } |
| | | -(void)dealloc{ |
| | | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| | |
| | | NSString *phoneEventStr = eventArray.lastObject; |
| | | |
| | | if([phoneEventStr isEqual:@"EVT_Ringing"]){ |
| | | _es.showView.hidden = NO; |
| | | //反呼成功 允许接听 看需求是否需要播放铃声和震动 |
| | | [self setAnswerBtnEnable:YES]; |
| | | |
| | |
| | | } else if([phoneEventStr isEqual:@"EVT_StopStream"]){ |
| | | // [_mCallOrAccept setTitle:@"反呼" forState:UIControlStateNormal]; |
| | | }else if([phoneEventStr isEqual:@"EVT_Connected"]){ |
| | | |
| | | // [_mCallOrAccept setTitle:@"通话中..." forState:UIControlStateNormal]; |
| | | }else if([phoneEventStr isEqual:@"EVT_HangUp"]){ |
| | | [self showUIAlertViewWithBack:@"已挂断"]; |
| | | // [_mCallOrAccept setTitle:@"反呼" forState:UIControlStateNormal]; |
| | | }else if([phoneEventStr isEqual:@"EVT_P2POnlineStatusChanged"]){ |
| | | //EVT_P2PStarted(p2p初始化OK,可以连接),EVT_P2POnlineStatusChangedonline=1 |