Переглянути джерело

1.推流设置页显示 修改完成

huangxiaodong 8 місяців тому
батько
коміт
835021b7bd

+ 2 - 0
创维盒子/双子星云手机/CloudPlayer/View/playerSetView.h

@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface playerSetView : UIView
 @property (nonatomic,copy) void (^didClickButtonFun)(NSInteger tag);
+
+- (void)setWebRctMsgBydelayed:(NSInteger)delayedMS withPacketLoss:(NSString*)PacketLossStr withSpeed:(NSString*)speedStr withFPS:(NSString*)fpsStr;
 @end
 
 NS_ASSUME_NONNULL_END

+ 143 - 6
创维盒子/双子星云手机/CloudPlayer/View/playerSetView.m

@@ -136,11 +136,128 @@
     
     /***************************顶部按钮显示*******************************************************/
     
-//    UILabel * delayedTipLabel = [UILabel a]
-//    @property(nonatomic, strong) UILabel *delayedLabel;//延时
-//    @property(nonatomic, strong) UILabel *PacketLossLabel;//丢包
-//    @property(nonatomic, strong) UILabel *speedLabel;//速度(带宽)
-//    @property(nonatomic, strong) UILabel *fpsLabel;
+    CGFloat laberTop = 24.0;
+    CGFloat laberW = 30.0;
+    CGFloat laberH = 16.0;
+    
+    //延迟
+    UILabel * delayedTipLabel =  [[UILabel alloc] init];
+    delayedTipLabel.font = [UIFont systemFontOfSize:12.0];
+    delayedTipLabel.textColor = [UIColor whiteColor];
+    delayedTipLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
+    [blackBgView addSubview:delayedTipLabel];
+    //delayedTipLabel.backgroundColor = [UIColor redColor];
+    
+    [delayedTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(15);
+        make.width.mas_equalTo(laberW);
+        make.height.mas_equalTo(laberH);
+        make.top.mas_equalTo(laberTop);
+    }];
+    
+    _delayedLabel =  [[UILabel alloc] init];
+    _delayedLabel.font = [UIFont systemFontOfSize:12.0];
+    //_delayedLabel.textColor = [UIColor whiteColor];
+    //_delayedLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
+    [blackBgView addSubview:_delayedLabel];
+    //_delayedLabel.backgroundColor = [UIColor redColor];
+    
+    [_delayedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(delayedTipLabel.mas_right).offset(0);
+        make.width.mas_equalTo(laberW+5);
+        make.height.mas_equalTo(laberH);
+        make.top.mas_equalTo(laberTop);
+    }];
+    
+    //丢包
+    UILabel * PacketLossTipLabel =  [[UILabel alloc] init];
+    PacketLossTipLabel.font = [UIFont systemFontOfSize:12.0];
+    PacketLossTipLabel.textColor = [UIColor whiteColor];
+    PacketLossTipLabel.text = NSLocalizedString(@"webrtc_msg_PacketLoss",nil);
+    [blackBgView addSubview:PacketLossTipLabel];
+    //delayedTipLabel.backgroundColor = [UIColor redColor];
+    
+    [PacketLossTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.centerX.mas_equalTo(- 1.5*laberW -10);
+        make.width.mas_equalTo(laberW);
+        make.height.mas_equalTo(laberH);
+        make.top.mas_equalTo(laberTop);
+    }];
+    
+    _PacketLossLabel =  [[UILabel alloc] init];
+    _PacketLossLabel.font = [UIFont systemFontOfSize:12.0];
+    _PacketLossLabel.textColor = [UIColor hwColor:@"#FF2855"];
+    //_PacketLossLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
+    [blackBgView addSubview:_PacketLossLabel];
+    //_PacketLossLabel.backgroundColor = [UIColor redColor];
+    
+    [_PacketLossLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(PacketLossTipLabel.mas_right).offset(0);
+        make.width.mas_equalTo(laberW+5);
+        make.height.mas_equalTo(laberH);
+        make.top.mas_equalTo(laberTop);
+    }];
+
+    //带宽
+//    UILabel * speedLossTipLabel =  [[UILabel alloc] init];
+//    speedLossTipLabel.font = [UIFont systemFontOfSize:12.0];
+//    speedLossTipLabel.textColor = [UIColor whiteColor];
+//    speedLossTipLabel.text = NSLocalizedString(@"webrtc_msg_speed",nil);
+//    [blackBgView addSubview:speedLossTipLabel];
+//    //speedLossTipLabel.backgroundColor = [UIColor redColor];
+//    
+//    [speedLossTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+//        make.centerX.mas_equalTo(1.5*laberW -10);
+//        make.width.mas_equalTo(laberW +10 );
+//        make.height.mas_equalTo(laberH);
+//        make.top.mas_equalTo(laberTop);
+//    }];
+    
+    _speedLabel =  [[UILabel alloc] init];
+    _speedLabel.font = [UIFont systemFontOfSize:12.0];
+    _speedLabel.textColor = [UIColor whiteColor];
+    //_speedLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
+    [blackBgView addSubview:_speedLabel];
+    //_speedLabel.backgroundColor = [UIColor redColor];
+    
+    [_speedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.centerX.mas_equalTo(1.5*laberW);
+        make.width.mas_equalTo(laberW*2.9);
+        make.height.mas_equalTo(laberH);
+        make.top.mas_equalTo(laberTop);
+    }];
+    
+    //fps
+//    UILabel * fpsTipLabel =  [[UILabel alloc] init];
+//    fpsTipLabel.font = [UIFont systemFontOfSize:12.0];
+//    fpsTipLabel.textColor = [UIColor whiteColor];
+//    fpsTipLabel.text = @"FPS:";
+//    [blackBgView addSubview:fpsTipLabel];
+//    //speedLossTipLabel.backgroundColor = [UIColor redColor];
+//    
+//    [fpsTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+//        make.right.mas_equalTo(- 15 - 0.5*laberW);
+//        make.width.mas_equalTo(laberW);
+//        make.height.mas_equalTo(laberH);
+//        make.top.mas_equalTo(laberTop);
+//    }];
+    
+    _fpsLabel =  [[UILabel alloc] init];
+    _fpsLabel.textAlignment = NSTextAlignmentRight;
+    _fpsLabel.font = [UIFont systemFontOfSize:12.0];
+    _fpsLabel.textColor = [UIColor whiteColor];
+    //_fpsLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
+    [blackBgView addSubview:_fpsLabel];
+    //_fpsLabel.backgroundColor = [UIColor redColor];
+    
+    [_fpsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.right.mas_equalTo(-15);
+        make.width.mas_equalTo(laberW*2);
+        make.height.mas_equalTo(laberH);
+        make.top.mas_equalTo(laberTop);
+    }];
+    
+    [self setWebRctMsgBydelayed:0 withPacketLoss:@"-" withSpeed:@"-" withFPS:@"-"];
     
     /**********************************************************************************/
     UIView *bg2View = [UIView new];
