|
|
@@ -22,6 +22,9 @@
|
|
|
long lasPacketsReceived;
|
|
|
//记录上次 总丢包数据
|
|
|
long lastAlllostData;
|
|
|
+ //记录上次 丢包率
|
|
|
+ long prelostRate;
|
|
|
+ double prelostTimestamp;//计算丢包率时间戳(X秒算一次)
|
|
|
|
|
|
BOOL isExitType;//退出云机
|
|
|
|
|
|
@@ -1186,9 +1189,7 @@
|
|
|
_didReportWebRtcFailType = NO;//链接成功后 失败要重新上报
|
|
|
}
|
|
|
|
|
|
- NSString *selectedCandidatePairId = nil;
|
|
|
- NSString *localCandidateId = nil;
|
|
|
- NSString *remoteCandidateId = nil;
|
|
|
+ //NSString *selectedCandidatePairId = nil;
|
|
|
/*延时数据*/
|
|
|
NSNumber *currentRoundTripTime = nil;
|
|
|
|
|
|
@@ -1227,30 +1228,12 @@
|
|
|
|
|
|
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 = (NSString *)[rtcStatistics.values objectForKey:@"selectedCandidatePairId"];
|
|
|
- //HLog(@"三网数据--selectedCandidatePairId-->%@",selectedCandidatePairId);
|
|
|
+ //selectedCandidatePairId = (NSString *)[rtcStatistics.values objectForKey:@"selectedCandidatePairId"];
|
|
|
}
|
|
|
|
|
|
/*丢包数据*/
|
|
|
@@ -1282,125 +1265,53 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //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 = (NSString *)[rtcStatistics.values objectForKey:@"localCandidateId"];
|
|
|
- remoteCandidateId = (NSString *)[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 = (NSString *)[rtcStatistics.values objectForKey:@"candidateType"];
|
|
|
- if (candidateType) {
|
|
|
- localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"candidateType:%@",candidateType]];
|
|
|
- localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
|
|
|
- }
|
|
|
- NSString *address = (NSString *)[rtcStatistics.values objectForKey:@"address"];
|
|
|
- if (address) {
|
|
|
- localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"address:%@",address]];
|
|
|
- localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
|
|
|
- }
|
|
|
- NSString *ip = (NSString *)[rtcStatistics.values objectForKey:@"ip"];
|
|
|
- if (ip) {
|
|
|
- localCandidateStr = [localCandidateStr stringByAppendingString:[NSString stringWithFormat:@"ip:%@",ip]];
|
|
|
- localCandidateStr = [localCandidateStr stringByAppendingString:@"\n"];
|
|
|
- }
|
|
|
- NSString *relatedAddress = (NSString *)[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 = (NSString *)[rtcStatistics.values objectForKey:@"candidateType"];
|
|
|
- if (candidateType) {
|
|
|
- remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"candidateType:%@",candidateType]];
|
|
|
- remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
|
|
|
- }
|
|
|
- NSString *address = (NSString *)[rtcStatistics.values objectForKey:@"address"];
|
|
|
- if (address) {
|
|
|
- remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"address:%@",address]];
|
|
|
- remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
|
|
|
- }
|
|
|
- NSString *ip = (NSString *)[rtcStatistics.values objectForKey:@"ip"];
|
|
|
- if (ip) {
|
|
|
- remoteCandidateStr = [remoteCandidateStr stringByAppendingString:[NSString stringWithFormat:@"ip:%@",ip]];
|
|
|
- remoteCandidateStr = [remoteCandidateStr stringByAppendingString:@"\n"];
|
|
|
- }
|
|
|
- NSString *relatedAddress = (NSString *)[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];
|
|
|
-// }
|
|
|
-// if (remoteCandidateStr) {
|
|
|
-// showStr = [showStr stringByAppendingString:remoteCandidateStr];
|
|
|
-// }
|
|
|
-
|
|
|
+
|
|
|
//网络延迟, 丢包率,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;
|
|
|
+ double curlostTimestamp = [iTools getNowTimeStamp];
|
|
|
+
|
|
|
+ if(prelostTimestamp == 0 || (curlostTimestamp - prelostTimestamp >= 3)){
|
|
|
+
|
|
|
+ long allPacketsReceived = packetsReceived - lasPacketsReceived;
|
|
|
+
|
|
|
+ if(allPacketsReceived < 0){//异常处理
|
|
|
+ lastAlllostData = 0;
|
|
|
+ lasPacketsReceived = 0;
|
|
|
+ prelostRate = 0;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ alllostData = audiolostData + videolostData;
|
|
|
+
|
|
|
+ NSInteger lostRate = ((alllostData - lastAlllostData) *1.0 / (allPacketsReceived + (alllostData - lastAlllostData))) *100;
|
|
|
+ //记录上一次丢包数
|
|
|
+ lastAlllostData = alllostData;
|
|
|
+ //记录上一次接收包数
|
|
|
+ lasPacketsReceived = packetsReceived;
|
|
|
+
|
|
|
+ prelostRate = lostRate;
|
|
|
+ prelostTimestamp = curlostTimestamp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- 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];
|
|
|
+ NSString*lostDataStr = [[NSString alloc] initWithFormat:@"%ld%%",prelostRate];
|
|
|
|
|
|
//FPS
|
|
|
- NSString*FPSStr = [[NSString alloc] initWithFormat:@"%ld\n",framesPerSecond];
|
|
|
- //showStr = [showStr stringByAppendingString:FPSStr];
|
|
|
+ NSString*FPSStr = @"";//[[NSString alloc] initWithFormat:@"%ld\n",framesPerSecond];
|
|
|
|
|
|
//网速 传输数据速度
|
|
|
NSString *netDataSpeedStr = @"";
|
|
|
if(preReceive/1024.0 > 1024){
|
|
|
- netDataSpeedStr = [NSString stringWithFormat:@"%.01fMB/S\n",preReceive/1024.0/1024.0];
|
|
|
+ netDataSpeedStr = [NSString stringWithFormat:@"%.01fMB/S",preReceive/1024.0/1024.0];
|
|
|
}
|
|
|
else{
|
|
|
- netDataSpeedStr = [NSString stringWithFormat:@"%ldkB/S\n",preReceive/1024];
|
|
|
+ netDataSpeedStr = [NSString stringWithFormat:@"%ldkB/S",preReceive/1024];
|
|
|
}
|
|
|
- //showStr = [showStr stringByAppendingString:netDataSpeedStr];
|
|
|
|
|
|
mainBlock(^{
|
|
|
if(weakSelf.playerSetV){
|