@webex/internal-media-core 2.10.2 → 2.10.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/cjs/index.js +618 -5
- package/dist/esm/index.js +618 -5
- package/dist/types/MediaConnection/MediaConnection.d.ts +6 -1
- package/dist/types/MediaConnection/MediaConnection.d.ts.map +1 -1
- package/dist/types/MediaConnection/MultistreamRoapMediaConnection.d.ts +1 -2
- package/dist/types/MediaConnection/MultistreamRoapMediaConnection.d.ts.map +1 -1
- package/dist/types/MediaConnection/RoapMediaConnection.d.ts +6 -2
- package/dist/types/MediaConnection/RoapMediaConnection.d.ts.map +1 -1
- package/dist/types/MediaConnection/types.d.ts +3 -0
- package/dist/types/MediaConnection/types.d.ts.map +1 -0
- package/package.json +3 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1456,6 +1456,573 @@ var Error$1 = /*#__PURE__*/Object.freeze({
|
|
|
1456
1456
|
SdpOfferHandlingError: SdpOfferHandlingError
|
|
1457
1457
|
});
|
|
1458
1458
|
|
|
1459
|
+
var commonjsGlobal$5 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
1460
|
+
|
|
1461
|
+
var rtcstats$1 = {};
|
|
1462
|
+
|
|
1463
|
+
var __awaiter$3 = commonjsGlobal$5 && commonjsGlobal$5.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
1464
|
+
function adopt(value) {
|
|
1465
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
1466
|
+
resolve(value);
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1470
|
+
function fulfilled(value) {
|
|
1471
|
+
try {
|
|
1472
|
+
step(generator.next(value));
|
|
1473
|
+
} catch (e) {
|
|
1474
|
+
reject(e);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
function rejected(value) {
|
|
1478
|
+
try {
|
|
1479
|
+
step(generator["throw"](value));
|
|
1480
|
+
} catch (e) {
|
|
1481
|
+
reject(e);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
function step(result) {
|
|
1485
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1486
|
+
}
|
|
1487
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1488
|
+
});
|
|
1489
|
+
};
|
|
1490
|
+
var __generator$1 = commonjsGlobal$5 && commonjsGlobal$5.__generator || function (thisArg, body) {
|
|
1491
|
+
var _ = {
|
|
1492
|
+
label: 0,
|
|
1493
|
+
sent: function sent() {
|
|
1494
|
+
if (t[0] & 1) throw t[1];
|
|
1495
|
+
return t[1];
|
|
1496
|
+
},
|
|
1497
|
+
trys: [],
|
|
1498
|
+
ops: []
|
|
1499
|
+
},
|
|
1500
|
+
f,
|
|
1501
|
+
y,
|
|
1502
|
+
t,
|
|
1503
|
+
g;
|
|
1504
|
+
return g = {
|
|
1505
|
+
next: verb(0),
|
|
1506
|
+
"throw": verb(1),
|
|
1507
|
+
"return": verb(2)
|
|
1508
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
1509
|
+
return this;
|
|
1510
|
+
}), g;
|
|
1511
|
+
function verb(n) {
|
|
1512
|
+
return function (v) {
|
|
1513
|
+
return step([n, v]);
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
function step(op) {
|
|
1517
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1518
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) {
|
|
1519
|
+
try {
|
|
1520
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1521
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1522
|
+
switch (op[0]) {
|
|
1523
|
+
case 0:
|
|
1524
|
+
case 1:
|
|
1525
|
+
t = op;
|
|
1526
|
+
break;
|
|
1527
|
+
case 4:
|
|
1528
|
+
_.label++;
|
|
1529
|
+
return {
|
|
1530
|
+
value: op[1],
|
|
1531
|
+
done: false
|
|
1532
|
+
};
|
|
1533
|
+
case 5:
|
|
1534
|
+
_.label++;
|
|
1535
|
+
y = op[1];
|
|
1536
|
+
op = [0];
|
|
1537
|
+
continue;
|
|
1538
|
+
case 7:
|
|
1539
|
+
op = _.ops.pop();
|
|
1540
|
+
_.trys.pop();
|
|
1541
|
+
continue;
|
|
1542
|
+
default:
|
|
1543
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1544
|
+
_ = 0;
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1548
|
+
_.label = op[1];
|
|
1549
|
+
break;
|
|
1550
|
+
}
|
|
1551
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1552
|
+
_.label = t[1];
|
|
1553
|
+
t = op;
|
|
1554
|
+
break;
|
|
1555
|
+
}
|
|
1556
|
+
if (t && _.label < t[2]) {
|
|
1557
|
+
_.label = t[2];
|
|
1558
|
+
_.ops.push(op);
|
|
1559
|
+
break;
|
|
1560
|
+
}
|
|
1561
|
+
if (t[2]) _.ops.pop();
|
|
1562
|
+
_.trys.pop();
|
|
1563
|
+
continue;
|
|
1564
|
+
}
|
|
1565
|
+
op = body.call(thisArg, _);
|
|
1566
|
+
} catch (e) {
|
|
1567
|
+
op = [6, e];
|
|
1568
|
+
y = 0;
|
|
1569
|
+
} finally {
|
|
1570
|
+
f = t = 0;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
if (op[0] & 5) throw op[1];
|
|
1574
|
+
return {
|
|
1575
|
+
value: op[0] ? op[1] : void 0,
|
|
1576
|
+
done: true
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
Object.defineProperty(rtcstats$1, "__esModule", {
|
|
1581
|
+
value: true
|
|
1582
|
+
});
|
|
1583
|
+
var rtcStats_1$1 = rtcstats$1.rtcStats = void 0;
|
|
1584
|
+
/**
|
|
1585
|
+
* Copies values of any nested depth.
|
|
1586
|
+
*
|
|
1587
|
+
* @param value - The value to be copied.
|
|
1588
|
+
* @returns - Copied value.
|
|
1589
|
+
*/
|
|
1590
|
+
var deepCopy$2 = function deepCopy(value) {
|
|
1591
|
+
return JSON.parse(JSON.stringify(value));
|
|
1592
|
+
};
|
|
1593
|
+
/**
|
|
1594
|
+
* Check deep equality between two values.
|
|
1595
|
+
*
|
|
1596
|
+
* @param value1 - First value to check.
|
|
1597
|
+
* @param value2 - Second value to check.
|
|
1598
|
+
* @returns True if values are deeply equal, false otherwise.
|
|
1599
|
+
*/
|
|
1600
|
+
var deepEqual$1 = function deepEqual(value1, value2) {
|
|
1601
|
+
// If both immutable values are equal, return true.
|
|
1602
|
+
if (value1 === value2) {
|
|
1603
|
+
return true;
|
|
1604
|
+
}
|
|
1605
|
+
// If both are objects, we check the length and properties of each.
|
|
1606
|
+
if (value1 && value2 && typeof value1 === 'object' && typeof value2 === 'object') {
|
|
1607
|
+
if (value1.constructor !== value2.constructor) return false;
|
|
1608
|
+
// Return false if the objects are of different sizes.
|
|
1609
|
+
if (Object.keys(value1).length !== Object.keys(value2).length) {
|
|
1610
|
+
return false;
|
|
1611
|
+
}
|
|
1612
|
+
// Deep equal check each property in the object, returns true if we found no
|
|
1613
|
+
// differing properties.
|
|
1614
|
+
return Object.keys(value1).reduce(function (val, prop) {
|
|
1615
|
+
if (value2[prop]) {
|
|
1616
|
+
if (!deepEqual(value1[prop], value2[prop])) {
|
|
1617
|
+
return false;
|
|
1618
|
+
}
|
|
1619
|
+
} else {
|
|
1620
|
+
return false;
|
|
1621
|
+
}
|
|
1622
|
+
return val;
|
|
1623
|
+
}, true);
|
|
1624
|
+
}
|
|
1625
|
+
// Return false if no other conditions are met.
|
|
1626
|
+
return false;
|
|
1627
|
+
};
|
|
1628
|
+
/**
|
|
1629
|
+
* Translates a Map into an object.
|
|
1630
|
+
*
|
|
1631
|
+
* @param report - The report in Map form.
|
|
1632
|
+
* @returns - A deduped object.
|
|
1633
|
+
*/
|
|
1634
|
+
var map2obj$1 = function map2obj(report) {
|
|
1635
|
+
if (!report.size) {
|
|
1636
|
+
return report;
|
|
1637
|
+
}
|
|
1638
|
+
var o = {};
|
|
1639
|
+
report.forEach(function (value, key) {
|
|
1640
|
+
o[key] = value;
|
|
1641
|
+
});
|
|
1642
|
+
return o;
|
|
1643
|
+
};
|
|
1644
|
+
var dumpStream$1 = function dumpStream(stream) {
|
|
1645
|
+
return {
|
|
1646
|
+
id: stream.id,
|
|
1647
|
+
tracks: stream.getTracks().map(function (track) {
|
|
1648
|
+
return {
|
|
1649
|
+
id: track.id,
|
|
1650
|
+
kind: track.kind,
|
|
1651
|
+
label: track.label,
|
|
1652
|
+
enabled: track.enabled,
|
|
1653
|
+
muted: track.muted,
|
|
1654
|
+
readyState: track.readyState
|
|
1655
|
+
};
|
|
1656
|
+
})
|
|
1657
|
+
};
|
|
1658
|
+
};
|
|
1659
|
+
var persistedKeys$1 = ['type', 'id', 'timestamp'];
|
|
1660
|
+
/**
|
|
1661
|
+
* Check to see if the report consists of more than just the persisted metadata.
|
|
1662
|
+
*
|
|
1663
|
+
* @param report - The report line being checked.
|
|
1664
|
+
* @returns True if the report item contains non-persisted keys, false otherwise.
|
|
1665
|
+
*/
|
|
1666
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1667
|
+
var hasNonMetadata$1 = function hasNonMetadata(report) {
|
|
1668
|
+
return !!Object.keys(report).filter(function (key) {
|
|
1669
|
+
return !persistedKeys$1.includes(key);
|
|
1670
|
+
}).length;
|
|
1671
|
+
};
|
|
1672
|
+
/**
|
|
1673
|
+
* Apply a delta compression to the stats report. Reduces size by ~90%.
|
|
1674
|
+
* To reduce further, report keys could be compressed.
|
|
1675
|
+
*
|
|
1676
|
+
* @param oldStats - Previous report items that we dedupe against.
|
|
1677
|
+
* @param newStats - New incoming stats.
|
|
1678
|
+
* @returns - Compressed Stats.
|
|
1679
|
+
*/
|
|
1680
|
+
var deltaCompression$1 = function deltaCompression(oldStats, newStats) {
|
|
1681
|
+
var updatedStats = deepCopy$2(newStats);
|
|
1682
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
1683
|
+
var report = updatedStats[id];
|
|
1684
|
+
if (!oldStats[id]) {
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
// Persist specific values beyond delta compression, as long as they
|
|
1688
|
+
// aren't the only non-deduped keys.
|
|
1689
|
+
Object.keys(report).forEach(function (name) {
|
|
1690
|
+
if (deepEqual$1(report[name], oldStats[id][name]) && !persistedKeys$1.includes(name)) {
|
|
1691
|
+
delete updatedStats[id][name];
|
|
1692
|
+
}
|
|
1693
|
+
if (!hasNonMetadata$1(report)) {
|
|
1694
|
+
delete updatedStats[id];
|
|
1695
|
+
}
|
|
1696
|
+
});
|
|
1697
|
+
});
|
|
1698
|
+
// Use the most recent timestamp.
|
|
1699
|
+
var timestamp = -Infinity;
|
|
1700
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
1701
|
+
var report = updatedStats[id];
|
|
1702
|
+
if (report.timestamp > timestamp) {
|
|
1703
|
+
timestamp = report.timestamp;
|
|
1704
|
+
}
|
|
1705
|
+
});
|
|
1706
|
+
// Delete the timestamps on each item.
|
|
1707
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
1708
|
+
var report = updatedStats[id];
|
|
1709
|
+
if (report.timestamp === timestamp) {
|
|
1710
|
+
delete report.timestamp;
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
updatedStats.timestamp = timestamp;
|
|
1714
|
+
return updatedStats;
|
|
1715
|
+
};
|
|
1716
|
+
/**
|
|
1717
|
+
* Format the stats report into an array.
|
|
1718
|
+
*
|
|
1719
|
+
* @param report - A WebRTC stats report.
|
|
1720
|
+
* @returns - An array of Stats Report items.
|
|
1721
|
+
*/
|
|
1722
|
+
var formatStatsReport$1 = function formatStatsReport(report) {
|
|
1723
|
+
return Object.keys(report).filter(function (name) {
|
|
1724
|
+
return name !== 'timestamp';
|
|
1725
|
+
}).map(function (name) {
|
|
1726
|
+
return JSON.stringify(report[name]);
|
|
1727
|
+
});
|
|
1728
|
+
};
|
|
1729
|
+
/**
|
|
1730
|
+
* Parametrize a single string event to contain type and an (empty) id.
|
|
1731
|
+
*
|
|
1732
|
+
* @param value - The value to parametrize.
|
|
1733
|
+
* @returns An event object.
|
|
1734
|
+
*/
|
|
1735
|
+
var makeEvent$1 = function makeEvent(value) {
|
|
1736
|
+
return [JSON.stringify({
|
|
1737
|
+
value: value,
|
|
1738
|
+
type: 'string',
|
|
1739
|
+
id: ''
|
|
1740
|
+
})];
|
|
1741
|
+
};
|
|
1742
|
+
/**
|
|
1743
|
+
* Attach a Peer Connection to periodically get updated on events and stats.
|
|
1744
|
+
*
|
|
1745
|
+
* @param pc - Peer Connection in which we attach.
|
|
1746
|
+
* @param logger - Logging function to log events and stats.
|
|
1747
|
+
* @param intervalTime - Time between each `getStats` check.
|
|
1748
|
+
* @param statsPreProcessor - Optional function that modifies stats.
|
|
1749
|
+
*/
|
|
1750
|
+
var rtcStats$1 = function rtcStats(pc, logger, intervalTime, statsPreProcessor) {
|
|
1751
|
+
if (statsPreProcessor === void 0) {
|
|
1752
|
+
statsPreProcessor = function statsPreProcessor() {
|
|
1753
|
+
return Promise.resolve();
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
var prev = {};
|
|
1757
|
+
/**
|
|
1758
|
+
* Log stats or event data with additional tracking information.
|
|
1759
|
+
*
|
|
1760
|
+
* @param name - Name of the event to log.
|
|
1761
|
+
* @param payload - Log data pertaining to the event.
|
|
1762
|
+
* @param timestamp - Time the event happened in milliseconds.
|
|
1763
|
+
*/
|
|
1764
|
+
var trace = function trace(name, payload, timestamp) {
|
|
1765
|
+
logger({
|
|
1766
|
+
timestamp: timestamp ? Math.round(timestamp) : Date.now(),
|
|
1767
|
+
name: name,
|
|
1768
|
+
payload: payload
|
|
1769
|
+
});
|
|
1770
|
+
};
|
|
1771
|
+
var origPeerConnection = window.RTCPeerConnection;
|
|
1772
|
+
pc.addEventListener('icecandidate', function (e) {
|
|
1773
|
+
if (e.candidate) {
|
|
1774
|
+
trace('onicecandidate', makeEvent$1(JSON.stringify(e.candidate)));
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
pc.addEventListener('icecandidateerror', function (event) {
|
|
1778
|
+
var url = event.url,
|
|
1779
|
+
errorCode = event.errorCode,
|
|
1780
|
+
errorText = event.errorText;
|
|
1781
|
+
trace('onicecandidateerror', makeEvent$1("[".concat(url, "] ").concat(errorCode, ": ").concat(errorText)));
|
|
1782
|
+
});
|
|
1783
|
+
pc.addEventListener('track', function (e) {
|
|
1784
|
+
trace('ontrack', makeEvent$1("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams.map(function (stream) {
|
|
1785
|
+
return "stream:".concat(stream.id);
|
|
1786
|
+
}).join(' '))));
|
|
1787
|
+
});
|
|
1788
|
+
pc.addEventListener('signalingstatechange', function () {
|
|
1789
|
+
trace('onsignalingstatechange', makeEvent$1(pc.signalingState));
|
|
1790
|
+
});
|
|
1791
|
+
pc.addEventListener('iceconnectionstatechange', function () {
|
|
1792
|
+
trace('oniceconnectionstatechange', makeEvent$1(pc.iceConnectionState));
|
|
1793
|
+
});
|
|
1794
|
+
pc.addEventListener('icegatheringstatechange', function () {
|
|
1795
|
+
trace('onicegatheringstatechange', makeEvent$1(pc.iceGatheringState));
|
|
1796
|
+
});
|
|
1797
|
+
pc.addEventListener('connectionstatechange', function () {
|
|
1798
|
+
trace('onconnectionstatechange', makeEvent$1(pc.connectionState));
|
|
1799
|
+
});
|
|
1800
|
+
pc.addEventListener('negotiationneeded', function () {
|
|
1801
|
+
trace('onnegotiationneeded', makeEvent$1('negotiationneeded'));
|
|
1802
|
+
});
|
|
1803
|
+
pc.addEventListener('datachannel', function (event) {
|
|
1804
|
+
trace('ondatachannel', makeEvent$1("".concat(event.channel.id, ": ").concat(event.channel.label)));
|
|
1805
|
+
});
|
|
1806
|
+
['createDataChannel', 'close'].forEach(function (method) {
|
|
1807
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1808
|
+
if (nativeMethod) {
|
|
1809
|
+
origPeerConnection.prototype[method] = function () {
|
|
1810
|
+
trace("on".concat(method), makeEvent$1(method));
|
|
1811
|
+
return nativeMethod.apply(this, arguments);
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
['addStream', 'removeStream'].forEach(function (method) {
|
|
1816
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1817
|
+
if (nativeMethod) {
|
|
1818
|
+
origPeerConnection.prototype[method] = function () {
|
|
1819
|
+
var stream = arguments[0];
|
|
1820
|
+
var streamInfo = stream.getTracks().map(function (t) {
|
|
1821
|
+
return "".concat(t.kind, ":").concat(t.id);
|
|
1822
|
+
}).join(',');
|
|
1823
|
+
trace("on".concat(method), makeEvent$1("".concat(stream.id, " ").concat(streamInfo)));
|
|
1824
|
+
return nativeMethod.apply(this, arguments);
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
});
|
|
1828
|
+
['addTrack'].forEach(function (method) {
|
|
1829
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1830
|
+
if (nativeMethod) {
|
|
1831
|
+
origPeerConnection.prototype[method] = function () {
|
|
1832
|
+
var track = arguments[0];
|
|
1833
|
+
var streams = [].slice.call(arguments, 1);
|
|
1834
|
+
trace("on".concat(method), makeEvent$1("".concat(track.kind, ":").concat(track.id, " ").concat(streams.map(function (s) {
|
|
1835
|
+
return "stream:".concat(s.id);
|
|
1836
|
+
}).join(';') || '-')));
|
|
1837
|
+
return nativeMethod.apply(this, arguments);
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
['removeTrack'].forEach(function (method) {
|
|
1842
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1843
|
+
if (nativeMethod) {
|
|
1844
|
+
origPeerConnection.prototype[method] = function () {
|
|
1845
|
+
var track = arguments[0].track;
|
|
1846
|
+
trace("on".concat(method), makeEvent$1(track ? "".concat(track.kind, ":").concat(track.id) : 'null'));
|
|
1847
|
+
return nativeMethod.apply(this, arguments);
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
['createOffer', 'createAnswer'].forEach(function (method) {
|
|
1852
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1853
|
+
if (nativeMethod) {
|
|
1854
|
+
origPeerConnection.prototype[method] = function () {
|
|
1855
|
+
var opts;
|
|
1856
|
+
var args = arguments;
|
|
1857
|
+
if (arguments.length === 1 && typeof arguments[0] === 'object') {
|
|
1858
|
+
// eslint-disable-next-line prefer-destructuring
|
|
1859
|
+
opts = arguments[0];
|
|
1860
|
+
} else if (arguments.length === 3 && typeof arguments[2] === 'object') {
|
|
1861
|
+
// eslint-disable-next-line prefer-destructuring
|
|
1862
|
+
opts = arguments[2];
|
|
1863
|
+
}
|
|
1864
|
+
trace("on".concat(method), makeEvent$1(opts || ''));
|
|
1865
|
+
return nativeMethod.apply(this, opts ? [opts] : undefined).then(function (description) {
|
|
1866
|
+
trace("on".concat(method, "OnSuccess"), makeEvent$1(description.sdp));
|
|
1867
|
+
if (args.length > 0 && typeof args[0] === 'function') {
|
|
1868
|
+
args[0].apply(null, [description]);
|
|
1869
|
+
return undefined;
|
|
1870
|
+
}
|
|
1871
|
+
return description;
|
|
1872
|
+
}, function (err) {
|
|
1873
|
+
trace("on".concat(method, "OnFailure"), makeEvent$1(err.toString()));
|
|
1874
|
+
if (args.length > 1 && typeof args[1] === 'function') {
|
|
1875
|
+
args[1].apply(null, [err]);
|
|
1876
|
+
return;
|
|
1877
|
+
}
|
|
1878
|
+
throw err;
|
|
1879
|
+
});
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
|
|
1884
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1885
|
+
if (nativeMethod) {
|
|
1886
|
+
origPeerConnection.prototype[method] = function () {
|
|
1887
|
+
var _this = this;
|
|
1888
|
+
var args = arguments;
|
|
1889
|
+
trace("on".concat(method), makeEvent$1(method === 'addIceCandidate' ? arguments[0] : arguments[0] ? arguments[0].sdp : 'undefined'));
|
|
1890
|
+
return nativeMethod.apply(this, [arguments[0]]).then(function () {
|
|
1891
|
+
var _a;
|
|
1892
|
+
trace("on".concat(method, "OnSuccess"), makeEvent$1('success'));
|
|
1893
|
+
if (method.endsWith('Description')) {
|
|
1894
|
+
if (!_this.transportEventsPreviouslyAdded) {
|
|
1895
|
+
var senders = _this.getSenders();
|
|
1896
|
+
var _loop_1 = function _loop_1(sender) {
|
|
1897
|
+
if (sender.transport) {
|
|
1898
|
+
sender.transport.addEventListener('statechange', function () {
|
|
1899
|
+
if (sender && sender.transport) {
|
|
1900
|
+
trace("ondtlsStateChange", makeEvent$1(sender.transport.state));
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1903
|
+
sender.transport.addEventListener('error', function (error) {
|
|
1904
|
+
var errorEvent = error;
|
|
1905
|
+
trace("ondtlsError", makeEvent$1(errorEvent.error.errorDetail));
|
|
1906
|
+
});
|
|
1907
|
+
if (sender.transport.iceTransport) {
|
|
1908
|
+
sender.transport.iceTransport.addEventListener('selectedcandidatepairchange', function () {
|
|
1909
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1910
|
+
if (sender.transport && sender.transport.iceTransport) {
|
|
1911
|
+
var pair = sender.transport.iceTransport.getSelectedCandidatePair();
|
|
1912
|
+
var localCandidate = "".concat((_a = pair === null || pair === void 0 ? void 0 : pair.local) === null || _a === void 0 ? void 0 : _a.address, ":").concat((_b = pair === null || pair === void 0 ? void 0 : pair.local) === null || _b === void 0 ? void 0 : _b.port, "/").concat((_c = pair === null || pair === void 0 ? void 0 : pair.local) === null || _c === void 0 ? void 0 : _c.protocol);
|
|
1913
|
+
var remoteCandidate = "".concat((_d = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _d === void 0 ? void 0 : _d.address, ":").concat((_e = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _e === void 0 ? void 0 : _e.port, "/").concat((_f = pair === null || pair === void 0 ? void 0 : pair.remote) === null || _f === void 0 ? void 0 : _f.protocol);
|
|
1914
|
+
var pairString = "local: ".concat(localCandidate, ", remote: ").concat(remoteCandidate);
|
|
1915
|
+
trace('onselectedCandidatePairChange', makeEvent$1(pairString));
|
|
1916
|
+
}
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
_this.transportEventsPreviouslyAdded = true;
|
|
1920
|
+
if (pc.getConfiguration().bundlePolicy === 'max-bundle') {
|
|
1921
|
+
return "break";
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
for (var _i = 0, senders_1 = senders; _i < senders_1.length; _i++) {
|
|
1926
|
+
var sender = senders_1[_i];
|
|
1927
|
+
var state_1 = _loop_1(sender);
|
|
1928
|
+
if (state_1 === "break") break;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
if (!_this.sctpEventsPreviouslyAdded) {
|
|
1932
|
+
// Some Firefox versions prior to 113 have sctp defined but not the events, so check both here.
|
|
1933
|
+
if ((_a = _this.sctp) === null || _a === void 0 ? void 0 : _a.addEventListener) {
|
|
1934
|
+
_this.sctp.addEventListener('statechange', function () {
|
|
1935
|
+
trace('onsctpStateChange', makeEvent$1(_this.sctp.state));
|
|
1936
|
+
});
|
|
1937
|
+
_this.sctpEventsPreviouslyAdded = true;
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
if (args.length >= 2 && typeof args[1] === 'function') {
|
|
1942
|
+
args[1].apply(null, []);
|
|
1943
|
+
return undefined;
|
|
1944
|
+
}
|
|
1945
|
+
return undefined;
|
|
1946
|
+
}, function (err) {
|
|
1947
|
+
trace("on".concat(method, "OnFailure"), makeEvent$1(err.toString()));
|
|
1948
|
+
if (args.length >= 3 && typeof args[2] === 'function') {
|
|
1949
|
+
args[2].apply(null, [err]);
|
|
1950
|
+
return undefined;
|
|
1951
|
+
}
|
|
1952
|
+
throw err;
|
|
1953
|
+
});
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
1958
|
+
var origGetUserMedia_1 = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
|
|
1959
|
+
var gum = function gum() {
|
|
1960
|
+
trace('onnavigator.mediaDevices.getUserMedia', makeEvent$1(JSON.stringify(arguments[0])));
|
|
1961
|
+
return origGetUserMedia_1.apply(navigator.mediaDevices, arguments).then(function (stream) {
|
|
1962
|
+
trace('onnavigator.mediaDevices.getUserMediaOnSuccess', makeEvent$1(JSON.stringify(dumpStream$1(stream))));
|
|
1963
|
+
return stream;
|
|
1964
|
+
}, function (err) {
|
|
1965
|
+
trace('onnavigator.mediaDevices.getUserMediaOnFailure', makeEvent$1(err.name));
|
|
1966
|
+
return Promise.reject(err);
|
|
1967
|
+
});
|
|
1968
|
+
};
|
|
1969
|
+
navigator.mediaDevices.getUserMedia = gum.bind(navigator.mediaDevices);
|
|
1970
|
+
}
|
|
1971
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
1972
|
+
var origGetDisplayMedia_1 = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
|
|
1973
|
+
var gdm = function gdm() {
|
|
1974
|
+
trace('onnavigator.mediaDevices.getDisplayMedia', makeEvent$1(JSON.stringify(arguments[0])));
|
|
1975
|
+
return origGetDisplayMedia_1.apply(navigator.mediaDevices, arguments).then(function (stream) {
|
|
1976
|
+
trace('onnavigator.mediaDevices.getDisplayMediaOnSuccess', makeEvent$1(JSON.stringify(dumpStream$1(stream))));
|
|
1977
|
+
return stream;
|
|
1978
|
+
}, function (err) {
|
|
1979
|
+
trace('onnavigator.mediaDevices.getDisplayMediaOnFailure', makeEvent$1(err.name));
|
|
1980
|
+
return Promise.reject(err);
|
|
1981
|
+
});
|
|
1982
|
+
};
|
|
1983
|
+
navigator.mediaDevices.getDisplayMedia = gdm.bind(navigator.mediaDevices);
|
|
1984
|
+
}
|
|
1985
|
+
var getStatsReport = function getStatsReport() {
|
|
1986
|
+
return __awaiter$3(void 0, void 0, void 0, function () {
|
|
1987
|
+
return __generator$1(this, function (_a) {
|
|
1988
|
+
return [2 /*return*/, pc.getStats(null).then(function (res) {
|
|
1989
|
+
// Convert from stats report to js Map in order to have values set in `statsPreProcessor`
|
|
1990
|
+
var statsMap = new Map();
|
|
1991
|
+
res.forEach(function (stats, key) {
|
|
1992
|
+
return statsMap.set(key, stats);
|
|
1993
|
+
});
|
|
1994
|
+
return statsPreProcessor(statsMap).then(function () {
|
|
1995
|
+
var now = map2obj$1(statsMap);
|
|
1996
|
+
var base = deepCopy$2(now); // our new prev
|
|
1997
|
+
var compressed = deltaCompression$1(prev, now);
|
|
1998
|
+
trace('stats-report', formatStatsReport$1(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
|
|
1999
|
+
prev = base;
|
|
2000
|
+
return Promise.resolve();
|
|
2001
|
+
});
|
|
2002
|
+
})];
|
|
2003
|
+
});
|
|
2004
|
+
});
|
|
2005
|
+
};
|
|
2006
|
+
var interval = window.setInterval(function () {
|
|
2007
|
+
if (pc.signalingState === 'closed') {
|
|
2008
|
+
window.clearInterval(interval);
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
getStatsReport();
|
|
2012
|
+
}, intervalTime);
|
|
2013
|
+
var forceStatsReport = function forceStatsReport() {
|
|
2014
|
+
return __awaiter$3(void 0, void 0, void 0, function () {
|
|
2015
|
+
return __generator$1(this, function (_a) {
|
|
2016
|
+
return [2 /*return*/, getStatsReport()];
|
|
2017
|
+
});
|
|
2018
|
+
});
|
|
2019
|
+
};
|
|
2020
|
+
return {
|
|
2021
|
+
forceStatsReport: forceStatsReport
|
|
2022
|
+
};
|
|
2023
|
+
};
|
|
2024
|
+
rtcStats_1$1 = rtcstats$1.rtcStats = rtcStats$1;
|
|
2025
|
+
|
|
1459
2026
|
var global$1 = (typeof global !== "undefined" ? global :
|
|
1460
2027
|
typeof self !== "undefined" ? self :
|
|
1461
2028
|
typeof window !== "undefined" ? window : {});
|
|
@@ -6533,7 +7100,9 @@ var localTrackTypes = [{
|
|
|
6533
7100
|
kind: 'video'
|
|
6534
7101
|
}];
|
|
6535
7102
|
class MediaConnection extends EventEmitter$5 {
|
|
6536
|
-
constructor(mediaConnectionConfig, options
|
|
7103
|
+
constructor(mediaConnectionConfig, options) {
|
|
7104
|
+
var metricsCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
|
|
7105
|
+
var debugId = arguments.length > 3 ? arguments[3] : undefined;
|
|
6537
7106
|
super();
|
|
6538
7107
|
_defineProperty__default["default"](this, "id", void 0);
|
|
6539
7108
|
_defineProperty__default["default"](this, "config", void 0);
|
|
@@ -6542,7 +7111,10 @@ class MediaConnection extends EventEmitter$5 {
|
|
|
6542
7111
|
_defineProperty__default["default"](this, "transceivers", void 0);
|
|
6543
7112
|
_defineProperty__default["default"](this, "mediaDirection", void 0);
|
|
6544
7113
|
_defineProperty__default["default"](this, "remoteQualityLevel", void 0);
|
|
7114
|
+
_defineProperty__default["default"](this, "metricsCallback", void 0);
|
|
7115
|
+
_defineProperty__default["default"](this, "forceStatsReport", void 0);
|
|
6545
7116
|
this.config = mediaConnectionConfig;
|
|
7117
|
+
this.metricsCallback = metricsCallback;
|
|
6546
7118
|
this.mediaDirection = _objectSpread$4({}, options.direction);
|
|
6547
7119
|
this.localTracks = _objectSpread$4({}, options.localTracks);
|
|
6548
7120
|
this.remoteQualityLevel = options.remoteQualityLevel;
|
|
@@ -6552,6 +7124,7 @@ class MediaConnection extends EventEmitter$5 {
|
|
|
6552
7124
|
iceServers: this.config.iceServers,
|
|
6553
7125
|
bundlePolicy: 'max-compat'
|
|
6554
7126
|
});
|
|
7127
|
+
this.forceStatsReport = rtcStats_1$1(this.pc, data => this.metricsCallback(data), 5000).forceStatsReport;
|
|
6555
7128
|
this.pc.ontrack = this.onTrack.bind(this);
|
|
6556
7129
|
this.pc.oniceconnectionstatechange = this.onIceConnectionStateChange.bind(this);
|
|
6557
7130
|
this.pc.onconnectionstatechange = this.onPeerConnectionStateChange.bind(this);
|
|
@@ -6615,6 +7188,9 @@ class MediaConnection extends EventEmitter$5 {
|
|
|
6615
7188
|
getConfig() {
|
|
6616
7189
|
return this.config;
|
|
6617
7190
|
}
|
|
7191
|
+
getMetricsCallback() {
|
|
7192
|
+
return this.metricsCallback;
|
|
7193
|
+
}
|
|
6618
7194
|
getSendReceiveOptions() {
|
|
6619
7195
|
return {
|
|
6620
7196
|
localTracks: this.localTracks,
|
|
@@ -7051,6 +7627,10 @@ class MediaConnection extends EventEmitter$5 {
|
|
|
7051
7627
|
};
|
|
7052
7628
|
});
|
|
7053
7629
|
}
|
|
7630
|
+
forceRtcMetricsCallback() {
|
|
7631
|
+
var _this$forceStatsRepor;
|
|
7632
|
+
(_this$forceStatsRepor = this.forceStatsReport) === null || _this$forceStatsRepor === void 0 ? void 0 : _this$forceStatsRepor.call(this);
|
|
7633
|
+
}
|
|
7054
7634
|
}
|
|
7055
7635
|
|
|
7056
7636
|
/*
|
|
@@ -14985,19 +15565,31 @@ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if
|
|
|
14985
15565
|
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14986
15566
|
class RoapMediaConnection extends EventEmitter$5 {
|
|
14987
15567
|
constructor(mediaConnectionConfig, options, debugId) {
|
|
15568
|
+
var metricsCallback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => {};
|
|
15569
|
+
var closeCallback = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : () => {};
|
|
15570
|
+
var sendMetricsCallback = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : () => {};
|
|
14988
15571
|
super();
|
|
14989
15572
|
_defineProperty__default["default"](this, "id", void 0);
|
|
14990
15573
|
_defineProperty__default["default"](this, "debugId", void 0);
|
|
14991
15574
|
_defineProperty__default["default"](this, "mediaConnection", void 0);
|
|
14992
15575
|
_defineProperty__default["default"](this, "roap", void 0);
|
|
14993
15576
|
_defineProperty__default["default"](this, "sdpNegotiationStarted", void 0);
|
|
15577
|
+
_defineProperty__default["default"](this, "closeCallback", void 0);
|
|
15578
|
+
_defineProperty__default["default"](this, "sendMetricsCallback", void 0);
|
|
14994
15579
|
this.debugId = debugId;
|
|
14995
15580
|
this.id = debugId || 'RoapMediaConnection';
|
|
14996
15581
|
this.sdpNegotiationStarted = false;
|
|
14997
15582
|
configureWcmeLogger(debugId);
|
|
14998
15583
|
this.log('constructor()', "config: ".concat(JSON.stringify(mediaConnectionConfig), ", options: ").concat(JSON.stringify(options)));
|
|
14999
|
-
this.mediaConnection = this.createMediaConnection(
|
|
15584
|
+
this.mediaConnection = this.createMediaConnection({
|
|
15585
|
+
mediaConnectionConfig,
|
|
15586
|
+
options,
|
|
15587
|
+
metricsCallback,
|
|
15588
|
+
debugId
|
|
15589
|
+
});
|
|
15000
15590
|
this.roap = this.createRoap(debugId);
|
|
15591
|
+
this.closeCallback = closeCallback;
|
|
15592
|
+
this.sendMetricsCallback = sendMetricsCallback;
|
|
15001
15593
|
}
|
|
15002
15594
|
log(action, description) {
|
|
15003
15595
|
getLogger().info("".concat(this.id, ":").concat(action, " ").concat(description));
|
|
@@ -15014,8 +15606,14 @@ class RoapMediaConnection extends EventEmitter$5 {
|
|
|
15014
15606
|
_this.emit(eventType, ...eventData);
|
|
15015
15607
|
});
|
|
15016
15608
|
}
|
|
15017
|
-
createMediaConnection(
|
|
15018
|
-
var
|
|
15609
|
+
createMediaConnection(_ref) {
|
|
15610
|
+
var {
|
|
15611
|
+
mediaConnectionConfig,
|
|
15612
|
+
options,
|
|
15613
|
+
metricsCallback,
|
|
15614
|
+
debugId
|
|
15615
|
+
} = _ref;
|
|
15616
|
+
var mediaConnection = new MediaConnection(mediaConnectionConfig, options, metricsCallback, debugId);
|
|
15019
15617
|
mediaConnection.on(exports.MediaConnectionEventNames.REMOTE_TRACK_ADDED, this.onRemoteTrack.bind(this));
|
|
15020
15618
|
this.forwardEvent(mediaConnection, exports.MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED);
|
|
15021
15619
|
this.forwardEvent(mediaConnection, exports.MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED);
|
|
@@ -15051,6 +15649,15 @@ class RoapMediaConnection extends EventEmitter$5 {
|
|
|
15051
15649
|
this.log('close()', 'called');
|
|
15052
15650
|
this.closeMediaConnection();
|
|
15053
15651
|
this.stopRoapSession();
|
|
15652
|
+
this.closeCallback();
|
|
15653
|
+
}
|
|
15654
|
+
forceRtcMetricsSend() {
|
|
15655
|
+
var _this2 = this;
|
|
15656
|
+
return _asyncToGenerator__default["default"](function* () {
|
|
15657
|
+
var _this2$mediaConnectio;
|
|
15658
|
+
yield (_this2$mediaConnectio = _this2.mediaConnection) === null || _this2$mediaConnectio === void 0 ? void 0 : _this2$mediaConnectio.forceRtcMetricsCallback();
|
|
15659
|
+
_this2.sendMetricsCallback();
|
|
15660
|
+
})();
|
|
15054
15661
|
}
|
|
15055
15662
|
closeMediaConnection() {
|
|
15056
15663
|
this.mediaConnection.close();
|
|
@@ -15068,10 +15675,16 @@ class RoapMediaConnection extends EventEmitter$5 {
|
|
|
15068
15675
|
});
|
|
15069
15676
|
var options = this.mediaConnection.getSendReceiveOptions();
|
|
15070
15677
|
var seq = this.roap.getSeq();
|
|
15678
|
+
var callback = this.mediaConnection.getMetricsCallback();
|
|
15071
15679
|
this.stopRoapSession();
|
|
15072
15680
|
this.closeMediaConnection();
|
|
15073
15681
|
this.sdpNegotiationStarted = false;
|
|
15074
|
-
this.mediaConnection = this.createMediaConnection(
|
|
15682
|
+
this.mediaConnection = this.createMediaConnection({
|
|
15683
|
+
mediaConnectionConfig: config,
|
|
15684
|
+
options,
|
|
15685
|
+
metricsCallback: callback,
|
|
15686
|
+
debugId: this.debugId
|
|
15687
|
+
});
|
|
15075
15688
|
this.roap = this.createRoap(this.debugId, seq);
|
|
15076
15689
|
if (initiateOffer) {
|
|
15077
15690
|
return this.initiateOffer();
|