Просмотр исходного кода

Process stats immediately before setting the interval.

dev1
Boris Grozev 5 лет назад
Родитель
Сommit
c8255f3ab1
1 измененных файлов: 31 добавлений и 31 удалений
  1. 31
    31
      modules/statistics/RTPStatsCollector.js

+ 31
- 31
modules/statistics/RTPStatsCollector.js Просмотреть файл

@@ -354,41 +354,41 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
354 354
         );
355 355
     }
356 356
 
357
-    this.statsIntervalId = setInterval(
358
-        () => {
359
-            // Interval updates
360
-            this.peerconnection.getStats(
361
-                report => {
362
-                    let results = null;
363
-
364
-                    if (!report || !report.result
365
-                        || typeof report.result !== 'function') {
366
-                        // firefox
367
-                        results = report;
357
+    function processStats() {
358
+        // Interval updates
359
+        this.peerconnection.getStats(
360
+            report => {
361
+                let results = null;
362
+
363
+                if (!report || !report.result
364
+                    || typeof report.result !== 'function') {
365
+                    // firefox
366
+                    results = report;
367
+                } else {
368
+                    // chrome
369
+                    results = report.result();
370
+                }
371
+
372
+                this.currentStatsReport = results;
373
+                try {
374
+                    if (this._usesPromiseGetStats) {
375
+                        this.processNewStatsReport();
368 376
                     } else {
369
-                        // chrome
370
-                        results = report.result();
377
+                        this.processStatsReport();
371 378
                     }
379
+                } catch (e) {
380
+                    GlobalOnErrorHandler.callErrorHandler(e);
381
+                    logger.error(`Unsupported key:${e}`, e);
382
+                }
372 383
 
373
-                    this.currentStatsReport = results;
374
-                    try {
375
-                        if (this._usesPromiseGetStats) {
376
-                            this.processNewStatsReport();
377
-                        } else {
378
-                            this.processStatsReport();
379
-                        }
380
-                    } catch (e) {
381
-                        GlobalOnErrorHandler.callErrorHandler(e);
382
-                        logger.error(`Unsupported key:${e}`, e);
383
-                    }
384
+                this.previousStatsReport = this.currentStatsReport;
385
+            },
386
+            error => this.errorCallback(error)
387
+        );
388
+    };
384 389
 
385
-                    this.previousStatsReport = this.currentStatsReport;
386
-                },
387
-                error => this.errorCallback(error)
388
-            );
389
-        },
390
-        this.statsIntervalMilis
391
-    );
390
+    processStats();
391
+    this.statsIntervalId = setInterval(processStats, this.statsIntervalMilis);
392 392
 };
393 393
 
394 394
 /**

Загрузка…
Отмена
Сохранить