@@ -207,7 +324,7 @@
         
         UILabel *textLabel = [[UILabel alloc] init];
         textLabel.textAlignment = NSTextAlignmentCenter;
-        textLabel.font = [UIFont systemFontOfSize:10.0];
+        textLabel.font = [UIFont systemFontOfSize:12.0];
         textLabel.textColor = [UIColor whiteColor];
         textLabel.text = titleArr[i];
         [but addSubview:textLabel];
@@ -336,4 +453,24 @@
         _TVShowLabel.text = NSLocalizedString(@"my_set_no_TV_p2p",nil);
     }
 }
+
+- (void)setWebRctMsgBydelayed:(NSInteger)delayedMS withPacketLoss:(NSString*)PacketLossStr withSpeed:(NSString*)speedStr withFPS:(NSString*)fpsStr
+{
+    //网络延迟: [0, 50ms)= 绿色 #22A082 ,[50ms, 100ms= 黄色, [100ms, ∞)= 红色 #FF2855
+    
+    if (delayedMS < 50) {
+        _delayedLabel.textColor = [UIColor hwColor:@"22A082"];
+    }
+    else if (delayedMS < 100){
+        _delayedLabel.textColor = [UIColor yellowColor];
+    }
+    else{
+        _delayedLabel.textColor = [UIColor hwColor:@"#FF2855"];
+    }
+    
+    _delayedLabel.text = [[NSString alloc] initWithFormat:@"%ldms",delayedMS];
+    _PacketLossLabel.text = PacketLossStr;
+    _speedLabel.text = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"webrtc_msg_speed",nil),speedStr];
+    _fpsLabel.text = [[NSString alloc] initWithFormat:@"FPS:%@",fpsStr];
+}
 @end

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

