Parcourir la source

1.推流页云机重启 --- 未完成

huangxiaodong il y a 9 mois
Parent
commit
b6f52dfdcf

+ 106 - 2
创维盒子/双子星云手机/webRtc/webRtcPlayerViewController.m

@@ -18,7 +18,7 @@
     BOOL outputVolumeKVO;/*标记声音监听通知*/
 }
 @property (nonatomic, copy)   NSTimer      *playerSecondTimer; // 定时器-控制按钮
-
+@property (nonatomic, assign) RTCIceConnectionState linkState;
 @end
 
 @implementation webRtcPlayerViewController
@@ -148,6 +148,18 @@
 #pragma mark 重连
 - (void)relinkWebRtcFun
 {
+    if(_linkState == RTCIceConnectionStateConnected
+       || _linkState == RTCIceConnectionStateCompleted)
+    {//链接中 不处理重连事件
+        HLog(@"链接中 不处理重连事件")
+        return;
+    }
+    
+    HLog(@"发起重连 relinkWebRtcFun")
+    mainBlock(^{
+        [self showNewIndicatorWithCanBack:YES canTouch:NO];
+    });
+    
     //判断是否是全屏
     BOOL fullscreenType = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
     CGSize  phoneSize = CGSizeMake(1080.0, 1920.0);
@@ -255,7 +267,7 @@
 #pragma mark 重启盒子
             case 11:
                 {
-                    //[weakSelf didClickRestartFun];
+                    [weakSelf didClickRestartFun];
                 }
                 break;
             case 12:
@@ -290,6 +302,87 @@
     };
 }
 
+#pragma mark 点击了重启云机
+- (void)didClickRestartFun
+{
+    KWeakSelf
+    /*弹窗提示重启*/
+    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
+                                                                                     msg:@""
+                                                                                imageStr:@""
+                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                                                 okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
+                                                                              didClickOk:^{
+        [weakSelf needToRebootFun];
+        //提示语
+        [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
+    } didClickCancel:^{
+        
+    }];
+    nextVC.modalPresentationStyle = UIModalPresentationCustom;
+
+    [self presentViewController:nextVC animated:YES completion:^{
+        nextVC.view.superview.backgroundColor = [UIColor clearColor];
+    }];
+}
+
+#pragma mark p2p通道 重启云机
+- (void)needToRebootFun
+{
+    [[webRtcManager shareManager] needToRebootFun];
+    
+    [self startForceStartTimerFun];
+    
+    //最后一帧 没显示正在重启问题
+    //_canShowImgAndVoiceType = YES;
+    
+    [webRtcManager shareManager].isRebootIngType = YES;
+}
+
+#pragma mark X 秒后检查是否软件重启成功
+- (void)startForceStartTimerFun
+{
+    KWeakSelf
+    //1.  5秒后跟硬件发起硬重启
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        [weakSelf updateForceStartFun];
+    });
+    
+    //2.  20秒后尝试重连
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        [weakSelf relinkWebRtcFun];
+        [[webRtcManager shareManager] relinkWebRtcFun];
+    });
+}
+
+#pragma mark 需要强制重启
+- (void)updateForceStartFun{
+    
+    
+    NSString* curSn = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
+    
+    NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
+    [paraDict setValue:curSn forKey:@"sn"];
+    [paraDict setValue:[NSNumber numberWithBool:YES] forKey:@"isForceStart"];
+    
+    [[netWorkManager shareInstance] CommonPostCallBackCode:updateForceStart Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        
+      SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
+
+       if (model.status == 0) {
+          
+       }
+       else
+       {
+           
+       }
+
+    } failure:^(NSError * _Nonnull error) {
+       HLog(@"%@", error);
+    }];
+}
+
+
 #pragma mark 退出云机
 - (void)exitCloudPhoneFun
 {
@@ -388,6 +481,12 @@
         cardDensity:(NSInteger)cardDensit
 {
     [_mediaStream setCardSize:cardWidth cardHeight:cardHeight cardDensity:cardDensit];
+    
+//    [_mediaStream pauseStream];
+//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+//        [self->_mediaStream resumeStream];
+//    });
+    
 }
 
 #pragma mark -- /*通知添加与移除*/
@@ -485,6 +584,7 @@
 -(void)onChangeConnectionStateFromPeerName:(NSString*)peerName didChangeIceConnectionState:(RTCIceConnectionState)state
 {
     HLog(@"onChangeConnectionStateFromPeerName: state:%ld",state)
+    _linkState = state;
     switch (state) {
         case RTCIceConnectionStateConnected:{
             //链接成功
@@ -498,6 +598,7 @@
             break;
         case RTCIceConnectionStateFailed:
             //链接失败
+            [self relinkWebRtcFun];
             break;
         case RTCIceConnectionStateDisconnected:
             //链接断开
@@ -505,6 +606,9 @@
             break;
         case RTCIceConnectionStateClosed:
             //链接关闭
+            if([webRtcManager shareManager].isRebootIngType){
+                [self relinkWebRtcFun];
+            }
             break;
             
         default: