@whereby.com/media 1.14.2 → 1.16.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.mjs CHANGED
@@ -2701,6 +2701,27 @@ function setCodecPreferenceSDP(sdp, vp9On, redOn) {
2701
2701
  logger$6.error("setCodecPreferenceSDP error:", error);
2702
2702
  }
2703
2703
  }
2704
+ function cleanSdp(sdp) {
2705
+ try {
2706
+ const sdpObject = sdpTransform.parse(sdp);
2707
+ sdpObject.media.forEach(mediaObject => {
2708
+ const usedPayloads = {};
2709
+ if (mediaObject.payloads)
2710
+ mediaObject.payloads = ("" + mediaObject.payloads).split(' ').filter(p => !usedPayloads[p] && (usedPayloads[p] = true)).join(' ');
2711
+ const usedRtps = {};
2712
+ mediaObject.rtp = mediaObject.rtp.filter(p => !p.payload || (usedPayloads[p.payload] && !usedRtps[p.payload] && (usedRtps[p.payload] = true)));
2713
+ const usedFmtps = {};
2714
+ if (mediaObject.fmtp)
2715
+ mediaObject.fmtp = mediaObject.fmtp.filter(p => !p.payload || (usedPayloads[p.payload] && !usedFmtps[p.payload] && (usedFmtps[p.payload] = true)));
2716
+ const usedRtcpFb = {};
2717
+ if (mediaObject.rtcpFb)
2718
+ mediaObject.rtcpFb = mediaObject.rtcpFb.filter(p => !p.payload || (usedPayloads[p.payload] && !usedRtcpFb[p.payload + p.type] && (usedRtcpFb[p.payload + p.type] = true)));
2719
+ });
2720
+ return sdpTransform.write(sdpObject);
2721
+ }
2722
+ catch (_) { }
2723
+ return sdp;
2724
+ }
2704
2725
  function maybeRejectNoH264(sdp) {
2705
2726
  if (browserName$2 !== "safari") {
2706
2727
  return sdp;
@@ -3022,13 +3043,7 @@ class Session {
3022
3043
  });
3023
3044
  }
