|
|
@@ -507,6 +507,18 @@ StatsCollector.prototype.processStatsReport = function () {
|
|
507
|
507
|
}
|
|
508
|
508
|
|
|
509
|
509
|
var getStatValue = this._getStatValue;
|
|
|
510
|
+ function getNonNegativeStat(report, name) {
|
|
|
511
|
+ var value = getStatValue(report, name);
|
|
|
512
|
+ if (typeof value !== 'number') {
|
|
|
513
|
+ value = Number(value);
|
|
|
514
|
+ }
|
|
|
515
|
+
|
|
|
516
|
+ if (isNaN(value)) {
|
|
|
517
|
+ return 0;
|
|
|
518
|
+ }
|
|
|
519
|
+
|
|
|
520
|
+ return Math.max(0, value);
|
|
|
521
|
+ }
|
|
510
|
522
|
var byteSentStats = {};
|
|
511
|
523
|
|
|
512
|
524
|
for (var idx in this.currentStatsReport) {
|
|
|
@@ -589,18 +601,11 @@ StatsCollector.prototype.processStatsReport = function () {
|
|
589
|
601
|
if (!packetsNow || packetsNow < 0)
|
|
590
|
602
|
packetsNow = 0;
|
|
591
|
603
|
|
|
592
|
|
- var packetsBefore = getStatValue(before, key);
|
|
593
|
|
- if (!packetsBefore || packetsBefore < 0)
|
|
594
|
|
- packetsBefore = 0;
|
|
|
604
|
+ var packetsBefore = getNonNegativeStat(before, key);
|
|
595
|
605
|
var packetsDiff = Math.max(0, packetsNow - packetsBefore);
|
|
596
|
606
|
|
|
597
|
|
- var packetsLostNow = getStatValue(now, 'packetsLost');
|
|
598
|
|
- if (!packetsLostNow || packetsLostNow < 0)
|
|
599
|
|
- packetsLostNow = 0;
|
|
600
|
|
-
|
|
601
|
|
- var packetsLostBefore = getStatValue(before, 'packetsLost');
|
|
602
|
|
- if (!packetsLostBefore || packetsBefore < 0)
|
|
603
|
|
- packetsLostBefore = 0;
|
|
|
607
|
+ var packetsLostNow = getNonNegativeStat(now, 'packetsLost');
|
|
|
608
|
+ var packetsLostBefore = getNonNegativeStat(before, 'packetsLost');
|
|
604
|
609
|
var packetsLostDiff = Math.max(0, packetsLostNow - packetsLostBefore);
|
|
605
|
610
|
|
|
606
|
611
|
ssrcStats.setSsrcLoss({
|