@whereby.com/media 1.16.2 → 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 CHANGED
@@ -1448,33 +1448,38 @@ const debugLogger = {
1448
1448
  logger$9.withDebugLogger(debugLogger);
1449
1449
  class PacketLossAnalyser {
1450
1450
  constructor() {
1451
- this.PACKET_LOSS_PERIOD_THRESHOLD = 0.03;
1452
- this.INTERVAL_DIFF_THRESHOLD_MS = 5000;
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
1460
  this.handleStaleMeasurements(id);
1459
- const hasPacketLoss = packetLoss > this.PACKET_LOSS_PERIOD_THRESHOLD;
1461
+ const beginNewPacketLossPeriod = packetLoss > this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD;
1460
1462
  let history = this.ssrcsHistory.get(id);
1461
1463
  if (!history) {
1462
1464
  history = {
1463
1465
  id,
1464
- hasActivePacketLoss: hasPacketLoss,
1465
- currPeriod: hasPacketLoss ? { begin: timestamp } : undefined,
1466
+ hasActivePacketLoss: beginNewPacketLossPeriod,
1467
+ currPeriod: beginNewPacketLossPeriod ? { begin: timestamp } : undefined,
1466
1468
  hasPeriodicPacketLoss: false,
1467
1469
  };
1468
1470
  this.ssrcsHistory.set(id, history);
1469
1471
  return;
1470
1472
  }
1471
1473
  if (history.hasActivePacketLoss) {
1472
- if (!hasPacketLoss) {
1474
+ if (packetLoss < this.END_PACKET_LOSS_PERIOD_THRESHOLD) {
1473
1475
  this.endPacketLossPeriod(history, timestamp);
1476
+ if (history.prevIntervalInMs && history.prevIntervalInMs < this.MINIMUM_INTERVAL_MS) {
1477
+ this.ssrcsHistory.delete(id);
1478
+ }
1474
1479
  }
1475
1480
  return;
1476
1481
  }
1477
- if (hasPacketLoss) {
1482
+ if (beginNewPacketLossPeriod) {
1478
1483
  history.hasActivePacketLoss = true;
1479
1484
  history.currPeriod = {
1480
1485
  begin: timestamp,
@@ -1483,15 +1488,17 @@ class PacketLossAnalyser {
1483
1488
  }
1484
1489
  hasPeriodicPacketLoss(id, timestamp) {
1485
1490
  const history = this.ssrcsHistory.get(id);
1486
- if (history && this.intervalExceeded(history, timestamp)) {
1491
+ if (history && this.prevIntervalExceeded(history, timestamp)) {
1487
1492
  this.ssrcsHistory.delete(history.id);
1488
1493
  return false;
1489
1494
  }
1490
1495
  return (history === null || history === void 0 ? void 0 : history.hasPeriodicPacketLoss) || false;
1491
1496
  }
1492
- intervalExceeded(history, timestamp) {
1497
+ prevIntervalExceeded(history, timestamp) {
1493
1498
  if (history.prevPeriod && history.prevIntervalInMs) {
1494
- const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) + history.prevIntervalInMs;
1499
+ const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) +
1500
+ history.prevIntervalInMs +
1501
+ this.INTERVAL_DIFF_THRESHOLD_MS;
1495
1502
  return timestamp > intervalLimitTimestamp;
1496
1503
  }
1497
1504
  return false;
@@ -1502,7 +1509,7 @@ class PacketLossAnalyser {
1502
1509
  clearTimeout(staleMeasurementTimeout);
1503
1510
  }
1504
1511
  this.staleMeasurementTimeouts.set(id, setTimeout(() => {
1505
- logger$9.debug("Invalidating measurements for ssrc: %s", id);
1512
+ logger$9.debug("handleStaleMeasurements() [measurements invalid for ssrc: %s]", id);
1506
1513
  this.ssrcsHistory.delete(id);
1507
1514
  }, this.STALE_MEASUREMENT_TIMEOUT_MS));
1508
1515
  }
package/dist/index.mjs CHANGED
@@ -1427,33 +1427,38 @@ const debugLogger = {
1427
1427
  logger$9.withDebugLogger(debugLogger);
1428
1428
  class PacketLossAnalyser {
1429
1429
  constructor() {
1430
- this.PACKET_LOSS_PERIOD_THRESHOLD = 0.03;
1431
- this.INTERVAL_DIFF_THRESHOLD_MS = 5000;
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
1439
  this.handleStaleMeasurements(id);
1438
- const hasPacketLoss = packetLoss > this.PACKET_LOSS_PERIOD_THRESHOLD;
1440
+ const beginNewPacketLossPeriod = packetLoss > this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD;
1439
1441
  let history = this.ssrcsHistory.get(id);
1440
1442
  if (!history) {
1441
1443
  history = {
1442
1444
  id,
1443
- hasActivePacketLoss: hasPacketLoss,
1444
- currPeriod: hasPacketLoss ? { begin: timestamp } : undefined,
1445
+ hasActivePacketLoss: beginNewPacketLossPeriod,
1446
+ currPeriod: beginNewPacketLossPeriod ? { begin: timestamp } : undefined,
1445
1447
  hasPeriodicPacketLoss: false,
1446
1448
  };
1447
1449
  this.ssrcsHistory.set(id, history);
1448
1450
  return;
1449
1451
  }
1450
1452
  if (history.hasActivePacketLoss) {
1451
- if (!hasPacketLoss) {
1453
+ if (packetLoss < this.END_PACKET_LOSS_PERIOD_THRESHOLD) {
1452
1454
  this.endPacketLossPeriod(history, timestamp);
1455
+ if (history.prevIntervalInMs && history.prevIntervalInMs < this.MINIMUM_INTERVAL_MS) {
1456
+ this.ssrcsHistory.delete(id);
1457
+ }
1453
1458
  }
1454
1459
  return;
1455
1460
  }
1456
- if (hasPacketLoss) {
1461
+ if (beginNewPacketLossPeriod) {
1457
1462
  history.hasActivePacketLoss = true;
1458
1463
  history.currPeriod = {
1459
1464
  begin: timestamp,
@@ -1462,15 +1467,17 @@ class PacketLossAnalyser {
1462
1467
  }
1463
1468
  hasPeriodicPacketLoss(id, timestamp) {
1464
1469
  const history = this.ssrcsHistory.get(id);
1465
- if (history && this.intervalExceeded(history, timestamp)) {
1470
+ if (history && this.prevIntervalExceeded(history, timestamp)) {
1466
1471
  this.ssrcsHistory.delete(history.id);
1467
1472
  return false;
1468
1473
  }
1469
1474
  return (history === null || history === void 0 ? void 0 : history.hasPeriodicPacketLoss) || false;
1470
1475
  }
1471
- intervalExceeded(history, timestamp) {
1476
+ prevIntervalExceeded(history, timestamp) {
1472
1477
  if (history.prevPeriod && history.prevIntervalInMs) {
1473
- const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) + history.prevIntervalInMs;
1478
+ const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) +
1479
+ history.prevIntervalInMs +
1480
+ this.INTERVAL_DIFF_THRESHOLD_MS;
1474
1481
  return timestamp > intervalLimitTimestamp;
1475
1482
  }
1476
1483
  return false;
@@ -1481,7 +1488,7 @@ class PacketLossAnalyser {
1481
1488
  clearTimeout(staleMeasurementTimeout);
1482
1489
  }
1483
1490
  this.staleMeasurementTimeouts.set(id, setTimeout(() => {
1484
- logger$9.debug("Invalidating measurements for ssrc: %s", id);
1491
+ logger$9.debug("handleStaleMeasurements() [measurements invalid for ssrc: %s]", id);
1485
1492
  this.ssrcsHistory.delete(id);
1486
1493
  }, this.STALE_MEASUREMENT_TIMEOUT_MS));
1487
1494
  }
@@ -1427,33 +1427,38 @@ const debugLogger = {
1427
1427
  logger$9.withDebugLogger(debugLogger);
1428
1428
  class PacketLossAnalyser {
1429
1429
  constructor() {
1430
- this.PACKET_LOSS_PERIOD_THRESHOLD = 0.03;
1431
- this.INTERVAL_DIFF_THRESHOLD_MS = 5000;
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
1439
  this.handleStaleMeasurements(id);
1438
- const hasPacketLoss = packetLoss > this.PACKET_LOSS_PERIOD_THRESHOLD;
1440
+ const beginNewPacketLossPeriod = packetLoss > this.BEGIN_PACKET_LOSS_PERIOD_THRESHOLD;
1439
1441
  let history = this.ssrcsHistory.get(id);
1440
1442
  if (!history) {
1441
1443
  history = {
1442
1444
  id,
1443
- hasActivePacketLoss: hasPacketLoss,
1444
- currPeriod: hasPacketLoss ? { begin: timestamp } : undefined,
1445
+ hasActivePacketLoss: beginNewPacketLossPeriod,
1446
+ currPeriod: beginNewPacketLossPeriod ? { begin: timestamp } : undefined,
1445
1447
  hasPeriodicPacketLoss: false,
1446
1448
  };
1447
1449
  this.ssrcsHistory.set(id, history);
1448
1450
  return;
1449
1451
  }
1450
1452
  if (history.hasActivePacketLoss) {
1451
- if (!hasPacketLoss) {
1453
+ if (packetLoss < this.END_PACKET_LOSS_PERIOD_THRESHOLD) {
1452
1454
  this.endPacketLossPeriod(history, timestamp);
1455
+ if (history.prevIntervalInMs && history.prevIntervalInMs < this.MINIMUM_INTERVAL_MS) {
1456
+ this.ssrcsHistory.delete(id);
1457
+ }
1453
1458
  }
1454
1459
  return;
1455
1460
  }
1456
- if (hasPacketLoss) {
1461
+ if (beginNewPacketLossPeriod) {
1457
1462
  history.hasActivePacketLoss = true;
1458
1463
  history.currPeriod = {
1459
1464
  begin: timestamp,
@@ -1462,15 +1467,17 @@ class PacketLossAnalyser {
1462
1467
  }
1463
1468
  hasPeriodicPacketLoss(id, timestamp) {
1464
1469
  const history = this.ssrcsHistory.get(id);
1465
- if (history && this.intervalExceeded(history, timestamp)) {
1470
+ if (history && this.prevIntervalExceeded(history, timestamp)) {
1466
1471
  this.ssrcsHistory.delete(history.id);
1467
1472
  return false;
1468
1473
  }
1469
1474
  return (history === null || history === void 0 ? void 0 : history.hasPeriodicPacketLoss) || false;
1470
1475
  }
1471
- intervalExceeded(history, timestamp) {
1476
+ prevIntervalExceeded(history, timestamp) {
1472
1477
  if (history.prevPeriod && history.prevIntervalInMs) {
1473
- const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) + history.prevIntervalInMs;
1478
+ const intervalLimitTimestamp = this.calculatePeriodCenterTimestamp(history.prevPeriod) +
1479
+ history.prevIntervalInMs +
1480
+ this.INTERVAL_DIFF_THRESHOLD_MS;
1474
1481
  return timestamp > intervalLimitTimestamp;
1475
1482
  }
1476
1483
  return false;
@@ -1481,7 +1488,7 @@ class PacketLossAnalyser {
1481
1488
  clearTimeout(staleMeasurementTimeout);
1482
1489
  }
1483
1490
  this.staleMeasurementTimeouts.set(id, setTimeout(() => {
1484
- logger$9.debug("Invalidating measurements for ssrc: %s", id);
1491
+ logger$9.debug("handleStaleMeasurements() [measurements invalid for ssrc: %s]", id);
1485
1492
  this.ssrcsHistory.delete(id);
1486
1493
  }, this.STALE_MEASUREMENT_TIMEOUT_MS));
1487
1494
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "1.16.2",
4
+ "version": "1.16.3",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {