Browse Source

1.webrtc部分调整

huangxiaodong 1 year ago
parent
commit
2a11cd3b3a

+ 1 - 1
创维盒子/双子星云手机/AppDelegate/SceneDelegate.m

@@ -448,7 +448,7 @@
             [self showCalculatorVC];
         }
         else{
-            [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
+            [[webRtcManager shareManager] beginToLinkWebRtcFun];
         }
 
     }

+ 2 - 2
创维盒子/双子星云手机/Class/Calculator/CalculatorViewController.m

@@ -415,8 +415,8 @@
                     ksharedAppDelegate.isDidShowPwdType = NO;
                     [self.view removeFromSuperview];
                     //被别的设备挤下线 重新链接 如果是链接中 走这个函数会被return
-                    if(![webSocketManager shareInstance].isWaitShowLogoutAlert){
-                        [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
+                    if(![webRtcManager shareManager].isWaitShowLogoutAlert){
+                        [[webRtcManager shareManager] beginToLinkWebRtcFun];
                         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                             [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
                         });

+ 2 - 2
创维盒子/双子星云手机/Class/Controller/HWWebViewController.m

@@ -357,8 +357,8 @@
                         ksharedAppDelegate.isDidShowPwdType = NO;
                         [self.view removeFromSuperview];
                         //被别的设备挤下线 重新链接 如果是链接中 走这个函数会被return
-                        if(![webSocketManager shareInstance].isWaitShowLogoutAlert){
-                            [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
+                        if(![webRtcManager shareManager].isWaitShowLogoutAlert){
+                            [[webRtcManager shareManager] beginToLinkWebRtcFun];
                             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                 [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
                             });

+ 1 - 1
创维盒子/双子星云手机/Class/Guide/SetPWDSecondViewController.m

@@ -339,7 +339,7 @@
     window.rootViewController = nextVC;
     
     //第一次没有主动链接的问题
-    [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
+    [[webRtcManager shareManager] beginToLinkWebRtcFun];
 }
 
 @end

+ 2 - 2
创维盒子/双子星云手机/Class/Guide/inputPWDViewController.m

@@ -532,8 +532,8 @@
     }
    
     //非隐私模式被别的设备挤下线 重新链接 如果是链接中 走这个函数会被return
-    if(![webSocketManager shareInstance].isWaitShowLogoutAlert){
-        [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
+    if(![webRtcManager shareManager].isWaitShowLogoutAlert){
+        [[webRtcManager shareManager] beginToLinkWebRtcFun];
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
             [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
         });

+ 4 - 5
创维盒子/双子星云手机/Class/Set/ChangeDevice/QRCodeScanForChangeDeviceViewController.m

@@ -372,9 +372,8 @@ bool isDownType22 = YES;
                     [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background) value:YES];
                 }
                 
-                [webSocketManager shareInstance].isChangeBoxType = YES;
-                [[webSocketManager shareInstance].commandChannelManager rc_close];
-                [webSocketManager shareInstance].commandChannelManager = nil;
+                [webRtcManager shareManager].isChangeBoxType = YES;
+                [[webRtcManager shareManager] closeLinkWebRtcFun];
                 
                 //尝试修复偶现扫码切换云机 已经扫码到 要输新SN密码 但是云机显示是旧SN的 延时一秒跳转
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@@ -393,14 +392,14 @@ bool isDownType22 = YES;
                     ksharedAppDelegate.NASShareFileService = nil;
                     HLog(@"isWebSockLinkOKAginType NO")
                     
-                    [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
+                    [[webRtcManager shareManager] beginToLinkWebRtcFun];
                     [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
                 });
                 
                 
             }else{
                 
-                [webSocketManager shareInstance].isChangeBoxType = NO;
+                [webRtcManager shareManager].isChangeBoxType = NO;
                 
 //                if(didSuc == 2){
 //                    [[iToast makeText:NSLocalizedString(@"scan_sn_data_error_tip",nil)] show];

+ 2 - 2
创维盒子/双子星云手机/Class/Set/uploadFile/fileTransfeSet/fileTransferPathCheckViewController.m

@@ -46,7 +46,7 @@
 
 - (void)getFolderListFun
 {
-    [[webSocketManager shareInstance] getBackupFolderListFun];
+    [[webRtcManager shareManager] getBackupFolderListFun];
 }
 
 - (void)drawAnyView{
@@ -315,7 +315,7 @@
     }
     
     
-    [[webSocketManager shareInstance] createBackupsFolderBy:curbackupsDefaultPath];
+    [[webRtcManager shareManager] createBackupsFolderBy:curbackupsDefaultPath];
 }
 
 - (void)createFolderDoneNotFun:(NSNotification *)notification

+ 1 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/uploadImageOrVideoViewController.m

@@ -70,7 +70,7 @@
     }
     [self checkVideoAccessFun];
     
-    [[webSocketManager shareInstance] getBaseInfoFun];
+    [[webRtcManager shareManager] getBaseInfoFun];
 }
 
 - (void)initBaselUIFun

