|
@@ -71,13 +71,6 @@ let startBitrate = 800;
|
71
|
71
|
* @param videoQualitySettings {Object} the bitrate and codec settings for the local video source.
|
72
|
72
|
*/
|
73
|
73
|
function getTarget(simulcast, resolution, millisSinceStart, videoQualitySettings) {
|
74
|
|
- // Completely ignore the bitrate in the first 5 seconds, as the first
|
75
|
|
- // event seems to fire very early and the value is suspicious and causes
|
76
|
|
- // false positives.
|
77
|
|
- if (millisSinceStart < 15000) {
|
78
|
|
- return 1;
|
79
|
|
- }
|
80
|
|
-
|
81
|
74
|
let target = 0;
|
82
|
75
|
let height = Math.min(resolution.height, resolution.width);
|
83
|
76
|
|
|
@@ -163,6 +156,11 @@ export default class ConnectionQuality {
|
163
|
156
|
*/
|
164
|
157
|
this._lastConnectionQualityUpdate = -1;
|
165
|
158
|
|
|
159
|
+ /**
|
|
160
|
+ * Conference options.
|
|
161
|
+ */
|
|
162
|
+ this._options = options;
|
|
163
|
+
|
166
|
164
|
/**
|
167
|
165
|
* Maps a participant ID to an object holding connection quality
|
168
|
166
|
* statistics received from this participant.
|
|
@@ -182,8 +180,8 @@ export default class ConnectionQuality {
|
182
|
180
|
this._timeVideoUnmuted = -1;
|
183
|
181
|
|
184
|
182
|
// We assume a global startBitrate value for the sake of simplicity.
|
185
|
|
- if (options.config.startBitrate && options.config.startBitrate > 0) {
|
186
|
|
- startBitrate = options.config.startBitrate;
|
|
183
|
+ if (this._options.config?.startBitrate > 0) {
|
|
184
|
+ startBitrate = this._options.config.startBitrate;
|
187
|
185
|
}
|
188
|
186
|
|
189
|
187
|
// TODO: consider ignoring these events and letting the user of
|
|
@@ -354,12 +352,17 @@ export default class ConnectionQuality {
|
354
|
352
|
// Time since sending of video was enabled.
|
355
|
353
|
const millisSinceStart = window.performance.now()
|
356
|
354
|
- Math.max(this._timeVideoUnmuted, this._timeIceConnected);
|
|
355
|
+ const statsInterval = this._options.config?.pcStatsInterval ?? 10000;
|
357
|
356
|
|
358
|
357
|
// Expected sending bitrate in perfect conditions.
|
359
|
358
|
let target = getTarget(isSimulcastOn, resolution, millisSinceStart, videoQualitySettings);
|
360
|
359
|
|
361
|
360
|
target = Math.min(target, MAX_TARGET_BITRATE);
|
362
|
|
- quality = 100 * this._localStats.bitrate.upload / target;
|
|
361
|
+
|
|
362
|
+ // Calculate the quality only after the stats are available (after video was enabled).
|
|
363
|
+ if (millisSinceStart > statsInterval) {
|
|
364
|
+ quality = 100 * this._localStats.bitrate.upload / target;
|
|
365
|
+ }
|
363
|
366
|
}
|
364
|
367
|
|
365
|
368
|
// Whatever the bitrate, drop early if there is significant loss
|