|
|
@@ -253,32 +253,33 @@ export default class ConnectionQuality {
|
|
253
|
253
|
let resolution = Resolutions[resolutionName];
|
|
254
|
254
|
|
|
255
|
255
|
let quality = 100;
|
|
|
256
|
+ let packetLoss = undefined;
|
|
|
257
|
+ // TODO: take into account packet loss for received streams
|
|
|
258
|
+ if (this._localStats.packetLoss) {
|
|
|
259
|
+ packetLoss = this._localStats.packetLoss.upload;
|
|
|
260
|
+ }
|
|
256
|
261
|
|
|
257
|
262
|
if (isMuted || !resolution || videoType === VideoType.DESKTOP
|
|
258
|
263
|
|| this._timeIceConnected < 0
|
|
259
|
264
|
|| this._timeVideoUnmuted < 0) {
|
|
260
|
265
|
|
|
261
|
266
|
// Calculate a value based on packet loss only.
|
|
262
|
|
- if (!this._localStats.packetLoss
|
|
263
|
|
- || this._localStats.packetLoss.total === undefined) {
|
|
|
267
|
+ if (packetLoss === undefined) {
|
|
264
|
268
|
logger.error("Cannot calculate connection quality, unknown "
|
|
265
|
269
|
+ "packet loss.");
|
|
266
|
270
|
quality = 100;
|
|
|
271
|
+ } else if (packetLoss <= 2) {
|
|
|
272
|
+ quality = 100; // Full 5 bars.
|
|
|
273
|
+ } else if (packetLoss <= 4) {
|
|
|
274
|
+ quality = 70; // 4 bars
|
|
|
275
|
+ } else if (packetLoss <= 6) {
|
|
|
276
|
+ quality = 50; // 3 bars
|
|
|
277
|
+ } else if (packetLoss <= 8) {
|
|
|
278
|
+ quality = 30; // 2 bars
|
|
|
279
|
+ } else if (packetLoss <= 12) {
|
|
|
280
|
+ quality = 10; // 1 bars
|
|
267
|
281
|
} else {
|
|
268
|
|
- let loss = this._localStats.packetLoss.total;
|
|
269
|
|
- if (loss <= 2) {
|
|
270
|
|
- quality = 100;
|
|
271
|
|
- } else if (loss <= 4) {
|
|
272
|
|
- quality = 70; // 4 bars
|
|
273
|
|
- } else if (loss <= 6) {
|
|
274
|
|
- quality = 50; // 3 bars
|
|
275
|
|
- } else if (loss <= 8) {
|
|
276
|
|
- quality = 30; // 2 bars
|
|
277
|
|
- } else if (loss <= 12) {
|
|
278
|
|
- quality = 10; // 1 bars
|
|
279
|
|
- } else {
|
|
280
|
|
- quality = 0; // Still 1 bar, but slower climb-up.
|
|
281
|
|
- }
|
|
|
282
|
+ quality = 0; // Still 1 bar, but slower climb-up.
|
|
282
|
283
|
}
|
|
283
|
284
|
} else {
|
|
284
|
285
|
// Calculate a value based on the sending bitrate.
|
|
|
@@ -295,8 +296,7 @@ export default class ConnectionQuality {
|
|
295
|
296
|
quality = 100 * this._localStats.bitrate.upload / target;
|
|
296
|
297
|
|
|
297
|
298
|
// Whatever the bitrate, drop early if there is significant loss
|
|
298
|
|
- if (this._localStats.packetLoss
|
|
299
|
|
- && this._localStats.packetLoss.total >= 10) {
|
|
|
299
|
+ if (packetLoss && packetLoss >= 10) {
|
|
300
|
300
|
quality = Math.min(quality, 30);
|
|
301
|
301
|
}
|
|
302
|
302
|
}
|