@whereby.com/media 8.2.8 → 8.3.1
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 +9 -9
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +9 -9
- package/dist/legacy-esm.js +9 -9
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1473,7 +1473,7 @@ if (window.RTCPeerConnection) {
|
|
|
1473
1473
|
PatchedRTCPeerConnection.prototype = OriginalRTCPeerConnection.prototype;
|
|
1474
1474
|
window.RTCPeerConnection = PatchedRTCPeerConnection;
|
|
1475
1475
|
}
|
|
1476
|
-
const getCurrentPeerConnections = () => peerConnections;
|
|
1476
|
+
const getCurrentPeerConnections = () => peerConnections.filter((p) => p.connectionState !== "closed");
|
|
1477
1477
|
const getPeerConnectionIndex = (pc) => { var _a; return (_a = peerConnectionData.get(pc)) === null || _a === void 0 ? void 0 : _a.index; };
|
|
1478
1478
|
const setPeerConnectionsForTests = (pcs) => (peerConnections = pcs);
|
|
1479
1479
|
|
|
@@ -1483,7 +1483,7 @@ let numFailedTrackSsrcLookups = 0;
|
|
|
1483
1483
|
const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promise.all(getCurrentPeerConnections().map((pc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1484
1484
|
let pcData = pcDataByPc.get(pc);
|
|
1485
1485
|
if (!pcData) {
|
|
1486
|
-
pcData = { ssrcToTrackId: {} };
|
|
1486
|
+
pcData = { ssrcToTrackId: {}, currentSSRCs: {} };
|
|
1487
1487
|
pcDataByPc.set(pc, pcData);
|
|
1488
1488
|
}
|
|
1489
1489
|
try {
|
|
@@ -1517,7 +1517,7 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1517
1517
|
}
|
|
1518
1518
|
});
|
|
1519
1519
|
if (missingSsrcs) {
|
|
1520
|
-
const sendersAndReceivers = [...pc.getSenders(), ...pc.getReceivers()];
|
|
1520
|
+
const sendersAndReceivers = [...pc.getSenders(), ...pc.getReceivers()].filter((o) => o.track);
|
|
1521
1521
|
const reports = yield Promise.all(sendersAndReceivers.map((o) => o.getStats()));
|
|
1522
1522
|
reports.forEach((tReport, index) => {
|
|
1523
1523
|
tReport.forEach((stats) => {
|
|
@@ -1527,13 +1527,13 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1527
1527
|
});
|
|
1528
1528
|
});
|
|
1529
1529
|
missingSsrcs.forEach((ssrc) => {
|
|
1530
|
-
numMissingTrackSsrcLookups++;
|
|
1531
1530
|
if (!pcData.ssrcToTrackId[ssrc]) {
|
|
1531
|
+
numMissingTrackSsrcLookups++;
|
|
1532
1532
|
pcData.ssrcToTrackId[ssrc] = "?" + ssrc;
|
|
1533
1533
|
}
|
|
1534
1534
|
});
|
|
1535
1535
|
}
|
|
1536
|
-
return
|
|
1536
|
+
return { pc, report, pcData };
|
|
1537
1537
|
}
|
|
1538
1538
|
catch (e) {
|
|
1539
1539
|
rtcStats.sendEvent("trackSsrcLookupFailed", {
|
|
@@ -1542,7 +1542,7 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1542
1542
|
message: e === null || e === void 0 ? void 0 : e.message,
|
|
1543
1543
|
});
|
|
1544
1544
|
numFailedTrackSsrcLookups++;
|
|
1545
|
-
return
|
|
1545
|
+
return { pc, report: new Map(), pcData };
|
|
1546
1546
|
}
|
|
1547
1547
|
})));
|
|
1548
1548
|
|
|
@@ -1622,7 +1622,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1622
1622
|
return;
|
|
1623
1623
|
}
|
|
1624
1624
|
state.lastUpdateTime = Date.now();
|
|
1625
|
-
(yield getPeerConnectionsWithStatsReports()).forEach((
|
|
1625
|
+
(yield getPeerConnectionsWithStatsReports()).forEach(({ pc, report, pcData }) => {
|
|
1626
1626
|
const pcIndex = getPeerConnectionIndex(pc);
|
|
1627
1627
|
if (pcIndex === undefined) {
|
|
1628
1628
|
logger.warn("Could not find index for PeerConnection");
|
|
@@ -1631,7 +1631,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1631
1631
|
report = new Map();
|
|
1632
1632
|
removePeerConnection(pc);
|
|
1633
1633
|
}
|
|
1634
|
-
pcData.previousSSRCs = pcData.currentSSRCs
|
|
1634
|
+
pcData.previousSSRCs = pcData.currentSSRCs;
|
|
1635
1635
|
pcData.currentSSRCs = {};
|
|
1636
1636
|
report.forEach((currentRtcStats) => {
|
|
1637
1637
|
var _a, _b;
|
|
@@ -1669,7 +1669,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1669
1669
|
pcData.ssrcToTrackId[ssrc] = clientTrack.id;
|
|
1670
1670
|
}
|
|
1671
1671
|
pcData.currentSSRCs[ssrc] = client.id;
|
|
1672
|
-
if (prevRtcStats) {
|
|
1672
|
+
if (prevRtcStats && pcData._oldReport) {
|
|
1673
1673
|
const newTransport = report.get(currentRtcStats.transportId);
|
|
1674
1674
|
const oldTransport = pcData._oldReport.get(prevRtcStats.transportId);
|
|
1675
1675
|
if (oldTransport &&
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1452,7 +1452,7 @@ if (window.RTCPeerConnection) {
|
|
|
1452
1452
|
PatchedRTCPeerConnection.prototype = OriginalRTCPeerConnection.prototype;
|
|
1453
1453
|
window.RTCPeerConnection = PatchedRTCPeerConnection;
|
|
1454
1454
|
}
|
|
1455
|
-
const getCurrentPeerConnections = () => peerConnections;
|
|
1455
|
+
const getCurrentPeerConnections = () => peerConnections.filter((p) => p.connectionState !== "closed");
|
|
1456
1456
|
const getPeerConnectionIndex = (pc) => { var _a; return (_a = peerConnectionData.get(pc)) === null || _a === void 0 ? void 0 : _a.index; };
|
|
1457
1457
|
const setPeerConnectionsForTests = (pcs) => (peerConnections = pcs);
|
|
1458
1458
|
|
|
@@ -1462,7 +1462,7 @@ let numFailedTrackSsrcLookups = 0;
|
|
|
1462
1462
|
const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promise.all(getCurrentPeerConnections().map((pc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1463
1463
|
let pcData = pcDataByPc.get(pc);
|
|
1464
1464
|
if (!pcData) {
|
|
1465
|
-
pcData = { ssrcToTrackId: {} };
|
|
1465
|
+
pcData = { ssrcToTrackId: {}, currentSSRCs: {} };
|
|
1466
1466
|
pcDataByPc.set(pc, pcData);
|
|
1467
1467
|
}
|
|
1468
1468
|
try {
|
|
@@ -1496,7 +1496,7 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1496
1496
|
}
|
|
1497
1497
|
});
|
|
1498
1498
|
if (missingSsrcs) {
|
|
1499
|
-
const sendersAndReceivers = [...pc.getSenders(), ...pc.getReceivers()];
|
|
1499
|
+
const sendersAndReceivers = [...pc.getSenders(), ...pc.getReceivers()].filter((o) => o.track);
|
|
1500
1500
|
const reports = yield Promise.all(sendersAndReceivers.map((o) => o.getStats()));
|
|
1501
1501
|
reports.forEach((tReport, index) => {
|
|
1502
1502
|
tReport.forEach((stats) => {
|
|
@@ -1506,13 +1506,13 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1506
1506
|
});
|
|
1507
1507
|
});
|
|
1508
1508
|
missingSsrcs.forEach((ssrc) => {
|
|
1509
|
-
numMissingTrackSsrcLookups++;
|
|
1510
1509
|
if (!pcData.ssrcToTrackId[ssrc]) {
|
|
1510
|
+
numMissingTrackSsrcLookups++;
|
|
1511
1511
|
pcData.ssrcToTrackId[ssrc] = "?" + ssrc;
|
|
1512
1512
|
}
|
|
1513
1513
|
});
|
|
1514
1514
|
}
|
|
1515
|
-
return
|
|
1515
|
+
return { pc, report, pcData };
|
|
1516
1516
|
}
|
|
1517
1517
|
catch (e) {
|
|
1518
1518
|
rtcStats.sendEvent("trackSsrcLookupFailed", {
|
|
@@ -1521,7 +1521,7 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1521
1521
|
message: e === null || e === void 0 ? void 0 : e.message,
|
|
1522
1522
|
});
|
|
1523
1523
|
numFailedTrackSsrcLookups++;
|
|
1524
|
-
return
|
|
1524
|
+
return { pc, report: new Map(), pcData };
|
|
1525
1525
|
}
|
|
1526
1526
|
})));
|
|
1527
1527
|
|
|
@@ -1601,7 +1601,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1601
1601
|
return;
|
|
1602
1602
|
}
|
|
1603
1603
|
state.lastUpdateTime = Date.now();
|
|
1604
|
-
(yield getPeerConnectionsWithStatsReports()).forEach((
|
|
1604
|
+
(yield getPeerConnectionsWithStatsReports()).forEach(({ pc, report, pcData }) => {
|
|
1605
1605
|
const pcIndex = getPeerConnectionIndex(pc);
|
|
1606
1606
|
if (pcIndex === undefined) {
|
|
1607
1607
|
logger.warn("Could not find index for PeerConnection");
|
|
@@ -1610,7 +1610,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1610
1610
|
report = new Map();
|
|
1611
1611
|
removePeerConnection(pc);
|
|
1612
1612
|
}
|
|
1613
|
-
pcData.previousSSRCs = pcData.currentSSRCs
|
|
1613
|
+
pcData.previousSSRCs = pcData.currentSSRCs;
|
|
1614
1614
|
pcData.currentSSRCs = {};
|
|
1615
1615
|
report.forEach((currentRtcStats) => {
|
|
1616
1616
|
var _a, _b;
|
|
@@ -1648,7 +1648,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1648
1648
|
pcData.ssrcToTrackId[ssrc] = clientTrack.id;
|
|
1649
1649
|
}
|
|
1650
1650
|
pcData.currentSSRCs[ssrc] = client.id;
|
|
1651
|
-
if (prevRtcStats) {
|
|
1651
|
+
if (prevRtcStats && pcData._oldReport) {
|
|
1652
1652
|
const newTransport = report.get(currentRtcStats.transportId);
|
|
1653
1653
|
const oldTransport = pcData._oldReport.get(prevRtcStats.transportId);
|
|
1654
1654
|
if (oldTransport &&
|
package/dist/legacy-esm.js
CHANGED
|
@@ -1452,7 +1452,7 @@ if (window.RTCPeerConnection) {
|
|
|
1452
1452
|
PatchedRTCPeerConnection.prototype = OriginalRTCPeerConnection.prototype;
|
|
1453
1453
|
window.RTCPeerConnection = PatchedRTCPeerConnection;
|
|
1454
1454
|
}
|
|
1455
|
-
const getCurrentPeerConnections = () => peerConnections;
|
|
1455
|
+
const getCurrentPeerConnections = () => peerConnections.filter((p) => p.connectionState !== "closed");
|
|
1456
1456
|
const getPeerConnectionIndex = (pc) => { var _a; return (_a = peerConnectionData.get(pc)) === null || _a === void 0 ? void 0 : _a.index; };
|
|
1457
1457
|
const setPeerConnectionsForTests = (pcs) => (peerConnections = pcs);
|
|
1458
1458
|
|
|
@@ -1462,7 +1462,7 @@ let numFailedTrackSsrcLookups = 0;
|
|
|
1462
1462
|
const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promise.all(getCurrentPeerConnections().map((pc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1463
1463
|
let pcData = pcDataByPc.get(pc);
|
|
1464
1464
|
if (!pcData) {
|
|
1465
|
-
pcData = { ssrcToTrackId: {} };
|
|
1465
|
+
pcData = { ssrcToTrackId: {}, currentSSRCs: {} };
|
|
1466
1466
|
pcDataByPc.set(pc, pcData);
|
|
1467
1467
|
}
|
|
1468
1468
|
try {
|
|
@@ -1496,7 +1496,7 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1496
1496
|
}
|
|
1497
1497
|
});
|
|
1498
1498
|
if (missingSsrcs) {
|
|
1499
|
-
const sendersAndReceivers = [...pc.getSenders(), ...pc.getReceivers()];
|
|
1499
|
+
const sendersAndReceivers = [...pc.getSenders(), ...pc.getReceivers()].filter((o) => o.track);
|
|
1500
1500
|
const reports = yield Promise.all(sendersAndReceivers.map((o) => o.getStats()));
|
|
1501
1501
|
reports.forEach((tReport, index) => {
|
|
1502
1502
|
tReport.forEach((stats) => {
|
|
@@ -1506,13 +1506,13 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1506
1506
|
});
|
|
1507
1507
|
});
|
|
1508
1508
|
missingSsrcs.forEach((ssrc) => {
|
|
1509
|
-
numMissingTrackSsrcLookups++;
|
|
1510
1509
|
if (!pcData.ssrcToTrackId[ssrc]) {
|
|
1510
|
+
numMissingTrackSsrcLookups++;
|
|
1511
1511
|
pcData.ssrcToTrackId[ssrc] = "?" + ssrc;
|
|
1512
1512
|
}
|
|
1513
1513
|
});
|
|
1514
1514
|
}
|
|
1515
|
-
return
|
|
1515
|
+
return { pc, report, pcData };
|
|
1516
1516
|
}
|
|
1517
1517
|
catch (e) {
|
|
1518
1518
|
rtcStats.sendEvent("trackSsrcLookupFailed", {
|
|
@@ -1521,7 +1521,7 @@ const getPeerConnectionsWithStatsReports = (pcDataByPc = PC_DATA_BY_PC) => Promi
|
|
|
1521
1521
|
message: e === null || e === void 0 ? void 0 : e.message,
|
|
1522
1522
|
});
|
|
1523
1523
|
numFailedTrackSsrcLookups++;
|
|
1524
|
-
return
|
|
1524
|
+
return { pc, report: new Map(), pcData };
|
|
1525
1525
|
}
|
|
1526
1526
|
})));
|
|
1527
1527
|
|
|
@@ -1601,7 +1601,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1601
1601
|
return;
|
|
1602
1602
|
}
|
|
1603
1603
|
state.lastUpdateTime = Date.now();
|
|
1604
|
-
(yield getPeerConnectionsWithStatsReports()).forEach((
|
|
1604
|
+
(yield getPeerConnectionsWithStatsReports()).forEach(({ pc, report, pcData }) => {
|
|
1605
1605
|
const pcIndex = getPeerConnectionIndex(pc);
|
|
1606
1606
|
if (pcIndex === undefined) {
|
|
1607
1607
|
logger.warn("Could not find index for PeerConnection");
|
|
@@ -1610,7 +1610,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1610
1610
|
report = new Map();
|
|
1611
1611
|
removePeerConnection(pc);
|
|
1612
1612
|
}
|
|
1613
|
-
pcData.previousSSRCs = pcData.currentSSRCs
|
|
1613
|
+
pcData.previousSSRCs = pcData.currentSSRCs;
|
|
1614
1614
|
pcData.currentSSRCs = {};
|
|
1615
1615
|
report.forEach((currentRtcStats) => {
|
|
1616
1616
|
var _a, _b;
|
|
@@ -1648,7 +1648,7 @@ function collectStats(state_1, _a, immediate_1) {
|
|
|
1648
1648
|
pcData.ssrcToTrackId[ssrc] = clientTrack.id;
|
|
1649
1649
|
}
|
|
1650
1650
|
pcData.currentSSRCs[ssrc] = client.id;
|
|
1651
|
-
if (prevRtcStats) {
|
|
1651
|
+
if (prevRtcStats && pcData._oldReport) {
|
|
1652
1652
|
const newTransport = report.get(currentRtcStats.transportId);
|
|
1653
1653
|
const oldTransport = pcData._oldReport.get(prevRtcStats.transportId);
|
|
1654
1654
|
if (oldTransport &&
|
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": "8.
|
|
4
|
+
"version": "8.3.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/whereby/sdk",
|
|
7
7
|
"repository": {
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"typescript": "^5.8.3",
|
|
64
64
|
"@whereby.com/eslint-config": "0.1.0",
|
|
65
65
|
"@whereby.com/jest-config": "0.1.0",
|
|
66
|
+
"@whereby.com/prettier-config": "0.1.0",
|
|
66
67
|
"@whereby.com/rollup-config": "0.1.1",
|
|
67
|
-
"@whereby.com/tsconfig": "0.1.0"
|
|
68
|
-
"@whereby.com/prettier-config": "0.1.0"
|
|
68
|
+
"@whereby.com/tsconfig": "0.1.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=16.0.0"
|