Pārlūkot izejas kodu

1.丢包保留两个小数点

huangxiaodong 11 mēneši atpakaļ
vecāks
revīzija
789256bebd

+ 2 - 2
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -6214,7 +6214,7 @@
 				CODE_SIGN_ENTITLEMENTS = "隐私保护.entitlements";
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 10;
+				CURRENT_PROJECT_VERSION = 11;
 				DEVELOPMENT_TEAM = 6SV76WTUUR;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -6293,7 +6293,7 @@
 				CODE_SIGN_ENTITLEMENTS = "隐私保护.entitlements";
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 10;
+				CURRENT_PROJECT_VERSION = 11;
 				DEVELOPMENT_TEAM = 6SV76WTUUR;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",

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

@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
 @interface playerSetView : UIView
 @property (nonatomic,copy) void (^didClickButtonFun)(NSInteger tag);
 
-- (void)setWebRctMsgBydelayed:(NSInteger)delayedMS withPacketLoss:(NSInteger)PacketLoss withSpeed:(NSString*)speedStr withFPS:(NSString*)fpsStr;
+- (void)setWebRctMsgBydelayed:(NSInteger)delayedMS withPacketLoss:(double)PacketLoss withSpeed:(NSString*)speedStr withFPS:(NSString*)fpsStr;
 
 - (void)setAllSwitchFun;
 @end

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

@@ -200,7 +200,7 @@
 //        make.top.mas_equalTo(laberTop);
 //    }];
     
-    [self setWebRctMsgBydelayed:0 withPacketLoss:@"-" withSpeed:@"-" withFPS:@"-"];
+    [self setWebRctMsgBydelayed:0 withPacketLoss:0.0 withSpeed:@"-" withFPS:@"-"];
     
     /***************************分辨率*******************************************************/
     
@@ -573,7 +573,7 @@
     }
 }
 
-- (void)setWebRctMsgBydelayed:(NSInteger)delayedMS withPacketLoss:(NSInteger)PacketLoss withSpeed:(NSString*)speedStr withFPS:(NSString*)fpsStr
+- (void)setWebRctMsgBydelayed:(NSInteger)delayedMS withPacketLoss:(double)PacketLoss withSpeed:(NSString*)speedStr withFPS:(NSString*)fpsStr
 {
     //网络延迟: [0, 50ms)= 绿色 #22A082 ,[50ms, 100ms= 黄色, [100ms, ∞)= 红色 #FF2855
     
@@ -595,7 +595,7 @@
     }
     
     NSString*LossleftStr = NSLocalizedString(@"webrtc_msg_PacketLoss",nil);
-    NSString*LossRightStr  = [[NSString alloc] initWithFormat:@"%ld%%",PacketLoss];
+    NSString*LossRightStr  = [[NSString alloc] initWithFormat:@"%.02f%%",PacketLoss];
     NSString *LossfullTitle = [[NSString alloc] initWithFormat:@"%@%@",LossleftStr,LossRightStr];
     NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:LossfullTitle];
     NSRange rightRange = NSMakeRange([LossfullTitle rangeOfString:LossRightStr].location, LossRightStr.length);

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

@@ -23,7 +23,7 @@
     //记录上次 总丢包数据
     long lastAlllostData;
     //记录上次 丢包率
-    long prelostRate;
+    double prelostRate;
     double prelostTimestamp;//计算丢包率时间戳(X秒算一次)
     
     BOOL isExitType;//退出云机
@@ -62,6 +62,7 @@
         [[DFPlayer sharedPlayer] df_pause];
     }
    
+    prelostRate = 0.0;
 }
 
 - (void)viewWillAppear:(BOOL)animated {
@@ -1300,14 +1301,19 @@
         else{
             alllostData = audiolostData + videolostData;
             
-            NSInteger lostRate = ((alllostData - lastAlllostData) *1.0 / (allPacketsReceived + (alllostData - lastAlllostData))) *100;
-              //记录上一次丢包数
-            lastAlllostData = alllostData;
-              //记录上一次接收包数
-            lasPacketsReceived = packetsReceived;
+            long NsecondLostData = (alllostData - lastAlllostData) *1.0;
+            long NsecondReceivedData = (allPacketsReceived + (alllostData - lastAlllostData));
             
-            prelostRate = lostRate;
-            prelostTimestamp = curlostTimestamp;
+            if(NsecondReceivedData > 0){
+                double lostRate = (NsecondLostData / NsecondReceivedData) *100;
+                  //记录上一次丢包数
+                lastAlllostData = alllostData;
+                  //记录上一次接收包数
+                lasPacketsReceived = packetsReceived;
+                
+                prelostRate = lostRate;
+                prelostTimestamp = curlostTimestamp;
+            }
         }
     }