@whereby.com/media 1.16.1 → 1.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +31 -16
- package/dist/index.mjs +31 -16
- package/dist/legacy-esm.js +31 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1443,48 +1443,65 @@ fromLocation(window && window.location);
|
|
|
1443
1443
|
|
|
1444
1444
|
const logger$9 = new Logger();
|
|
1445
1445
|
const debugLogger = {
|
|
1446
|
-
print: (...args) => console.
|
|
1446
|
+
print: (...args) => console.debug(args[0], ...args.slice(1)),
|
|
1447
1447
|
};
|
|
1448
1448
|
logger$9.withDebugLogger(debugLogger);
|
|
1449
1449
|
class PacketLossAnalyser {
|
|
1450
1450
|
constructor() {
|
|
1451
|
-
this.
|
|
1452
|
-
this.
|
|
1451
|
+
this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD = 0.04;
|
|
1452
|
+
this.END_PACKET_LOSS_PERIOD_THRESHOLD = 0.005;
|
|
1453
|
+
this.INTERVAL_DIFF_THRESHOLD_MS = 4000;
|
|
1453
1454
|
this.STALE_MEASUREMENT_TIMEOUT_MS = 10000;
|
|
1455
|
+
this.MINIMUM_INTERVAL_MS = 30000;
|
|
1454
1456
|
this.ssrcsHistory = new Map();
|
|
1455
1457
|
this.staleMeasurementTimeouts = new Map();
|
|
1456
1458
|
}
|
|
1457
1459
|
addPacketLossMeasurement(id, packetLoss, timestamp) {
|
|
1458
|
-
logger$9.debug("addPacketLossMeasurement() [ssrcId: %s, loss: %s, timestamp: %s]", id, packetLoss, timestamp);
|
|
1459
1460
|
this.handleStaleMeasurements(id);
|
|
1460
|
-
const
|
|
1461
|
+
const beginNewPacketLossPeriod = packetLoss > this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD;
|
|
1461
1462
|
let history = this.ssrcsHistory.get(id);
|
|
1462
1463
|
if (!history) {
|
|
1463
1464
|
history = {
|
|
1464
1465
|
id,
|
|
1465
|
-
hasActivePacketLoss:
|
|
1466
|
-
currPeriod:
|
|
1466
|
+
hasActivePacketLoss: beginNewPacketLossPeriod,
|
|
1467
|
+
currPeriod: beginNewPacketLossPeriod ? { begin: timestamp } : undefined,
|
|
1467
1468
|
hasPeriodicPacketLoss: false,
|
|
1468
1469
|
};
|
|
1469
1470
|
this.ssrcsHistory.set(id, history);
|
|
1470
1471
|
return;
|
|
1471
1472
|
}
|
|
1472
1473
|
if (history.hasActivePacketLoss) {
|
|
1473
|
-
if (
|
|
1474
|
+
if (packetLoss < this.END_PACKET_LOSS_PERIOD_THRESHOLD) {
|
|
1474
1475
|
this.endPacketLossPeriod(history, timestamp);
|
|
1476
|
+
if (history.prevIntervalInMs && history.prevIntervalInMs < this.MINIMUM_INTERVAL_MS) {
|
|
1477
|
+
this.ssrcsHistory.delete(id);
|
|
1478
|
+
}
|
|
1475
1479
|
}
|
|
1476
1480
|
return;
|
|
1477
1481
|
}
|
|
1478
|
-
if (
|
|
1482
|
+
if (beginNewPacketLossPeriod) {
|
|
1479
1483
|
history.hasActivePacketLoss = true;
|
|
1480
1484
|
history.currPeriod = {
|
|
1481
1485
|
begin: timestamp,
|
|
1482
1486
|
};
|
|
1483
1487
|
}
|
|
1484
1488
|
}
|
|
1485
|
-
hasPeriodicPacketLoss(id) {
|
|
1486
|
-
|
|
1487
|
-
|
|
1489
|
+
hasPeriodicPacketLoss(id, timestamp) {
|
|
1490
|
+
const history = this.ssrcsHistory.get(id);
|
|
1491
|
+
if (history && this.prevIntervalExceeded(history, timestamp)) {
|
|
1492
|
+
this.ssrcsHistory.delete(history.id);
|
|
1493
|
+
return false;
|
|
1494
|
+
}
|
|
1495
|
+
return (history === null || history === void 0 ? void 0 : history.hasPeriodicPacketLoss) || false;
|
|
1496
|
+
}
|
|
1497
|
+
prevIntervalExceeded(history, timestamp) {
|
|
1498
|
+
if (history.prevPeriod && history.prevIntervalInMs) {
|
|
1499
|
+
const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) +
|
|
1500
|
+
history.prevIntervalInMs +
|
|
1501
|
+
this.INTERVAL_DIFF_THRESHOLD_MS;
|
|
1502
|
+
return timestamp > intervalLimitTimestamp;
|
|
1503
|
+
}
|
|
1504
|
+
return false;
|
|
1488
1505
|
}
|
|
1489
1506
|
handleStaleMeasurements(id) {
|
|
1490
1507
|
const staleMeasurementTimeout = this.staleMeasurementTimeouts.get(id);
|
|
@@ -1492,7 +1509,7 @@ class PacketLossAnalyser {
|
|
|
1492
1509
|
clearTimeout(staleMeasurementTimeout);
|
|
1493
1510
|
}
|
|
1494
1511
|
this.staleMeasurementTimeouts.set(id, setTimeout(() => {
|
|
1495
|
-
logger$9.debug("
|
|
1512
|
+
logger$9.debug("handleStaleMeasurements() [measurements invalid for ssrc: %s]", id);
|
|
1496
1513
|
this.ssrcsHistory.delete(id);
|
|
1497
1514
|
}, this.STALE_MEASUREMENT_TIMEOUT_MS));
|
|
1498
1515
|
}
|
|
@@ -1540,9 +1557,7 @@ const periodicPacketLossDetector = {
|
|
|
1540
1557
|
},
|
|
1541
1558
|
check: ({ ssrc0 }) => {
|
|
1542
1559
|
packetLossAnalyser.addPacketLossMeasurement(ssrc0.ssrc, ssrc0.fractionLost || 0, Date.now());
|
|
1543
|
-
|
|
1544
|
-
return true;
|
|
1545
|
-
return false;
|
|
1560
|
+
return packetLossAnalyser.hasPeriodicPacketLoss(ssrc0.ssrc, Date.now());
|
|
1546
1561
|
},
|
|
1547
1562
|
};
|
|
1548
1563
|
const badNetworkIssueDetector = {
|
package/dist/index.mjs
CHANGED
|
@@ -1422,48 +1422,65 @@ fromLocation(window && window.location);
|
|
|
1422
1422
|
|
|
1423
1423
|
const logger$9 = new Logger();
|
|
1424
1424
|
const debugLogger = {
|
|
1425
|
-
print: (...args) => console.
|
|
1425
|
+
print: (...args) => console.debug(args[0], ...args.slice(1)),
|
|
1426
1426
|
};
|
|
1427
1427
|
logger$9.withDebugLogger(debugLogger);
|
|
1428
1428
|
class PacketLossAnalyser {
|
|
1429
1429
|
constructor() {
|
|
1430
|
-
this.
|
|
1431
|
-
this.
|
|
1430
|
+
this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD = 0.04;
|
|
1431
|
+
this.END_PACKET_LOSS_PERIOD_THRESHOLD = 0.005;
|
|
1432
|
+
this.INTERVAL_DIFF_THRESHOLD_MS = 4000;
|
|
1432
1433
|
this.STALE_MEASUREMENT_TIMEOUT_MS = 10000;
|
|
1434
|
+
this.MINIMUM_INTERVAL_MS = 30000;
|
|
1433
1435
|
this.ssrcsHistory = new Map();
|
|
1434
1436
|
this.staleMeasurementTimeouts = new Map();
|
|
1435
1437
|
}
|
|
1436
1438
|
addPacketLossMeasurement(id, packetLoss, timestamp) {
|
|
1437
|
-
logger$9.debug("addPacketLossMeasurement() [ssrcId: %s, loss: %s, timestamp: %s]", id, packetLoss, timestamp);
|
|
1438
1439
|
this.handleStaleMeasurements(id);
|
|
1439
|
-
const
|
|
1440
|
+
const beginNewPacketLossPeriod = packetLoss > this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD;
|
|
1440
1441
|
let history = this.ssrcsHistory.get(id);
|
|
1441
1442
|
if (!history) {
|
|
1442
1443
|
history = {
|
|
1443
1444
|
id,
|
|
1444
|
-
hasActivePacketLoss:
|
|
1445
|
-
currPeriod:
|
|
1445
|
+
hasActivePacketLoss: beginNewPacketLossPeriod,
|
|
1446
|
+
currPeriod: beginNewPacketLossPeriod ? { begin: timestamp } : undefined,
|
|
1446
1447
|
hasPeriodicPacketLoss: false,
|
|
1447
1448
|
};
|
|
1448
1449
|
this.ssrcsHistory.set(id, history);
|
|
1449
1450
|
return;
|
|
1450
1451
|
}
|
|
1451
1452
|
if (history.hasActivePacketLoss) {
|
|
1452
|
-
if (
|
|
1453
|
+
if (packetLoss < this.END_PACKET_LOSS_PERIOD_THRESHOLD) {
|
|
1453
1454
|
this.endPacketLossPeriod(history, timestamp);
|
|
1455
|
+
if (history.prevIntervalInMs && history.prevIntervalInMs < this.MINIMUM_INTERVAL_MS) {
|
|
1456
|
+
this.ssrcsHistory.delete(id);
|
|
1457
|
+
}
|
|
1454
1458
|
}
|
|
1455
1459
|
return;
|
|
1456
1460
|
}
|
|
1457
|
-
if (
|
|
1461
|
+
if (beginNewPacketLossPeriod) {
|
|
1458
1462
|
history.hasActivePacketLoss = true;
|
|
1459
1463
|
history.currPeriod = {
|
|
1460
1464
|
begin: timestamp,
|
|
1461
1465
|
};
|
|
1462
1466
|
}
|
|
1463
1467
|
}
|
|
1464
|
-
hasPeriodicPacketLoss(id) {
|
|
1465
|
-
|
|
1466
|
-
|
|
1468
|
+
hasPeriodicPacketLoss(id, timestamp) {
|
|
1469
|
+
const history = this.ssrcsHistory.get(id);
|
|
1470
|
+
if (history && this.prevIntervalExceeded(history, timestamp)) {
|
|
1471
|
+
this.ssrcsHistory.delete(history.id);
|
|
1472
|
+
return false;
|
|
1473
|
+
}
|
|
1474
|
+
return (history === null || history === void 0 ? void 0 : history.hasPeriodicPacketLoss) || false;
|
|
1475
|
+
}
|
|
1476
|
+
prevIntervalExceeded(history, timestamp) {
|
|
1477
|
+
if (history.prevPeriod && history.prevIntervalInMs) {
|
|
1478
|
+
const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) +
|
|
1479
|
+
history.prevIntervalInMs +
|
|
1480
|
+
this.INTERVAL_DIFF_THRESHOLD_MS;
|
|
1481
|
+
return timestamp > intervalLimitTimestamp;
|
|
1482
|
+
}
|
|
1483
|
+
return false;
|
|
1467
1484
|
}
|
|
1468
1485
|
handleStaleMeasurements(id) {
|
|
1469
1486
|
const staleMeasurementTimeout = this.staleMeasurementTimeouts.get(id);
|
|
@@ -1471,7 +1488,7 @@ class PacketLossAnalyser {
|
|
|
1471
1488
|
clearTimeout(staleMeasurementTimeout);
|
|
1472
1489
|
}
|
|
1473
1490
|
this.staleMeasurementTimeouts.set(id, setTimeout(() => {
|
|
1474
|
-
logger$9.debug("
|
|
1491
|
+
logger$9.debug("handleStaleMeasurements() [measurements invalid for ssrc: %s]", id);
|
|
1475
1492
|
this.ssrcsHistory.delete(id);
|
|
1476
1493
|
}, this.STALE_MEASUREMENT_TIMEOUT_MS));
|
|
1477
1494
|
}
|
|
@@ -1519,9 +1536,7 @@ const periodicPacketLossDetector = {
|
|
|
1519
1536
|
},
|
|
1520
1537
|
check: ({ ssrc0 }) => {
|
|
1521
1538
|
packetLossAnalyser.addPacketLossMeasurement(ssrc0.ssrc, ssrc0.fractionLost || 0, Date.now());
|
|
1522
|
-
|
|
1523
|
-
return true;
|
|
1524
|
-
return false;
|
|
1539
|
+
return packetLossAnalyser.hasPeriodicPacketLoss(ssrc0.ssrc, Date.now());
|
|
1525
1540
|
},
|
|
1526
1541
|
};
|
|
1527
1542
|
const badNetworkIssueDetector = {
|
package/dist/legacy-esm.js
CHANGED
|
@@ -1422,48 +1422,65 @@ fromLocation(window && window.location);
|
|
|
1422
1422
|
|
|
1423
1423
|
const logger$9 = new Logger();
|
|
1424
1424
|
const debugLogger = {
|
|
1425
|
-
print: (...args) => console.
|
|
1425
|
+
print: (...args) => console.debug(args[0], ...args.slice(1)),
|
|
1426
1426
|
};
|
|
1427
1427
|
logger$9.withDebugLogger(debugLogger);
|
|
1428
1428
|
class PacketLossAnalyser {
|
|
1429
1429
|
constructor() {
|
|
1430
|
-
this.
|
|
1431
|
-
this.
|
|
1430
|
+
this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD = 0.04;
|
|
1431
|
+
this.END_PACKET_LOSS_PERIOD_THRESHOLD = 0.005;
|
|
1432
|
+
this.INTERVAL_DIFF_THRESHOLD_MS = 4000;
|
|
1432
1433
|
this.STALE_MEASUREMENT_TIMEOUT_MS = 10000;
|
|
1434
|
+
this.MINIMUM_INTERVAL_MS = 30000;
|
|
1433
1435
|
this.ssrcsHistory = new Map();
|
|
1434
1436
|
this.staleMeasurementTimeouts = new Map();
|
|
1435
1437
|
}
|
|
1436
1438
|
addPacketLossMeasurement(id, packetLoss, timestamp) {
|
|
1437
|
-
logger$9.debug("addPacketLossMeasurement() [ssrcId: %s, loss: %s, timestamp: %s]", id, packetLoss, timestamp);
|
|
1438
1439
|
this.handleStaleMeasurements(id);
|
|
1439
|
-
const
|
|
1440
|
+
const beginNewPacketLossPeriod = packetLoss > this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD;
|
|
1440
1441
|
let history = this.ssrcsHistory.get(id);
|
|
1441
1442
|
if (!history) {
|
|
1442
1443
|
history = {
|
|
1443
1444
|
id,
|
|
1444
|
-
hasActivePacketLoss:
|
|
1445
|
-
currPeriod:
|
|
1445
|
+
hasActivePacketLoss: beginNewPacketLossPeriod,
|
|
1446
|
+
currPeriod: beginNewPacketLossPeriod ? { begin: timestamp } : undefined,
|
|
1446
1447
|
hasPeriodicPacketLoss: false,
|
|
1447
1448
|
};
|
|
1448
1449
|
this.ssrcsHistory.set(id, history);
|
|
1449
1450
|
return;
|
|
1450
1451
|
}
|
|
1451
1452
|
if (history.hasActivePacketLoss) {
|
|
1452
|
-
if (
|
|
1453
|
+
if (packetLoss < this.END_PACKET_LOSS_PERIOD_THRESHOLD) {
|
|
1453
1454
|
this.endPacketLossPeriod(history, timestamp);
|
|
1455
|
+
if (history.prevIntervalInMs && history.prevIntervalInMs < this.MINIMUM_INTERVAL_MS) {
|
|
1456
|
+
this.ssrcsHistory.delete(id);
|
|
1457
|
+
}
|
|
1454
1458
|
}
|
|
1455
1459
|
return;
|
|
1456
1460
|
}
|
|
1457
|
-
if (
|
|
1461
|
+
if (beginNewPacketLossPeriod) {
|
|
1458
1462
|
history.hasActivePacketLoss = true;
|
|
1459
1463
|
history.currPeriod = {
|
|
1460
1464
|
begin: timestamp,
|
|
1461
1465
|
};
|
|
1462
1466
|
}
|
|
1463
1467
|
}
|
|
1464
|
-
hasPeriodicPacketLoss(id) {
|
|
1465
|
-
|
|
1466
|
-
|
|
1468
|
+
hasPeriodicPacketLoss(id, timestamp) {
|
|
1469
|
+
const history = this.ssrcsHistory.get(id);
|
|
1470
|
+
if (history && this.prevIntervalExceeded(history, timestamp)) {
|
|
1471
|
+
this.ssrcsHistory.delete(history.id);
|
|
1472
|
+
return false;
|
|
1473
|
+
}
|
|
1474
|
+
return (history === null || history === void 0 ? void 0 : history.hasPeriodicPacketLoss) || false;
|
|
1475
|
+
}
|
|
1476
|
+
prevIntervalExceeded(history, timestamp) {
|
|
1477
|
+
if (history.prevPeriod && history.prevIntervalInMs) {
|
|
1478
|
+
const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) +
|
|
1479
|
+
history.prevIntervalInMs +
|
|
1480
|
+
this.INTERVAL_DIFF_THRESHOLD_MS;
|
|
1481
|
+
return timestamp > intervalLimitTimestamp;
|
|
1482
|
+
}
|
|
1483
|
+
return false;
|
|
1467
1484
|
}
|
|
1468
1485
|
handleStaleMeasurements(id) {
|
|
1469
1486
|
const staleMeasurementTimeout = this.staleMeasurementTimeouts.get(id);
|
|
@@ -1471,7 +1488,7 @@ class PacketLossAnalyser {
|
|
|
1471
1488
|
clearTimeout(staleMeasurementTimeout);
|
|
1472
1489
|
}
|
|
1473
1490
|
this.staleMeasurementTimeouts.set(id, setTimeout(() => {
|
|
1474
|
-
logger$9.debug("
|
|
1491
|
+
logger$9.debug("handleStaleMeasurements() [measurements invalid for ssrc: %s]", id);
|
|
1475
1492
|
this.ssrcsHistory.delete(id);
|
|
1476
1493
|
}, this.STALE_MEASUREMENT_TIMEOUT_MS));
|
|
1477
1494
|
}
|
|
@@ -1519,9 +1536,7 @@ const periodicPacketLossDetector = {
|
|
|
1519
1536
|
},
|
|
1520
1537
|
check: ({ ssrc0 }) => {
|
|
1521
1538
|
packetLossAnalyser.addPacketLossMeasurement(ssrc0.ssrc, ssrc0.fractionLost || 0, Date.now());
|
|
1522
|
-
|
|
1523
|
-
return true;
|
|
1524
|
-
return false;
|
|
1539
|
+
return packetLossAnalyser.hasPeriodicPacketLoss(ssrc0.ssrc, Date.now());
|
|
1525
1540
|
},
|
|
1526
1541
|
};
|
|
1527
1542
|
const badNetworkIssueDetector = {
|