|
@@ -220,22 +220,15 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
|
220
|
220
|
}
|
221
|
221
|
} else {
|
222
|
222
|
// Interval updates
|
223
|
|
- this.peerconnection.getStats(
|
224
|
|
- report => {
|
225
|
|
- let results = null;
|
226
|
|
-
|
227
|
|
- if (!report || !report.result
|
228
|
|
- || typeof report.result !== 'function') {
|
229
|
|
- results = report;
|
230
|
|
- } else {
|
231
|
|
- results = report.result();
|
232
|
|
- }
|
233
|
|
- this.currentAudioLevelsReport = results;
|
|
223
|
+ this.peerconnection.getStats()
|
|
224
|
+ .then(report => {
|
|
225
|
+ this.currentAudioLevelsReport = typeof report?.result === 'function'
|
|
226
|
+ ? report.result()
|
|
227
|
+ : report;
|
234
|
228
|
this.processAudioLevelReport();
|
235
|
229
|
this.baselineAudioLevelsReport = this.currentAudioLevelsReport;
|
236
|
|
- },
|
237
|
|
- error => this.errorCallback(error)
|
238
|
|
- );
|
|
230
|
+ })
|
|
231
|
+ .catch(error => this.errorCallback(error));
|
239
|
232
|
}
|
240
|
233
|
},
|
241
|
234
|
this.audioLevelsIntervalMilis
|
|
@@ -244,20 +237,12 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
|
244
|
237
|
|
245
|
238
|
const processStats = () => {
|
246
|
239
|
// Interval updates
|
247
|
|
- this.peerconnection.getStats(
|
248
|
|
- report => {
|
249
|
|
- let results = null;
|
250
|
|
-
|
251
|
|
- if (!report || !report.result
|
252
|
|
- || typeof report.result !== 'function') {
|
253
|
|
- // firefox
|
254
|
|
- results = report;
|
255
|
|
- } else {
|
256
|
|
- // chrome
|
257
|
|
- results = report.result();
|
258
|
|
- }
|
|
240
|
+ this.peerconnection.getStats()
|
|
241
|
+ .then(report => {
|
|
242
|
+ this.currentStatsReport = typeof report?.result === 'function'
|
|
243
|
+ ? report.result()
|
|
244
|
+ : report;
|
259
|
245
|
|
260
|
|
- this.currentStatsReport = results;
|
261
|
246
|
try {
|
262
|
247
|
this.processStatsReport();
|
263
|
248
|
} catch (error) {
|
|
@@ -265,9 +250,8 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
|
265
|
250
|
logger.error('Processing of RTP stats failed:', error);
|
266
|
251
|
}
|
267
|
252
|
this.previousStatsReport = this.currentStatsReport;
|
268
|
|
- },
|
269
|
|
- error => this.errorCallback(error)
|
270
|
|
- );
|
|
253
|
+ })
|
|
254
|
+ .catch(error => this.errorCallback(error));
|
271
|
255
|
};
|
272
|
256
|
|
273
|
257
|
processStats();
|
|
@@ -680,7 +664,9 @@ StatsCollector.prototype.processStatsReport = function() {
|
680
|
664
|
// Get the number of simulcast streams currently enabled from TPC.
|
681
|
665
|
const numberOfActiveStreams = this.peerconnection.getActiveSimulcastStreams();
|
682
|
666
|
|
683
|
|
- ssrcStats.setFramerate(Math.round((frameRate / numberOfActiveStreams) || 0));
|
|
667
|
+ // Reset frame rate to 0 when video is suspended as a result of endpoint falling out of last-n.
|
|
668
|
+ frameRate = numberOfActiveStreams ? Math.round(frameRate / numberOfActiveStreams) : 0;
|
|
669
|
+ ssrcStats.setFramerate(frameRate);
|
684
|
670
|
}
|
685
|
671
|
});
|
686
|
672
|
|