Browse Source

1.添加webrtc 链接失败的状态上报

huangxiaodong 1 year ago
parent
commit
fa70f63363

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

@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
 + (instancetype)shareManager;
 
 @property (nonatomic, strong) AMediaStream *mediaStream;
-@property (nonatomic, assign) BOOL needToReportWebRtcType;
+@property (nonatomic, assign) BOOL didReportWebRtcType;
 
 @property(nonatomic,assign)BOOL isRebootIngType;//是否重启中
 @property(nonatomic,assign)BOOL isResetingType;//是否恢复出厂中

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

@@ -15,6 +15,7 @@
 {
     NSMutableArray *commandSendCheckArr;//需要检测任务是否发出的的指令
     NSTimer      *linkCheckSecondTimer; // 检测链接状态
+    NSInteger  tryRelinkNum;//重连次数
 }
 
 //第一次链接设备 要发送指令信息 实现单点登录
@@ -57,6 +58,15 @@
        ||(_ConnectionState != RTCIceConnectionStateConnected
           && _ConnectionState != RTCIceConnectionStateCompleted)
        ){
+        
+        if(!_didReportWebRtcType){//还没上报过通道链接情况
+            tryRelinkNum ++;
+            if(tryRelinkNum == 2){
+                _didReportWebRtcType = YES;
+                [self reportWebRtcRePoportTypeIsChannel:YES withStats:nil];
+            }
+        }
+        
         [self relinkWebRtcFun];
     }
 }
@@ -856,9 +866,13 @@
             break;
         case RTCIceConnectionStateFailed:
         case RTCIceConnectionStateDisconnected:
-        case RTCIceConnectionStateClosed:
+        case RTCIceConnectionStateClosed:{
+            if(!_didReportWebRtcType){//还没上报过通道链接情况
+                [self reportWebRtcRePoportTypeIsChannel:YES withStats:nil];
+            }
             //链接关闭
             [self relinkWebRtcFun];
+        }
             break;
             
         default:
@@ -915,9 +929,10 @@
 -(void)didGetStats:(NSString*)peerName stats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats
 {
     //HLog(@"didGetStats:%@",stats)
-    if(!_needToReportWebRtcType){
+    if(!_didReportWebRtcType
+       && (self.ConnectionState == RTCIceConnectionStateConnected ||self.ConnectionState == RTCIceConnectionStateCompleted)){
         [self reportWebRtcRePoportTypeIsChannel:YES withStats:stats];
-        _needToReportWebRtcType = YES;
+        _didReportWebRtcType = YES;
         [_mediaStream setShouldGetStats:NO];
     }
 }

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

@@ -27,11 +27,12 @@
     
     NSInteger checkLinkTimerNumber;//0 --2 开始发起重连
     NSInteger preDelayedMS;//记录上一次延时数据 控制controlBtn 的图片刷新 非必要 不刷新
+    NSInteger  tryRelinkNum;//重连次数
 }
 @property (nonatomic, copy)   NSTimer      *playerSecondTimer; // 定时器-控制按钮
 @property (nonatomic, assign) RTCIceConnectionState linkState;
 @property (nonatomic, assign) BOOL didHandleRotation;//第一次处理旋转
-@property (nonatomic, assign) BOOL needToReportWebRtcType;//上报打洞是否成功
+@property (nonatomic, assign) BOOL didReportWebRtcType;//上报打洞是否成功
 
 @property (nonatomic, strong)playerSetView *playerSetV;//推流设置页
 @end
@@ -330,6 +331,15 @@
         
         if(_linkState != RTCIceConnectionStateConnected
            && _linkState != RTCIceConnectionStateCompleted){
+            
+            if(!_didReportWebRtcType){//还没上报过通道链接情况
+                tryRelinkNum ++;
+                if(tryRelinkNum == 6){
+                    _didReportWebRtcType = YES;
+                    [[webRtcManager shareManager] reportWebRtcRePoportTypeIsChannel:YES withStats:nil];
+                }
+            }
+            
             [self relinkWebRtcFun];
         }
     }
@@ -948,9 +958,13 @@
             break;
         case RTCIceConnectionStateFailed:
         case RTCIceConnectionStateDisconnected:
-        case RTCIceConnectionStateClosed:
+        case RTCIceConnectionStateClosed:{
+            if(!_didReportWebRtcType){//还没上报过通道链接情况
+                [[webRtcManager shareManager] reportWebRtcRePoportTypeIsChannel:YES withStats:nil];
+            }
             //链接关闭
             [self relinkWebRtcFun];
+        }
             break;
             
         default:
@@ -1004,9 +1018,9 @@
 
 -(void)didGetStats:(NSString*)peerName stats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats {
     
-    if(!_needToReportWebRtcType){
+    if(!_didReportWebRtcType){
         [[webRtcManager shareManager] reportWebRtcRePoportTypeIsChannel:NO withStats:stats];
-        _needToReportWebRtcType = YES;
+        _didReportWebRtcType = YES;
     }
     
     NSString *selectedCandidatePairId = nil;