@whereby.com/media 1.14.1 → 1.15.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 +16 -26
- package/dist/index.d.cts +576 -581
- package/dist/index.d.mts +576 -581
- package/dist/index.d.ts +576 -581
- package/dist/index.mjs +16 -26
- package/dist/legacy-esm.js +16 -26
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1421,10 +1421,6 @@ class VegaConnection extends EventEmitter.EventEmitter {
|
|
|
1421
1421
|
var _a;
|
|
1422
1422
|
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
|
|
1423
1423
|
}
|
|
1424
|
-
isConnected() {
|
|
1425
|
-
var _a, _b;
|
|
1426
|
-
return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN || ((_b = this.socket) === null || _b === void 0 ? void 0 : _b.readyState) === WebSocket.CONNECTING;
|
|
1427
|
-
}
|
|
1428
1424
|
_onOpen() {
|
|
1429
1425
|
logger$9.info("Connected");
|
|
1430
1426
|
this.emit("open");
|
|
@@ -3544,7 +3540,6 @@ class P2pRtcManager {
|
|
|
3544
3540
|
this._isAudioOnlyMode = false;
|
|
3545
3541
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
3546
3542
|
this._pendingActionsForConnectedPeerConnections = [];
|
|
3547
|
-
this._nodeJsClients = [];
|
|
3548
3543
|
this._audioTrackOnEnded = () => {
|
|
3549
3544
|
rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
|
|
3550
3545
|
this._emit(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
|
|
@@ -3660,11 +3655,6 @@ class P2pRtcManager {
|
|
|
3660
3655
|
setupSocketListeners() {
|
|
3661
3656
|
this._socketListenerDeregisterFunctions = [
|
|
3662
3657
|
() => this._clearMediaServersRefresh(),
|
|
3663
|
-
this._serverSocket.on(PROTOCOL_RESPONSES.NEW_CLIENT, (data) => {
|
|
3664
|
-
if (data.client.isDialIn && !this._nodeJsClients.includes(data.client.id)) {
|
|
3665
|
-
this._nodeJsClients.push(data.client.id);
|
|
3666
|
-
}
|
|
3667
|
-
}),
|
|
3668
3658
|
this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, (data) => {
|
|
3669
3659
|
if (data.error) {
|
|
3670
3660
|
logger$4.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
|
|
@@ -3862,7 +3852,7 @@ class P2pRtcManager {
|
|
|
3862
3852
|
_transformOutgoingSdp(original) {
|
|
3863
3853
|
return { type: original.type, sdpU: original.sdp };
|
|
3864
3854
|
}
|
|
3865
|
-
_createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo,
|
|
3855
|
+
_createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
|
|
3866
3856
|
if (!peerConnectionId) {
|
|
3867
3857
|
throw new Error("peerConnectionId is missing");
|
|
3868
3858
|
}
|
|
@@ -3898,13 +3888,13 @@ class P2pRtcManager {
|
|
|
3898
3888
|
return entry;
|
|
3899
3889
|
});
|
|
3900
3890
|
}
|
|
3901
|
-
if (
|
|
3891
|
+
if (this._features.useOnlyTURN) {
|
|
3902
3892
|
peerConnectionConfig.iceTransportPolicy = "relay";
|
|
3903
3893
|
const filter = {
|
|
3904
3894
|
onlyudp: /^turn:.*transport=udp$/,
|
|
3905
3895
|
onlytcp: /^turn:.*transport=tcp$/,
|
|
3906
3896
|
onlytls: /^turns:.*transport=tcp$/,
|
|
3907
|
-
}[
|
|
3897
|
+
}[this._features.useOnlyTURN];
|
|
3908
3898
|
if (filter) {
|
|
3909
3899
|
peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.filter((entry) => entry.url && entry.url.match(filter));
|
|
3910
3900
|
}
|
|
@@ -4164,16 +4154,11 @@ class P2pRtcManager {
|
|
|
4164
4154
|
else {
|
|
4165
4155
|
initialBandwidth = this._changeBandwidthForAllClients(true);
|
|
4166
4156
|
}
|
|
4167
|
-
let enforceTurnProtocol;
|
|
4168
|
-
if (this._nodeJsClients.includes(clientId)) {
|
|
4169
|
-
enforceTurnProtocol = this._features.isNodeSdk ? "onlyudp" : "onlytls";
|
|
4170
|
-
}
|
|
4171
4157
|
session = this._createP2pSession({
|
|
4172
4158
|
clientId,
|
|
4173
4159
|
initialBandwidth,
|
|
4174
4160
|
shouldAddLocalVideo: true,
|
|
4175
4161
|
isOfferer: true,
|
|
4176
|
-
enforceTurnProtocol,
|
|
4177
4162
|
});
|
|
4178
4163
|
this._negotiatePeerConnection(clientId, session);
|
|
4179
4164
|
return Promise.resolve(session);
|
|
@@ -4345,14 +4330,13 @@ class P2pRtcManager {
|
|
|
4345
4330
|
});
|
|
4346
4331
|
return bandwidth;
|
|
4347
4332
|
}
|
|
4348
|
-
_createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false,
|
|
4333
|
+
_createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, }) {
|
|
4349
4334
|
const session = this._createSession({
|
|
4350
4335
|
peerConnectionId: clientId,
|
|
4351
4336
|
clientId,
|
|
4352
4337
|
initialBandwidth,
|
|
4353
4338
|
shouldAddLocalVideo,
|
|
4354
4339
|
isOfferer,
|
|
4355
|
-
enforceTurnProtocol,
|
|
4356
4340
|
});
|
|
4357
4341
|
const pc = session.pc;
|
|
4358
4342
|
if (this._features.increaseIncomingMediaBufferOn) {
|
|
@@ -4466,7 +4450,7 @@ class P2pRtcManager {
|
|
|
4466
4450
|
};
|
|
4467
4451
|
return session;
|
|
4468
4452
|
}
|
|
4469
|
-
acceptNewStream({ streamId, clientId, shouldAddLocalVideo,
|
|
4453
|
+
acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
|
|
4470
4454
|
let session = this._getSession(clientId);
|
|
4471
4455
|
if (session && streamId !== clientId) {
|
|
4472
4456
|
return session;
|
|
@@ -4483,7 +4467,6 @@ class P2pRtcManager {
|
|
|
4483
4467
|
clientId,
|
|
4484
4468
|
initialBandwidth,
|
|
4485
4469
|
shouldAddLocalVideo: !!shouldAddLocalVideo,
|
|
4486
|
-
enforceTurnProtocol,
|
|
4487
4470
|
isOfferer: false,
|
|
4488
4471
|
});
|
|
4489
4472
|
this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
|
|
@@ -5080,6 +5063,7 @@ class VegaRtcManager {
|
|
|
5080
5063
|
this._socketListenerDeregisterFunctions = [];
|
|
5081
5064
|
this._reconnect = true;
|
|
5082
5065
|
this._reconnectTimeOut = null;
|
|
5066
|
+
this._hasVegaConnection = false;
|
|
5083
5067
|
this._qualityMonitor = new VegaMediaQualityMonitor();
|
|
5084
5068
|
this._qualityMonitor.on(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, (payload) => {
|
|
5085
5069
|
this._emitToPWA(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, payload);
|
|
@@ -5114,7 +5098,7 @@ class VegaRtcManager {
|
|
|
5114
5098
|
}), this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, () => {
|
|
5115
5099
|
if (this._screenVideoTrack)
|
|
5116
5100
|
this._emitScreenshareStarted();
|
|
5117
|
-
if (this._features.sfuReconnectV2On && !this.
|
|
5101
|
+
if (this._features.sfuReconnectV2On && !this._hasVegaConnection && this._reconnect) {
|
|
5118
5102
|
this._connect();
|
|
5119
5103
|
}
|
|
5120
5104
|
}));
|
|
@@ -5128,6 +5112,8 @@ class VegaRtcManager {
|
|
|
5128
5112
|
}
|
|
5129
5113
|
_connect() {
|
|
5130
5114
|
if (this._features.sfuReconnectV2On) {
|
|
5115
|
+
if (this._hasVegaConnection)
|
|
5116
|
+
return;
|
|
5131
5117
|
if (!this._serverSocket.isConnected()) {
|
|
5132
5118
|
const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
|
|
5133
5119
|
if (!reconnectThresholdInMs)
|
|
@@ -5145,6 +5131,7 @@ class VegaRtcManager {
|
|
|
5145
5131
|
const queryString = searchParams.toString();
|
|
5146
5132
|
const wsUrl = `wss://${host}?${queryString}`;
|
|
5147
5133
|
this._vegaConnection = new VegaConnection(wsUrl);
|
|
5134
|
+
this._hasVegaConnection = true;
|
|
5148
5135
|
this._vegaConnection.on("open", () => this._join());
|
|
5149
5136
|
this._vegaConnection.on("close", () => this._onClose());
|
|
5150
5137
|
this._vegaConnection.on("message", (message) => this._onMessage(message));
|
|
@@ -5152,6 +5139,7 @@ class VegaRtcManager {
|
|
|
5152
5139
|
_onClose() {
|
|
5153
5140
|
var _a, _b;
|
|
5154
5141
|
logger$1.info("_onClose()");
|
|
5142
|
+
this._hasVegaConnection = false;
|
|
5155
5143
|
(_a = this._sendTransport) === null || _a === void 0 ? void 0 : _a.close();
|
|
5156
5144
|
(_b = this._receiveTransport) === null || _b === void 0 ? void 0 : _b.close();
|
|
5157
5145
|
this._sendTransport = null;
|
|
@@ -5848,7 +5836,7 @@ class VegaRtcManager {
|
|
|
5848
5836
|
if (!videoTrack.effectTrack) {
|
|
5849
5837
|
this._monitorVideoTrack(videoTrack);
|
|
5850
5838
|
}
|
|
5851
|
-
const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "video");
|
|
5839
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
5852
5840
|
if (beforeEffectTrack) {
|
|
5853
5841
|
this._monitorVideoTrack(beforeEffectTrack);
|
|
5854
5842
|
}
|
|
@@ -5859,7 +5847,7 @@ class VegaRtcManager {
|
|
|
5859
5847
|
if (!audioTrack.effectTrack) {
|
|
5860
5848
|
this._monitorAudioTrack(audioTrack);
|
|
5861
5849
|
}
|
|
5862
|
-
const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "audio");
|
|
5850
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
5863
5851
|
if (beforeEffectTrack) {
|
|
5864
5852
|
this._monitorAudioTrack(beforeEffectTrack);
|
|
5865
5853
|
}
|
|
@@ -5930,7 +5918,9 @@ class VegaRtcManager {
|
|
|
5930
5918
|
}
|
|
5931
5919
|
if (!enable) {
|
|
5932
5920
|
clearTimeout(this._stopCameraTimeout);
|
|
5933
|
-
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended"
|
|
5921
|
+
const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended"
|
|
5922
|
+
? 0
|
|
5923
|
+
: 5000;
|
|
5934
5924
|
this._stopCameraTimeout = setTimeout(() => {
|
|
5935
5925
|
localStream.getVideoTracks().forEach((track) => {
|
|
5936
5926
|
if (track.enabled === false) {
|