Browse Source

1.瑞云链接相关逻辑优化

huangxiaodong 1 year ago
parent
commit
53d361951a

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

@@ -148,7 +148,7 @@
     //非扫码进入 进入到这里很可能还没联网拿到设备最新信息
     //非扫码进入 进入到这里很可能还没联网拿到设备最新信息
     if(![connectDeviceManager shareInstance].DeviceThirdIdMod){
     if(![connectDeviceManager shareInstance].DeviceThirdIdMod){
         if(!_checkSNDataTimer){
         if(!_checkSNDataTimer){
-            _checkSNDataTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(enterMainVCFromScene) userInfo:nil repeats:YES];
+            _checkSNDataTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(enterMainVCFromScene) userInfo:nil repeats:YES];
             
             
             //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
             //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
             NSInteger maskModel =  [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
             NSInteger maskModel =  [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
@@ -206,7 +206,7 @@
         [_curPlayerVC disconnectVideoServer];
         [_curPlayerVC disconnectVideoServer];
         
         
         [_curPlayerVC recyclResource];
         [_curPlayerVC recyclResource];
-        ///
+        ///后续要清掉下面的代码
         [_curPlayerVC toStopRecoder];
         [_curPlayerVC toStopRecoder];
         [_curPlayerVC toStopAudioRecoder];
         [_curPlayerVC toStopAudioRecoder];
 
 
@@ -220,6 +220,8 @@
 //        });
 //        });
         /////////
         /////////
         
         
+        _curPlayerVC.liveStreamManager = nil;
+        _curPlayerVC.commandChannelManager = nil;
         _curPlayerVC = nil;
         _curPlayerVC = nil;
     }
     }
     
     

+ 13 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

@@ -2047,6 +2047,19 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
 
 
 - (void)tryAgainInLinkFailFun
 - (void)tryAgainInLinkFailFun
 {
 {
+    
+    if([[connectDeviceManager shareInstance] curConnectDeviceState] <= 3)
+    {
+        //瑞云发起重连
+        NSString *snStr = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
+        if(snStr){
+            _checkThridConnectNum = 1;
+            [[connectDeviceManager shareInstance] getThridMsgBySN:snStr needReconnect:YES didNetEnd:^(bool didSuc) {
+            }];
+        }
+        return;
+    }
+    
     [self showNewIndicator];
     [self showNewIndicator];
     reConnectAccount = 0;
     reConnectAccount = 0;
     [self tryAgain];
     [self tryAgain];

+ 1 - 1
创维盒子/双子星云手机/CloudPlayer/View/PlayerView.m

@@ -71,7 +71,7 @@ ShowImageViewDelegate>{
                   inRect:CGRectMake(0, 0, glkshowImageView.drawableWidth, glkshowImageView.drawableHeight)
                   inRect:CGRectMake(0, 0, glkshowImageView.drawableWidth, glkshowImageView.drawableHeight)
                 fromRect:[ciImage extent]];
                 fromRect:[ciImage extent]];
     
     
-    //[self->glkshowImageView display];
+    [self->glkshowImageView display];
 }
 }
 
 
 - (void)showIMage
 - (void)showIMage

+ 38 - 30
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.m

@@ -59,12 +59,12 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
 {
 {
     if(needReconnect){
     if(needReconnect){
         _curConnectDeviceState = DeviceConnectGetThridMsging;
         _curConnectDeviceState = DeviceConnectGetThridMsging;
-        
+
         //更换设备
         //更换设备
-        NSString *curSdnId = self.DeviceThirdIdMod.data.sdnId;
-        if(curSdnId){
-            _Pre_sdnId = curSdnId;
-        }
+//        NSString *curSdnId = self.DeviceThirdIdMod.data.sdnId;
+//        if(curSdnId){
+//            _Pre_sdnId = curSdnId;
+//        }
         
         
     }
     }
     
     
@@ -139,13 +139,15 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
 
 
 #pragma mark 初始化瑞云的SDK等
 #pragma mark 初始化瑞云的SDK等
 - (void)initRuiyunSDKFun{
 - (void)initRuiyunSDKFun{
-    HLog(@"initRuiyunSDKFun");
     
     
-//    bool connected = [RaylinkProxy.sharedManager isSdnConnected];
-//    if(connected){
-//        [self disconnect];
-//    }
+    bool connected = [RaylinkProxy.sharedManager isSdnConnected];
+    if(connected){
+        [self onConnectFun];
+        return;
+    }
         
         
+    HLog(@"initRuiyunSDKFun");
+    
     self.sdnConnected = NO;
     self.sdnConnected = NO;
     self.peerConnected = NO;
     self.peerConnected = NO;
     
     
@@ -180,7 +182,7 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
         NSLog(@"accept ok %d",self.serverSocket.localPort);
         NSLog(@"accept ok %d",self.serverSocket.localPort);
     }
     }
     
     
-    
+    KWeakSelf
     /// 启动定时器监听 SND 连接状态
     /// 启动定时器监听 SND 连接状态
     self.connectCheckTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 repeats:YES block:^(NSTimer * _Nonnull timer) {
     self.connectCheckTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 repeats:YES block:^(NSTimer * _Nonnull timer) {
         
         
@@ -194,6 +196,9 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
         
         
         if (self.sdnConnected) {
         if (self.sdnConnected) {
             
             
+            [weakSelf onConnectFun];
+            [self->_connectCheckTimer invalidate];
+            
             //self.sdnConnectStateLab.text = @"SDN state: Connected";
             //self.sdnConnectStateLab.text = @"SDN state: Connected";
             //self.sdnIDLab.text = [@"My SDN ID: " stringByAppendingString:[RaylinkProxy.sharedManager getSdnId]];
             //self.sdnIDLab.text = [@"My SDN ID: " stringByAppendingString:[RaylinkProxy.sharedManager getSdnId]];
             
             
@@ -206,34 +211,34 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
     }];
     }];
     
     
     
     
-    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        mainBlock(^{
-            [self onConnectFun];
-        });
-    });
+//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+//        mainBlock(^{
+//            [self onConnectFun];
+//        });
+//    });
 }
 }
 
 
 
 
 - (void)onConnectFun{
 - (void)onConnectFun{
     
     
     // 2. 监听SDN 连接状态
     // 2. 监听SDN 连接状态
-    bool connected = [RaylinkProxy.sharedManager isSdnConnected];
-    
-    HLog(@"协助瑞云看日志onConnectFun isSdnConnected:%d",connected);
-    
-    if(!connected){
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-            mainBlock(^{
-                [self onConnectFun];
-            });
-        });
-        
-        return;
-    }
+//    bool connected = [RaylinkProxy.sharedManager isSdnConnected];
+//
+//    HLog(@"协助瑞云看日志onConnectFun isSdnConnected:%d",connected);
+//
+//    if(!connected){
+//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+//            mainBlock(^{
+//                [self onConnectFun];
+//            });
+//        });
+//
+//        return;
+//    }
     
     
     if (self.peerConnected == YES) {
     if (self.peerConnected == YES) {
         [self disconnect];
         [self disconnect];
-        return;
+        //return;
     }
     }
     
     
     _curConnectDeviceState = DeviceConnectDeciceing;
     _curConnectDeviceState = DeviceConnectDeciceing;
@@ -321,6 +326,9 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
         [self.socket connectToHost:@"127.0.0.1" onPort:self.tcpPort error:NULL];
         [self.socket connectToHost:@"127.0.0.1" onPort:self.tcpPort error:NULL];
         
         
         _curConnectDeviceState = DeviceConnectDeciceOk;
         _curConnectDeviceState = DeviceConnectDeciceOk;
+        
+        _Pre_sdnId = self.DeviceThirdIdMod.data.sdnId;
+        
 //        [self.connectBtn setTitle:@"连接成功" forState:UIControlStateDisabled];
 //        [self.connectBtn setTitle:@"连接成功" forState:UIControlStateDisabled];
 //        [self.sendBtn setEnabled:YES];
 //        [self.sendBtn setEnabled:YES];
     } else {
     } else {