@whereby.com/media 1.32.1 → 2.0.0
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 +35 -728
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +36 -725
- package/dist/legacy-esm.js +36 -725
- package/package.json +4 -4
package/dist/legacy-esm.js
CHANGED
|
@@ -6,18 +6,7 @@ import * as sdpTransform from 'sdp-transform';
|
|
|
6
6
|
import { Address6 } from 'ip-address';
|
|
7
7
|
import checkIp from 'check-ip';
|
|
8
8
|
import validate from 'uuid-validate';
|
|
9
|
-
import { Device,
|
|
10
|
-
import { UAParser } from 'ua-parser-js';
|
|
11
|
-
import { Logger as Logger$1 } from 'mediasoup-client/lib/Logger.js';
|
|
12
|
-
import * as utils from 'mediasoup-client/lib/utils.js';
|
|
13
|
-
import * as ortc from 'mediasoup-client/lib/ortc.js';
|
|
14
|
-
import * as sdpCommonUtils from 'mediasoup-client/lib/handlers/sdp/commonUtils.js';
|
|
15
|
-
import * as ortcUtils from 'mediasoup-client/lib/handlers/ortc/utils.js';
|
|
16
|
-
import { InvalidStateError } from 'mediasoup-client/lib/errors.js';
|
|
17
|
-
import { HandlerInterface } from 'mediasoup-client/lib/handlers/HandlerInterface.js';
|
|
18
|
-
import { RemoteSdp } from 'mediasoup-client/lib/handlers/sdp/RemoteSdp.js';
|
|
19
|
-
import { parse } from 'mediasoup-client/lib/scalabilityModes.js';
|
|
20
|
-
import { Safari12 } from 'mediasoup-client/lib/handlers/Safari12.js';
|
|
9
|
+
import { Device, detectDeviceAsync } from 'mediasoup-client';
|
|
21
10
|
import EventEmitter, { EventEmitter as EventEmitter$1 } from 'events';
|
|
22
11
|
import { io } from 'socket.io-client';
|
|
23
12
|
|
|
@@ -842,7 +831,7 @@ function subscribeStats(subscription, options = OPTIONS, state = STATE) {
|
|
|
842
831
|
|
|
843
832
|
var _a$6;
|
|
844
833
|
const adapter$6 = (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
|
|
845
|
-
const logger$
|
|
834
|
+
const logger$a = new Logger();
|
|
846
835
|
const browserName$2 = adapter$6.browserDetails.browser;
|
|
847
836
|
const browserVersion$1 = adapter$6.browserDetails.version;
|
|
848
837
|
function setCodecPreferenceSDP(sdp, redOn) {
|
|
@@ -883,7 +872,7 @@ function setCodecPreferenceSDP(sdp, redOn) {
|
|
|
883
872
|
return newSdp;
|
|
884
873
|
}
|
|
885
874
|
catch (error) {
|
|
886
|
-
logger$
|
|
875
|
+
logger$a.error("setCodecPreferenceSDP error:", error);
|
|
887
876
|
}
|
|
888
877
|
}
|
|
889
878
|
function cleanSdp(sdp) {
|
|
@@ -1069,7 +1058,7 @@ function setVideoBandwidthUsingSetParameters(pc, bandwidth, logger = console) {
|
|
|
1069
1058
|
|
|
1070
1059
|
var _a$5;
|
|
1071
1060
|
const adapter$5 = (_a$5 = adapterRaw.default) !== null && _a$5 !== void 0 ? _a$5 : adapterRaw;
|
|
1072
|
-
const logger$
|
|
1061
|
+
const logger$9 = new Logger();
|
|
1073
1062
|
class Session {
|
|
1074
1063
|
constructor({ peerConnectionId, bandwidth, deprioritizeH264Encoding, }) {
|
|
1075
1064
|
this.peerConnectionId = peerConnectionId;
|
|
@@ -1213,7 +1202,7 @@ class Session {
|
|
|
1213
1202
|
return this._setRemoteDescription(desc).then(() => {
|
|
1214
1203
|
return setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
|
|
1215
1204
|
}, (e) => {
|
|
1216
|
-
logger$
|
|
1205
|
+
logger$9.warn("Could not set remote description from remote answer: ", e);
|
|
1217
1206
|
});
|
|
1218
1207
|
}
|
|
1219
1208
|
addIceCandidate(candidate) {
|
|
@@ -1229,7 +1218,7 @@ class Session {
|
|
|
1229
1218
|
return;
|
|
1230
1219
|
}
|
|
1231
1220
|
this.pc.addIceCandidate(candidate).catch((e) => {
|
|
1232
|
-
logger$
|
|
1221
|
+
logger$9.warn("Failed to add ICE candidate ('%s'): %s", candidate ? candidate.candidate : null, e);
|
|
1233
1222
|
});
|
|
1234
1223
|
});
|
|
1235
1224
|
}
|
|
@@ -1248,7 +1237,7 @@ class Session {
|
|
|
1248
1237
|
pc.close();
|
|
1249
1238
|
}
|
|
1250
1239
|
catch (e) {
|
|
1251
|
-
logger$
|
|
1240
|
+
logger$9.warn("failures during close of session", e);
|
|
1252
1241
|
}
|
|
1253
1242
|
}
|
|
1254
1243
|
hasConnectedPeerConnection() {
|
|
@@ -1749,694 +1738,17 @@ const generateByteString = (count) => {
|
|
|
1749
1738
|
return result + result.substring(0, count - result.length);
|
|
1750
1739
|
};
|
|
1751
1740
|
|
|
1752
|
-
const
|
|
1753
|
-
const NAME = "Safari17";
|
|
1754
|
-
const SCTP_NUM_STREAMS = { OS: 1024, MIS: 1024 };
|
|
1755
|
-
class Safari17 extends HandlerInterface {
|
|
1756
|
-
static createFactory() {
|
|
1757
|
-
return () => new Safari17();
|
|
1758
|
-
}
|
|
1759
|
-
constructor() {
|
|
1760
|
-
super();
|
|
1761
|
-
this._closed = false;
|
|
1762
|
-
this._mapMidTransceiver = new Map();
|
|
1763
|
-
this._sendStream = new MediaStream();
|
|
1764
|
-
this._hasDataChannelMediaSection = false;
|
|
1765
|
-
this._nextSendSctpStreamId = 0;
|
|
1766
|
-
this._transportReady = false;
|
|
1767
|
-
}
|
|
1768
|
-
get name() {
|
|
1769
|
-
return NAME;
|
|
1770
|
-
}
|
|
1771
|
-
close() {
|
|
1772
|
-
logger$9.debug("close()");
|
|
1773
|
-
if (this._closed) {
|
|
1774
|
-
return;
|
|
1775
|
-
}
|
|
1776
|
-
this._closed = true;
|
|
1777
|
-
if (this._pc) {
|
|
1778
|
-
try {
|
|
1779
|
-
this._pc.close();
|
|
1780
|
-
}
|
|
1781
|
-
catch (error) { }
|
|
1782
|
-
}
|
|
1783
|
-
this.emit("@close");
|
|
1784
|
-
}
|
|
1785
|
-
getNativeRtpCapabilities() {
|
|
1786
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1787
|
-
logger$9.debug("getNativeRtpCapabilities()");
|
|
1788
|
-
const pc = new RTCPeerConnection({
|
|
1789
|
-
iceServers: [],
|
|
1790
|
-
iceTransportPolicy: "all",
|
|
1791
|
-
bundlePolicy: "max-bundle",
|
|
1792
|
-
rtcpMuxPolicy: "require",
|
|
1793
|
-
});
|
|
1794
|
-
try {
|
|
1795
|
-
pc.addTransceiver("audio");
|
|
1796
|
-
pc.addTransceiver("video");
|
|
1797
|
-
const offer = yield pc.createOffer();
|
|
1798
|
-
try {
|
|
1799
|
-
pc.close();
|
|
1800
|
-
}
|
|
1801
|
-
catch (error) { }
|
|
1802
|
-
const sdpObject = sdpTransform.parse(offer.sdp);
|
|
1803
|
-
const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities({
|
|
1804
|
-
sdpObject,
|
|
1805
|
-
});
|
|
1806
|
-
ortcUtils.addNackSuppportForOpus(nativeRtpCapabilities);
|
|
1807
|
-
return nativeRtpCapabilities;
|
|
1808
|
-
}
|
|
1809
|
-
catch (error) {
|
|
1810
|
-
try {
|
|
1811
|
-
pc.close();
|
|
1812
|
-
}
|
|
1813
|
-
catch (error2) { }
|
|
1814
|
-
throw error;
|
|
1815
|
-
}
|
|
1816
|
-
});
|
|
1817
|
-
}
|
|
1818
|
-
getNativeSctpCapabilities() {
|
|
1819
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1820
|
-
logger$9.debug("getNativeSctpCapabilities()");
|
|
1821
|
-
return {
|
|
1822
|
-
numStreams: SCTP_NUM_STREAMS,
|
|
1823
|
-
};
|
|
1824
|
-
});
|
|
1825
|
-
}
|
|
1826
|
-
run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities, }) {
|
|
1827
|
-
this.assertNotClosed();
|
|
1828
|
-
logger$9.debug("run()");
|
|
1829
|
-
this._direction = direction;
|
|
1830
|
-
this._remoteSdp = new RemoteSdp({
|
|
1831
|
-
iceParameters,
|
|
1832
|
-
iceCandidates,
|
|
1833
|
-
dtlsParameters,
|
|
1834
|
-
sctpParameters,
|
|
1835
|
-
});
|
|
1836
|
-
this._sendingRtpParametersByKind = {
|
|
1837
|
-
audio: ortc.getSendingRtpParameters("audio", extendedRtpCapabilities),
|
|
1838
|
-
video: ortc.getSendingRtpParameters("video", extendedRtpCapabilities),
|
|
1839
|
-
};
|
|
1840
|
-
this._sendingRemoteRtpParametersByKind = {
|
|
1841
|
-
audio: ortc.getSendingRemoteRtpParameters("audio", extendedRtpCapabilities),
|
|
1842
|
-
video: ortc.getSendingRemoteRtpParameters("video", extendedRtpCapabilities),
|
|
1843
|
-
};
|
|
1844
|
-
if (dtlsParameters.role && dtlsParameters.role !== "auto") {
|
|
1845
|
-
this._forcedLocalDtlsRole = dtlsParameters.role === "server" ? "client" : "server";
|
|
1846
|
-
}
|
|
1847
|
-
this._pc = new RTCPeerConnection(Object.assign({ iceServers: iceServers !== null && iceServers !== void 0 ? iceServers : [], iceTransportPolicy: iceTransportPolicy !== null && iceTransportPolicy !== void 0 ? iceTransportPolicy : "all", bundlePolicy: "max-bundle", rtcpMuxPolicy: "require" }, additionalSettings), proprietaryConstraints);
|
|
1848
|
-
this._pc.addEventListener("icegatheringstatechange", () => {
|
|
1849
|
-
this.emit("@icegatheringstatechange", this._pc.iceGatheringState);
|
|
1850
|
-
});
|
|
1851
|
-
if (this._pc.connectionState) {
|
|
1852
|
-
this._pc.addEventListener("connectionstatechange", () => {
|
|
1853
|
-
this.emit("@connectionstatechange", this._pc.connectionState);
|
|
1854
|
-
});
|
|
1855
|
-
}
|
|
1856
|
-
else {
|
|
1857
|
-
this._pc.addEventListener("iceconnectionstatechange", () => {
|
|
1858
|
-
logger$9.warn("run() | pc.connectionState not supported, using pc.iceConnectionState");
|
|
1859
|
-
switch (this._pc.iceConnectionState) {
|
|
1860
|
-
case "checking": {
|
|
1861
|
-
this.emit("@connectionstatechange", "connecting");
|
|
1862
|
-
break;
|
|
1863
|
-
}
|
|
1864
|
-
case "connected":
|
|
1865
|
-
case "completed": {
|
|
1866
|
-
this.emit("@connectionstatechange", "connected");
|
|
1867
|
-
break;
|
|
1868
|
-
}
|
|
1869
|
-
case "failed": {
|
|
1870
|
-
this.emit("@connectionstatechange", "failed");
|
|
1871
|
-
break;
|
|
1872
|
-
}
|
|
1873
|
-
case "disconnected": {
|
|
1874
|
-
this.emit("@connectionstatechange", "disconnected");
|
|
1875
|
-
break;
|
|
1876
|
-
}
|
|
1877
|
-
case "closed": {
|
|
1878
|
-
this.emit("@connectionstatechange", "closed");
|
|
1879
|
-
break;
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
});
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
updateIceServers(iceServers) {
|
|
1886
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1887
|
-
this.assertNotClosed();
|
|
1888
|
-
logger$9.debug("updateIceServers()");
|
|
1889
|
-
const configuration = this._pc.getConfiguration();
|
|
1890
|
-
configuration.iceServers = iceServers;
|
|
1891
|
-
this._pc.setConfiguration(configuration);
|
|
1892
|
-
});
|
|
1893
|
-
}
|
|
1894
|
-
restartIce(iceParameters) {
|
|
1895
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1896
|
-
this.assertNotClosed();
|
|
1897
|
-
logger$9.debug("restartIce()");
|
|
1898
|
-
this._remoteSdp.updateIceParameters(iceParameters);
|
|
1899
|
-
if (!this._transportReady) {
|
|
1900
|
-
return;
|
|
1901
|
-
}
|
|
1902
|
-
if (this._direction === "send") {
|
|
1903
|
-
const offer = yield this._pc.createOffer({ iceRestart: true });
|
|
1904
|
-
logger$9.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]", offer);
|
|
1905
|
-
yield this._pc.setLocalDescription(offer);
|
|
1906
|
-
const answer = { type: "answer", sdp: this._remoteSdp.getSdp() };
|
|
1907
|
-
logger$9.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
1908
|
-
yield this._pc.setRemoteDescription(answer);
|
|
1909
|
-
}
|
|
1910
|
-
else {
|
|
1911
|
-
const offer = { type: "offer", sdp: this._remoteSdp.getSdp() };
|
|
1912
|
-
logger$9.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]", offer);
|
|
1913
|
-
yield this._pc.setRemoteDescription(offer);
|
|
1914
|
-
const answer = yield this._pc.createAnswer();
|
|
1915
|
-
logger$9.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]", answer);
|
|
1916
|
-
yield this._pc.setLocalDescription(answer);
|
|
1917
|
-
}
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
getTransportStats() {
|
|
1921
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1922
|
-
this.assertNotClosed();
|
|
1923
|
-
return this._pc.getStats();
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
|
-
send(_a) {
|
|
1927
|
-
return __awaiter(this, arguments, void 0, function* ({ track, encodings, codecOptions, codec, onRtpSender }) {
|
|
1928
|
-
var _b;
|
|
1929
|
-
this.assertNotClosed();
|
|
1930
|
-
this.assertSendDirection();
|
|
1931
|
-
logger$9.debug("send() [kind:%s, track.id:%s]", track.kind, track.id);
|
|
1932
|
-
const sendingRtpParameters = utils.clone(this._sendingRtpParametersByKind[track.kind]);
|
|
1933
|
-
sendingRtpParameters.codecs = ortc.reduceCodecs(sendingRtpParameters.codecs, codec);
|
|
1934
|
-
if (encodings && encodings.length > 1 && encodings.every(({ rid }) => !rid)) {
|
|
1935
|
-
encodings = encodings.map((e, i) => {
|
|
1936
|
-
e.rid = `r${i}`;
|
|
1937
|
-
return e;
|
|
1938
|
-
});
|
|
1939
|
-
}
|
|
1940
|
-
if (encodings) {
|
|
1941
|
-
if (!sendingRtpParameters.encodings) {
|
|
1942
|
-
sendingRtpParameters.encodings = [];
|
|
1943
|
-
}
|
|
1944
|
-
Object.assign(sendingRtpParameters.encodings, encodings);
|
|
1945
|
-
}
|
|
1946
|
-
const layers = parse((encodings !== null && encodings !== void 0 ? encodings : [{}])[0].scalabilityMode);
|
|
1947
|
-
if (sendingRtpParameters.encodings &&
|
|
1948
|
-
sendingRtpParameters.encodings.length > 1 &&
|
|
1949
|
-
(sendingRtpParameters.codecs[0].mimeType.toLowerCase() === "video/vp8" ||
|
|
1950
|
-
sendingRtpParameters.codecs[0].mimeType.toLowerCase() === "video/h264")) {
|
|
1951
|
-
for (const encoding of sendingRtpParameters.encodings) {
|
|
1952
|
-
if (encoding.scalabilityMode) {
|
|
1953
|
-
encoding.scalabilityMode = `L1T${layers.temporalLayers}`;
|
|
1954
|
-
}
|
|
1955
|
-
else {
|
|
1956
|
-
encoding.scalabilityMode = "L1T3";
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
const sendingRemoteRtpParameters = utils.clone(this._sendingRemoteRtpParametersByKind[track.kind]);
|
|
1961
|
-
sendingRemoteRtpParameters.codecs = ortc.reduceCodecs(sendingRemoteRtpParameters.codecs, codec);
|
|
1962
|
-
const mediaSectionIdx = this._remoteSdp.getNextMediaSectionIdx();
|
|
1963
|
-
const transceiver = this._pc.addTransceiver(track, {
|
|
1964
|
-
direction: "sendonly",
|
|
1965
|
-
streams: [this._sendStream],
|
|
1966
|
-
sendEncodings: track.kind === "video" ? encodings : undefined,
|
|
1967
|
-
});
|
|
1968
|
-
if (onRtpSender) {
|
|
1969
|
-
onRtpSender(transceiver.sender);
|
|
1970
|
-
}
|
|
1971
|
-
const offer = yield this._pc.createOffer();
|
|
1972
|
-
const localSdpObject = sdpTransform.parse(offer.sdp);
|
|
1973
|
-
let offerMediaObject = localSdpObject.media[mediaSectionIdx.idx];
|
|
1974
|
-
if (!this._transportReady) {
|
|
1975
|
-
yield this.setupTransport({
|
|
1976
|
-
localDtlsRole: (_b = this._forcedLocalDtlsRole) !== null && _b !== void 0 ? _b : "client",
|
|
1977
|
-
localSdpObject,
|
|
1978
|
-
});
|
|
1979
|
-
}
|
|
1980
|
-
logger$9.debug("send() | calling pc.setLocalDescription() [offer:%o]", offer);
|
|
1981
|
-
yield this._pc.setLocalDescription(offer);
|
|
1982
|
-
const localId = transceiver.mid;
|
|
1983
|
-
sendingRtpParameters.mid = localId;
|
|
1984
|
-
offerMediaObject = localSdpObject.media[mediaSectionIdx.idx];
|
|
1985
|
-
sendingRtpParameters.rtcp.cname = sdpCommonUtils.getCname({
|
|
1986
|
-
offerMediaObject,
|
|
1987
|
-
});
|
|
1988
|
-
this._remoteSdp.send({
|
|
1989
|
-
offerMediaObject,
|
|
1990
|
-
reuseMid: mediaSectionIdx.reuseMid,
|
|
1991
|
-
offerRtpParameters: sendingRtpParameters,
|
|
1992
|
-
answerRtpParameters: sendingRemoteRtpParameters,
|
|
1993
|
-
codecOptions,
|
|
1994
|
-
});
|
|
1995
|
-
const answer = { type: "answer", sdp: this._remoteSdp.getSdp() };
|
|
1996
|
-
logger$9.debug("send() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
1997
|
-
yield this._pc.setRemoteDescription(answer);
|
|
1998
|
-
this._mapMidTransceiver.set(localId, transceiver);
|
|
1999
|
-
return {
|
|
2000
|
-
localId,
|
|
2001
|
-
rtpParameters: sendingRtpParameters,
|
|
2002
|
-
rtpSender: transceiver.sender,
|
|
2003
|
-
};
|
|
2004
|
-
});
|
|
2005
|
-
}
|
|
2006
|
-
stopSending(localId) {
|
|
2007
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2008
|
-
this.assertSendDirection();
|
|
2009
|
-
if (this._closed) {
|
|
2010
|
-
return;
|
|
2011
|
-
}
|
|
2012
|
-
logger$9.debug("stopSending() [localId:%s]", localId);
|
|
2013
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2014
|
-
if (!transceiver) {
|
|
2015
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2016
|
-
}
|
|
2017
|
-
void transceiver.sender.replaceTrack(null);
|
|
2018
|
-
this._pc.removeTrack(transceiver.sender);
|
|
2019
|
-
const mediaSectionClosed = this._remoteSdp.closeMediaSection(transceiver.mid);
|
|
2020
|
-
if (mediaSectionClosed) {
|
|
2021
|
-
try {
|
|
2022
|
-
transceiver.stop();
|
|
2023
|
-
}
|
|
2024
|
-
catch (error) { }
|
|
2025
|
-
}
|
|
2026
|
-
const offer = yield this._pc.createOffer();
|
|
2027
|
-
logger$9.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]", offer);
|
|
2028
|
-
yield this._pc.setLocalDescription(offer);
|
|
2029
|
-
const answer = { type: "answer", sdp: this._remoteSdp.getSdp() };
|
|
2030
|
-
logger$9.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
2031
|
-
yield this._pc.setRemoteDescription(answer);
|
|
2032
|
-
this._mapMidTransceiver.delete(localId);
|
|
2033
|
-
});
|
|
2034
|
-
}
|
|
2035
|
-
pauseSending(localId) {
|
|
2036
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2037
|
-
this.assertNotClosed();
|
|
2038
|
-
this.assertSendDirection();
|
|
2039
|
-
logger$9.debug("pauseSending() [localId:%s]", localId);
|
|
2040
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2041
|
-
if (!transceiver) {
|
|
2042
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2043
|
-
}
|
|
2044
|
-
transceiver.direction = "inactive";
|
|
2045
|
-
this._remoteSdp.pauseMediaSection(localId);
|
|
2046
|
-
const offer = yield this._pc.createOffer();
|
|
2047
|
-
logger$9.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]", offer);
|
|
2048
|
-
yield this._pc.setLocalDescription(offer);
|
|
2049
|
-
const answer = { type: "answer", sdp: this._remoteSdp.getSdp() };
|
|
2050
|
-
logger$9.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
2051
|
-
yield this._pc.setRemoteDescription(answer);
|
|
2052
|
-
});
|
|
2053
|
-
}
|
|
2054
|
-
resumeSending(localId) {
|
|
2055
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2056
|
-
this.assertNotClosed();
|
|
2057
|
-
this.assertSendDirection();
|
|
2058
|
-
logger$9.debug("resumeSending() [localId:%s]", localId);
|
|
2059
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2060
|
-
if (!transceiver) {
|
|
2061
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2062
|
-
}
|
|
2063
|
-
transceiver.direction = "sendonly";
|
|
2064
|
-
this._remoteSdp.resumeSendingMediaSection(localId);
|
|
2065
|
-
const offer = yield this._pc.createOffer();
|
|
2066
|
-
logger$9.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]", offer);
|
|
2067
|
-
yield this._pc.setLocalDescription(offer);
|
|
2068
|
-
const answer = { type: "answer", sdp: this._remoteSdp.getSdp() };
|
|
2069
|
-
logger$9.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
2070
|
-
yield this._pc.setRemoteDescription(answer);
|
|
2071
|
-
});
|
|
2072
|
-
}
|
|
2073
|
-
replaceTrack(localId, track) {
|
|
2074
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2075
|
-
this.assertNotClosed();
|
|
2076
|
-
this.assertSendDirection();
|
|
2077
|
-
if (track) {
|
|
2078
|
-
logger$9.debug("replaceTrack() [localId:%s, track.id:%s]", localId, track.id);
|
|
2079
|
-
}
|
|
2080
|
-
else {
|
|
2081
|
-
logger$9.debug("replaceTrack() [localId:%s, no track]", localId);
|
|
2082
|
-
}
|
|
2083
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2084
|
-
if (!transceiver) {
|
|
2085
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2086
|
-
}
|
|
2087
|
-
yield transceiver.sender.replaceTrack(track);
|
|
2088
|
-
});
|
|
2089
|
-
}
|
|
2090
|
-
setMaxSpatialLayer(localId, spatialLayer) {
|
|
2091
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2092
|
-
this.assertNotClosed();
|
|
2093
|
-
this.assertSendDirection();
|
|
2094
|
-
logger$9.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]", localId, spatialLayer);
|
|
2095
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2096
|
-
if (!transceiver) {
|
|
2097
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2098
|
-
}
|
|
2099
|
-
const parameters = transceiver.sender.getParameters();
|
|
2100
|
-
parameters.encodings.forEach((encoding, idx) => {
|
|
2101
|
-
if (idx <= spatialLayer) {
|
|
2102
|
-
encoding.active = true;
|
|
2103
|
-
}
|
|
2104
|
-
else {
|
|
2105
|
-
encoding.active = false;
|
|
2106
|
-
}
|
|
2107
|
-
});
|
|
2108
|
-
yield transceiver.sender.setParameters(parameters);
|
|
2109
|
-
this._remoteSdp.muxMediaSectionSimulcast(localId, parameters.encodings);
|
|
2110
|
-
const offer = yield this._pc.createOffer();
|
|
2111
|
-
logger$9.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]", offer);
|
|
2112
|
-
yield this._pc.setLocalDescription(offer);
|
|
2113
|
-
const answer = { type: "answer", sdp: this._remoteSdp.getSdp() };
|
|
2114
|
-
logger$9.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
2115
|
-
yield this._pc.setRemoteDescription(answer);
|
|
2116
|
-
});
|
|
2117
|
-
}
|
|
2118
|
-
setRtpEncodingParameters(localId, params) {
|
|
2119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2120
|
-
this.assertNotClosed();
|
|
2121
|
-
this.assertSendDirection();
|
|
2122
|
-
logger$9.debug("setRtpEncodingParameters() [localId:%s, params:%o]", localId, params);
|
|
2123
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2124
|
-
if (!transceiver) {
|
|
2125
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2126
|
-
}
|
|
2127
|
-
const parameters = transceiver.sender.getParameters();
|
|
2128
|
-
parameters.encodings.forEach((encoding, idx) => {
|
|
2129
|
-
parameters.encodings[idx] = Object.assign(Object.assign({}, encoding), params);
|
|
2130
|
-
});
|
|
2131
|
-
yield transceiver.sender.setParameters(parameters);
|
|
2132
|
-
this._remoteSdp.muxMediaSectionSimulcast(localId, parameters.encodings);
|
|
2133
|
-
const offer = yield this._pc.createOffer();
|
|
2134
|
-
logger$9.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]", offer);
|
|
2135
|
-
yield this._pc.setLocalDescription(offer);
|
|
2136
|
-
const answer = { type: "answer", sdp: this._remoteSdp.getSdp() };
|
|
2137
|
-
logger$9.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
2138
|
-
yield this._pc.setRemoteDescription(answer);
|
|
2139
|
-
});
|
|
2140
|
-
}
|
|
2141
|
-
getSenderStats(localId) {
|
|
2142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2143
|
-
this.assertNotClosed();
|
|
2144
|
-
this.assertSendDirection();
|
|
2145
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2146
|
-
if (!transceiver) {
|
|
2147
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2148
|
-
}
|
|
2149
|
-
return transceiver.sender.getStats();
|
|
2150
|
-
});
|
|
2151
|
-
}
|
|
2152
|
-
sendDataChannel(_a) {
|
|
2153
|
-
return __awaiter(this, arguments, void 0, function* ({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol, }) {
|
|
2154
|
-
var _b;
|
|
2155
|
-
this.assertNotClosed();
|
|
2156
|
-
this.assertSendDirection();
|
|
2157
|
-
const options = {
|
|
2158
|
-
negotiated: true,
|
|
2159
|
-
id: this._nextSendSctpStreamId,
|
|
2160
|
-
ordered,
|
|
2161
|
-
maxPacketLifeTime,
|
|
2162
|
-
maxRetransmits,
|
|
2163
|
-
protocol,
|
|
2164
|
-
};
|
|
2165
|
-
logger$9.debug("sendDataChannel() [options:%o]", options);
|
|
2166
|
-
const dataChannel = this._pc.createDataChannel(label, options);
|
|
2167
|
-
this._nextSendSctpStreamId = ++this._nextSendSctpStreamId % SCTP_NUM_STREAMS.MIS;
|
|
2168
|
-
if (!this._hasDataChannelMediaSection) {
|
|
2169
|
-
const offer = yield this._pc.createOffer();
|
|
2170
|
-
const localSdpObject = sdpTransform.parse(offer.sdp);
|
|
2171
|
-
const offerMediaObject = localSdpObject.media.find((m) => m.type === "application");
|
|
2172
|
-
if (!this._transportReady) {
|
|
2173
|
-
yield this.setupTransport({
|
|
2174
|
-
localDtlsRole: (_b = this._forcedLocalDtlsRole) !== null && _b !== void 0 ? _b : "client",
|
|
2175
|
-
localSdpObject,
|
|
2176
|
-
});
|
|
2177
|
-
}
|
|
2178
|
-
logger$9.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]", offer);
|
|
2179
|
-
yield this._pc.setLocalDescription(offer);
|
|
2180
|
-
this._remoteSdp.sendSctpAssociation({ offerMediaObject });
|
|
2181
|
-
const answer = { type: "answer", sdp: this._remoteSdp.getSdp() };
|
|
2182
|
-
logger$9.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
2183
|
-
yield this._pc.setRemoteDescription(answer);
|
|
2184
|
-
this._hasDataChannelMediaSection = true;
|
|
2185
|
-
}
|
|
2186
|
-
const sctpStreamParameters = {
|
|
2187
|
-
streamId: options.id,
|
|
2188
|
-
ordered: options.ordered,
|
|
2189
|
-
maxPacketLifeTime: options.maxPacketLifeTime,
|
|
2190
|
-
maxRetransmits: options.maxRetransmits,
|
|
2191
|
-
};
|
|
2192
|
-
return { dataChannel, sctpStreamParameters };
|
|
2193
|
-
});
|
|
2194
|
-
}
|
|
2195
|
-
receive(optionsList) {
|
|
2196
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2197
|
-
var _a, _b;
|
|
2198
|
-
this.assertNotClosed();
|
|
2199
|
-
this.assertRecvDirection();
|
|
2200
|
-
const results = [];
|
|
2201
|
-
const mapLocalId = new Map();
|
|
2202
|
-
for (const options of optionsList) {
|
|
2203
|
-
const { trackId, kind, rtpParameters, streamId } = options;
|
|
2204
|
-
logger$9.debug("receive() [trackId:%s, kind:%s]", trackId, kind);
|
|
2205
|
-
const localId = (_a = rtpParameters.mid) !== null && _a !== void 0 ? _a : String(this._mapMidTransceiver.size);
|
|
2206
|
-
mapLocalId.set(trackId, localId);
|
|
2207
|
-
this._remoteSdp.receive({
|
|
2208
|
-
mid: localId,
|
|
2209
|
-
kind,
|
|
2210
|
-
offerRtpParameters: rtpParameters,
|
|
2211
|
-
streamId: streamId !== null && streamId !== void 0 ? streamId : rtpParameters.rtcp.cname,
|
|
2212
|
-
trackId,
|
|
2213
|
-
});
|
|
2214
|
-
}
|
|
2215
|
-
const offer = { type: "offer", sdp: this._remoteSdp.getSdp() };
|
|
2216
|
-
logger$9.debug("receive() | calling pc.setRemoteDescription() [offer:%o]", offer);
|
|
2217
|
-
yield this._pc.setRemoteDescription(offer);
|
|
2218
|
-
for (const options of optionsList) {
|
|
2219
|
-
const { trackId, onRtpReceiver } = options;
|
|
2220
|
-
if (onRtpReceiver) {
|
|
2221
|
-
const localId = mapLocalId.get(trackId);
|
|
2222
|
-
const transceiver = this._pc.getTransceivers().find((t) => t.mid === localId);
|
|
2223
|
-
if (!transceiver) {
|
|
2224
|
-
throw new Error("transceiver not found");
|
|
2225
|
-
}
|
|
2226
|
-
onRtpReceiver(transceiver.receiver);
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
|
-
let answer = yield this._pc.createAnswer();
|
|
2230
|
-
const localSdpObject = sdpTransform.parse(answer.sdp);
|
|
2231
|
-
for (const options of optionsList) {
|
|
2232
|
-
const { trackId, rtpParameters } = options;
|
|
2233
|
-
const localId = mapLocalId.get(trackId);
|
|
2234
|
-
const answerMediaObject = localSdpObject.media.find((m) => String(m.mid) === localId);
|
|
2235
|
-
sdpCommonUtils.applyCodecParameters({
|
|
2236
|
-
offerRtpParameters: rtpParameters,
|
|
2237
|
-
answerMediaObject,
|
|
2238
|
-
});
|
|
2239
|
-
}
|
|
2240
|
-
answer = { type: "answer", sdp: sdpTransform.write(localSdpObject) };
|
|
2241
|
-
if (!this._transportReady) {
|
|
2242
|
-
yield this.setupTransport({
|
|
2243
|
-
localDtlsRole: (_b = this._forcedLocalDtlsRole) !== null && _b !== void 0 ? _b : "client",
|
|
2244
|
-
localSdpObject,
|
|
2245
|
-
});
|
|
2246
|
-
}
|
|
2247
|
-
logger$9.debug("receive() | calling pc.setLocalDescription() [answer:%o]", answer);
|
|
2248
|
-
yield this._pc.setLocalDescription(answer);
|
|
2249
|
-
for (const options of optionsList) {
|
|
2250
|
-
const { trackId } = options;
|
|
2251
|
-
const localId = mapLocalId.get(trackId);
|
|
2252
|
-
const transceiver = this._pc.getTransceivers().find((t) => t.mid === localId);
|
|
2253
|
-
if (!transceiver) {
|
|
2254
|
-
throw new Error("new RTCRtpTransceiver not found");
|
|
2255
|
-
}
|
|
2256
|
-
this._mapMidTransceiver.set(localId, transceiver);
|
|
2257
|
-
results.push({
|
|
2258
|
-
localId,
|
|
2259
|
-
track: transceiver.receiver.track,
|
|
2260
|
-
rtpReceiver: transceiver.receiver,
|
|
2261
|
-
});
|
|
2262
|
-
}
|
|
2263
|
-
return results;
|
|
2264
|
-
});
|
|
2265
|
-
}
|
|
2266
|
-
stopReceiving(localIds) {
|
|
2267
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2268
|
-
this.assertRecvDirection();
|
|
2269
|
-
if (this._closed) {
|
|
2270
|
-
return;
|
|
2271
|
-
}
|
|
2272
|
-
for (const localId of localIds) {
|
|
2273
|
-
logger$9.debug("stopReceiving() [localId:%s]", localId);
|
|
2274
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2275
|
-
if (!transceiver) {
|
|
2276
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2277
|
-
}
|
|
2278
|
-
this._remoteSdp.closeMediaSection(transceiver.mid);
|
|
2279
|
-
}
|
|
2280
|
-
const offer = { type: "offer", sdp: this._remoteSdp.getSdp() };
|
|
2281
|
-
logger$9.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]", offer);
|
|
2282
|
-
yield this._pc.setRemoteDescription(offer);
|
|
2283
|
-
const answer = yield this._pc.createAnswer();
|
|
2284
|
-
logger$9.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]", answer);
|
|
2285
|
-
yield this._pc.setLocalDescription(answer);
|
|
2286
|
-
for (const localId of localIds) {
|
|
2287
|
-
this._mapMidTransceiver.delete(localId);
|
|
2288
|
-
}
|
|
2289
|
-
});
|
|
2290
|
-
}
|
|
2291
|
-
pauseReceiving(localIds) {
|
|
2292
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2293
|
-
this.assertNotClosed();
|
|
2294
|
-
this.assertRecvDirection();
|
|
2295
|
-
for (const localId of localIds) {
|
|
2296
|
-
logger$9.debug("pauseReceiving() [localId:%s]", localId);
|
|
2297
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2298
|
-
if (!transceiver) {
|
|
2299
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2300
|
-
}
|
|
2301
|
-
transceiver.direction = "inactive";
|
|
2302
|
-
this._remoteSdp.pauseMediaSection(localId);
|
|
2303
|
-
}
|
|
2304
|
-
const offer = { type: "offer", sdp: this._remoteSdp.getSdp() };
|
|
2305
|
-
logger$9.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]", offer);
|
|
2306
|
-
yield this._pc.setRemoteDescription(offer);
|
|
2307
|
-
const answer = yield this._pc.createAnswer();
|
|
2308
|
-
logger$9.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]", answer);
|
|
2309
|
-
yield this._pc.setLocalDescription(answer);
|
|
2310
|
-
});
|
|
2311
|
-
}
|
|
2312
|
-
resumeReceiving(localIds) {
|
|
2313
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2314
|
-
this.assertNotClosed();
|
|
2315
|
-
this.assertRecvDirection();
|
|
2316
|
-
for (const localId of localIds) {
|
|
2317
|
-
logger$9.debug("resumeReceiving() [localId:%s]", localId);
|
|
2318
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2319
|
-
if (!transceiver) {
|
|
2320
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2321
|
-
}
|
|
2322
|
-
transceiver.direction = "recvonly";
|
|
2323
|
-
this._remoteSdp.resumeReceivingMediaSection(localId);
|
|
2324
|
-
}
|
|
2325
|
-
const offer = { type: "offer", sdp: this._remoteSdp.getSdp() };
|
|
2326
|
-
logger$9.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]", offer);
|
|
2327
|
-
yield this._pc.setRemoteDescription(offer);
|
|
2328
|
-
const answer = yield this._pc.createAnswer();
|
|
2329
|
-
logger$9.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]", answer);
|
|
2330
|
-
yield this._pc.setLocalDescription(answer);
|
|
2331
|
-
});
|
|
2332
|
-
}
|
|
2333
|
-
getReceiverStats(localId) {
|
|
2334
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2335
|
-
this.assertNotClosed();
|
|
2336
|
-
this.assertRecvDirection();
|
|
2337
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
2338
|
-
if (!transceiver) {
|
|
2339
|
-
throw new Error("associated RTCRtpTransceiver not found");
|
|
2340
|
-
}
|
|
2341
|
-
return transceiver.receiver.getStats();
|
|
2342
|
-
});
|
|
2343
|
-
}
|
|
2344
|
-
receiveDataChannel(_a) {
|
|
2345
|
-
return __awaiter(this, arguments, void 0, function* ({ sctpStreamParameters, label, protocol, }) {
|
|
2346
|
-
var _b;
|
|
2347
|
-
this.assertNotClosed();
|
|
2348
|
-
this.assertRecvDirection();
|
|
2349
|
-
const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
|
|
2350
|
-
const options = {
|
|
2351
|
-
negotiated: true,
|
|
2352
|
-
id: streamId,
|
|
2353
|
-
ordered,
|
|
2354
|
-
maxPacketLifeTime,
|
|
2355
|
-
maxRetransmits,
|
|
2356
|
-
protocol,
|
|
2357
|
-
};
|
|
2358
|
-
logger$9.debug("receiveDataChannel() [options:%o]", options);
|
|
2359
|
-
const dataChannel = this._pc.createDataChannel(label, options);
|
|
2360
|
-
if (!this._hasDataChannelMediaSection) {
|
|
2361
|
-
this._remoteSdp.receiveSctpAssociation();
|
|
2362
|
-
const offer = { type: "offer", sdp: this._remoteSdp.getSdp() };
|
|
2363
|
-
logger$9.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]", offer);
|
|
2364
|
-
yield this._pc.setRemoteDescription(offer);
|
|
2365
|
-
const answer = yield this._pc.createAnswer();
|
|
2366
|
-
if (!this._transportReady) {
|
|
2367
|
-
const localSdpObject = sdpTransform.parse(answer.sdp);
|
|
2368
|
-
yield this.setupTransport({
|
|
2369
|
-
localDtlsRole: (_b = this._forcedLocalDtlsRole) !== null && _b !== void 0 ? _b : "client",
|
|
2370
|
-
localSdpObject,
|
|
2371
|
-
});
|
|
2372
|
-
}
|
|
2373
|
-
logger$9.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]", answer);
|
|
2374
|
-
yield this._pc.setLocalDescription(answer);
|
|
2375
|
-
this._hasDataChannelMediaSection = true;
|
|
2376
|
-
}
|
|
2377
|
-
return { dataChannel };
|
|
2378
|
-
});
|
|
2379
|
-
}
|
|
2380
|
-
setupTransport(_a) {
|
|
2381
|
-
return __awaiter(this, arguments, void 0, function* ({ localDtlsRole, localSdpObject, }) {
|
|
2382
|
-
if (!localSdpObject) {
|
|
2383
|
-
localSdpObject = sdpTransform.parse(this._pc.localDescription.sdp);
|
|
2384
|
-
}
|
|
2385
|
-
const dtlsParameters = sdpCommonUtils.extractDtlsParameters({
|
|
2386
|
-
sdpObject: localSdpObject,
|
|
2387
|
-
});
|
|
2388
|
-
dtlsParameters.role = localDtlsRole;
|
|
2389
|
-
this._remoteSdp.updateDtlsRole(localDtlsRole === "client" ? "server" : "client");
|
|
2390
|
-
yield new Promise((resolve, reject) => {
|
|
2391
|
-
this.safeEmit("@connect", { dtlsParameters }, resolve, reject);
|
|
2392
|
-
});
|
|
2393
|
-
this._transportReady = true;
|
|
2394
|
-
});
|
|
2395
|
-
}
|
|
2396
|
-
assertNotClosed() {
|
|
2397
|
-
if (this._closed) {
|
|
2398
|
-
throw new InvalidStateError("method called in a closed handler");
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
assertSendDirection() {
|
|
2402
|
-
if (this._direction !== "send") {
|
|
2403
|
-
throw new Error('method can just be called for handlers with "send" direction');
|
|
2404
|
-
}
|
|
2405
|
-
}
|
|
2406
|
-
assertRecvDirection() {
|
|
2407
|
-
if (this._direction !== "recv") {
|
|
2408
|
-
throw new Error('method can just be called for handlers with "recv" direction');
|
|
2409
|
-
}
|
|
2410
|
-
}
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2413
|
-
const getMediasoupDevice = (features) => {
|
|
2414
|
-
var _a;
|
|
1741
|
+
const getMediasoupDeviceAsync = (features) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2415
1742
|
if (features.isNodeSdk) {
|
|
2416
|
-
return new Device({
|
|
2417
|
-
}
|
|
2418
|
-
let handlerName = detectDevice() || (/applecoremedia|applewebkit|safari/i.test(navigator.userAgent) ? "Safari12" : undefined);
|
|
2419
|
-
if (handlerName === "Safari12" && typeof navigator === "object" && typeof navigator.userAgent === "string") {
|
|
2420
|
-
const uaParser = new UAParser(navigator.userAgent);
|
|
2421
|
-
const browser = uaParser.getBrowser();
|
|
2422
|
-
const browserVersion = parseInt((_a = browser.major) !== null && _a !== void 0 ? _a : "0");
|
|
2423
|
-
if (browserVersion >= 17 && features.safari17HandlerOn) {
|
|
2424
|
-
handlerName = "Safari17";
|
|
2425
|
-
}
|
|
1743
|
+
return new Device({ handlerName: "Safari12" });
|
|
2426
1744
|
}
|
|
1745
|
+
let handlerName = (yield detectDeviceAsync()) ||
|
|
1746
|
+
(/applecoremedia|applewebkit|safari/i.test(navigator.userAgent) ? "Safari12" : undefined);
|
|
2427
1747
|
if (/iphone|ipad/i.test(navigator.userAgent)) {
|
|
2428
|
-
|
|
2429
|
-
handlerName = "Safari17";
|
|
2430
|
-
}
|
|
2431
|
-
else {
|
|
2432
|
-
handlerName = "Safari12";
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
if (handlerName === "Safari17") {
|
|
2436
|
-
return new Device({ handlerFactory: Safari17.createFactory() });
|
|
1748
|
+
handlerName = "Safari12";
|
|
2437
1749
|
}
|
|
2438
1750
|
return new Device({ handlerName });
|
|
2439
|
-
};
|
|
1751
|
+
});
|
|
2440
1752
|
|
|
2441
1753
|
const AUDIO_SETTINGS = {
|
|
2442
1754
|
codecOptions: {
|
|
@@ -2559,11 +1871,12 @@ function prioritizeRouterRtpCapabilitiesCodecs(codecs, preferredCodec) {
|
|
|
2559
1871
|
return codecs;
|
|
2560
1872
|
}
|
|
2561
1873
|
return [...codecs].sort((left, right) => {
|
|
1874
|
+
var _a;
|
|
2562
1875
|
if (left.mimeType.toLowerCase() === preferredCodec) {
|
|
2563
1876
|
return -1;
|
|
2564
1877
|
}
|
|
2565
1878
|
if (left.mimeType.toLowerCase() === "video/rtx" &&
|
|
2566
|
-
left.parameters.apt === preferredCodecEntry.preferredPayloadType) {
|
|
1879
|
+
((_a = left.parameters) === null || _a === void 0 ? void 0 : _a.apt) === preferredCodecEntry.preferredPayloadType) {
|
|
2567
1880
|
if (right.mimeType.toLowerCase() === preferredCodec) {
|
|
2568
1881
|
return 1;
|
|
2569
1882
|
}
|
|
@@ -4939,7 +4252,7 @@ class VegaRtcManager {
|
|
|
4939
4252
|
this._vegaConnection = null;
|
|
4940
4253
|
this._micAnalyser = null;
|
|
4941
4254
|
this._micAnalyserDebugger = null;
|
|
4942
|
-
this.
|
|
4255
|
+
this._mediasoupDeviceInitializedAsync = getMediasoupDeviceAsync(features);
|
|
4943
4256
|
this._routerRtpCapabilities = null;
|
|
4944
4257
|
this._sendTransport = null;
|
|
4945
4258
|
this._receiveTransport = null;
|
|
@@ -5056,7 +4369,7 @@ class VegaRtcManager {
|
|
|
5056
4369
|
}
|
|
5057
4370
|
if (this._screenVideoTrack)
|
|
5058
4371
|
this._emitScreenshareStarted();
|
|
5059
|
-
if (this.
|
|
4372
|
+
if (this._reconnect) {
|
|
5060
4373
|
this._connect();
|
|
5061
4374
|
}
|
|
5062
4375
|
}), this._serverSocket.on("connect", () => this._onNetworkIsDetectedUpBySignal()), this._serverSocket.onEngineEvent("packet", () => this._onNetworkIsDetectedUpBySignal()), this._serverSocket.on("disconnect", () => this._onNetworkIsDetectedPossiblyDownBySignal()));
|
|
@@ -5069,19 +4382,17 @@ class VegaRtcManager {
|
|
|
5069
4382
|
});
|
|
5070
4383
|
}
|
|
5071
4384
|
_connect() {
|
|
5072
|
-
if (this.
|
|
5073
|
-
|
|
4385
|
+
if (this._isConnectingOrConnected)
|
|
4386
|
+
return;
|
|
4387
|
+
if (!this._serverSocket.isConnected()) {
|
|
4388
|
+
const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
|
|
4389
|
+
if (!reconnectThresholdInMs)
|
|
4390
|
+
return;
|
|
4391
|
+
if (Date.now() > (this._serverSocket.disconnectTimestamp || 0) + reconnectThresholdInMs)
|
|
5074
4392
|
return;
|
|
5075
|
-
if (!this._serverSocket.isConnected()) {
|
|
5076
|
-
const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
|
|
5077
|
-
if (!reconnectThresholdInMs)
|
|
5078
|
-
return;
|
|
5079
|
-
if (Date.now() > (this._serverSocket.disconnectTimestamp || 0) + reconnectThresholdInMs)
|
|
5080
|
-
return;
|
|
5081
|
-
}
|
|
5082
|
-
if (this._reconnectTimeOut)
|
|
5083
|
-
clearTimeout(this._reconnectTimeOut);
|
|
5084
4393
|
}
|
|
4394
|
+
if (this._reconnectTimeOut)
|
|
4395
|
+
clearTimeout(this._reconnectTimeOut);
|
|
5085
4396
|
if (!this._vegaConnectionManager) {
|
|
5086
4397
|
const hostList = this._features.sfuServersOverride ||
|
|
5087
4398
|
this._sfuServers ||
|
|
@@ -5143,10 +4454,10 @@ class VegaRtcManager {
|
|
|
5143
4454
|
if (!this._routerRtpCapabilities) {
|
|
5144
4455
|
const modifiedCapabilities = modifyMediaCapabilities(routerRtpCapabilities, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }));
|
|
5145
4456
|
this._routerRtpCapabilities = modifiedCapabilities;
|
|
5146
|
-
yield ((_a = this.
|
|
4457
|
+
yield ((_a = (yield this._mediasoupDeviceInitializedAsync)) === null || _a === void 0 ? void 0 : _a.load({ routerRtpCapabilities: modifiedCapabilities }));
|
|
5147
4458
|
}
|
|
5148
4459
|
this._vegaConnection.message("setCapabilities", {
|
|
5149
|
-
rtpCapabilities: (_b = this.
|
|
4460
|
+
rtpCapabilities: (_b = (yield this._mediasoupDeviceInitializedAsync)) === null || _b === void 0 ? void 0 : _b.rtpCapabilities,
|
|
5150
4461
|
});
|
|
5151
4462
|
if (this._colocation)
|
|
5152
4463
|
this._vegaConnection.message("setColocation", { colocation: this._colocation });
|
|
@@ -5189,7 +4500,7 @@ class VegaRtcManager {
|
|
|
5189
4500
|
});
|
|
5190
4501
|
transportOptions.iceServers = turnServerOverride(this._features.turnServersOn ? this._turnServers : this._iceServers, this._features.turnServerOverrideHost);
|
|
5191
4502
|
maybeTurnOnly(transportOptions, this._features);
|
|
5192
|
-
const transport = (_a = this.
|
|
4503
|
+
const transport = (_a = (yield this._mediasoupDeviceInitializedAsync)) === null || _a === void 0 ? void 0 : _a[creator](transportOptions);
|
|
5193
4504
|
const onConnectionStateListener = (connectionState) => __awaiter(this, void 0, void 0, function* () {
|
|
5194
4505
|
logger$3.info(`Transport ConnectionStateChanged ${connectionState}`);
|
|
5195
4506
|
if (connectionState !== "disconnected" && connectionState !== "failed") {
|
|
@@ -6005,7 +5316,7 @@ class VegaRtcManager {
|
|
|
6005
5316
|
this._screenVideoTrack = null;
|
|
6006
5317
|
this._screenAudioTrack = null;
|
|
6007
5318
|
this._streamIdToVideoConsumerId.clear();
|
|
6008
|
-
this.
|
|
5319
|
+
this._mediasoupDeviceInitializedAsync = Promise.resolve(null);
|
|
6009
5320
|
}
|
|
6010
5321
|
sendAudioMutedStats(muted) {
|
|
6011
5322
|
rtcStats.sendEvent("audio_muted", { muted });
|
|
@@ -7170,7 +6481,7 @@ class BandwidthTester extends EventEmitter {
|
|
|
7170
6481
|
this.closed = false;
|
|
7171
6482
|
this._features = features || {};
|
|
7172
6483
|
this._vegaConnection = null;
|
|
7173
|
-
this.
|
|
6484
|
+
this._mediasoupDeviceInitializedAsync = getMediasoupDeviceAsync(this._features);
|
|
7174
6485
|
this._routerRtpCapabilities = null;
|
|
7175
6486
|
this._sendTransport = null;
|
|
7176
6487
|
this._receiveTransport = null;
|
|
@@ -7230,7 +6541,7 @@ class BandwidthTester extends EventEmitter {
|
|
|
7230
6541
|
this._receiveTransport.close();
|
|
7231
6542
|
}
|
|
7232
6543
|
this._receiveTransport = null;
|
|
7233
|
-
this.
|
|
6544
|
+
this._mediasoupDeviceInitializedAsync = Promise.resolve(null);
|
|
7234
6545
|
if (this._vegaConnection) {
|
|
7235
6546
|
this._vegaConnection.removeAllListeners();
|
|
7236
6547
|
this._vegaConnection.close();
|
|
@@ -7258,10 +6569,10 @@ class BandwidthTester extends EventEmitter {
|
|
|
7258
6569
|
if (!this._routerRtpCapabilities) {
|
|
7259
6570
|
const modifiedCapabilities = modifyMediaCapabilities(routerRtpCapabilities, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }));
|
|
7260
6571
|
this._routerRtpCapabilities = modifiedCapabilities;
|
|
7261
|
-
yield ((_a = this.
|
|
6572
|
+
yield ((_a = (yield this._mediasoupDeviceInitializedAsync)) === null || _a === void 0 ? void 0 : _a.load({ routerRtpCapabilities: modifiedCapabilities }));
|
|
7262
6573
|
}
|
|
7263
6574
|
this._vegaConnection.message("setCapabilities", {
|
|
7264
|
-
rtpCapabilities: (_b = this.
|
|
6575
|
+
rtpCapabilities: (_b = (yield this._mediasoupDeviceInitializedAsync)) === null || _b === void 0 ? void 0 : _b.rtpCapabilities,
|
|
7265
6576
|
});
|
|
7266
6577
|
yield Promise.all([this._createTransport(true), this._createTransport(false)]);
|
|
7267
6578
|
yield this._createProducer();
|
|
@@ -7303,7 +6614,7 @@ class BandwidthTester extends EventEmitter {
|
|
|
7303
6614
|
preferUdp: true,
|
|
7304
6615
|
});
|
|
7305
6616
|
transportOptions.iceServers = [{ urls: "stun:any.turn.svc.whereby.com" }];
|
|
7306
|
-
const transport = (_a = this.
|
|
6617
|
+
const transport = (_a = (yield this._mediasoupDeviceInitializedAsync)) === null || _a === void 0 ? void 0 : _a[creator](transportOptions);
|
|
7307
6618
|
transport === null || transport === void 0 ? void 0 : transport.on("connect", ({ dtlsParameters }, callback) => {
|
|
7308
6619
|
this._vegaConnection.message("connectTransport", {
|
|
7309
6620
|
transportId: transport.id,
|
|
@@ -7919,5 +7230,5 @@ var RtcEventNames;
|
|
|
7919
7230
|
RtcEventNames["stream_added"] = "stream_added";
|
|
7920
7231
|
})(RtcEventNames || (RtcEventNames = {}));
|
|
7921
7232
|
|
|
7922
|
-
export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings,
|
|
7233
|
+
export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, turnServerOverride, variance };
|
|
7923
7234
|
//# sourceMappingURL=legacy-esm.js.map
|