@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/esm/index.js
CHANGED
|
@@ -1445,6 +1445,573 @@ var Error$1 = /*#__PURE__*/Object.freeze({
|
|
|
1445
1445
|
SdpOfferHandlingError: SdpOfferHandlingError
|
|
1446
1446
|
});
|
|
1447
1447
|
|
|
1448
|
+
var commonjsGlobal$5 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
1449
|
+
|
|
1450
|
+
var rtcstats$1 = {};
|
|
1451
|
+
|
|
1452
|
+
var __awaiter$3 = commonjsGlobal$5 && commonjsGlobal$5.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
1453
|
+
function adopt(value) {
|
|
1454
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
1455
|
+
resolve(value);
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1459
|
+
function fulfilled(value) {
|
|
1460
|
+
try {
|
|
1461
|
+
step(generator.next(value));
|
|
1462
|
+
} catch (e) {
|
|
1463
|
+
reject(e);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
function rejected(value) {
|
|
1467
|
+
try {
|
|
1468
|
+
step(generator["throw"](value));
|
|
1469
|
+
} catch (e) {
|
|
1470
|
+
reject(e);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
function step(result) {
|
|
1474
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1475
|
+
}
|
|
1476
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1477
|
+
});
|
|
1478
|
+
};
|
|
1479
|
+
var __generator$1 = commonjsGlobal$5 && commonjsGlobal$5.__generator || function (thisArg, body) {
|
|
1480
|
+
var _ = {
|
|
1481
|
+
label: 0,
|
|
1482
|
+
sent: function sent() {
|
|
1483
|
+
if (t[0] & 1) throw t[1];
|
|
1484
|
+
return t[1];
|
|
1485
|
+
},
|
|
1486
|
+
trys: [],
|
|
1487
|
+
ops: []
|
|
1488
|
+
},
|
|
1489
|
+
f,
|
|
1490
|
+
y,
|
|
1491
|
+
t,
|
|
1492
|
+
g;
|
|
1493
|
+
return g = {
|
|
1494
|
+
next: verb(0),
|
|
1495
|
+
"throw": verb(1),
|
|
1496
|
+
"return": verb(2)
|
|
1497
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
1498
|
+
return this;
|
|
1499
|
+
}), g;
|
|
1500
|
+
function verb(n) {
|
|
1501
|
+
return function (v) {
|
|
1502
|
+
return step([n, v]);
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
function step(op) {
|
|
1506
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1507
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) {
|
|
1508
|
+
try {
|
|
1509
|
+
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;
|
|
1510
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1511
|
+
switch (op[0]) {
|
|
1512
|
+
case 0:
|
|
1513
|
+
case 1:
|
|
1514
|
+
t = op;
|
|
1515
|
+
break;
|
|
1516
|
+
case 4:
|
|
1517
|
+
_.label++;
|
|
1518
|
+
return {
|
|
1519
|
+
value: op[1],
|
|
1520
|
+
done: false
|
|
1521
|
+
};
|
|
1522
|
+
case 5:
|
|
1523
|
+
_.label++;
|
|
1524
|
+
y = op[1];
|
|
1525
|
+
op = [0];
|
|
1526
|
+
continue;
|
|
1527
|
+
case 7:
|
|
1528
|
+
op = _.ops.pop();
|
|
1529
|
+
_.trys.pop();
|
|
1530
|
+
continue;
|
|
1531
|
+
default:
|
|
1532
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1533
|
+
_ = 0;
|
|
1534
|
+
continue;
|
|
1535
|
+
}
|
|
1536
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1537
|
+
_.label = op[1];
|
|
1538
|
+
break;
|
|
1539
|
+
}
|
|
1540
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1541
|
+
_.label = t[1];
|
|
1542
|
+
t = op;
|
|
1543
|
+
break;
|
|
1544
|
+
}
|
|
1545
|
+
if (t && _.label < t[2]) {
|
|
1546
|
+
_.label = t[2];
|
|
1547
|
+
_.ops.push(op);
|
|
1548
|
+
break;
|
|
1549
|
+
}
|
|
1550
|
+
if (t[2]) _.ops.pop();
|
|
1551
|
+
_.trys.pop();
|
|
1552
|
+
continue;
|
|
1553
|
+
}
|
|
1554
|
+
op = body.call(thisArg, _);
|
|
1555
|
+
} catch (e) {
|
|
1556
|
+
op = [6, e];
|
|
1557
|
+
y = 0;
|
|
1558
|
+
} finally {
|
|
1559
|
+
f = t = 0;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
if (op[0] & 5) throw op[1];
|
|
1563
|
+
return {
|
|
1564
|
+
value: op[0] ? op[1] : void 0,
|
|
1565
|
+
done: true
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
Object.defineProperty(rtcstats$1, "__esModule", {
|
|
1570
|
+
value: true
|
|
1571
|
+
});
|
|
1572
|
+
var rtcStats_1$1 = rtcstats$1.rtcStats = void 0;
|
|
1573
|
+
/**
|
|
1574
|
+
* Copies values of any nested depth.
|
|
1575
|
+
*
|
|
1576
|
+
* @param value - The value to be copied.
|
|
1577
|
+
* @returns - Copied value.
|
|
1578
|
+
*/
|
|
1579
|
+
var deepCopy$2 = function deepCopy(value) {
|
|
1580
|
+
return JSON.parse(JSON.stringify(value));
|
|
1581
|
+
};
|
|
1582
|
+
/**
|
|
1583
|
+
* Check deep equality between two values.
|
|
1584
|
+
*
|
|
1585
|
+
* @param value1 - First value to check.
|
|
1586
|
+
* @param value2 - Second value to check.
|
|
1587
|
+
* @returns True if values are deeply equal, false otherwise.
|
|
1588
|
+
*/
|
|
1589
|
+
var deepEqual$1 = function deepEqual(value1, value2) {
|
|
1590
|
+
// If both immutable values are equal, return true.
|
|
1591
|
+
if (value1 === value2) {
|
|
1592
|
+
return true;
|
|
1593
|
+
}
|
|
1594
|
+
// If both are objects, we check the length and properties of each.
|
|
1595
|
+
if (value1 && value2 && typeof value1 === 'object' && typeof value2 === 'object') {
|
|
1596
|
+
if (value1.constructor !== value2.constructor) return false;
|
|
1597
|
+
// Return false if the objects are of different sizes.
|
|
1598
|
+
if (Object.keys(value1).length !== Object.keys(value2).length) {
|
|
1599
|
+
return false;
|
|
1600
|
+
}
|
|
1601
|
+
// Deep equal check each property in the object, returns true if we found no
|
|
1602
|
+
// differing properties.
|
|
1603
|
+
return Object.keys(value1).reduce(function (val, prop) {
|
|
1604
|
+
if (value2[prop]) {
|
|
1605
|
+
if (!deepEqual(value1[prop], value2[prop])) {
|
|
1606
|
+
return false;
|
|
1607
|
+
}
|
|
1608
|
+
} else {
|
|
1609
|
+
return false;
|
|
1610
|
+
}
|
|
1611
|
+
return val;
|
|
1612
|
+
}, true);
|
|
1613
|
+
}
|
|
1614
|
+
// Return false if no other conditions are met.
|
|
1615
|
+
return false;
|
|
1616
|
+
};
|
|
1617
|
+
/**
|
|
1618
|
+
* Translates a Map into an object.
|
|
1619
|
+
*
|
|
1620
|
+
* @param report - The report in Map form.
|
|
1621
|
+
* @returns - A deduped object.
|
|
1622
|
+
*/
|
|
1623
|
+
var map2obj$1 = function map2obj(report) {
|
|
1624
|
+
if (!report.size) {
|
|
1625
|
+
return report;
|
|
1626
|
+
}
|
|
1627
|
+
var o = {};
|
|
1628
|
+
report.forEach(function (value, key) {
|
|
1629
|
+
o[key] = value;
|
|
1630
|
+
});
|
|
1631
|
+
return o;
|
|
1632
|
+
};
|
|
1633
|
+
var dumpStream$1 = function dumpStream(stream) {
|
|
1634
|
+
return {
|
|
1635
|
+
id: stream.id,
|
|
1636
|
+
tracks: stream.getTracks().map(function (track) {
|
|
1637
|
+
return {
|
|
1638
|
+
id: track.id,
|
|
1639
|
+
kind: track.kind,
|
|
1640
|
+
label: track.label,
|
|
1641
|
+
enabled: track.enabled,
|
|
1642
|
+
muted: track.muted,
|
|
1643
|
+
readyState: track.readyState
|
|
1644
|
+
};
|
|
1645
|
+
})
|
|
1646
|
+
};
|
|
1647
|
+
};
|
|
1648
|
+
var persistedKeys$1 = ['type', 'id', 'timestamp'];
|
|
1649
|
+
/**
|
|
1650
|
+
* Check to see if the report consists of more than just the persisted metadata.
|
|
1651
|
+
*
|
|
1652
|
+
* @param report - The report line being checked.
|
|
1653
|
+
* @returns True if the report item contains non-persisted keys, false otherwise.
|
|
1654
|
+
*/
|
|
1655
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1656
|
+
var hasNonMetadata$1 = function hasNonMetadata(report) {
|
|
1657
|
+
return !!Object.keys(report).filter(function (key) {
|
|
1658
|
+
return !persistedKeys$1.includes(key);
|
|
1659
|
+
}).length;
|
|
1660
|
+
};
|
|
1661
|
+
/**
|
|
1662
|
+
* Apply a delta compression to the stats report. Reduces size by ~90%.
|
|
1663
|
+
* To reduce further, report keys could be compressed.
|
|
1664
|
+
*
|
|
1665
|
+
* @param oldStats - Previous report items that we dedupe against.
|
|
1666
|
+
* @param newStats - New incoming stats.
|
|
1667
|
+
* @returns - Compressed Stats.
|
|
1668
|
+
*/
|
|
1669
|
+
var deltaCompression$1 = function deltaCompression(oldStats, newStats) {
|
|
1670
|
+
var updatedStats = deepCopy$2(newStats);
|
|
1671
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
1672
|
+
var report = updatedStats[id];
|
|
1673
|
+
if (!oldStats[id]) {
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
// Persist specific values beyond delta compression, as long as they
|
|
1677
|
+
// aren't the only non-deduped keys.
|
|
1678
|
+
Object.keys(report).forEach(function (name) {
|
|
1679
|
+
if (deepEqual$1(report[name], oldStats[id][name]) && !persistedKeys$1.includes(name)) {
|
|
1680
|
+
delete updatedStats[id][name];
|
|
1681
|
+
}
|
|
1682
|
+
if (!hasNonMetadata$1(report)) {
|
|
1683
|
+
delete updatedStats[id];
|
|
1684
|
+
}
|
|
1685
|
+
});
|
|
1686
|
+
});
|
|
1687
|
+
// Use the most recent timestamp.
|
|
1688
|
+
var timestamp = -Infinity;
|
|
1689
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
1690
|
+
var report = updatedStats[id];
|
|
1691
|
+
if (report.timestamp > timestamp) {
|
|
1692
|
+
timestamp = report.timestamp;
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
// Delete the timestamps on each item.
|
|
1696
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
1697
|
+
var report = updatedStats[id];
|
|
1698
|
+
if (report.timestamp === timestamp) {
|
|
1699
|
+
delete report.timestamp;
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
updatedStats.timestamp = timestamp;
|
|
1703
|
+
return updatedStats;
|
|
1704
|
+
};
|
|
1705
|
+
/**
|
|
1706
|
+
* Format the stats report into an array.
|
|
1707
|
+
*
|
|
1708
|
+
* @param report - A WebRTC stats report.
|
|
1709
|
+
* @returns - An array of Stats Report items.
|
|
1710
|
+
*/
|
|
1711
|
+
var formatStatsReport$1 = function formatStatsReport(report) {
|
|
1712
|
+
return Object.keys(report).filter(function (name) {
|
|
1713
|
+
return name !== 'timestamp';
|
|
1714
|
+
}).map(function (name) {
|
|
1715
|
+
return JSON.stringify(report[name]);
|
|
1716
|
+
});
|
|
1717
|
+
};
|
|
1718
|
+
/**
|
|
1719
|
+
* Parametrize a single string event to contain type and an (empty) id.
|
|
1720
|
+
*
|
|
1721
|
+
* @param value - The value to parametrize.
|
|
1722
|
+
* @returns An event object.
|
|
1723
|
+
*/
|
|
1724
|
+
var makeEvent$1 = function makeEvent(value) {
|
|
1725
|
+
return [JSON.stringify({
|
|
1726
|
+
value: value,
|
|
1727
|
+
type: 'string',
|
|
1728
|
+
id: ''
|
|
1729
|
+
})];
|
|
1730
|
+
};
|
|
1731
|
+
/**
|
|
1732
|
+
* Attach a Peer Connection to periodically get updated on events and stats.
|
|
1733
|
+
*
|
|
1734
|
+
* @param pc - Peer Connection in which we attach.
|
|
1735
|
+
* @param logger - Logging function to log events and stats.
|
|
1736
|
+
* @param intervalTime - Time between each `getStats` check.
|
|
1737
|
+
* @param statsPreProcessor - Optional function that modifies stats.
|
|
1738
|
+
*/
|
|
1739
|
+
var rtcStats$1 = function rtcStats(pc, logger, intervalTime, statsPreProcessor) {
|
|
1740
|
+
if (statsPreProcessor === void 0) {
|
|
1741
|
+
statsPreProcessor = function statsPreProcessor() {
|
|
1742
|
+
return Promise.resolve();
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
var prev = {};
|
|
1746
|
+
/**
|
|
1747
|
+
* Log stats or event data with additional tracking information.
|
|
1748
|
+
*
|
|
1749
|
+
* @param name - Name of the event to log.
|
|
1750
|
+
* @param payload - Log data pertaining to the event.
|
|
1751
|
+
* @param timestamp - Time the event happened in milliseconds.
|
|
1752
|
+
*/
|
|
1753
|
+
var trace = function trace(name, payload, timestamp) {
|
|
1754
|
+
logger({
|
|
1755
|
+
timestamp: timestamp ? Math.round(timestamp) : Date.now(),
|
|
1756
|
+
name: name,
|
|
1757
|
+
payload: payload
|
|
1758
|
+
});
|
|
1759
|
+
};
|
|
1760
|
+
var origPeerConnection = window.RTCPeerConnection;
|
|
1761
|
+
pc.addEventListener('icecandidate', function (e) {
|
|
1762
|
+
if (e.candidate) {
|
|
1763
|
+
trace('onicecandidate', makeEvent$1(JSON.stringify(e.candidate)));
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
pc.addEventListener('icecandidateerror', function (event) {
|
|
1767
|
+
var url = event.url,
|
|
1768
|
+
errorCode = event.errorCode,
|
|
1769
|
+
errorText = event.errorText;
|
|
1770
|
+
trace('onicecandidateerror', makeEvent$1("[".concat(url, "] ").concat(errorCode, ": ").concat(errorText)));
|
|
1771
|
+
});
|
|
1772
|
+
pc.addEventListener('track', function (e) {
|
|
1773
|
+
trace('ontrack', makeEvent$1("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams.map(function (stream) {
|
|
1774
|
+
return "stream:".concat(stream.id);
|
|
1775
|
+
}).join(' '))));
|
|
1776
|
+
});
|
|
1777
|
+
pc.addEventListener('signalingstatechange', function () {
|
|
1778
|
+
trace('onsignalingstatechange', makeEvent$1(pc.signalingState));
|
|
1779
|
+
});
|
|
1780
|
+
pc.addEventListener('iceconnectionstatechange', function () {
|
|
1781
|
+
trace('oniceconnectionstatechange', makeEvent$1(pc.iceConnectionState));
|
|
1782
|
+
});
|
|
1783
|
+
pc.addEventListener('icegatheringstatechange', function () {
|
|
1784
|
+
trace('onicegatheringstatechange', makeEvent$1(pc.iceGatheringState));
|
|
1785
|
+
});
|
|
1786
|
+
pc.addEventListener('connectionstatechange', function () {
|
|
1787
|
+
trace('onconnectionstatechange', makeEvent$1(pc.connectionState));
|
|
1788
|
+
});
|
|
1789
|
+
pc.addEventListener('negotiationneeded', function () {
|
|
1790
|
+
trace('onnegotiationneeded', makeEvent$1('negotiationneeded'));
|
|
1791
|
+
});
|
|
1792
|
+
pc.addEventListener('datachannel', function (event) {
|
|
1793
|
+
trace('ondatachannel', makeEvent$1("".concat(event.channel.id, ": ").concat(event.channel.label)));
|
|
1794
|
+
});
|
|
1795
|
+
['createDataChannel', 'close'].forEach(function (method) {
|
|
1796
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1797
|
+
if (nativeMethod) {
|
|
1798
|
+
origPeerConnection.prototype[method] = function () {
|
|
1799
|
+
trace("on".concat(method), makeEvent$1(method));
|
|
1800
|
+
return nativeMethod.apply(this, arguments);
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
});
|
|
1804
|
+
['addStream', 'removeStream'].forEach(function (method) {
|
|
1805
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1806
|
+
if (nativeMethod) {
|
|
1807
|
+
origPeerConnection.prototype[method] = function () {
|
|
1808
|
+
var stream = arguments[0];
|
|
1809
|
+
var streamInfo = stream.getTracks().map(function (t) {
|
|
1810
|
+
return "".concat(t.kind, ":").concat(t.id);
|
|
1811
|
+
}).join(',');
|
|
1812
|
+
trace("on".concat(method), makeEvent$1("".concat(stream.id, " ").concat(streamInfo)));
|
|
1813
|
+
return nativeMethod.apply(this, arguments);
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
['addTrack'].forEach(function (method) {
|
|
1818
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1819
|
+
if (nativeMethod) {
|
|
1820
|
+
origPeerConnection.prototype[method] = function () {
|
|
1821
|
+
var track = arguments[0];
|
|
1822
|
+
var streams = [].slice.call(arguments, 1);
|
|
1823
|
+
trace("on".concat(method), makeEvent$1("".concat(track.kind, ":").concat(track.id, " ").concat(streams.map(function (s) {
|
|
1824
|
+
return "stream:".concat(s.id);
|
|
1825
|
+
}).join(';') || '-')));
|
|
1826
|
+
return nativeMethod.apply(this, arguments);
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
1829
|
+
});
|
|
1830
|
+
['removeTrack'].forEach(function (method) {
|
|
1831
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1832
|
+
if (nativeMethod) {
|
|
1833
|
+
origPeerConnection.prototype[method] = function () {
|
|
1834
|
+
var track = arguments[0].track;
|
|
1835
|
+
trace("on".concat(method), makeEvent$1(track ? "".concat(track.kind, ":").concat(track.id) : 'null'));
|
|
1836
|
+
return nativeMethod.apply(this, arguments);
|
|
1837
|
+
};
|
|
1838
|
+
}
|
|
1839
|
+
});
|
|
1840
|
+
['createOffer', 'createAnswer'].forEach(function (method) {
|
|
1841
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1842
|
+
if (nativeMethod) {
|
|
1843
|
+
origPeerConnection.prototype[method] = function () {
|
|
1844
|
+
var opts;
|
|
1845
|
+
var args = arguments;
|
|
1846
|
+
if (arguments.length === 1 && typeof arguments[0] === 'object') {
|
|
1847
|
+
// eslint-disable-next-line prefer-destructuring
|
|
1848
|
+
opts = arguments[0];
|
|
1849
|
+
} else if (arguments.length === 3 && typeof arguments[2] === 'object') {
|
|
1850
|
+
// eslint-disable-next-line prefer-destructuring
|
|
1851
|
+
opts = arguments[2];
|
|
1852
|
+
}
|
|
1853
|
+
trace("on".concat(method), makeEvent$1(opts || ''));
|
|
1854
|
+
return nativeMethod.apply(this, opts ? [opts] : undefined).then(function (description) {
|
|
1855
|
+
trace("on".concat(method, "OnSuccess"), makeEvent$1(description.sdp));
|
|
1856
|
+
if (args.length > 0 && typeof args[0] === 'function') {
|
|
1857
|
+
args[0].apply(null, [description]);
|
|
1858
|
+
return undefined;
|
|
1859
|
+
}
|
|
1860
|
+
return description;
|
|
1861
|
+
}, function (err) {
|
|
1862
|
+
trace("on".concat(method, "OnFailure"), makeEvent$1(err.toString()));
|
|
1863
|
+
if (args.length > 1 && typeof args[1] === 'function') {
|
|
1864
|
+
args[1].apply(null, [err]);
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
throw err;
|
|
1868
|
+
});
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
});
|
|
1872
|
+
['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
|
|
1873
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
1874
|
+
if (nativeMethod) {
|
|
1875
|
+
origPeerConnection.prototype[method] = function () {
|
|
1876
|
+
var _this = this;
|
|
1877
|
+
var args = arguments;
|
|
1878
|
+
trace("on".concat(method), makeEvent$1(method === 'addIceCandidate' ? arguments[0] : arguments[0] ? arguments[0].sdp : 'undefined'));
|
|
1879
|
+
return nativeMethod.apply(this, [arguments[0]]).then(function () {
|
|
1880
|
+
var _a;
|
|
1881
|
+
trace("on".concat(method, "OnSuccess"), makeEvent$1('success'));
|
|
1882
|
+
if (method.endsWith('Description')) {
|
|
1883
|
+
if (!_this.transportEventsPreviouslyAdded) {
|
|
1884
|
+
var senders = _this.getSenders();
|
|
1885
|
+
var _loop_1 = function _loop_1(sender) {
|
|
1886
|
+
if (sender.transport) {
|
|
1887
|
+
sender.transport.addEventListener('statechange', function () {
|
|
1888
|
+
if (sender && sender.transport) {
|
|
1889
|
+
trace("ondtlsStateChange", makeEvent$1(sender.transport.state));
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
sender.transport.addEventListener('error', function (error) {
|
|
1893
|
+
var errorEvent = error;
|
|
1894
|
+
trace("ondtlsError", makeEvent$1(errorEvent.error.errorDetail));
|
|
1895
|
+
});
|
|
1896
|
+
if (sender.transport.iceTransport) {
|
|
1897
|
+
sender.transport.iceTransport.addEventListener('selectedcandidatepairchange', function () {
|
|
1898
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1899
|
+
if (sender.transport && sender.transport.iceTransport) {
|
|
1900
|
+
var pair = sender.transport.iceTransport.getSelectedCandidatePair();
|
|
1901
|
+
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);
|
|
1902
|
+
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);
|
|
1903
|
+
var pairString = "local: ".concat(localCandidate, ", remote: ").concat(remoteCandidate);
|
|
1904
|
+
trace('onselectedCandidatePairChange', makeEvent$1(pairString));
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
_this.transportEventsPreviouslyAdded = true;
|
|
1909
|
+
if (pc.getConfiguration().bundlePolicy === 'max-bundle') {
|
|
1910
|
+
return "break";
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
for (var _i = 0, senders_1 = senders; _i < senders_1.length; _i++) {
|
|
1915
|
+
var sender = senders_1[_i];
|
|
1916
|
+
var state_1 = _loop_1(sender);
|
|
1917
|
+
if (state_1 === "break") break;
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
if (!_this.sctpEventsPreviouslyAdded) {
|
|
1921
|
+
// Some Firefox versions prior to 113 have sctp defined but not the events, so check both here.
|
|
1922
|
+
if ((_a = _this.sctp) === null || _a === void 0 ? void 0 : _a.addEventListener) {
|
|
1923
|
+
_this.sctp.addEventListener('statechange', function () {
|
|
1924
|
+
trace('onsctpStateChange', makeEvent$1(_this.sctp.state));
|
|
1925
|
+
});
|
|
1926
|
+
_this.sctpEventsPreviouslyAdded = true;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
if (args.length >= 2 && typeof args[1] === 'function') {
|
|
1931
|
+
args[1].apply(null, []);
|
|
1932
|
+
return undefined;
|
|
1933
|
+
}
|
|
1934
|
+
return undefined;
|
|
1935
|
+
}, function (err) {
|
|
1936
|
+
trace("on".concat(method, "OnFailure"), makeEvent$1(err.toString()));
|
|
1937
|
+
if (args.length >= 3 && typeof args[2] === 'function') {
|
|
1938
|
+
args[2].apply(null, [err]);
|
|
1939
|
+
return undefined;
|
|
1940
|
+
}
|
|
1941
|
+
throw err;
|
|
1942
|
+
});
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
1947
|
+
var origGetUserMedia_1 = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
|
|
1948
|
+
var gum = function gum() {
|
|
1949
|
+
trace('onnavigator.mediaDevices.getUserMedia', makeEvent$1(JSON.stringify(arguments[0])));
|
|
1950
|
+
return origGetUserMedia_1.apply(navigator.mediaDevices, arguments).then(function (stream) {
|
|
1951
|
+
trace('onnavigator.mediaDevices.getUserMediaOnSuccess', makeEvent$1(JSON.stringify(dumpStream$1(stream))));
|
|
1952
|
+
return stream;
|
|
1953
|
+
}, function (err) {
|
|
1954
|
+
trace('onnavigator.mediaDevices.getUserMediaOnFailure', makeEvent$1(err.name));
|
|
1955
|
+
return Promise.reject(err);
|
|
1956
|
+
});
|
|
1957
|
+
};
|
|
1958
|
+
navigator.mediaDevices.getUserMedia = gum.bind(navigator.mediaDevices);
|
|
1959
|
+
}
|
|
1960
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
1961
|
+
var origGetDisplayMedia_1 = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
|
|
1962
|
+
var gdm = function gdm() {
|
|
1963
|
+
trace('onnavigator.mediaDevices.getDisplayMedia', makeEvent$1(JSON.stringify(arguments[0])));
|
|
1964
|
+
return origGetDisplayMedia_1.apply(navigator.mediaDevices, arguments).then(function (stream) {
|
|
1965
|
+
trace('onnavigator.mediaDevices.getDisplayMediaOnSuccess', makeEvent$1(JSON.stringify(dumpStream$1(stream))));
|
|
1966
|
+
return stream;
|
|
1967
|
+
}, function (err) {
|
|
1968
|
+
trace('onnavigator.mediaDevices.getDisplayMediaOnFailure', makeEvent$1(err.name));
|
|
1969
|
+
return Promise.reject(err);
|
|
1970
|
+
});
|
|
1971
|
+
};
|
|
1972
|
+
navigator.mediaDevices.getDisplayMedia = gdm.bind(navigator.mediaDevices);
|
|
1973
|
+
}
|
|
1974
|
+
var getStatsReport = function getStatsReport() {
|
|
1975
|
+
return __awaiter$3(void 0, void 0, void 0, function () {
|
|
1976
|
+
return __generator$1(this, function (_a) {
|
|
1977
|
+
return [2 /*return*/, pc.getStats(null).then(function (res) {
|
|
1978
|
+
// Convert from stats report to js Map in order to have values set in `statsPreProcessor`
|
|
1979
|
+
var statsMap = new Map();
|
|
1980
|
+
res.forEach(function (stats, key) {
|
|
1981
|
+
return statsMap.set(key, stats);
|
|
1982
|
+
});
|
|
1983
|
+
return statsPreProcessor(statsMap).then(function () {
|
|
1984
|
+
var now = map2obj$1(statsMap);
|
|
1985
|
+
var base = deepCopy$2(now); // our new prev
|
|
1986
|
+
var compressed = deltaCompression$1(prev, now);
|
|
1987
|
+
trace('stats-report', formatStatsReport$1(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
|
|
1988
|
+
prev = base;
|
|
1989
|
+
return Promise.resolve();
|
|
1990
|
+
});
|
|
1991
|
+
})];
|
|
1992
|
+
});
|
|
1993
|
+
});
|
|
1994
|
+
};
|
|
1995
|
+
var interval = window.setInterval(function () {
|
|
1996
|
+
if (pc.signalingState === 'closed') {
|
|
1997
|
+
window.clearInterval(interval);
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
getStatsReport();
|
|
2001
|
+
}, intervalTime);
|
|
2002
|
+
var forceStatsReport = function forceStatsReport() {
|
|
2003
|
+
return __awaiter$3(void 0, void 0, void 0, function () {
|
|
2004
|
+
return __generator$1(this, function (_a) {
|
|
2005
|
+
return [2 /*return*/, getStatsReport()];
|
|
2006
|
+
});
|
|
2007
|
+
});
|
|
2008
|
+
};
|
|
2009
|
+
return {
|
|
2010
|
+
forceStatsReport: forceStatsReport
|
|
2011
|
+
};
|
|
2012
|
+
};
|
|
2013
|
+
rtcStats_1$1 = rtcstats$1.rtcStats = rtcStats$1;
|
|
2014
|
+
|
|
1448
2015
|
var global$1 = (typeof global !== "undefined" ? global :
|
|
1449
2016
|
typeof self !== "undefined" ? self :
|
|
1450
2017
|
typeof window !== "undefined" ? window : {});
|
|
@@ -6522,7 +7089,9 @@ var localTrackTypes = [{
|
|
|
6522
7089
|
kind: 'video'
|
|
6523
7090
|
}];
|
|
6524
7091
|
class MediaConnection extends EventEmitter$5 {
|
|
6525
|
-
constructor(mediaConnectionConfig, options
|
|
7092
|
+
constructor(mediaConnectionConfig, options) {
|
|
7093
|
+
var metricsCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
|
|
7094
|
+
var debugId = arguments.length > 3 ? arguments[3] : undefined;
|
|
6526
7095
|
super();
|
|
6527
7096
|
_defineProperty(this, "id", void 0);
|
|
6528
7097
|
_defineProperty(this, "config", void 0);
|
|
@@ -6531,7 +7100,10 @@ class MediaConnection extends EventEmitter$5 {
|
|
|
6531
7100
|
_defineProperty(this, "transceivers", void 0);
|
|
6532
7101
|
_defineProperty(this, "mediaDirection", void 0);
|
|
6533
7102
|
_defineProperty(this, "remoteQualityLevel", void 0);
|
|
7103
|
+
_defineProperty(this, "metricsCallback", void 0);
|
|
7104
|
+
_defineProperty(this, "forceStatsReport", void 0);
|
|
6534
7105
|
this.config = mediaConnectionConfig;
|
|
7106
|
+
this.metricsCallback = metricsCallback;
|
|
6535
7107
|
this.mediaDirection = _objectSpread$4({}, options.direction);
|
|
6536
7108
|
this.localTracks = _objectSpread$4({}, options.localTracks);
|
|
6537
7109
|
this.remoteQualityLevel = options.remoteQualityLevel;
|
|
@@ -6541,6 +7113,7 @@ class MediaConnection extends EventEmitter$5 {
|
|
|
6541
7113
|
iceServers: this.config.iceServers,
|
|
6542
7114
|
bundlePolicy: 'max-compat'
|
|
6543
7115
|
});
|
|
7116
|
+
this.forceStatsReport = rtcStats_1$1(this.pc, data => this.metricsCallback(data), 5000).forceStatsReport;
|
|
6544
7117
|
this.pc.ontrack = this.onTrack.bind(this);
|
|
6545
7118
|
this.pc.oniceconnectionstatechange = this.onIceConnectionStateChange.bind(this);
|
|
6546
7119
|
this.pc.onconnectionstatechange = this.onPeerConnectionStateChange.bind(this);
|
|
@@ -6604,6 +7177,9 @@ class MediaConnection extends EventEmitter$5 {
|
|
|
6604
7177
|
getConfig() {
|
|
6605
7178
|
return this.config;
|
|
6606
7179
|
}
|
|
7180
|
+
getMetricsCallback() {
|
|
7181
|
+
return this.metricsCallback;
|
|
7182
|
+
}
|
|
6607
7183
|
getSendReceiveOptions() {
|
|
6608
7184
|
return {
|
|
6609
7185
|
localTracks: this.localTracks,
|
|
@@ -7040,6 +7616,10 @@ class MediaConnection extends EventEmitter$5 {
|
|
|
7040
7616
|
};
|
|
7041
7617
|
});
|
|
7042
7618
|
}
|
|
7619
|
+
forceRtcMetricsCallback() {
|
|
7620
|
+
var _this$forceStatsRepor;
|
|
7621
|
+
(_this$forceStatsRepor = this.forceStatsReport) === null || _this$forceStatsRepor === void 0 ? void 0 : _this$forceStatsRepor.call(this);
|
|
7622
|
+
}
|
|
7043
7623
|
}
|
|
7044
7624
|
|
|
7045
7625
|
/*
|
|
@@ -14974,19 +15554,31 @@ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if
|
|
|
14974
15554
|
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(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; }
|
|
14975
15555
|
class RoapMediaConnection extends EventEmitter$5 {
|
|
14976
15556
|
constructor(mediaConnectionConfig, options, debugId) {
|
|
15557
|
+
var metricsCallback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => {};
|
|
15558
|
+
var closeCallback = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : () => {};
|
|
15559
|
+
var sendMetricsCallback = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : () => {};
|
|
14977
15560
|
super();
|
|
14978
15561
|
_defineProperty(this, "id", void 0);
|
|
14979
15562
|
_defineProperty(this, "debugId", void 0);
|
|
14980
15563
|
_defineProperty(this, "mediaConnection", void 0);
|
|
14981
15564
|
_defineProperty(this, "roap", void 0);
|
|
14982
15565
|
_defineProperty(this, "sdpNegotiationStarted", void 0);
|
|
15566
|
+
_defineProperty(this, "closeCallback", void 0);
|
|
15567
|
+
_defineProperty(this, "sendMetricsCallback", void 0);
|
|
14983
15568
|
this.debugId = debugId;
|
|
14984
15569
|
this.id = debugId || 'RoapMediaConnection';
|
|
14985
15570
|
this.sdpNegotiationStarted = false;
|
|
14986
15571
|
configureWcmeLogger(debugId);
|
|
14987
15572
|
this.log('constructor()', "config: ".concat(JSON.stringify(mediaConnectionConfig), ", options: ").concat(JSON.stringify(options)));
|
|
14988
|
-
this.mediaConnection = this.createMediaConnection(
|
|
15573
|
+
this.mediaConnection = this.createMediaConnection({
|
|
15574
|
+
mediaConnectionConfig,
|
|
15575
|
+
options,
|
|
15576
|
+
metricsCallback,
|
|
15577
|
+
debugId
|
|
15578
|
+
});
|
|
14989
15579
|
this.roap = this.createRoap(debugId);
|
|
15580
|
+
this.closeCallback = closeCallback;
|
|
15581
|
+
this.sendMetricsCallback = sendMetricsCallback;
|
|
14990
15582
|
}
|
|
14991
15583
|
log(action, description) {
|
|
14992
15584
|
getLogger().info("".concat(this.id, ":").concat(action, " ").concat(description));
|
|
@@ -15003,8 +15595,14 @@ class RoapMediaConnection extends EventEmitter$5 {
|
|
|
15003
15595
|
_this.emit(eventType, ...eventData);
|
|
15004
15596
|
});
|
|
15005
15597
|
}
|
|
15006
|
-
createMediaConnection(
|
|
15007
|
-
var
|
|
15598
|
+
createMediaConnection(_ref) {
|
|
15599
|
+
var {
|
|
15600
|
+
mediaConnectionConfig,
|
|
15601
|
+
options,
|
|
15602
|
+
metricsCallback,
|
|
15603
|
+
debugId
|
|
15604
|
+
} = _ref;
|
|
15605
|
+
var mediaConnection = new MediaConnection(mediaConnectionConfig, options, metricsCallback, debugId);
|
|
15008
15606
|
mediaConnection.on(MediaConnectionEventNames.REMOTE_TRACK_ADDED, this.onRemoteTrack.bind(this));
|
|
15009
15607
|
this.forwardEvent(mediaConnection, MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED);
|
|
15010
15608
|
this.forwardEvent(mediaConnection, MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED);
|
|
@@ -15040,6 +15638,15 @@ class RoapMediaConnection extends EventEmitter$5 {
|
|
|
15040
15638
|
this.log('close()', 'called');
|
|
15041
15639
|
this.closeMediaConnection();
|
|
15042
15640
|
this.stopRoapSession();
|
|
15641
|
+
this.closeCallback();
|
|
15642
|
+
}
|
|
15643
|
+
forceRtcMetricsSend() {
|
|
15644
|
+
var _this2 = this;
|
|
15645
|
+
return _asyncToGenerator(function* () {
|
|
15646
|
+
var _this2$mediaConnectio;
|
|
15647
|
+
yield (_this2$mediaConnectio = _this2.mediaConnection) === null || _this2$mediaConnectio === void 0 ? void 0 : _this2$mediaConnectio.forceRtcMetricsCallback();
|
|
15648
|
+
_this2.sendMetricsCallback();
|
|
15649
|
+
})();
|
|
15043
15650
|
}
|
|
15044
15651
|
closeMediaConnection() {
|
|
15045
15652
|
this.mediaConnection.close();
|
|
@@ -15057,10 +15664,16 @@ class RoapMediaConnection extends EventEmitter$5 {
|
|
|
15057
15664
|
});
|
|
15058
15665
|
var options = this.mediaConnection.getSendReceiveOptions();
|
|
15059
15666
|
var seq = this.roap.getSeq();
|
|
15667
|
+
var callback = this.mediaConnection.getMetricsCallback();
|
|
15060
15668
|
this.stopRoapSession();
|
|
15061
15669
|
this.closeMediaConnection();
|
|
15062
15670
|
this.sdpNegotiationStarted = false;
|
|
15063
|
-
this.mediaConnection = this.createMediaConnection(
|
|
15671
|
+
this.mediaConnection = this.createMediaConnection({
|
|
15672
|
+
mediaConnectionConfig: config,
|
|
15673
|
+
options,
|
|
15674
|
+
metricsCallback: callback,
|
|
15675
|
+
debugId: this.debugId
|
|
15676
|
+
});
|
|
15064
15677
|
this.roap = this.createRoap(this.debugId, seq);
|
|
15065
15678
|
if (initiateOffer) {
|
|
15066
15679
|
return this.initiateOffer();
|