3024
3045
  handleAnswer(message) {
3025
- if (this.pendingOffer) {
3026
- const pendingOffer = this.pendingOffer;
3027
- delete this.pendingOffer;
3028
- return this.pc.setLocalDescription(pendingOffer).then(() => this.handleAnswer(message));
3029
- }
3030
- let sdp = message.sdp;
3031
- sdp = filterMsidSemantic(sdp);
3046
+ const sdp = filterMsidSemantic(message.sdp);
3032
3047
  const desc = { type: message.type, sdp };
3033
3048
  return this._setRemoteDescription(desc).then(() => {
3034
3049
  return setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
@@ -3482,6 +3497,9 @@ var rtcManagerEvents = {
3482
3497
  SFU_CONNECTION_CLOSED: "sfu_connection_closed",
3483
3498
  COLOCATION_SPEAKER: "colocation_speaker",
3484
3499
  DOMINANT_SPEAKER: "dominant_speaker",
3500
+ PC_SLD_FAILURE: "pc_sld_failure",
3501
+ PC_ON_ANSWER_FAILURE: "pc_on_answer_failure",
3502
+ PC_ON_OFFER_FAILURE: "pc_on_offer_failure",
3485
3503
  };
3486
3504
 
3487
3505
  var _a$2, _b;
@@ -3519,7 +3537,6 @@ class P2pRtcManager {
3519
3537
  this._isAudioOnlyMode = false;
3520
3538
  this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
3521
3539
  this._pendingActionsForConnectedPeerConnections = [];
3522
- this._nodeJsClients = [];
3523
3540
  this._audioTrackOnEnded = () => {
3524
3541
  rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
3525
3542
  this._emit(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
@@ -3635,11 +3652,6 @@ class P2pRtcManager {
3635
3652
  setupSocketListeners() {
3636
3653
  this._socketListenerDeregisterFunctions = [
3637
3654
  () => this._clearMediaServersRefresh(),
3638
- this._serverSocket.on(PROTOCOL_RESPONSES.NEW_CLIENT, (data) => {
3639
- if (data.client.isDialIn && !this._nodeJsClients.includes(data.client.id)) {
3640
- this._nodeJsClients.push(data.client.id);
3641
- }
3642
- }),
3643
3655
  this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, (data) => {
3644
3656
  if (data.error) {
3645
3657
  logger$4.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
@@ -3667,27 +3679,33 @@ class P2pRtcManager {
3667
3679
  session.addIceCandidate(null);
3668
3680
  }),
3669
3681
  this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
3682
+ var _a, _b;
3670
3683
  const session = this._getSession(data.clientId);
3671
3684
  if (!session) {
3672
3685
  logger$4.warn("No RTCPeerConnection on SDP_OFFER", data);
3673
3686
  return;
3674
3687
  }
3675
3688
  const offer = this._transformIncomingSdp(data.message, session.pc);
3676
- session.handleOffer(offer).then((answer) => {
3689
+ (_b = (_a = session.handleOffer(offer).then((answer) => {
3677
3690
  this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
3678
3691
  receiverId: data.clientId,
3679
3692
  message: this._transformOutgoingSdp(answer),
3680
3693
  });
3694
+ })).catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
3695
+ this._emit(rtcManagerEvents.PC_ON_OFFER_FAILURE, e);
3681
3696
  });
3682
3697
  }),
3683
3698
  this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
3699
+ var _a, _b;
3684
3700
  const session = this._getSession(data.clientId);
3685
3701
  if (!session) {
3686
3702
  logger$4.warn("No RTCPeerConnection on SDP_ANSWER", data);
3687
3703
  return;
3688
3704
  }
3689
3705
  const answer = this._transformIncomingSdp(data.message, session.pc);
3690
- session.handleAnswer(answer);
3706
+ (_b = (_a = session.handleAnswer(answer)) === null || _a === void 0 ? void 0 : _a.catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
3707
+ this._emit(rtcManagerEvents.PC_ON_ANSWER_FAILURE, e);
3708
+ });
3691
3709
  }),
3692
3710
  this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, ({ room: { sfuServer: isSfu } }) => {
3693
3711
  if (isSfu || !this._wasScreenSharing)
@@ -3837,7 +3855,7 @@ class P2pRtcManager {
3837
3855
  _transformOutgoingSdp(original) {
3838
3856
  return { type: original.type, sdpU: original.sdp };
3839
3857
  }
3840
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, enforceTurnProtocol, }) {
3858
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
3841
3859
  if (!peerConnectionId) {
3842
3860
  throw new Error("peerConnectionId is missing");
3843
3861
  }
@@ -3873,13 +3891,13 @@ class P2pRtcManager {
3873
3891
  return entry;
3874
3892
  });
3875
3893
  }
3876
- if (enforceTurnProtocol || this._features.useOnlyTURN) {
3894
+ if (this._features.useOnlyTURN) {
3877
3895
  peerConnectionConfig.iceTransportPolicy = "relay";
3878
3896
  const filter = {
3879
3897
  onlyudp: /^turn:.*transport=udp$/,
3880
3898
  onlytcp: /^turn:.*transport=tcp$/,
3881
3899
  onlytls: /^turns:.*transport=tcp$/,
3882
- }[enforceTurnProtocol || this._features.useOnlyTURN];
3900
+ }[this._features.useOnlyTURN];
3883
3901
  if (filter) {
3884
3902
  peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.filter((entry) => entry.url && entry.url.match(filter));
3885
3903
  }
@@ -4139,16 +4157,11 @@ class P2pRtcManager {
4139
4157
  else {
4140
4158
  initialBandwidth = this._changeBandwidthForAllClients(true);
4141
4159
  }
4142
- let enforceTurnProtocol;
4143
- if (this._nodeJsClients.includes(clientId)) {
4144
- enforceTurnProtocol = this._features.isNodeSdk ? "onlyudp" : "onlytls";
4145
- }
4146
4160
  session = this._createP2pSession({
4147
4161
  clientId,
4148
4162
  initialBandwidth,
4149
4163
  shouldAddLocalVideo: true,
4150
4164
  isOfferer: true,
4151
- enforceTurnProtocol,
4152
4165
  });
4153
4166
  this._negotiatePeerConnection(clientId, session);
4154
4167
  return Promise.resolve(session);
@@ -4229,7 +4242,7 @@ class P2pRtcManager {
4229
4242
  return;
4230
4243
  }
4231
4244
  session.isOperationPending = true;
4232
- const { vp9On, av1On, redOn, rtpAbsCaptureTimeOn } = this._features;
4245
+ const { vp9On, av1On, redOn, rtpAbsCaptureTimeOn, cleanSdpOn } = this._features;
4233
4246
  if (vp9On || av1On || redOn) {
4234
4247
  this._setCodecPreferences(pc, vp9On, av1On, redOn);
4235
4248
  }
@@ -4240,26 +4253,17 @@ class P2pRtcManager {
4240
4253
  if ((vp9On || redOn) && browserName$1 === "firefox") {
4241
4254
  offer.sdp = setCodecPreferenceSDP(offer.sdp, vp9On, redOn);
4242
4255
  }
4243
- this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
4244
- receiverId: clientId,
4245
- message: this._transformOutgoingSdp(offer),
4246
- });
4247
- if (browserName$1 === "chrome" &&
4248
- pc.getSenders().filter((sender) => sender.track && sender.track.kind === "video").length >= 2) {
4249
- session.pendingOffer = offer;
4250
- return;
4251
- }
4256
+ if (cleanSdpOn)
4257
+ offer.sdp = cleanSdp(offer.sdp);
4252
4258
  pc.setLocalDescription(offer).catch((e) => {
4253
4259
  logger$4.warn("RTCPeerConnection.setLocalDescription() failed with local offer", e);
4254
- if (this._features.reverseOfferOnFailure) {
4255
- if (!this._lastReverseDirectionAttemptByClientId)
4256
- this._lastReverseDirectionAttemptByClientId = {};
4257
- if (!this._lastReverseDirectionAttemptByClientId[clientId] ||
4258
- this._lastReverseDirectionAttemptByClientId[clientId] < Date.now() - 10000) {
4259
- this.acceptNewStream({ clientId, streamId: clientId, shouldAddLocalVideo: true });
4260
- this._lastReverseDirectionAttemptByClientId[clientId] = Date.now();
4261
- }
4262
- }
4260
+ this._emit(rtcManagerEvents.PC_SLD_FAILURE, e);
4261
+ throw e;
4262
+ }).then(() => {
4263
+ this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
4264
+ receiverId: clientId,
4265
+ message: this._transformOutgoingSdp(offer),
4266
+ });
4263
4267
  });
4264
4268
  })
