Skip to content

Commit

Permalink
fix: kilobytes is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur committed Aug 31, 2018
1 parent 877d113 commit aa53fd4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dev/googCodecName.video.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ getStatsParser.checkVideoTracks = function(result) {

var packets = result.packetsLost - getStatsResult.internal.video[sendrecvType].prevLostPacket;
kilolostPackets = packets / 1024;
getStatsResult.video[sendrecvType].packetsLostRate = (kilolostPackets / kilobytes).toFixed(4) * 100 + "%";
getStatsResult.video[sendrecvType].packetsLostRate = kilobytes != 0 ? (kilolostPackets / kilobytes).toFixed(4) * 100 + "%" : '0.00%';
}
if (result.googFrameHeightReceived && result.googFrameWidthReceived) {
getStatsResult.resolutions[sendrecvType].width = result.googFrameWidthReceived;
Expand Down
4 changes: 2 additions & 2 deletions getStats.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// Last time updated: 2018-08-30 9:35:45 AM UTC
// Last time updated: 2018-08-31 9:46:30 AM UTC

// _______________
// getStats v1.0.7
Expand Down Expand Up @@ -334,7 +334,7 @@ window.getStats = function(mediaStreamTrack, callback, interval) {

var packets = result.packetsLost - getStatsResult.internal.video[sendrecvType].prevLostPacket;
kilolostPackets = packets / 1024;
getStatsResult.video[sendrecvType].packetsLostRate = (kilolostPackets / kilobytes).toFixed(4) * 100 + "%";
getStatsResult.video[sendrecvType].packetsLostRate = kilobytes != 0 ? (kilolostPackets / kilobytes).toFixed(4) * 100 + "%" : '0.00%';
}
if (result.googFrameHeightReceived && result.googFrameWidthReceived) {
getStatsResult.resolutions[sendrecvType].width = result.googFrameWidthReceived;
Expand Down
Loading

0 comments on commit aa53fd4

Please sign in to comment.