瀏覽代碼

1.重连次数改为3秒一次

huangxiaodong 1 年之前
父節點
當前提交
1708eacddf
共有 1 個文件被更改,包括 22 次插入3 次删除
  1. 22 3
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

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

@@ -95,6 +95,8 @@ ComontAlretViewControllerDelegate>
     CIContext *videoContext;
     
     NSInteger reConnectAccount;/*记录重连次数*/
+    NSInteger preTryAginTime;//上次重连时间戳
+    ConnectState RCLiveSteamlinkState;//视频流的链接状态
     
     BOOL isInPan;/*标记是否有手指在活动*/
     
@@ -1186,6 +1188,8 @@ ComontAlretViewControllerDelegate>
     HLog(@"\n------状态回调---state = %d--", state);
     //[[VclCrash sharedInstance] writeContent:[NSString stringWithFormat:@"_connectDisconnect连接返回句柄 = %d--state--=%d-",ihandle,state]];
     
+    RCLiveSteamlinkState = state;
+    
     switch (state){
         case 0:/*连接已释放*/{
         }
@@ -2289,13 +2293,11 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
 BOOL inReconnect = NO;
 - (void)tryAgain
 {
-    reConnectAccount++;
-    
     
     HLog(@"yyyyyyyyyyyyy 重连次数 %ld ",reConnectAccount);
     
     //20231017 修改后台3分钟再次进入 不断转圈圈问题
-    if (reConnectAccount >0 && reConnectAccount == 50 )
+    if (reConnectAccount >0 && reConnectAccount == 10 )
     {
         mainBlock(^{
             
@@ -2316,6 +2318,21 @@ BOOL inReconnect = NO;
         return;
     }
 
+    //hxd add 每次重新连接时间 要间隔3秒
+    NSInteger curTryAginTime = [iTools getNowTimeStamp];
+    if(preTryAginTime > 0
+       && (curTryAginTime - preTryAginTime < 3)){
+        return;
+    }
+    
+    if(RCLiveSteamlinkState == ConnectStateConnected){
+        return;
+    }
+    
+    preTryAginTime = curTryAginTime;
+    
+    reConnectAccount++;
+    
     if(linkFailAlretVC && linkFailAlretVC.view.tag == 2){
         [self WebSocketNeedRelinkFun];//hxd add 20240229
     }
@@ -3005,6 +3022,8 @@ static int  couneeee = 0;
              HLog(@"云手机30s 无渲染数据 自动断开连接");
              self.concentTime = [iTools getNowTimeStamp];
              
+             //这个赋值不是真的链接中 应该是失联了
+             RCLiveSteamlinkState = ConnectStateConnecting;
              [self showNewIndicator];
              [self tryAgain];
         }