123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- //
- // InCallViewController.m
- // JCSampleOC
- //
- // Created by Ginger on 2017/10/12.
- // Copyright © 2017年 juphoon. All rights reserved.
- //
- #import "SKInCallViewController.h"
- #import "SKInCallViewController+juphoon.h"
- #import "SKInCallViewController+agora.h"
- #import "SKInCallViewController+touch.h"
- #import "VideoManager+ringtone.h"
- @interface SKInCallViewController() {
- NSTimer* _timer;
- }
- @end
- @implementation SKInCallViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
-
- [EUtil setViewShadow:self.mWaitNameLabel color:[UIColor colorWithRed:0/255.0f green:1/255.0f blue:75/255.0f alpha:0.2] offset:CGSizeMake(0, 2) opacity:1 radius:4];
- [EUtil setViewShadow:self.mWaitOutHintLabel color:[UIColor colorWithRed:0/255.0f green:1/255.0f blue:75/255.0f alpha:0.2] offset:CGSizeMake(0, 2) opacity:1 radius:4];
- [EUtil setViewShadow:self.mWaitInHintLabel color:[UIColor colorWithRed:0/255.0f green:1/255.0f blue:75/255.0f alpha:0.2] offset:CGSizeMake(0, 2) opacity:1 radius:4];
-
- [EUtil setViewShadow:self.mIngNameLabel color:[UIColor colorWithRed:0/255.0f green:1/255.0f blue:75/255.0f alpha:0.2] offset:CGSizeMake(0, 2) opacity:1 radius:4];
- [EUtil setViewShadow:self.mIngTimeLabel color:[UIColor colorWithRed:0/255.0f green:1/255.0f blue:75/255.0f alpha:0.2] offset:CGSizeMake(0, 2) opacity:1 radius:4];
- [EUtil setViewShadow:self.mIngNetWorkLabel color:[UIColor colorWithRed:0/255.0f green:1/255.0f blue:75/255.0f alpha:0.2] offset:CGSizeMake(0, 2) opacity:1 radius:4];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateUI:) name:kCallNotification object:nil];
-
- _smallView = nil;
- self.isTouchInSmallCanvas = NO;
- self.isMoveInSmallCanvas = NO;
- [self initView];
- [self updateUI:nil];
- [[VideoManager shared] playVideoWaitingRingtone];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:YES animated:NO];
- }
- - (void)viewDidAppear:(BOOL)animated {
- [[VideoManager shared].mJuphoonMediaDevice enableSpeaker:YES];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [self.navigationController setNavigationBarHidden:NO animated:NO];
- [self stopTimer];
- self.mIngTimeLabel.text = @"";
- self.mIngNetWorkLabel.text = @"";
- }
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- return UIInterfaceOrientationMaskPortrait;
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
- [[VideoManager shared] playVideoFinishRingtone];
- }
- - (void)initView {
- [EUtil setURLImage:self.mWaitHeadImage placeHolderName:@"avatar" imageURL:[[VideoManager shared] getTalkHeadImageURL] cornerRadius:self.mWaitHeadImage.frame.size.width/2];
- }
- #pragma mark - Incoming Actions
- - (IBAction)endCall:(id)sender {
- //通话中挂断; 自己发起时,对方未接通,自己挂断//
- [[VideoManager shared] videoEnd:NO isSendMessage:YES];
- }
- - (IBAction)endCallWhenIncoming:(id)sender {
- //对方发起时,自己拒接//
- [[VideoManager shared] videoEnd:YES isSendMessage:YES];
- }
- - (IBAction)videoAnswer:(id)sender {
- JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
- [[VideoManager shared].mJuphoonCall answer:activeCall video:true];
- }
- - (IBAction)voiceAnswer:(id)sender {
- JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
- [[VideoManager shared].mJuphoonCall answer:activeCall video:false];
- }
- #pragma mark - In Calling Actions
- - (IBAction)setCameraState:(id)sender {
- JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
- [[VideoManager shared].mJuphoonCall enableUploadVideoStream:activeCall];
- }
- - (IBAction)addNewCall:(id)sender {
- }
- - (IBAction)switchCamera:(id)sender {
- [[VideoManager shared].mJuphoonMediaDevice switchCamera];
- }
- - (IBAction)hold:(id)sender {
- JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
- [[VideoManager shared].mJuphoonCall hold:activeCall];
- }
- - (IBAction)mute:(id)sender {
- JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
- [[VideoManager shared].mJuphoonCall mute:activeCall];
- }
- - (IBAction)audioRecord:(id)sender {
- }
- - (IBAction)videoRecord:(id)sender {
- }
- - (IBAction)snapshot:(id)sender {
- }
- - (IBAction)speaker:(id)sender {
- [[VideoManager shared].mJuphoonMediaDevice enableSpeaker:![VideoManager shared].mJuphoonMediaDevice.isSpeakerOn];
- self.speakerBtn.selected = [VideoManager shared].mJuphoonMediaDevice.isSpeakerOn;
- }
- - (IBAction)callStatistics:(id)sender {
- }
- #pragma mark - 工具函数
- - (NSString *)getCallInfo:(JCCallItem*)item {
- switch (item.state) {
- case JCCallStateTalking:
- return [self formatTalkingTime:((long)[[NSDate date] timeIntervalSince1970] - item.talkingBeginTime)];
- default:
- return @"";
- }
- }
- - (NSString *)formatTalkingTime:(long)time {
- return [NSString stringWithFormat:@"%02ld:%02ld", time/60, time%60];
- }
- #pragma mark - Timer
- - (void)startTimer {
- if (_timer == nil) {
- _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerProc) userInfo:nil repeats:YES];
- }
- }
- - (void)stopTimer {
- if (_timer) {
- if ([_timer isValid]) {
- [_timer invalidate];
- _timer = nil;
- }
- }
- }
- - (void)timerProc {
- self.mIngHeaderView.hidden = NO;
- JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
- self.mIngTimeLabel.text = [self getCallInfo:activeCall];
- self.mIngNetWorkLabel.text = [self getNetStatus:activeCall];
- if (activeCall.direction == JCCallDirectionOut) {
- }
- }
- @end
|