|
|
@@ -7,15 +7,18 @@
|
|
|
|
|
|
#import "webRtcPlayerViewController.h"
|
|
|
#import "webRtcPlayerViewController+AdjustBtnFrame.h"
|
|
|
-#import "webRtcPlayerBottomContrView.h"
|
|
|
+#import "webRtcPlayerViewController+AdjustPlayerViewFrame.h"
|
|
|
+
|
|
|
+
|
|
|
+#import "UIInterface+HXRotation.h"
|
|
|
+#import "playerSetView.h"
|
|
|
|
|
|
@interface webRtcPlayerViewController ()<MediaStreamClientEventsDelegate>
|
|
|
{
|
|
|
BOOL outputVolumeKVO;/*标记声音监听通知*/
|
|
|
}
|
|
|
@property (nonatomic, copy) NSTimer *playerSecondTimer; // 定时器-控制按钮
|
|
|
-@property (nonatomic, assign) NSInteger concentTime; // 拉流数据 渲染更新时间戳 /**30s后 渲染时间戳无更新 自动断开链接*/
|
|
|
-@property(nonatomic,strong)webRtcPlayerBottomContrView *bottomContrView;//底部按钮 选项 home 返回
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation webRtcPlayerViewController
|
|
|
@@ -29,6 +32,12 @@
|
|
|
[self.navigationBar setHidden:YES];
|
|
|
[self.navBarBGView setHidden:YES];
|
|
|
[self.view setBackgroundColor:[UIColor blackColor]];
|
|
|
+
|
|
|
+ if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
|
|
|
+ ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying){
|
|
|
+ _isCodeSuspendAudioType = YES;
|
|
|
+ [[DFPlayer sharedPlayer] df_pause];
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -46,6 +55,7 @@
|
|
|
[super viewDidAppear:animated];
|
|
|
[self noEnablePanRightBack];
|
|
|
[self addKVOObserverFun];
|
|
|
+ ksharedAppDelegate.supportScreenRotateType = YES;
|
|
|
}
|
|
|
|
|
|
- (void)viewDidDisappear:(BOOL)animated{
|
|
|
@@ -54,6 +64,7 @@
|
|
|
[_mediaStream disconnect];
|
|
|
[self enablePanRightBack];
|
|
|
[self removeKVOObserverFun];
|
|
|
+ ksharedAppDelegate.supportScreenRotateType = NO;
|
|
|
}
|
|
|
|
|
|
- (void)setWebRtcMsgMod:(webRtcMsgModel *)webRtcMsgMod
|
|
|
@@ -76,6 +87,20 @@
|
|
|
make.top.mas_equalTo(0.f);
|
|
|
}];
|
|
|
|
|
|
+ [self linkWebRtcFun];
|
|
|
+
|
|
|
+ [self initBaseUIFun];
|
|
|
+ [self setTimerCountDown];
|
|
|
+
|
|
|
+ CGFloat curRate = 1080.0/1920.0;
|
|
|
+ [self setPoMas_makeWithImageRate:curRate];
|
|
|
+ [self showNewIndicatorWithCanBack:YES canTouch:NO];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 链接webrtc
|
|
|
+- (void)linkWebRtcFun
|
|
|
+{
|
|
|
//链接用
|
|
|
NSString *signallingUrl = [[NSString alloc] initWithFormat:@"%@:%@",_webRtcMsgMod.data.signalling.domainName,_webRtcMsgMod.data.signalling.port];
|
|
|
NSURL *url = [NSURL URLWithString:signallingUrl];
|
|
|
@@ -107,14 +132,12 @@
|
|
|
token:@"vclusters"];
|
|
|
|
|
|
HLog(@"result:%ld",result)
|
|
|
-
|
|
|
- [self initBaseUIFun];
|
|
|
- [self setTimerCountDown];
|
|
|
-
|
|
|
- CGFloat curRate = 1080.0/1920.0;
|
|
|
- [self setPoMas_makeWithImageRate:curRate];
|
|
|
- [self showNewIndicatorWithCanBack:YES canTouch:NO];
|
|
|
-
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 重连
|
|
|
+- (void)relinkWebRtcFun
|
|
|
+{
|
|
|
+ [self linkWebRtcFun];
|
|
|
}
|
|
|
|
|
|
#pragma mark 初始化其他UI
|
|
|
@@ -176,7 +199,7 @@
|
|
|
|
|
|
// 初始化值计时数据
|
|
|
//self.adjustTime = 1;
|
|
|
- self.concentTime = [iTools getNowTimeStamp];
|
|
|
+ //self.concentTime = [iTools getNowTimeStamp];
|
|
|
|
|
|
_playerSecondTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(timerChange) userInfo:nil repeats:YES];
|
|
|
[[NSRunLoop currentRunLoop] addTimer:_playerSecondTimer forMode:NSRunLoopCommonModes];
|
|
|
@@ -191,7 +214,73 @@
|
|
|
#pragma mark 控制按钮点击事件
|
|
|
- (void)controlBtnPressed:(UIButton*)but
|
|
|
{
|
|
|
+ playerSetView *nextVC = [[playerSetView alloc] init];
|
|
|
+ [ksharedAppDelegate.window addSubview:nextVC];
|
|
|
+
|
|
|
+ [nextVC mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.top.mas_equalTo(0.f);
|
|
|
+ make.bottom.mas_equalTo(0.f);
|
|
|
+ }];
|
|
|
+
|
|
|
+ KWeakSelf
|
|
|
|
|
|
+ nextVC.didClickButtonFun = ^(NSInteger tag) {
|
|
|
+ switch (tag) {
|
|
|
+ case 10:
|
|
|
+ {//截图
|
|
|
+ //self->needScreenShotType = YES;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+#pragma mark 重启盒子
|
|
|
+ case 11:
|
|
|
+ {
|
|
|
+ //[weakSelf didClickRestartFun];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 12:
|
|
|
+ {//退出云机
|
|
|
+ [weakSelf exitCloudPhoneFun];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 100:
|
|
|
+ {
|
|
|
+// BOOL fullscreenType = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
|
|
|
+// if(fullscreenType){
|
|
|
+// [weakSelf showOpenTVP2PFun];
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// [weakSelf openTvShowFun];
|
|
|
+// }
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 101:
|
|
|
+ {
|
|
|
+// self->mPlayerView.controlBtn.userInteractionEnabled = NO;
|
|
|
+// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+// self->mPlayerView.controlBtn.userInteractionEnabled = YES;
|
|
|
+// });
|
|
|
+// [weakSelf showCloseTVP2PFun];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 退出云机
|
|
|
+- (void)exitCloudPhoneFun
|
|
|
+{
|
|
|
+
|
|
|
+ //[self setShowImgAndVoiceTypeFun:NO];
|
|
|
+ if(_isCodeSuspendAudioType){
|
|
|
+ [[DFPlayer sharedPlayer] df_play];
|
|
|
+ }
|
|
|
+
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];
|
|
|
}
|
|
|
|
|
|
#pragma mark 底部按钮事件
|
|
|
@@ -260,10 +349,43 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#pragma mark 监听到云机的宽高以及屏幕方向
|
|
|
+- (void)handlUIAfterGetCloudPhoneVideoWidth:(int)videoWidth videoHeight:(int)videoHeight rotation:(int)rotation
|
|
|
+{
|
|
|
+ CGFloat curRate = (CGFloat)videoWidth/(CGFloat)videoHeight;
|
|
|
+
|
|
|
+ if(lastVideoWHRate == curRate){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ didAdjusBtnType = NO;
|
|
|
+ if(rotation == 0){//竖屏
|
|
|
+ //切换到竖屏
|
|
|
+ isLan = NO;
|
|
|
+ [self hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
|
|
|
+ [self setPoMas_makeWithImageRate:curRate];
|
|
|
+ }
|
|
|
+ else if(rotation == 1){//横屏
|
|
|
+ //切换到横屏屏
|
|
|
+ isLan = YES;
|
|
|
+ [self hx_rotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
|
|
|
+ [self setLanMas_makeWithImageRate:curRate];
|
|
|
+ }
|
|
|
+
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [self extensionAdjustBtnFrameCheckAdjustTime];
|
|
|
+ });
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark WebRTC 回调 MediaStreamClientEventsDelegate
|
|
|
#pragma mark - 宽高变化
|
|
|
-(void)onFrameResolutionChangedFromPeerName:(NSString*)peerName videoWidth:(int)videoWidth videoHeight:(int)videoHeight rotation:(int)rotation {
|
|
|
HLog(@"peerName:%@---%d---%d--%d",peerName,videoWidth,videoHeight,rotation)
|
|
|
+
|
|
|
+ mainBlock(^{
|
|
|
+ [self handlUIAfterGetCloudPhoneVideoWidth:videoWidth videoHeight:videoHeight rotation:rotation];
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
//code 0 成功 1失败
|
|
|
@@ -272,100 +394,52 @@
|
|
|
HLog(@"onAuthResultFromPeerName:%@---%d---%@",peerName,code,descriptions)
|
|
|
}
|
|
|
|
|
|
-- (void)dataChannelDidChangeFromPeerName:(NSString*)peerName State:(RTCDataChannelState)state{
|
|
|
- ;
|
|
|
-}
|
|
|
-
|
|
|
--(void)onIceConnectedFromPeerName:(NSString*)peerName{
|
|
|
- HLog(@"onIceConnectedFromPeerName:%@",peerName);
|
|
|
- mainBlock(^{
|
|
|
- [self removeNewIndicator];
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
--(void)didGetStats:(NSString*)peerName stats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats {
|
|
|
- HLog(@"stats:%@",stats);
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setPoMas_makeWithImageRate:(CGFloat)w_h_rate{
|
|
|
- /*播放视图*/
|
|
|
-// touchCommondView.isLan = NO;
|
|
|
- BOOL fullScreenShow = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
|
|
|
-
|
|
|
- [_mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- CGFloat scr_W = SCREEN_W;
|
|
|
- CGFloat scr_H = SCREEN_H;
|
|
|
- if (SCREEN_W > SCREEN_H){
|
|
|
- scr_W = SCREEN_H;
|
|
|
- scr_H = SCREEN_W;
|
|
|
- }
|
|
|
- if ((scr_H - scr_W/w_h_rate - 40.f)/2.f < 0){
|
|
|
- if(fullScreenShow){
|
|
|
- make.height.mas_equalTo(scr_H);
|
|
|
- make.width.mas_equalTo(scr_W);
|
|
|
- }
|
|
|
- else{
|
|
|
- make.height.mas_equalTo(scr_H - 40.f);
|
|
|
- make.width.mas_equalTo((scr_H - 40.f)*w_h_rate);
|
|
|
- }
|
|
|
-
|
|
|
- make.centerX.equalTo(self.view.mas_centerX);
|
|
|
- make.top.mas_equalTo(0);
|
|
|
- }
|
|
|
- else{
|
|
|
- make.left.mas_equalTo(0.f);
|
|
|
- make.right.mas_equalTo(0.f);
|
|
|
- if(fullScreenShow){
|
|
|
- make.height.mas_equalTo(scr_H);
|
|
|
- make.top.mas_equalTo(0.f);
|
|
|
- }
|
|
|
- else{
|
|
|
- make.height.mas_equalTo(scr_W/w_h_rate);
|
|
|
- make.top.mas_equalTo((scr_H - scr_W/w_h_rate - 40.f)/2.f);
|
|
|
- }
|
|
|
+#pragma mark 链接发生变化
|
|
|
+-(void)onChangeConnectionStateFromPeerName:(NSString*)peerName didChangeIceConnectionState:(RTCIceConnectionState)state
|
|
|
+{
|
|
|
+ HLog(@"onChangeConnectionStateFromPeerName: state:%ld",state)
|
|
|
+ switch (state) {
|
|
|
+ case RTCIceConnectionStateConnected:{
|
|
|
+ //链接成功
|
|
|
+ mainBlock(^{
|
|
|
+ [self removeNewIndicator];
|
|
|
+ });
|
|
|
}
|
|
|
- }];
|
|
|
+ break;
|
|
|
+ case RTCIceConnectionStateCompleted:
|
|
|
+ //链接完成
|
|
|
+ break;
|
|
|
+ case RTCIceConnectionStateFailed:
|
|
|
+ //链接失败
|
|
|
+ break;
|
|
|
+ case RTCIceConnectionStateDisconnected:
|
|
|
+ //链接断开
|
|
|
+ [self relinkWebRtcFun];
|
|
|
+ break;
|
|
|
+ case RTCIceConnectionStateClosed:
|
|
|
+ //链接关闭
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- [_bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.height.mas_equalTo(40.f);
|
|
|
- make.right.equalTo(_mediaStream.mas_right);
|
|
|
- if(fullScreenShow){
|
|
|
- make.bottom.mas_equalTo(0);
|
|
|
- }
|
|
|
- else{
|
|
|
- make.top.equalTo(_mediaStream.mas_bottom);
|
|
|
- }
|
|
|
- make.left.equalTo(_mediaStream.mas_left);
|
|
|
- }];
|
|
|
+}
|
|
|
|
|
|
- [_bottomContrView updateFrameFun];
|
|
|
+- (void)dataChannelDidChangeFromPeerName:(NSString*)peerName State:(RTCDataChannelState)state{
|
|
|
+ ;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * @brief 设置横屏模式UI布局
|
|
|
- *
|
|
|
- * @param w_h_rate 宽高比
|
|
|
+//-(void)onIceConnectedFromPeerName:(NSString*)peerName{
|
|
|
+// HLog(@"onIceConnectedFromPeerName:%@",peerName);
|
|
|
+// mainBlock(^{
|
|
|
+// [self removeNewIndicator];
|
|
|
+// });
|
|
|
+//}
|
|
|
|
|
|
- */
|
|
|
-- (void)setLanMas_makeWithImageRate:(CGFloat)w_h_rate{
|
|
|
- /*需要考虑专业模式*/
|
|
|
|
|
|
- /*暂时只考虑非专业模式无虚拟键布局*/
|
|
|
- CGFloat h_forPhoneTop = 0;
|
|
|
- if (IPHONE_X){
|
|
|
- h_forPhoneTop = 44.f;
|
|
|
- }
|
|
|
- CGFloat des_W = SCREEN_W<SCREEN_H?SCREEN_W:SCREEN_H;/*实际较小的数字*/
|
|
|
- CGFloat des_H = (SCREEN_W>SCREEN_H?SCREEN_W:SCREEN_H) - h_forPhoneTop;/*实际较大的数字*/
|
|
|
- [_mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.bottom.mas_equalTo(0.f);
|
|
|
- make.width.mas_equalTo(des_W*w_h_rate);
|
|
|
- make.left.mas_equalTo(h_forPhoneTop + (des_H - des_W*w_h_rate)/2.f);
|
|
|
- make.top.mas_equalTo(0);
|
|
|
- }];
|
|
|
-
|
|
|
-
|
|
|
+-(void)didGetStats:(NSString*)peerName stats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats {
|
|
|
+ HLog(@"stats:%@",stats);
|
|
|
}
|
|
|
@end
|