| | |
| | | #import <AVFoundation/AVFoundation.h> |
| | | #import <ESVideoPhoneSDk/ESVideoPhone.h> |
| | | #import <ESVideoPhoneSDk/ESError.h> |
| | | #import "AudioSessionHelper.h" |
| | | //#import "AudioSessionHelper.h" |
| | | #import <Photos/Photos.h> |
| | | #import <AudioToolbox/AudioToolbox.h> |
| | | #import "ESVideo.h" |
| | |
| | | |
| | | @interface ESOnIntercomViewController ()<ESVideoPhoneDelegate> |
| | | |
| | | @property (nonatomic,strong) AudioSessionHelper *sessionHelper; |
| | | //@property (nonatomic,strong) AudioSessionHelper *sessionHelper; |
| | | @property (nonatomic,strong) ESVideoPhone *es; |
| | | @property (nonatomic,assign) BOOL playing; |
| | | @property (nonatomic,assign) BOOL isInterrupt; |
| | |
| | | NSString * unlockSuccessfullyStr; |
| | | NSString * callingStr; |
| | | NSString * hangUpStr; |
| | | NSString * hasBeenHungUpStr; |
| | | // int openDoorTimeout; |
| | | //全局变量 |
| | | SystemSoundID sound; |
| | |
| | | hangUpStr = @"挂断"; |
| | | unlockSuccessfullyStr = @"开锁成功"; |
| | | callingStr = @"来电中..."; |
| | | hasBeenHungUpStr = @"已挂断"; |
| | | }else{ |
| | | tipStr = @"Prompt"; |
| | | okStr = @"OK"; |
| | |
| | | hangUpStr = @"Hang up"; |
| | | unlockSuccessfullyStr = @"Unlock successfully"; |
| | | callingStr = @"Incoming call"; |
| | | hasBeenHungUpStr = @"Has been hung up"; |
| | | |
| | | } |
| | | } |
| | |
| | | // NSLog(@"VideoCaptureSession 初始化失败"); |
| | | // } |
| | | // } |
| | | //初始化AudioSession |
| | | _sessionHelper = [[AudioSessionHelper alloc]init]; |
| | | [_sessionHelper setAudioSession]; |
| | | // //初始化AudioSession |
| | | // _sessionHelper = [[AudioSessionHelper alloc]init]; |
| | | // [_sessionHelper setAudioSession]; |
| | | //添加进入后台,中断等通知 |
| | | [self addObservers]; |
| | | |
| | |
| | | |
| | | // [_mCallOrAccept setTitle:@"通话中..." forState:UIControlStateNormal]; |
| | | }else if([phoneEventStr isEqual:@"EVT_HangUp"]){ |
| | | [self showUIAlertViewWithBack:hasBeenHungUpStr]; |
| | | [self showUIAlertViewWithBack:@"已挂断"]; |
| | | // [_mCallOrAccept setTitle:@"反呼" forState:UIControlStateNormal]; |
| | | }else if([phoneEventStr isEqual:@"EVT_P2POnlineStatusChanged"]){ |
| | | //EVT_P2PStarted(p2p初始化OK,可以连接),EVT_P2POnlineStatusChangedonline=1 |
| | |
| | | NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; |
| | | NSInteger status = [[dic valueForKey:@"status"]integerValue]; |
| | | if(status && status == 1){ |
| | | // NSLog(@"开门成功"); |
| | | NSLog(@"开门成功"); |
| | | [self setOpenDoorSuccess]; |
| | | }else{ |
| | | NSLog(@"开门失败"); |
| | |
| | | // If media services were reset, and the last start succeeded, restart the session. |
| | | if (error.code == AVErrorMediaServicesWereReset) { |
| | | [_es onStopCapture]; |
| | | [_es startTalk]; |
| | | [_es stopTalk]; |
| | | } |
| | | } |
| | | |
| | |
| | | NSString *result = nil; |
| | | //听筒状态 插耳塞后拔掉后恢复到默认设置 |
| | | if (sender == nil) { |
| | | result = [_sessionHelper speaker:NO]; |
| | | // result = [_sessionHelper speaker:NO]; |
| | | [_es resetAudioCaptureIsSpeak:NO]; |
| | | }else{ |
| | | if(!_isSpeaking){ |
| | | result = [_sessionHelper speaker:YES]; |
| | | [_es resetAudioCaptureIsSpeak:YES]; |
| | | // result = [_sessionHelper speaker:YES]; |
| | | _isSpeaking = YES; |
| | | }else{ |
| | | result = [_sessionHelper speaker:NO]; |
| | | // result = [_sessionHelper speaker:NO]; |
| | | [_es resetAudioCaptureIsSpeak:NO]; |
| | | _isSpeaking = NO; |
| | | } |
| | | } |