+ 1 - 1
创维盒子/双子星云手机/NAS/NASMySpaceViewController.m

@@ -119,7 +119,7 @@
     
     if(!ksharedAppDelegate.cloudPhoneExtraFileListMod.data){
         _allDataArr = @[];
-        [[webSocketManager shareInstance] getExtraFilesListFun];
+        [[webRtcManager shareManager] getExtraFilesListFun];
     }
     else{
         _allDataArr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;

+ 1 - 1
创维盒子/双子星云手机/NAS/NASViewController.m

@@ -894,7 +894,7 @@
     
     //2. 强制盒子更新弹窗
     if(!didGetSysInfoType){
-        [[webSocketManager shareInstance] getSysInfoFun];
+        [[webRtcManager shareManager] getSysInfoFun];
     }
     
     //3. APP版本更新弹窗

+ 6 - 6
创维盒子/双子星云手机/NAS/view/errorAlertTool.m

@@ -79,14 +79,14 @@ static errorAlertTool *shareInstance = nil;
     }
     
     //重启后重连 出来的
-    if([webSocketManager shareInstance].isRebootIngType){
+    if([webRtcManager shareManager].isRebootIngType){
 //        if(![self isPlayerViewIsTopVCFun]){
 //            [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
 //        }
         return;
     }
     
-    if([webSocketManager shareInstance].isResetingType){
+    if([webRtcManager shareManager].isResetingType){
 //        if(![self isPlayerViewIsTopVCFun]){
 //            [[iToast makeText:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil)] show];
 //        }
@@ -94,12 +94,12 @@ static errorAlertTool *shareInstance = nil;
     }
     
     //切换盒子 出来的
-    if([webSocketManager shareInstance].isChangeBoxType){
+    if([webRtcManager shareManager].isChangeBoxType){
         return;
     }
     
     //被挤下线
-    if([webSocketManager shareInstance].isLogoutByOtherType){
+    if([webRtcManager shareManager].isLogoutByOtherType){
         return;
     }
     
@@ -227,7 +227,7 @@ static errorAlertTool *shareInstance = nil;
 #pragma mark 重启云机
 - (void)needToRebootFun
 {
-    [[webSocketManager shareInstance] needToRebootFun];
+    [[webRtcManager shareManager] needToRebootFun];
     
     [self startForceStartTimerFun];
 }
@@ -251,7 +251,7 @@ static errorAlertTool *shareInstance = nil;
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
         //[weakSelf reconnectDevice];
-        [[webSocketManager shareInstance] WebSocketNeedRelinkFun];
+        [[webRtcManager shareManager] relinkWebRtcFun];
     });
 }
 

+ 6 - 6
创维盒子/双子星云手机/cloudPhone/cloudPhoneViewController.m

@@ -200,10 +200,10 @@
         return;
     }
     
-//    if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
-//        [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
-//        return;
-//    }
+    if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
+        [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
+        return;
+    }
     
     NSInteger tag = but.tag;
     HLog(@"%ld",tag);
