Sfoglia il codice sorgente

1.丢包率给测试显示

huangxiaodong 5 mesi fa
parent
commit
5729bbfdeb

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

@@ -39,6 +39,8 @@
 @property (nonatomic, assign) BOOL didReportWebRtcFailType;//上报打洞是否成功
 
 @property (nonatomic, strong)playerSetView *playerSetV;//推流设置页
+
+@property (nonatomic, strong)UILabel *testLostLabel;//测试验证丢包率的
 @end
 
 @implementation webRtcPlayerViewController
@@ -238,7 +240,8 @@
     [ksharedAppDelegate.WebRtcLogger start];
     
     NSString* curToken = @"vclusters";
-    if(ksharedAppDelegate.isImageFor144Orlater){
+    if(ksharedAppDelegate.isImageFor144Orlater)
+    {
         curToken = @"mediakit";
     }
     
@@ -353,6 +356,19 @@
     //gester.delegate = self;
     
     [self initPointForControlBtnFun];
+    
+    _testLostLabel = [[UILabel alloc] init];
+    _testLostLabel.textColor = [UIColor yellowColor];
+    _testLostLabel.textAlignment = NSTextAlignmentCenter;
+    _testLostLabel.font = [UIFont systemFontOfSize:14.0];
+    _testLostLabel.numberOfLines = 0;
+    [self.view addSubview:_testLostLabel];
+    
+    [_testLostLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(20);
+        make.right.mas_equalTo(-20);
+        make.top.mas_equalTo(100.f);
+    }];
 }
 
 #pragma mark 设置 controlBtn 的初始位置
@@ -982,6 +998,7 @@
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(relinkWebRtcFun)  name:didPingBestWebRtcIPRoomNotification        object:nil];
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitCloudPhoneFun)  name:needToPoPCloudPhoneVCNotification        object:nil];
 }
 
 - (void)removeKVOObserverFun
@@ -1261,6 +1278,7 @@
             if([kind isEqualToString:@"video"]){
                 NSNumber*videolostDataNumber = (NSNumber *)[rtcStatistics.values objectForKey:@"packetsLost"];
                 videolostData = [videolostDataNumber longValue];
+                HLog(@"丢包率 视频频%@",videolostDataNumber)
                 
                 NSNumber*framesPerSecondNumber = (NSNumber *)[rtcStatistics.values objectForKey:@"framesPerSecond"];
                 framesPerSecond = [framesPerSecondNumber integerValue];
@@ -1268,6 +1286,7 @@
             else if([kind isEqualToString:@"audio"]){
                 NSNumber*audiolostDataNumber = (NSNumber *)[rtcStatistics.values objectForKey:@"packetsLost"];
                 audiolostData = [audiolostDataNumber longValue];
+                HLog(@"丢包率 音频%@",audiolostDataNumber)
             }
         
         }
@@ -1304,8 +1323,8 @@
         else{
             alllostData = audiolostData + videolostData;
             
-            long NsecondLostData = (alllostData - lastAlllostData) *1.0;
-            long NsecondReceivedData = (allPacketsReceived + (alllostData - lastAlllostData));
+            double NsecondLostData = (alllostData - lastAlllostData) *1.0;
+            double NsecondReceivedData = (allPacketsReceived + (alllostData - lastAlllostData));
             
             if(NsecondReceivedData > 0){
                 double lostRate = (NsecondLostData / NsecondReceivedData) *100;
@@ -1317,29 +1336,32 @@
                 prelostRate = lostRate;
                 prelostTimestamp = curlostTimestamp;
             }
+            
+            //FPS
+            __block NSString*lostDataStr = [[NSString alloc] initWithFormat:@"总包数:%ld --总丢包数:%ld--3秒接受到包数:%ld---3秒丢包数:%ld---3秒丢包率:%0.2f%%",lasPacketsReceived,lastAlllostData,(NSInteger)NsecondReceivedData,(NSInteger)NsecondLostData,prelostRate];
+            
+            mainBlock(^{
+                self->_testLostLabel.text = lostDataStr;
+            });
+            
         }
     }
     
     
     
-    //NSString*lostDataStr = [[NSString alloc] initWithFormat:@"%ld%%",prelostRate];
-    
-    //FPS
-    NSString*FPSStr = @"";//[[NSString alloc] initWithFormat:@"%ld\n",framesPerSecond];
-    
     //网速 传输数据速度
     NSString *netDataSpeedStr = @"";
     if(preReceive/1024.0 > 1024){
         netDataSpeedStr = [NSString stringWithFormat:@"%.01fMB/s",preReceive/1024.0/1024.0];
     }
     else{
-        netDataSpeedStr = [NSString stringWithFormat:@"%ldkB/s",preReceive/1024];
+        netDataSpeedStr = [NSString stringWithFormat:@"%ldKB/s",preReceive/1024];
     }
     
     mainBlock(^{
         if(weakSelf.playerSetV){
             [weakSelf updateControlBtnBgImageWith:delayedMS];
-            [weakSelf.playerSetV setWebRctMsgBydelayed:delayedMS withPacketLoss:self->prelostRate withSpeed:netDataSpeedStr withFPS:FPSStr];
+            [weakSelf.playerSetV setWebRctMsgBydelayed:delayedMS withPacketLoss:self->prelostRate withSpeed:netDataSpeedStr withFPS:@""];
         }
     });