|
@@ -301,8 +301,6 @@ StatsCollector.prototype.errorCallback = function(error) {
|
301
|
301
|
* Starts stats updates.
|
302
|
302
|
*/
|
303
|
303
|
StatsCollector.prototype.start = function(startAudioLevelStats) {
|
304
|
|
- const self = this;
|
305
|
|
-
|
306
|
304
|
if (startAudioLevelStats) {
|
307
|
305
|
if (browser.supportsReceiverStats()) {
|
308
|
306
|
logger.info('Using RTCRtpSynchronizationSource for remote audio levels');
|
|
@@ -356,12 +354,9 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
|
356
|
354
|
);
|
357
|
355
|
}
|
358
|
356
|
|
359
|
|
- /**
|
360
|
|
- * Call getStats on the PeerConnection and process the result.
|
361
|
|
- */
|
362
|
|
- function processStats() {
|
|
357
|
+ const processStats = () => {
|
363
|
358
|
// Interval updates
|
364
|
|
- self.peerconnection.getStats(
|
|
359
|
+ this.peerconnection.getStats(
|
365
|
360
|
report => {
|
366
|
361
|
let results = null;
|
367
|
362
|
|
|
@@ -374,23 +369,23 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
|
374
|
369
|
results = report.result();
|
375
|
370
|
}
|
376
|
371
|
|
377
|
|
- self.currentStatsReport = results;
|
|
372
|
+ this.currentStatsReport = results;
|
378
|
373
|
try {
|
379
|
|
- if (self._usesPromiseGetStats) {
|
380
|
|
- self.processNewStatsReport();
|
|
374
|
+ if (this._usesPromiseGetStats) {
|
|
375
|
+ this.processNewStatsReport();
|
381
|
376
|
} else {
|
382
|
|
- self.processStatsReport();
|
|
377
|
+ this.processStatsReport();
|
383
|
378
|
}
|
384
|
379
|
} catch (e) {
|
385
|
380
|
GlobalOnErrorHandler.callErrorHandler(e);
|
386
|
381
|
logger.error(`Unsupported key:${e}`, e);
|
387
|
382
|
}
|
388
|
383
|
|
389
|
|
- self.previousStatsReport = self.currentStatsReport;
|
|
384
|
+ this.previousStatsReport = this.currentStatsReport;
|
390
|
385
|
},
|
391
|
|
- error => self.errorCallback(error)
|
|
386
|
+ error => this.errorCallback(error)
|
392
|
387
|
);
|
393
|
|
- }
|
|
388
|
+ };
|
394
|
389
|
|
395
|
390
|
processStats();
|
396
|
391
|
this.statsIntervalId = setInterval(processStats, this.statsIntervalMilis);
|