@@ -17,7 +17,6 @@
     
     double lastTimestamp;/*最后一帧时间戳*/
     NSNumber *lastBytesReceived;/*最后一帧数据量*/
-    UILabel* netWorkInfoLabel;//网络延时等信息  正式环境屏蔽
     
     //记录上次 线性增长接收包数
     long lasPacketsReceived;
@@ -32,6 +31,8 @@
 @property (nonatomic, assign) RTCIceConnectionState linkState;
 @property (nonatomic, assign) BOOL didHandleRotation;//第一次处理旋转
 @property (nonatomic, assign) BOOL needToReportWebRtcType;//上报打洞是否成功
+
+@property (nonatomic, strong)playerSetView *playerSetV;//推流设置页
 @end
 
 @implementation webRtcPlayerViewController
@@ -236,21 +237,6 @@
 #pragma mark 初始化其他UI
 - (void)initBaseUIFun
 {
-    if(netWorkInfoLabel){
-        [netWorkInfoLabel removeFromSuperview];
-        netWorkInfoLabel = nil;
-    }
-    netWorkInfoLabel = [[UILabel alloc] init];
-    [netWorkInfoLabel setTextColor:[UIColor greenColor]];
-    [netWorkInfoLabel setBackgroundColor:HW000000Color60];
-    [netWorkInfoLabel setFont:[UIFont systemFontOfSize:17]];
-    [netWorkInfoLabel setNumberOfLines:0];
-    [self.view addSubview:netWorkInfoLabel];
-    
-    [netWorkInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.top.mas_equalTo(80);
-        make.left.mas_equalTo(20);
-    }];
     
     if(_bottomContrView){
         [_bottomContrView removeFromSuperview];
@@ -344,10 +330,22 @@
 #pragma mark 控制按钮点击事件
 - (void)controlBtnPressed:(UIButton*)but
 {
-    playerSetView *nextVC = [[playerSetView alloc] init];
-    [ksharedAppDelegate.window addSubview:nextVC];
+    if(_playerSetV){
+        [ksharedAppDelegate.window addSubview:_playerSetV];
+        [_playerSetV mas_remakeConstraints:^(MASConstraintMaker *make) {
+            make.left.mas_equalTo(0);
+            make.right.mas_equalTo(0);
+            make.top.mas_equalTo(0.f);
+            make.bottom.mas_equalTo(0.f);
+        }];
+        
+        return;
+    }
     
-    [nextVC mas_makeConstraints:^(MASConstraintMaker *make) {
+    _playerSetV = [[playerSetView alloc] init];
+    [ksharedAppDelegate.window addSubview:_playerSetV];
+    
+    [_playerSetV mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0);
         make.right.mas_equalTo(0);
         make.top.mas_equalTo(0.f);
@@ -356,7 +354,7 @@
     
     KWeakSelf
     
-    nextVC.didClickButtonFun = ^(NSInteger tag) {
+    _playerSetV.didClickButtonFun = ^(NSInteger tag) {
         switch (tag) {
             case 200:
                 {//截图
@@ -390,7 +388,7 @@
                 {
                     weakSelf.controlBtn.userInteractionEnabled = NO;
                     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-                        self->controlBtn.userInteractionEnabled = YES;
+                        weakSelf.controlBtn.userInteractionEnabled = YES;
                     });
                     [weakSelf showCloseTVP2PFun];
                 }
@@ -959,181 +957,181 @@
         _needToReportWebRtcType = YES;
     }
     
-//    NSString *selectedCandidatePairId = nil;
-//    NSString *localCandidateId  = nil;
-//    NSString *remoteCandidateId = nil;
-//    /*延时数据*/
-//    NSNumber *currentRoundTripTime = nil;
-//    
-//    //线性增长接收包数
-//    long packetsReceived = 0;
-//   
-//    //视频丢包数据
-//    long videolostData = 0;
-//    //音频丢包数据
-//    long audiolostData = 0;
-//    //总丢包数据
-//    long alllostData = 0;
-//    
-//    //每秒帧数 ----界面展示的帧率
-//    NSInteger framesPerSecond = 0;
-//    
-//    //计算传输速度
-//    long preReceive = 0;
-//    
-//    KWeakSelf
-//    for (NSString *key in [stats.statistics allKeys]) {
-//        RTCStatistics *rtcStatistics = [stats.statistics objectForKey:key];
-//        //HLog(@"hxd11111---->%@",rtcStatistics.type);
-//        
-//        if ([rtcStatistics.type isEqualToString:@"transport"]) {
-//            //HLog(@"传输数据---->%@",rtcStatistics.values);
-//            double timestamp     = rtcStatistics.timestamp_us;
-//            NSNumber *bytesReceived = [rtcStatistics.values objectForKey:@"bytesReceived"];
-//            
-//            NSNumber *packetsReceivedNumber = [rtcStatistics.values objectForKey:@"packetsReceived"];
-//            packetsReceived = [packetsReceivedNumber longValue];
-//            
-//            if (lastTimestamp > 0) {
-//                long diffReceive = [bytesReceived longValue] - [lastBytesReceived longValue];
-//                double diffTime    = timestamp - lastTimestamp;
-//                
-//                preReceive = (diffReceive / diffTime) * 1000000;
-//                
-//                //HLog(@"传输数据速度---->%ld",preReceive);
-//                
-////                mainBlock((^{
-////                    if (self->mPlayerView.upControlView.hidden == NO){
-////                        NSString *str = [NSString stringWithFormat:@"清晰度 %ldk/s",preReceive/1024];
-////                        NSMutableAttributedString *underAttr = [[NSMutableAttributedString alloc] initWithString:str attributes:@{NSForegroundColorAttributeName:[UIColor hwColor:@"#FFFFFF"]}];
-////                        [underAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} range:NSMakeRange(0, str.length - 2)];
-////                        [underAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} range:NSMakeRange(str.length - 2,2)];
-////                        [self->mPlayerView.upControlView.articulationBtn setAttributedTitle:underAttr forState:(UIControlStateNormal)];
-////                    }else{
-////                        NSString *str = [NSString stringWithFormat:@"%ldk/s",preReceive/1024];
-////                        NSMutableAttributedString *underAttr = [[NSMutableAttributedString alloc] initWithString:str attributes:@{NSForegroundColorAttributeName:[UIColor hwColor:@"#FFFFFF"]}];
-////                        [underAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} range:NSMakeRange(0, str.length - 2)];
-////                        [underAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} range:NSMakeRange(str.length - 2,2)];
-////                        [self->mPlayerView.controlBtn setAttributedTitle:underAttr forState:(UIControlStateNormal)];
-////                    }
-////                }));
-//            }else{
-//                lastTimestamp = timestamp;
-//                lastBytesReceived = bytesReceived;
-//            }
-//            
-//            selectedCandidatePairId = [rtcStatistics.values objectForKey:@"selectedCandidatePairId"];
-//            //HLog(@"三网数据--selectedCandidatePairId-->%@",selectedCandidatePairId);
-//        }
-//        
-//        /*丢包数据*/
-//        if ([rtcStatistics.type isEqualToString:@"inbound-rtp"]) {
-//            NSString *kind = [rtcStatistics.values objectForKey:@"kind"];
-//            
-//            if([kind isEqualToString:@"video"]){
-//                NSNumber*videolostDataNumber = [rtcStatistics.values objectForKey:@"packetsLost"];
-//                videolostData = [videolostDataNumber longValue];
-//                
-//                NSNumber*framesPerSecondNumber = [rtcStatistics.values objectForKey:@"framesPerSecond"];
-//                framesPerSecond = [framesPerSecondNumber integerValue];
-//            }
-//            else if([kind isEqualToString:@"audio"]){
-//                NSNumber*audiolostDataNumber = [rtcStatistics.values objectForKey:@"packetsLost"];
-//                audiolostData = [audiolostDataNumber longValue];
-//            }
-//        
-//        }
-//        
-//        for (NSString *keyin in [rtcStatistics.values allKeys]) {
-//            if ([keyin isEqualToString:@"currentRoundTripTime"]){
-//                /*延时数据*/
-//                currentRoundTripTime = [rtcStatistics.values objectForKey:@"currentRoundTripTime"];
-//                  
-//                //[self updateAutoRateAndNetWorkStatesWithDelatyMS:(NSInteger)currentRoundTripTime.floatValue*1000];
-//                break;
-//            }
-//        }
-//    }
-//
-//    //netWorkInfoLabel 网络信息 测试用
-//    
-//    if (selectedCandidatePairId) {
-//        for (NSString *key in [stats.statistics allKeys]) {
-//            RTCStatistics *rtcStatistics = [stats.statistics objectForKey:key];
-//            if ([rtcStatistics.type isEqualToString:@"candidate-pair"]){
-//                NSString *tempselectedCandidatePairId = rtcStatistics.id;
-//                if ([tempselectedCandidatePairId isEqualToString:selectedCandidatePairId]) {
-//                    localCandidateId  = [rtcStatistics.values objectForKey:@"localCandidateId"];
-//                    remoteCandidateId = [rtcStatistics.values objectForKey:@"remoteCandidateId"];
-//
-////                    HLog(@"三网数据--localCandidateId-->%@",localCandidateId);
-////                    HLog(@"三网数据--remoteCandidateId-->%@",remoteCandidateId);
-//                }
-//            }
-//        }
-//    }
-//
-//    NSString *remoteCandidateStr = nil;
-//    NSString *localCandidateStr  = nil;
-//    if (localCandidateId && remoteCandidateId) {
-//        for (NSString *key in [stats.statistics allKeys]) {
-//            RTCStatistics *rtcStatistics = [stats.statistics objectForKey:key];
-//            if ([rtcStatistics.type isEqualToString:@"local-candidate"]){
-//                NSString *templocalCandidateId = rtcStatistics.id;
-//                if ([templocalCandidateId isEqualToString:localCandidateId]) {
-//                    //HLog(@"三网数据--localCandidateIdInfo-->%@",rtcStatistics.values);
-//                    localCandidateStr = @"本地\n";
-//                    NSString *candidateType = [rtcStatistics.values objectForKey:@"candidateType"];
-//                    if (candidateType) {
-//                        localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"candidateType:%@",candidateType]];
-//                        localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
-//                    }
-//                    NSString *address = [rtcStatistics.values objectForKey:@"address"];
-//                    if (address) {
-//                        localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"address:%@",address]];
-//                        localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
-//                    }
-//                    NSString *ip = [rtcStatistics.values objectForKey:@"ip"];
-//                    if (ip) {
-//                        localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"ip:%@",ip]];
-//                        localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
-//                    }
-//                    NSString *relatedAddress = [rtcStatistics.values objectForKey:@"relatedAddress"];
-//                    if (relatedAddress) {
-//                        localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"relatedAddress:%@",relatedAddress]];
-//                        localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
-//                    }
-//                }
-//            }else if ([rtcStatistics.type isEqualToString:@"remote-candidate"]){
-//                NSString *tempRemoteCandidateId = rtcStatistics.id;
-//                if ([tempRemoteCandidateId isEqualToString:remoteCandidateId]) {
-//                    //HLog(@"三网数据--remoteCandidateIdInfo-->%@",rtcStatistics.values);
-//                    remoteCandidateStr = @"远端\n";
-//                    NSString *candidateType = [rtcStatistics.values objectForKey:@"candidateType"];
-//                    if (candidateType) {
-//                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"candidateType:%@",candidateType]];
-//                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
-//                    }
-//                    NSString *address = [rtcStatistics.values objectForKey:@"address"];
-//                    if (address) {
-//                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"address:%@",address]];
-//                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
-//                    }
-//                    NSString *ip = [rtcStatistics.values objectForKey:@"ip"];
-//                    if (ip) {
-//                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"ip:%@",ip]];
-//                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
-//                    }
-//                    NSString *relatedAddress = [rtcStatistics.values objectForKey:@"relatedAddress"];
-//                    if (relatedAddress) {
-//                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"relatedAddress:%@",relatedAddress]];
-//                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
+    NSString *selectedCandidatePairId = nil;
+    NSString *localCandidateId  = nil;
+    NSString *remoteCandidateId = nil;
+    /*延时数据*/
+    NSNumber *currentRoundTripTime = nil;
+    
+    //线性增长接收包数
+    long packetsReceived = 0;
+   
+    //视频丢包数据
+    long videolostData = 0;
+    //音频丢包数据
+    long audiolostData = 0;
+    //总丢包数据
+    long alllostData = 0;
+    
+    //每秒帧数 ----界面展示的帧率
+    NSInteger framesPerSecond = 0;
+    
+    //计算传输速度
+    long preReceive = 0;
+    
+    KWeakSelf
+    for (NSString *key in [stats.statistics allKeys]) {
+        RTCStatistics *rtcStatistics = [stats.statistics objectForKey:key];
+        //HLog(@"hxd11111---->%@",rtcStatistics.type);
+        
+        if ([rtcStatistics.type isEqualToString:@"transport"]) {
+            //HLog(@"传输数据---->%@",rtcStatistics.values);
+            double timestamp     = rtcStatistics.timestamp_us;
+            NSNumber *bytesReceived = [rtcStatistics.values objectForKey:@"bytesReceived"];
+            
+            NSNumber *packetsReceivedNumber = [rtcStatistics.values objectForKey:@"packetsReceived"];
+            packetsReceived = [packetsReceivedNumber longValue];
+            
+            if (lastTimestamp > 0) {
+                long diffReceive = [bytesReceived longValue] - [lastBytesReceived longValue];
+                double diffTime    = timestamp - lastTimestamp;
+                
+                preReceive = (diffReceive / diffTime) * 1000000;
+                
+                //HLog(@"传输数据速度---->%ld",preReceive);
+                
+//                mainBlock((^{
+//                    if (self->mPlayerView.upControlView.hidden == NO){
+//                        NSString *str = [NSString stringWithFormat:@"清晰度 %ldk/s",preReceive/1024];
+//                        NSMutableAttributedString *underAttr = [[NSMutableAttributedString alloc] initWithString:str attributes:@{NSForegroundColorAttributeName:[UIColor hwColor:@"#FFFFFF"]}];
+//                        [underAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} range:NSMakeRange(0, str.length - 2)];
+//                        [underAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} range:NSMakeRange(str.length - 2,2)];
+//                        [self->mPlayerView.upControlView.articulationBtn setAttributedTitle:underAttr forState:(UIControlStateNormal)];
+//                    }else{
+//                        NSString *str = [NSString stringWithFormat:@"%ldk/s",preReceive/1024];
+//                        NSMutableAttributedString *underAttr = [[NSMutableAttributedString alloc] initWithString:str attributes:@{NSForegroundColorAttributeName:[UIColor hwColor:@"#FFFFFF"]}];
+//                        [underAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} range:NSMakeRange(0, str.length - 2)];
+//                        [underAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} range:NSMakeRange(str.length - 2,2)];
+//                        [self->mPlayerView.controlBtn setAttributedTitle:underAttr forState:(UIControlStateNormal)];
 //                    }
-//                }
-//            }
-//        }
-//    }
-//
+//                }));
+            }else{
+                lastTimestamp = timestamp;
+                lastBytesReceived = bytesReceived;
+            }
+            
+            selectedCandidatePairId = [rtcStatistics.values objectForKey:@"selectedCandidatePairId"];
+            //HLog(@"三网数据--selectedCandidatePairId-->%@",selectedCandidatePairId);
+        }
+        
+        /*丢包数据*/
+        if ([rtcStatistics.type isEqualToString:@"inbound-rtp"]) {
+            NSString *kind = [rtcStatistics.values objectForKey:@"kind"];
+            
+            if([kind isEqualToString:@"video"]){
+                NSNumber*videolostDataNumber = [rtcStatistics.values objectForKey:@"packetsLost"];
+                videolostData = [videolostDataNumber longValue];
+                
+                NSNumber*framesPerSecondNumber = [rtcStatistics.values objectForKey:@"framesPerSecond"];
+                framesPerSecond = [framesPerSecondNumber integerValue];
+            }
+            else if([kind isEqualToString:@"audio"]){
+                NSNumber*audiolostDataNumber = [rtcStatistics.values objectForKey:@"packetsLost"];
+                audiolostData = [audiolostDataNumber longValue];
+            }
+        
+        }
+        
+        for (NSString *keyin in [rtcStatistics.values allKeys]) {
+            if ([keyin isEqualToString:@"currentRoundTripTime"]){
+                /*延时数据*/
+                currentRoundTripTime = [rtcStatistics.values objectForKey:@"currentRoundTripTime"];
+                  
+                //[self updateAutoRateAndNetWorkStatesWithDelatyMS:(NSInteger)currentRoundTripTime.floatValue*1000];
+                break;
+            }
+        }
+    }
+
+    //netWorkInfoLabel 网络信息 测试用
+    
+    if (selectedCandidatePairId) {
+        for (NSString *key in [stats.statistics allKeys]) {
+            RTCStatistics *rtcStatistics = [stats.statistics objectForKey:key];
+            if ([rtcStatistics.type isEqualToString:@"candidate-pair"]){
+                NSString *tempselectedCandidatePairId = rtcStatistics.id;
+                if ([tempselectedCandidatePairId isEqualToString:selectedCandidatePairId]) {
+                    localCandidateId  = [rtcStatistics.values objectForKey:@"localCandidateId"];
+                    remoteCandidateId = [rtcStatistics.values objectForKey:@"remoteCandidateId"];
+
+//                    HLog(@"三网数据--localCandidateId-->%@",localCandidateId);
+//                    HLog(@"三网数据--remoteCandidateId-->%@",remoteCandidateId);
+                }
+            }
+        }
+    }
+
+    NSString *remoteCandidateStr = nil;
+    NSString *localCandidateStr  = nil;
+    if (localCandidateId && remoteCandidateId) {
+        for (NSString *key in [stats.statistics allKeys]) {
+            RTCStatistics *rtcStatistics = [stats.statistics objectForKey:key];
+            if ([rtcStatistics.type isEqualToString:@"local-candidate"]){
+                NSString *templocalCandidateId = rtcStatistics.id;
+                if ([templocalCandidateId isEqualToString:localCandidateId]) {
+                    //HLog(@"三网数据--localCandidateIdInfo-->%@",rtcStatistics.values);
+                    localCandidateStr = @"本地\n";
+                    NSString *candidateType = [rtcStatistics.values objectForKey:@"candidateType"];
+                    if (candidateType) {
+                        localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"candidateType:%@",candidateType]];
+                        localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
+                    }
+                    NSString *address = [rtcStatistics.values objectForKey:@"address"];
+                    if (address) {
+                        localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"address:%@",address]];
+                        localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
+                    }
+                    NSString *ip = [rtcStatistics.values objectForKey:@"ip"];
+                    if (ip) {
+                        localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"ip:%@",ip]];
+                        localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
+                    }
+                    NSString *relatedAddress = [rtcStatistics.values objectForKey:@"relatedAddress"];
+                    if (relatedAddress) {
+                        localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"relatedAddress:%@",relatedAddress]];
+                        localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
+                    }
+                }
+            }else if ([rtcStatistics.type isEqualToString:@"remote-candidate"]){
+                NSString *tempRemoteCandidateId = rtcStatistics.id;
+                if ([tempRemoteCandidateId isEqualToString:remoteCandidateId]) {
+                    //HLog(@"三网数据--remoteCandidateIdInfo-->%@",rtcStatistics.values);
+                    remoteCandidateStr = @"远端\n";
+                    NSString *candidateType = [rtcStatistics.values objectForKey:@"candidateType"];
+                    if (candidateType) {
+                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"candidateType:%@",candidateType]];
+                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
+                    }
+                    NSString *address = [rtcStatistics.values objectForKey:@"address"];
+                    if (address) {
+                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"address:%@",address]];
+                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
+                    }
+                    NSString *ip = [rtcStatistics.values objectForKey:@"ip"];
+                    if (ip) {
+                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"ip:%@",ip]];
+                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
+                    }
+                    NSString *relatedAddress = [rtcStatistics.values objectForKey:@"relatedAddress"];
+                    if (relatedAddress) {
+                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"relatedAddress:%@",relatedAddress]];
+                        remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
+                    }
+                }
+            }
+        }
+    }
+
 //    NSString *showStr = @"";
 //    if (localCandidateStr) {
 //        showStr = [showStr stringByAppendingString:localCandidateStr];
