|
@@ -241,6 +241,13 @@ export default function StatsCollector(
|
241
|
241
|
throw `The browser type '${this._browserType}' isn't supported!`;
|
242
|
242
|
}
|
243
|
243
|
|
|
244
|
+ /**
|
|
245
|
+ * Whether to use the Promise-based getStats API or not.
|
|
246
|
+ * @type {boolean}
|
|
247
|
+ */
|
|
248
|
+ this._usesPromiseGetStats
|
|
249
|
+ = browser.isSafariWithWebrtc() || browser.isFirefox();
|
|
250
|
+
|
244
|
251
|
/**
|
245
|
252
|
* The function which is to be used to retrieve the value associated in a
|
246
|
253
|
* report returned by RTCPeerConnection#getStats with a lib-jitsi-meet
|
|
@@ -249,8 +256,10 @@ export default function StatsCollector(
|
249
|
256
|
* @function
|
250
|
257
|
* @private
|
251
|
258
|
*/
|
252
|
|
- this._getStatValue = this._defineGetStatValueMethod(keys);
|
253
|
|
- this._getNewStatValue = this._defineNewGetStatValueMethod(keys);
|
|
259
|
+ this._getStatValue
|
|
260
|
+ = this._usesPromiseGetStats
|
|
261
|
+ ? this._defineNewGetStatValueMethod(keys)
|
|
262
|
+ : this._defineGetStatValueMethod(keys);
|
254
|
263
|
|
255
|
264
|
this.peerconnection = peerconnection;
|
256
|
265
|
this.baselineAudioLevelsReport = null;
|
|
@@ -322,8 +331,7 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
|
322
|
331
|
results = report.result();
|
323
|
332
|
}
|
324
|
333
|
self.currentAudioLevelsReport = results;
|
325
|
|
- if (browser.isSafariWithWebrtc()
|
326
|
|
- || browser.isFirefox()) {
|
|
334
|
+ if (this._usesPromiseGetStats) {
|
327
|
335
|
self.processNewAudioLevelReport();
|
328
|
336
|
} else {
|
329
|
337
|
self.processAudioLevelReport();
|
|
@@ -358,8 +366,7 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
|
358
|
366
|
|
359
|
367
|
self.currentStatsReport = results;
|
360
|
368
|
try {
|
361
|
|
- if (browser.isSafariWithWebrtc()
|
362
|
|
- || browser.isFirefox()) {
|
|
369
|
+ if (this._usesPromiseGetStats) {
|
363
|
370
|
self.processNewStatsReport();
|
364
|
371
|
} else {
|
365
|
372
|
self.processStatsReport();
|
|
@@ -970,7 +977,7 @@ StatsCollector.prototype.processAudioLevelReport = function() {
|
970
|
977
|
|
971
|
978
|
/**
|
972
|
979
|
* New promised based getStats report processing.
|
973
|
|
- * Tested with chrome, firefox and safari. Not switching it on for for chrome as
|
|
980
|
+ * Tested with chrome, firefox and safari. Not switching it on for chrome as
|
974
|
981
|
* frameRate stat is missing and calculating it using framesSent,
|
975
|
982
|
* gives values double the values seen in webrtc-internals.
|
976
|
983
|
* https://w3c.github.io/webrtc-stats/
|
|
@@ -1061,7 +1068,7 @@ StatsCollector.prototype.processNewStatsReport = function() {
|
1061
|
1068
|
return;
|
1062
|
1069
|
}
|
1063
|
1070
|
|
1064
|
|
- const getStatValue = this._getNewStatValue;
|
|
1071
|
+ const getStatValue = this._getStatValue;
|
1065
|
1072
|
const byteSentStats = {};
|
1066
|
1073
|
|
1067
|
1074
|
this.currentStatsReport.forEach(now => {
|