4265
4269
  .catch((e) => {
@@ -4320,14 +4324,13 @@ class P2pRtcManager {
4320
4324
  });
4321
4325
  return bandwidth;
4322
4326
  }
4323
- _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, enforceTurnProtocol, }) {
4327
+ _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, }) {
4324
4328
  const session = this._createSession({
4325
4329
  peerConnectionId: clientId,
4326
4330
  clientId,
4327
4331
  initialBandwidth,
4328
4332
  shouldAddLocalVideo,
4329
4333
  isOfferer,
4330
- enforceTurnProtocol,
4331
4334
  });
4332
4335
  const pc = session.pc;
4333
4336
  if (this._features.increaseIncomingMediaBufferOn) {
@@ -4441,7 +4444,7 @@ class P2pRtcManager {
4441
4444
  };
4442
4445
  return session;
4443
4446
  }
4444
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, enforceTurnProtocol, }) {
4447
+ acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
4445
4448
  let session = this._getSession(clientId);
4446
4449
  if (session && streamId !== clientId) {
4447
4450
  return session;
@@ -4458,7 +4461,6 @@ class P2pRtcManager {
4458
4461
  clientId,
4459
4462
  initialBandwidth,
4460
4463
  shouldAddLocalVideo: !!shouldAddLocalVideo,
4461
- enforceTurnProtocol,
4462
4464
  isOfferer: false,
4463
4465
  });
4464
4466
  this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
@@ -6871,4 +6873,4 @@ function fromLocation({ host = "whereby.com", protocol = "https:" } = {}) {
6871
6873
  }
6872
6874
  fromLocation(window && window.location);
6873
6875
 
6874
- export { BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
6876
+ export { BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
@@ -2701,6 +2701,27 @@ function setCodecPreferenceSDP(sdp, vp9On, redOn) {
2701
2701
  logger$6.error("setCodecPreferenceSDP error:", error);
2702
2702
  }
2703
2703
  }
2704
+ function cleanSdp(sdp) {
2705
+ try {
2706
+ const sdpObject = sdpTransform.parse(sdp);
2707
+ sdpObject.media.forEach(mediaObject => {
2708
+ const usedPayloads = {};
2709
+ if (mediaObject.payloads)
2710
+ mediaObject.payloads = ("" + mediaObject.payloads).split(' ').filter(p => !usedPayloads[p] && (usedPayloads[p] = true)).join(' ');
2711
+ const usedRtps = {};
2712
+ mediaObject.rtp = mediaObject.rtp.filter(p => !p.payload || (usedPayloads[p.payload] && !usedRtps[p.payload] && (usedRtps[p.payload] = true)));
2713
+ const usedFmtps = {};
2714
+ if (mediaObject.fmtp)
2715
+ mediaObject.fmtp = mediaObject.fmtp.filter(p => !p.payload || (usedPayloads[p.payload] && !usedFmtps[p.payload] && (usedFmtps[p.payload] = true)));
2716
+ const usedRtcpFb = {};
2717
+ if (mediaObject.rtcpFb)
2718
+ mediaObject.rtcpFb = mediaObject.rtcpFb.filter(p => !p.payload || (usedPayloads[p.payload] && !usedRtcpFb[p.payload + p.type] && (usedRtcpFb[p.payload + p.type] = true)));
2719
+ });
2720
+ return sdpTransform.write(sdpObject);
2721
+ }
2722
+ catch (_) { }
2723
+ return sdp;
2724
+ }
2704
2725
  function maybeRejectNoH264(sdp) {
2705
2726
  if (browserName$2 !== "safari") {
2706
2727
  return sdp;
@@ -3022,13 +3043,7 @@ class Session {
3022
3043
  });
3023
3044
  }
3024
3045
  handleAnswer(message) {
3025
- if (this.pendingOffer) {
3026
- const pendingOffer = this.pendingOffer;
3027
- delete this.pendingOffer;
3028
- return this.pc.setLocalDescription(pendingOffer).then(() => this.handleAnswer(message));
3029
- }
3030
- let sdp = message.sdp;
3031
- sdp = filterMsidSemantic(sdp);
3046
+ const sdp = filterMsidSemantic(message.sdp);
3032
3047
  const desc = { type: message.type, sdp };
3033
3048
  return this._setRemoteDescription(desc).then(() => {
3034
3049
  return setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
@@ -3482,6 +3497,9 @@ var rtcManagerEvents = {
3482
3497
  SFU_CONNECTION_CLOSED: "sfu_connection_closed",
3483
3498
  COLOCATION_SPEAKER: "colocation_speaker",
3484
3499
  DOMINANT_SPEAKER: "dominant_speaker",
3500
+ PC_SLD_FAILURE: "pc_sld_failure",
3501
+ PC_ON_ANSWER_FAILURE: "pc_on_answer_failure",
3502
+ PC_ON_OFFER_FAILURE: "pc_on_offer_failure",
3485
3503
  };
3486
3504
 
3487
3505
  var _a$2, _b;
@@ -3519,7 +3537,6 @@ class P2pRtcManager {
3519
3537
  this._isAudioOnlyMode = false;
3520
3538
  this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
3521
3539
  this._pendingActionsForConnectedPeerConnections = [];
3522
- this._nodeJsClients = [];
3523
3540
  this._audioTrackOnEnded = () => {
3524
3541
  rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
3525
3542
  this._emit(rtcManagerEvents.MICROPHONE_STOPPED_WORKING, {});
@@ -3635,11 +3652,6 @@ class P2pRtcManager {
3635
3652
  setupSocketListeners() {
3636
3653
  this._socketListenerDeregisterFunctions = [
3637
3654
  () => this._clearMediaServersRefresh(),
3638
- this._serverSocket.on(PROTOCOL_RESPONSES.NEW_CLIENT, (data) => {
3639
- if (data.client.isDialIn && !this._nodeJsClients.includes(data.client.id)) {
3640
- this._nodeJsClients.push(data.client.id);
3641
- }
3642
- }),
3643
3655
  this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, (data) => {
3644
3656
  if (data.error) {
3645
3657
  logger$4.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
@@ -3667,27 +3679,33 @@ class P2pRtcManager {
3667
3679
  session.addIceCandidate(null);
3668
3680
  }),
3669
3681
  this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
3682
+ var _a, _b;
3670
3683
  const session = this._getSession(data.clientId);
3671
3684
  if (!session) {
3672
3685
  logger$4.warn("No RTCPeerConnection on SDP_OFFER", data);
3673
3686
  return;
3674
3687
  }
3675
3688
  const offer = this._transformIncomingSdp(data.message, session.pc);
3676
- session.handleOffer(offer).then((answer) => {
3689
+ (_b = (_a = session.handleOffer(offer).then((answer) => {
3677
3690
  this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
3678
3691
  receiverId: data.clientId,
3679
3692
  message: this._transformOutgoingSdp(answer),
3680
3693
  });
3694
+ })).catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
3695
+ this._emit(rtcManagerEvents.PC_ON_OFFER_FAILURE, e);
3681
3696
  });
3682
3697
  }),
3683
3698
  this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
3699
+ var _a, _b;
3684
3700
  const session = this._getSession(data.clientId);
3685
3701
  if (!session) {
3686
3702
  logger$4.warn("No RTCPeerConnection on SDP_ANSWER", data);
3687
3703
  return;
3688
3704
  }
3689
3705
  const answer = this._transformIncomingSdp(data.message, session.pc);
3690
- session.handleAnswer(answer);
3706
+ (_b = (_a = session.handleAnswer(answer)) === null || _a === void 0 ? void 0 : _a.catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
3707
+ this._emit(rtcManagerEvents.PC_ON_ANSWER_FAILURE, e);
3708
+ });
3691
3709
  }),
3692
3710
  this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, ({ room: { sfuServer: isSfu } }) => {
3693
3711
  if (isSfu || !this._wasScreenSharing)
@@ -3837,7 +3855,7 @@ class P2pRtcManager {
3837
3855
  _transformOutgoingSdp(original) {
3838
3856
  return { type: original.type, sdpU: original.sdp };
3839
3857
  }
3840
- _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, enforceTurnProtocol, }) {
3858
+ _createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId, shouldAddLocalVideo, }) {
3841
3859
  if (!peerConnectionId) {
3842
3860
  throw new Error("peerConnectionId is missing");
3843
3861
  }
@@ -3873,13 +3891,13 @@ class P2pRtcManager {
3873
3891
  return entry;
3874
3892
  });
3875
3893
  }
3876
- if (enforceTurnProtocol || this._features.useOnlyTURN) {
3894
+ if (this._features.useOnlyTURN) {
3877
3895
  peerConnectionConfig.iceTransportPolicy = "relay";
3878
3896
  const filter = {
3879
3897
  onlyudp: /^turn:.*transport=udp$/,
3880
3898
  onlytcp: /^turn:.*transport=tcp$/,
3881
3899
  onlytls: /^turns:.*transport=tcp$/,
3882
- }[enforceTurnProtocol || this._features.useOnlyTURN];
3900
+ }[this._features.useOnlyTURN];
3883
3901
  if (filter) {
3884
3902
  peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.filter((entry) => entry.url && entry.url.match(filter));
3885
3903
  }
@@ -4139,16 +4157,11 @@ class P2pRtcManager {
4139
4157
  else {
4140
4158
  initialBandwidth = this._changeBandwidthForAllClients(true);
4141
4159
  }
4142
- let enforceTurnProtocol;
4143
- if (this._nodeJsClients.includes(clientId)) {
4144
- enforceTurnProtocol = this._features.isNodeSdk ? "onlyudp" : "onlytls";
4145
- }
4146
4160
  session = this._createP2pSession({
4147
4161
  clientId,
4148
4162
  initialBandwidth,
4149
4163
  shouldAddLocalVideo: true,
4150
4164
  isOfferer: true,
4151
- enforceTurnProtocol,
4152
4165
  });
4153
4166
  this._negotiatePeerConnection(clientId, session);
4154
4167
  return Promise.resolve(session);
@@ -4229,7 +4242,7 @@ class P2pRtcManager {
4229
4242
  return;
4230
4243
  }
4231
4244
  session.isOperationPending = true;
4232
- const { vp9On, av1On, redOn, rtpAbsCaptureTimeOn } = this._features;
4245
+ const { vp9On, av1On, redOn, rtpAbsCaptureTimeOn, cleanSdpOn } = this._features;
4233
4246
  if (vp9On || av1On || redOn) {
4234
4247
  this._setCodecPreferences(pc, vp9On, av1On, redOn);
4235
4248
  }
@@ -4240,26 +4253,17 @@ class P2pRtcManager {
4240
4253
  if ((vp9On || redOn) && browserName$1 === "firefox") {
4241
4254
  offer.sdp = setCodecPreferenceSDP(offer.sdp, vp9On, redOn);
4242
4255
  }
4243
- this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
4244
- receiverId: clientId,
4245
- message: this._transformOutgoingSdp(offer),
4246
- });
4247
- if (browserName$1 === "chrome" &&
4248
- pc.getSenders().filter((sender) => sender.track && sender.track.kind === "video").length >= 2) {
4249
- session.pendingOffer = offer;
4250
- return;
4251
- }
4256
+ if (cleanSdpOn)
4257
+ offer.sdp = cleanSdp(offer.sdp);
4252
4258
  pc.setLocalDescription(offer).catch((e) => {
4253
4259
  logger$4.warn("RTCPeerConnection.setLocalDescription() failed with local offer", e);
4254
- if (this._features.reverseOfferOnFailure) {
4255
- if (!this._lastReverseDirectionAttemptByClientId)
4256
- this._lastReverseDirectionAttemptByClientId = {};
4257
- if (!this._lastReverseDirectionAttemptByClientId[clientId] ||
4258
- this._lastReverseDirectionAttemptByClientId[clientId] < Date.now() - 10000) {
4259
- this.acceptNewStream({ clientId, streamId: clientId, shouldAddLocalVideo: true });
4260
- this._lastReverseDirectionAttemptByClientId[clientId] = Date.now();
4261
- }
4262
- }
4260
+ this._emit(rtcManagerEvents.PC_SLD_FAILURE, e);
4261
+ throw e;
4262
+ }).then(() => {
4263
+ this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
4264
+ receiverId: clientId,
4265
+ message: this._transformOutgoingSdp(offer),
4266
+ });
4263
4267
  });
4264
4268
  })