@@ -284,7 +284,7 @@
 - (void)sureToRestartCloudPhoneFun{
 //    /*重启云手机*/
 //  通过指令通道发送 {"type":"reboot"}
-    [[webSocketManager shareInstance] needToRebootFun];
+    [[webRtcManager shareManager] needToRebootFun];
     
     //提示语
     [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
@@ -316,7 +316,7 @@
 #pragma mark 点击了恢复出厂
 - (void)gotoResetFun
 {
-    [[webSocketManager shareInstance] needToResetFun];
+    [[webRtcManager shareManager] needToResetFun];
     [self RestoreFactoryingFun];
 }
 

+ 5 - 7
创维盒子/双子星云手机/mine/mineViewController.m

@@ -210,7 +210,7 @@
         case 16:{
             AboutViewController *nextVC = [[AboutViewController alloc] init];
             nextVC.getSysInfo = ^{
-                [[webSocketManager shareInstance] getSysInfoFun];
+                [[webRtcManager shareManager] getSysInfoFun];
             };
             [self pushViewController:nextVC animated:YES];
         }
@@ -481,12 +481,10 @@
         NetButText = NSLocalizedString(@"mine_net_WAN",nil);
     }
     
-    RCSocketCloudPhoneStatus status = [[webSocketManager shareInstance].commandChannelManager rc_socketStatus];
-    HLog(@"rc_socketStatus:%ld",status)
-    if(status == RCSocketCloudPhoneStatusFailed
-       ||status == RCSocketCloudPhoneStatusClosedByServer
-       ||status == RCSocketCloudPhoneStatusClosedByUser
-       ||!ksharedAppDelegate.isWebSockLinkOKAginType//断开了 
+    RTCDataChannelState state = [webRtcManager shareManager].channelState;
+    
+    if(state != RTCDataChannelStateOpen
+       ||!ksharedAppDelegate.isWebSockLinkOKAginType//断开了
        )
     {
         NetButText = NSLocalizedString(@"mine_net_unLink",nil);

+ 23 - 0
创维盒子/双子星云手机/webRtc/webRtcManager/webRtcManager.h

@@ -27,7 +27,30 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property(nonatomic,assign)BOOL isDiDChangePhoneSizeType;//是否修改了分辨率(如果是 进去云机需要重设解码器)
 
+@property(nonatomic,assign) RTCDataChannelState  channelState;
+#pragma mark 开始链接
 - (void)beginToLinkWebRtcFun;
+#pragma mark 重新链接
+- (void)relinkWebRtcFun;
+#pragma mark 关闭链接
+- (void)closeLinkWebRtcFun;
+
+#pragma mark 获取云机系统镜像等信息
+- (void)getSysInfoFun;
+#pragma mark 获取云机基本信息
+- (void)getBaseInfoFun;
+#pragma mark 获取云机剩余空间(包含外挂磁盘)
+- (void)getExtraFilesListFun;
+#pragma mark 重启云机
+- (void)needToRebootFun;
+#pragma mark 恢复出厂设置云机
+- (void)needToResetFun;
+
+//创建备份文件夹
+- (void)createBackupsFolderBy:(NSString*)backupsDefaultPath;
+//获取备份文件夹列表
+- (void)getBackupFolderListFun;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 58 - 3
创维盒子/双子星云手机/webRtc/webRtcManager/webRtcManager.m

@@ -40,6 +40,12 @@
     return self;
 }
 
+#pragma mark 关闭链接
+- (void)closeLinkWebRtcFun
+{
+    [_mediaStream disconnect];
+}
+
 #pragma mark 开始链接
 - (void)beginToLinkWebRtcFun
 {
@@ -410,6 +416,54 @@
 //    }
 }
 
+#pragma mark 重启云机
+- (void)needToRebootFun
+{
+    NSString *commondStr  = @"{\"type\":\"reboot\"}";
+    [self send_data:commondStr];
+    
+    //添加到任务监听
+    [self addCommandSendTaskFunWithType:@"reboot" WithCommandStr:commondStr];
+    
+    //数据埋点
+    [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_restart"];
+    
+    _isRebootIngType = YES;
+}
+
+#pragma mark 恢复出厂设置
+- (void)needToResetFun
+{
+    NSString *commondStr  = @"{\"type\":\"reset\"}";
+    [self send_data:commondStr];
+    
+    //添加到任务监听
+    [self addCommandSendTaskFunWithType:@"reset" WithCommandStr:commondStr];
+    
+    //数据埋点
+    [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_restore_factory"];
+    _isResetingType = YES;
+}
+
+#pragma mark 创建备份文件夹
+- (void)createBackupsFolderBy:(NSString*)backupsDefaultPath
+{
+    NSString *folderName = backupsDefaultPath;
+    
+    if(folderName && folderName.length >0){
+        NSString * commandStr = [RCCommandHelp applyForCreateFolderwithFolderName:folderName];
+        [self send_data:commandStr];
+    }
+}
+
+#pragma mark 获取备份文件夹列表
+- (void)getBackupFolderListFun
+{
+    NSString * commandStr = [RCCommandHelp getCreateFolderList];
+    [self send_data:commandStr];
+}
+
+
 
 #pragma mark 收到的webrtc消息处理
 - (void)handleWebRtcMsgResponseBy:(NSData*)message
@@ -625,9 +679,9 @@
 //            [weakSelf getTvStatusFun];
 //        });
 //    }
-//    else if ([messageType isEqualToString:@"reboot"]){/*重启*/
-//        //[weakSelf stopForceStartTimerFun];
-//    }
+    else if ([messageType isEqualToString:@"reboot"]){/*重启*/
+        //[weakSelf stopForceStartTimerFun];
+    }
 //    else if ([messageType isEqualToString:@"mkdir"]){/*创建文件夹*/
 //        [weakSelf createFolderResponseFun:dataDict];
 //    }
@@ -685,6 +739,7 @@
 #pragma mark 通道连接状态变化监听
 - (void)dataChannelDidChangeFromPeerName:(NSString*)peerName State:(RTCDataChannelState)state
 {
+    self.channelState = state;
     switch (state) {
         case RTCDataChannelStateConnecting:
             {