@@ -1141,36 +1139,45 @@
 //    if (remoteCandidateStr) {
 //        showStr = [showStr stringByAppendingString:remoteCandidateStr];
 //    }
-//    
-//    //网络延迟, 丢包率,FPS,网速 分辨率   流量
-//    //延时数据
-//    NSString*currentRoundTripTimeStr = [[NSString alloc] initWithFormat:@"延时:%ldms\n",(NSInteger)(currentRoundTripTime.floatValue*1000)];
+    
+    //网络延迟, 丢包率,FPS,网速 分辨率   流量
+    //延时数据
+    NSInteger delayedMS = (NSInteger)(currentRoundTripTime.floatValue*1000);
+//    NSString*currentRoundTripTimeStr = [[NSString alloc] initWithFormat:@"延时:%ldms\n",delayedMS];
 //    showStr = [showStr stringByAppendingString:currentRoundTripTimeStr];
-//    
-//    //计算上次报道到这一次的丢包率---------界面展示百分比丢包率
-//    long allPacketsReceived = packetsReceived - lasPacketsReceived;
-//    alllostData = audiolostData + videolostData;
-//    
-//    NSInteger lostRate = ((alllostData - lastAlllostData) *1.0 / (allPacketsReceived + (alllostData - lastAlllostData))) *100;
-//      //记录上一次丢包数
-//    lastAlllostData = alllostData;
-//      //记录上一次接收包数
-//    lasPacketsReceived = packetsReceived;
-//    
-//    NSString*lostDataStr = [[NSString alloc] initWithFormat:@"丢包率:(%ld/%ld) %ld%%\n",alllostData - lastAlllostData,allPacketsReceived + alllostData - lastAlllostData,lostRate];
-//    showStr = [showStr stringByAppendingString:lostDataStr];
-//    
-//    //FPS
-//    NSString*FPSStr = [[NSString alloc] initWithFormat:@"FPS:%ld\n",framesPerSecond];
-//    showStr = [showStr stringByAppendingString:FPSStr];
-//    
-//    //网速 传输数据速度
-//    NSString *netDataSpeedStr = [NSString stringWithFormat:@"传输数据速度:%ldk/s\n",preReceive/1024];
-//    showStr = [showStr stringByAppendingString:netDataSpeedStr];
-//    
-//    mainBlock(^{
-//        [self->netWorkInfoLabel setText:showStr];
-//    });
+    
+    //计算上次报道到这一次的丢包率---------界面展示百分比丢包率
+    long allPacketsReceived = packetsReceived - lasPacketsReceived;
+    alllostData = audiolostData + videolostData;
+    
+    NSInteger lostRate = ((alllostData - lastAlllostData) *1.0 / (allPacketsReceived + (alllostData - lastAlllostData))) *100;
+      //记录上一次丢包数
+    lastAlllostData = alllostData;
+      //记录上一次接收包数
+    lasPacketsReceived = packetsReceived;
+    
+    NSString*lostDataStr = [[NSString alloc] initWithFormat:@"%ld%%\n",lostRate];
+    //showStr = [showStr stringByAppendingString:lostDataStr];
+    
+    //FPS
+    NSString*FPSStr = [[NSString alloc] initWithFormat:@"%ld\n",framesPerSecond];
+    //showStr = [showStr stringByAppendingString:FPSStr];
+    
+    //网速 传输数据速度
+    NSString *netDataSpeedStr = @"";
+    if(preReceive/1024.0 > 1024){
+        netDataSpeedStr = [NSString stringWithFormat:@"%.01fMB/s\n",preReceive/1024.0/1024.0];
+    }
+    else{
+        netDataSpeedStr = [NSString stringWithFormat:@"%ldkB/s\n",preReceive/1024];
+    }
+    //showStr = [showStr stringByAppendingString:netDataSpeedStr];
+    
+    mainBlock(^{
+        if(weakSelf.playerSetV){
+            [weakSelf.playerSetV setWebRctMsgBydelayed:delayedMS withPacketLoss:lostDataStr withSpeed:netDataSpeedStr withFPS:FPSStr];
+        }
+    });
     
 }
 

+ 3 - 0
创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

@@ -625,3 +625,6 @@
 "common_wwan_open_tip"   = "去开启";
 "no_wifi_warn_tip"   = "当前为非WIFI环境,如果想通过流量传输文件,请到设置页面开启流量传输。";
 "shortcatRep_tip"   = "截图已保存到云机目录control下";
+"webrtc_msg_delayed"   = "延迟:";
+"webrtc_msg_PacketLoss"   = "丢包:";
+"webrtc_msg_speed"   = "带宽:";