4265
4269
  .catch((e) => {
@@ -4320,14 +4324,13 @@ class P2pRtcManager {
4320
4324
  });
4321
4325
  return bandwidth;
4322
4326
  }
4323
- _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, enforceTurnProtocol, }) {
4327
+ _createP2pSession({ clientId, initialBandwidth, shouldAddLocalVideo = false, isOfferer = false, }) {
4324
4328
  const session = this._createSession({
4325
4329
  peerConnectionId: clientId,
4326
4330
  clientId,
4327
4331
  initialBandwidth,
4328
4332
  shouldAddLocalVideo,
4329
4333
  isOfferer,
4330
- enforceTurnProtocol,
4331
4334
  });
4332
4335
  const pc = session.pc;
4333
4336
  if (this._features.increaseIncomingMediaBufferOn) {
@@ -4441,7 +4444,7 @@ class P2pRtcManager {
4441
4444
  };
4442
4445
  return session;
4443
4446
  }
4444
- acceptNewStream({ streamId, clientId, shouldAddLocalVideo, enforceTurnProtocol, }) {
4447
+ acceptNewStream({ streamId, clientId, shouldAddLocalVideo, }) {
4445
4448
  let session = this._getSession(clientId);
4446
4449
  if (session && streamId !== clientId) {
4447
4450
  return session;
@@ -4458,7 +4461,6 @@ class P2pRtcManager {
4458
4461
  clientId,
4459
4462
  initialBandwidth,
4460
4463
  shouldAddLocalVideo: !!shouldAddLocalVideo,
4461
- enforceTurnProtocol,
4462
4464
  isOfferer: false,
4463
4465
  });
4464
4466
  this._emitServerEvent(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, {
@@ -6871,5 +6873,5 @@ function fromLocation({ host = "whereby.com", protocol = "https:" } = {}) {
6871
6873
  }
6872
6874
  fromLocation(window && window.location);
6873
6875
 
6874
- export { BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
6876
+ export { BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
6875
6877
  //# sourceMappingURL=legacy-esm.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "1.14.2",
4
+ "version": "1.16.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {