@whereby.com/media 1.16.3 → 1.17.1

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 CHANGED
@@ -809,9 +809,23 @@ const VIDEO_SETTINGS_VP9 = {
809
809
  },
810
810
  encodings: [{ scalabilityMode: "L3T2_KEY" }],
811
811
  };
812
+ const VIDEO_SETTINGS_VP9_LOW_BANDWIDTH = {
813
+ codecOptions: {
814
+ videoGoogleStartBitrate: 500,
815
+ },
816
+ encodings: [{ scalabilityMode: "L2T2_KEY", maxBitrate: 800000 }],
817
+ };
812
818
  const SCREEN_SHARE_SETTINGS = {
813
819
  encodings: [{}],
814
820
  };
821
+ const SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH = {
822
+ encodings: [
823
+ {
824
+ maxBitrate: 600000,
825
+ maxFramerate: 2,
826
+ },
827
+ ],
828
+ };
815
829
  const SCREEN_SHARE_SIMULCAST_SETTINGS = {
816
830
  encodings: [
817
831
  { scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
@@ -822,11 +836,13 @@ const SCREEN_SHARE_SETTINGS_VP9 = {
822
836
  encodings: [{ dtx: true }],
823
837
  };
824
838
  const getMediaSettings = (kind, isScreenShare, features) => {
825
- const { lowDataModeEnabled, simulcastScreenshareOn, vp9On } = features;
839
+ const { lowDataModeEnabled, simulcastScreenshareOn, vp9On, lowBandwidth } = features;
826
840
  if (kind === "audio") {
827
841
  return AUDIO_SETTINGS;
828
842
  }
829
843
  if (isScreenShare) {
844
+ if (lowBandwidth && !vp9On)
845
+ return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
830
846
  if (vp9On)
831
847
  return SCREEN_SHARE_SETTINGS_VP9;
832
848
  if (simulcastScreenshareOn)
@@ -834,6 +850,11 @@ const getMediaSettings = (kind, isScreenShare, features) => {
834
850
  return SCREEN_SHARE_SETTINGS;
835
851
  }
836
852
  else {
853
+ if (lowBandwidth) {
854
+ if (vp9On)
855
+ return VIDEO_SETTINGS_VP9_LOW_BANDWIDTH;
856
+ return VIDEO_SETTINGS_SD;
857
+ }
837
858
  if (vp9On)
838
859
  return VIDEO_SETTINGS_VP9;
839
860
  if (lowDataModeEnabled)
@@ -4337,7 +4358,9 @@ class P2pRtcManager {
4337
4358
  return;
4338
4359
  }
4339
4360
  const offer = this._transformIncomingSdp(data.message, session.pc);
4340
- (_b = (_a = session.handleOffer(offer).then((answer) => {
4361
+ (_b = (_a = session
4362
+ .handleOffer(offer)
4363
+ .then((answer) => {
4341
4364
  this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
4342
4365
  receiverId: data.clientId,
4343
4366
  message: this._transformOutgoingSdp(answer),
@@ -4542,6 +4565,20 @@ class P2pRtcManager {
4542
4565
  return entry;
4543
4566
  });
4544
4567
  }
4568
+ if (this._features.addGoogleStunServers) {
4569
+ peerConnectionConfig.iceServers = [
4570
+ ...peerConnectionConfig.iceServers,
4571
+ { urls: "stun:stun.l.google.com:19302" },
4572
+ { urls: "stun:stun2.l.google.com:19302" },
4573
+ ];
4574
+ }
4575
+ if (this._features.addCloudflareStunServers) {
4576
+ peerConnectionConfig.iceServers = [
4577
+ ...peerConnectionConfig.iceServers,
4578
+ { urls: "stun:stun.cloudflare.com:3478" },
4579
+ { urls: "stun:stun.cloudflare.com:53" },
4580
+ ];
4581
+ }
4545
4582
  if (this._features.useOnlyTURN) {
4546
4583
  peerConnectionConfig.iceTransportPolicy = "relay";
4547
4584
  const filter = {
@@ -4721,7 +4758,7 @@ class P2pRtcManager {
4721
4758
  logger$3.info("Session doesn't have a connected PeerConnection, adding pending action!");
4722
4759
  const pendingActions = this._pendingActionsForConnectedPeerConnections;
4723
4760
  if (!pendingActions) {
4724
- logger$3.warn(`No pending action is created to repalce track, because the pending actions array is null`);
4761
+ logger$3.warn(`No pending action is created to replace track, because the pending actions array is null`);
4725
4762
  return;
4726
4763
  }
4727
4764
  const promise = new Promise((resolve, reject) => {
@@ -4906,11 +4943,13 @@ class P2pRtcManager {
4906
4943
  }
4907
4944
  if (cleanSdpOn)
4908
4945
  offer.sdp = cleanSdp(offer.sdp);
4909
- pc.setLocalDescription(offer).catch((e) => {
4946
+ pc.setLocalDescription(offer)
4947
+ .catch((e) => {
4910
4948
  logger$3.warn("RTCPeerConnection.setLocalDescription() failed with local offer", e);
4911
4949
  this._emit(rtcManagerEvents.PC_SLD_FAILURE, e);
4912
4950
  throw e;
4913
- }).then(() => {
4951
+ })
4952
+ .then(() => {
4914
4953
  this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
4915
4954
  receiverId: clientId,
4916
4955
  message: this._transformOutgoingSdp(offer),
@@ -4943,9 +4982,9 @@ class P2pRtcManager {
4943
4982
  let bandwidth = this._features.bandwidth
4944
4983
  ? parseInt(this._features.bandwidth, 10)
4945
4984
  : {
4946
- 1: 0,
4947
- 2: this._features.highP2PBandwidth ? 768 : 384,
4948
- 3: this._features.highP2PBandwidth ? 512 : 256,
4985
+ 1: this._features.lowBandwidth ? 768 : 0,
4986
+ 2: this._features.highP2PBandwidth && !this._features.lowBandwidth ? 768 : 384,
4987
+ 3: this._features.highP2PBandwidth && !this._features.lowBandwidth ? 512 : 256,
4949
4988
  4: 192,
4950
4989
  5: 128,
4951
4990
  6: 128,
@@ -4967,7 +5006,7 @@ class P2pRtcManager {
4967
5006
  }
4968
5007
  }
4969
5008
  }
4970
- if (this._features.higherP2PBitrates) {
5009
+ if (this._features.higherP2PBitrates && !this._features.lowBandwidth) {
4971
5010
  bandwidth = bandwidth * 1.5;
4972
5011
  }
4973
5012
  this._forEachPeerConnection((session) => {
@@ -6146,7 +6185,7 @@ class VegaRtcManager {
6146
6185
  return;
6147
6186
  }
6148
6187
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
6149
- var _b;
6188
+ var _b, _c;
6150
6189
  try {
6151
6190
  const currentPaused = this._webcamPaused;
6152
6191
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
@@ -6184,6 +6223,9 @@ class VegaRtcManager {
6184
6223
  this._stopProducer(this._webcamProducer);
6185
6224
  this._webcamProducer = null;
6186
6225
  }
6226
+ if (this._features.lowBandwidth && this._screenVideoTrack) {
6227
+ (_c = this._webcamProducer) === null || _c === void 0 ? void 0 : _c.setMaxSpatialLayer(0);
6228
+ }
6187
6229
  }
6188
6230
  }))();
6189
6231
  });
@@ -6242,6 +6284,7 @@ class VegaRtcManager {
6242
6284
  return __awaiter(this, void 0, void 0, function* () {
6243
6285
  logger.info("_internalSendScreenVideo()");
6244
6286
  this._screenVideoProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
6287
+ var _a, _b;
6245
6288
  try {
6246
6289
  if (!this._screenVideoTrack || !this._sendTransport || this._screenVideoProducer) {
6247
6290
  this._screenVideoProducerPromise = null;
@@ -6267,6 +6310,9 @@ class VegaRtcManager {
6267
6310
  });
6268
6311
  if (this._screenVideoTrack !== this._screenVideoProducer.track)
6269
6312
  yield this._replaceScreenVideoTrack();
6313
+ if (this._features.lowBandwidth) {
6314
+ (_a = this._webcamProducer) === null || _a === void 0 ? void 0 : _a.setMaxSpatialLayer(0);
6315
+ }
6270
6316
  }
6271
6317
  catch (error) {
6272
6318
  logger.error("screenVideoProducer failed:%o", error);
@@ -6276,6 +6322,9 @@ class VegaRtcManager {
6276
6322
  if (!this._screenVideoTrack) {
6277
6323
  yield this._stopProducer(this._screenVideoProducer);
6278
6324
  this._screenVideoProducer = null;
6325
+ if (this._features.lowBandwidth) {
6326
+ (_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.setMaxSpatialLayer(Number.MAX_VALUE);
6327
+ }
6279
6328
  }
6280
6329
  }
6281
6330
  }))();
@@ -6438,6 +6487,7 @@ class VegaRtcManager {
6438
6487
  }
6439
6488
  }
6440
6489
  removeStream(streamId, _stream, requestedByClientId) {
6490
+ var _a;
6441
6491
  logger.info("removeStream() [streamId:%s, requestedByClientId:%s]", streamId, requestedByClientId);
6442
6492
  this._emitToSignal(PROTOCOL_REQUESTS.STOP_SCREENSHARE, {
6443
6493
  streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
@@ -6449,6 +6499,9 @@ class VegaRtcManager {
6449
6499
  this._stopProducer(this._screenAudioProducer);
6450
6500
  this._screenAudioProducer = null;
6451
6501
  this._screenAudioTrack = null;
6502
+ if (this._features.lowBandwidth) {
6503
+ (_a = this._webcamProducer) === null || _a === void 0 ? void 0 : _a.setMaxSpatialLayer(Number.MAX_VALUE);
6504
+ }
6452
6505
  }
6453
6506
  _onMicAnalyserScoreUpdated(data) {
6454
6507
  var _a, _b;
package/dist/index.mjs CHANGED
@@ -788,9 +788,23 @@ const VIDEO_SETTINGS_VP9 = {
788
788
  },
789
789
  encodings: [{ scalabilityMode: "L3T2_KEY" }],
790
790
  };
791
+ const VIDEO_SETTINGS_VP9_LOW_BANDWIDTH = {
792
+ codecOptions: {
793
+ videoGoogleStartBitrate: 500,
794
+ },
795
+ encodings: [{ scalabilityMode: "L2T2_KEY", maxBitrate: 800000 }],
796
+ };
791
797
  const SCREEN_SHARE_SETTINGS = {
792
798
  encodings: [{}],
793
799
  };
800
+ const SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH = {
801
+ encodings: [
802
+ {
803
+ maxBitrate: 600000,
804
+ maxFramerate: 2,
805
+ },
806
+ ],
807
+ };
794
808
  const SCREEN_SHARE_SIMULCAST_SETTINGS = {
795
809
  encodings: [
796
810
  { scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
@@ -801,11 +815,13 @@ const SCREEN_SHARE_SETTINGS_VP9 = {
801
815
  encodings: [{ dtx: true }],
802
816
  };
803
817
  const getMediaSettings = (kind, isScreenShare, features) => {
804
- const { lowDataModeEnabled, simulcastScreenshareOn, vp9On } = features;
818
+ const { lowDataModeEnabled, simulcastScreenshareOn, vp9On, lowBandwidth } = features;
805
819
  if (kind === "audio") {
806
820
  return AUDIO_SETTINGS;
807
821
  }
808
822
  if (isScreenShare) {
823
+ if (lowBandwidth && !vp9On)
824
+ return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
809
825
  if (vp9On)
810
826
  return SCREEN_SHARE_SETTINGS_VP9;
811
827
  if (simulcastScreenshareOn)
@@ -813,6 +829,11 @@ const getMediaSettings = (kind, isScreenShare, features) => {
813
829
  return SCREEN_SHARE_SETTINGS;
814
830
  }
815
831
  else {
832
+ if (lowBandwidth) {
833
+ if (vp9On)
834
+ return VIDEO_SETTINGS_VP9_LOW_BANDWIDTH;
835
+ return VIDEO_SETTINGS_SD;
836
+ }
816
837
  if (vp9On)
817
838
  return VIDEO_SETTINGS_VP9;
818
839
  if (lowDataModeEnabled)
@@ -4316,7 +4337,9 @@ class P2pRtcManager {
4316
4337
  return;
4317
4338
  }
4318
4339
  const offer = this._transformIncomingSdp(data.message, session.pc);
4319
- (_b = (_a = session.handleOffer(offer).then((answer) => {
4340
+ (_b = (_a = session
4341
+ .handleOffer(offer)
4342
+ .then((answer) => {
4320
4343
  this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
4321
4344
  receiverId: data.clientId,
4322
4345
  message: this._transformOutgoingSdp(answer),
@@ -4521,6 +4544,20 @@ class P2pRtcManager {
4521
4544
  return entry;
4522
4545
  });
4523
4546
  }
4547
+ if (this._features.addGoogleStunServers) {
4548
+ peerConnectionConfig.iceServers = [
4549
+ ...peerConnectionConfig.iceServers,
4550
+ { urls: "stun:stun.l.google.com:19302" },
4551
+ { urls: "stun:stun2.l.google.com:19302" },
4552
+ ];
4553
+ }
4554
+ if (this._features.addCloudflareStunServers) {
4555
+ peerConnectionConfig.iceServers = [
4556
+ ...peerConnectionConfig.iceServers,
4557
+ { urls: "stun:stun.cloudflare.com:3478" },
4558
+ { urls: "stun:stun.cloudflare.com:53" },
4559
+ ];
4560
+ }
4524
4561
  if (this._features.useOnlyTURN) {
4525
4562
  peerConnectionConfig.iceTransportPolicy = "relay";
4526
4563
  const filter = {
@@ -4700,7 +4737,7 @@ class P2pRtcManager {
4700
4737
  logger$3.info("Session doesn't have a connected PeerConnection, adding pending action!");
4701
4738
  const pendingActions = this._pendingActionsForConnectedPeerConnections;
4702
4739
  if (!pendingActions) {
4703
- logger$3.warn(`No pending action is created to repalce track, because the pending actions array is null`);
4740
+ logger$3.warn(`No pending action is created to replace track, because the pending actions array is null`);
4704
4741
  return;
4705
4742
  }
4706
4743
  const promise = new Promise((resolve, reject) => {
@@ -4885,11 +4922,13 @@ class P2pRtcManager {
4885
4922
  }
4886
4923
  if (cleanSdpOn)
4887
4924
  offer.sdp = cleanSdp(offer.sdp);
4888
- pc.setLocalDescription(offer).catch((e) => {
4925
+ pc.setLocalDescription(offer)
4926
+ .catch((e) => {
4889
4927
  logger$3.warn("RTCPeerConnection.setLocalDescription() failed with local offer", e);
4890
4928
  this._emit(rtcManagerEvents.PC_SLD_FAILURE, e);
4891
4929
  throw e;
4892
- }).then(() => {
4930
+ })
4931
+ .then(() => {
4893
4932
  this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
4894
4933
  receiverId: clientId,
4895
4934
  message: this._transformOutgoingSdp(offer),
@@ -4922,9 +4961,9 @@ class P2pRtcManager {
4922
4961
  let bandwidth = this._features.bandwidth
4923
4962
  ? parseInt(this._features.bandwidth, 10)
4924
4963
  : {
4925
- 1: 0,
4926
- 2: this._features.highP2PBandwidth ? 768 : 384,
4927
- 3: this._features.highP2PBandwidth ? 512 : 256,
4964
+ 1: this._features.lowBandwidth ? 768 : 0,
4965
+ 2: this._features.highP2PBandwidth && !this._features.lowBandwidth ? 768 : 384,
4966
+ 3: this._features.highP2PBandwidth && !this._features.lowBandwidth ? 512 : 256,
4928
4967
  4: 192,
4929
4968
  5: 128,
4930
4969
  6: 128,
@@ -4946,7 +4985,7 @@ class P2pRtcManager {
4946
4985
  }
4947
4986
  }
4948
4987
  }
4949
- if (this._features.higherP2PBitrates) {
4988
+ if (this._features.higherP2PBitrates && !this._features.lowBandwidth) {
4950
4989
  bandwidth = bandwidth * 1.5;
4951
4990
  }
4952
4991
  this._forEachPeerConnection((session) => {
@@ -6125,7 +6164,7 @@ class VegaRtcManager {
6125
6164
  return;
6126
6165
  }
6127
6166
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
6128
- var _b;
6167
+ var _b, _c;
6129
6168
  try {
6130
6169
  const currentPaused = this._webcamPaused;
6131
6170
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
@@ -6163,6 +6202,9 @@ class VegaRtcManager {
6163
6202
  this._stopProducer(this._webcamProducer);
6164
6203
  this._webcamProducer = null;
6165
6204
  }
6205
+ if (this._features.lowBandwidth && this._screenVideoTrack) {
6206
+ (_c = this._webcamProducer) === null || _c === void 0 ? void 0 : _c.setMaxSpatialLayer(0);
6207
+ }
6166
6208
  }
6167
6209
  }))();
6168
6210
  });
@@ -6221,6 +6263,7 @@ class VegaRtcManager {
6221
6263
  return __awaiter(this, void 0, void 0, function* () {
6222
6264
  logger.info("_internalSendScreenVideo()");
6223
6265
  this._screenVideoProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
6266
+ var _a, _b;
6224
6267
  try {
6225
6268
  if (!this._screenVideoTrack || !this._sendTransport || this._screenVideoProducer) {
6226
6269
  this._screenVideoProducerPromise = null;
@@ -6246,6 +6289,9 @@ class VegaRtcManager {
6246
6289
  });
6247
6290
  if (this._screenVideoTrack !== this._screenVideoProducer.track)
6248
6291
  yield this._replaceScreenVideoTrack();
6292
+ if (this._features.lowBandwidth) {
6293
+ (_a = this._webcamProducer) === null || _a === void 0 ? void 0 : _a.setMaxSpatialLayer(0);
6294
+ }
6249
6295
  }
6250
6296
  catch (error) {
6251
6297
  logger.error("screenVideoProducer failed:%o", error);
@@ -6255,6 +6301,9 @@ class VegaRtcManager {
6255
6301
  if (!this._screenVideoTrack) {
6256
6302
  yield this._stopProducer(this._screenVideoProducer);
6257
6303
  this._screenVideoProducer = null;
6304
+ if (this._features.lowBandwidth) {
6305
+ (_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.setMaxSpatialLayer(Number.MAX_VALUE);
6306
+ }
6258
6307
  }
6259
6308
  }
6260
6309
  }))();
@@ -6417,6 +6466,7 @@ class VegaRtcManager {
6417
6466
  }
6418
6467
  }
6419
6468
  removeStream(streamId, _stream, requestedByClientId) {
6469
+ var _a;
6420
6470
  logger.info("removeStream() [streamId:%s, requestedByClientId:%s]", streamId, requestedByClientId);
6421
6471
  this._emitToSignal(PROTOCOL_REQUESTS.STOP_SCREENSHARE, {
6422
6472
  streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
@@ -6428,6 +6478,9 @@ class VegaRtcManager {
6428
6478
  this._stopProducer(this._screenAudioProducer);
6429
6479
  this._screenAudioProducer = null;
6430
6480
  this._screenAudioTrack = null;
6481
+ if (this._features.lowBandwidth) {
6482
+ (_a = this._webcamProducer) === null || _a === void 0 ? void 0 : _a.setMaxSpatialLayer(Number.MAX_VALUE);
6483
+ }
6431
6484
  }
6432
6485
  _onMicAnalyserScoreUpdated(data) {
6433
6486
  var _a, _b;
@@ -788,9 +788,23 @@ const VIDEO_SETTINGS_VP9 = {
788
788
  },
789
789
  encodings: [{ scalabilityMode: "L3T2_KEY" }],
790
790
  };
791
+ const VIDEO_SETTINGS_VP9_LOW_BANDWIDTH = {
792
+ codecOptions: {
793
+ videoGoogleStartBitrate: 500,
794
+ },
795
+ encodings: [{ scalabilityMode: "L2T2_KEY", maxBitrate: 800000 }],
796
+ };
791
797
  const SCREEN_SHARE_SETTINGS = {
792
798
  encodings: [{}],
793
799
  };
800
+ const SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH = {
801
+ encodings: [
802
+ {
803
+ maxBitrate: 600000,
804
+ maxFramerate: 2,
805
+ },
806
+ ],
807
+ };
794
808
  const SCREEN_SHARE_SIMULCAST_SETTINGS = {
795
809
  encodings: [
796
810
  { scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
@@ -801,11 +815,13 @@ const SCREEN_SHARE_SETTINGS_VP9 = {
801
815
  encodings: [{ dtx: true }],
802
816
  };
803
817
  const getMediaSettings = (kind, isScreenShare, features) => {
804
- const { lowDataModeEnabled, simulcastScreenshareOn, vp9On } = features;
818
+ const { lowDataModeEnabled, simulcastScreenshareOn, vp9On, lowBandwidth } = features;
805
819
  if (kind === "audio") {
806
820
  return AUDIO_SETTINGS;
807
821
  }
808
822
  if (isScreenShare) {
823
+ if (lowBandwidth && !vp9On)
824
+ return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
809
825
  if (vp9On)
810
826
  return SCREEN_SHARE_SETTINGS_VP9;
811
827
  if (simulcastScreenshareOn)
@@ -813,6 +829,11 @@ const getMediaSettings = (kind, isScreenShare, features) => {
813
829
  return SCREEN_SHARE_SETTINGS;
814
830
  }
815
831
  else {
832
+ if (lowBandwidth) {
833
+ if (vp9On)
834
+ return VIDEO_SETTINGS_VP9_LOW_BANDWIDTH;
835
+ return VIDEO_SETTINGS_SD;
836
+ }
816
837
  if (vp9On)
817
838
  return VIDEO_SETTINGS_VP9;
818
839
  if (lowDataModeEnabled)
@@ -4316,7 +4337,9 @@ class P2pRtcManager {
4316
4337
  return;
4317
4338
  }
4318
4339
  const offer = this._transformIncomingSdp(data.message, session.pc);
4319
- (_b = (_a = session.handleOffer(offer).then((answer) => {
4340
+ (_b = (_a = session
4341
+ .handleOffer(offer)
4342
+ .then((answer) => {
4320
4343
  this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
4321
4344
  receiverId: data.clientId,
4322
4345
  message: this._transformOutgoingSdp(answer),
@@ -4521,6 +4544,20 @@ class P2pRtcManager {
4521
4544
  return entry;
4522
4545
  });
4523
4546
  }
4547
+ if (this._features.addGoogleStunServers) {
4548
+ peerConnectionConfig.iceServers = [
4549
+ ...peerConnectionConfig.iceServers,
4550
+ { urls: "stun:stun.l.google.com:19302" },
4551
+ { urls: "stun:stun2.l.google.com:19302" },
4552
+ ];
4553
+ }
4554
+ if (this._features.addCloudflareStunServers) {
4555
+ peerConnectionConfig.iceServers = [
4556
+ ...peerConnectionConfig.iceServers,
4557
+ { urls: "stun:stun.cloudflare.com:3478" },
4558
+ { urls: "stun:stun.cloudflare.com:53" },
4559
+ ];
4560
+ }
4524
4561
  if (this._features.useOnlyTURN) {
4525
4562
  peerConnectionConfig.iceTransportPolicy = "relay";
4526
4563
  const filter = {
@@ -4700,7 +4737,7 @@ class P2pRtcManager {
4700
4737
  logger$3.info("Session doesn't have a connected PeerConnection, adding pending action!");
4701
4738
  const pendingActions = this._pendingActionsForConnectedPeerConnections;
4702
4739
  if (!pendingActions) {
4703
- logger$3.warn(`No pending action is created to repalce track, because the pending actions array is null`);
4740
+ logger$3.warn(`No pending action is created to replace track, because the pending actions array is null`);
4704
4741
  return;
4705
4742
  }
4706
4743
  const promise = new Promise((resolve, reject) => {
@@ -4885,11 +4922,13 @@ class P2pRtcManager {
4885
4922
  }
4886
4923
  if (cleanSdpOn)
4887
4924
  offer.sdp = cleanSdp(offer.sdp);
4888
- pc.setLocalDescription(offer).catch((e) => {
4925
+ pc.setLocalDescription(offer)
4926
+ .catch((e) => {
4889
4927
  logger$3.warn("RTCPeerConnection.setLocalDescription() failed with local offer", e);
4890
4928
  this._emit(rtcManagerEvents.PC_SLD_FAILURE, e);
4891
4929
  throw e;
4892
- }).then(() => {
4930
+ })
4931
+ .then(() => {
4893
4932
  this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
4894
4933
  receiverId: clientId,
4895
4934
  message: this._transformOutgoingSdp(offer),
@@ -4922,9 +4961,9 @@ class P2pRtcManager {
4922
4961
  let bandwidth = this._features.bandwidth
4923
4962
  ? parseInt(this._features.bandwidth, 10)
4924
4963
  : {
4925
- 1: 0,
4926
- 2: this._features.highP2PBandwidth ? 768 : 384,
4927
- 3: this._features.highP2PBandwidth ? 512 : 256,
4964
+ 1: this._features.lowBandwidth ? 768 : 0,
4965
+ 2: this._features.highP2PBandwidth && !this._features.lowBandwidth ? 768 : 384,
4966
+ 3: this._features.highP2PBandwidth && !this._features.lowBandwidth ? 512 : 256,
4928
4967
  4: 192,
4929
4968
  5: 128,
4930
4969
  6: 128,
@@ -4946,7 +4985,7 @@ class P2pRtcManager {
4946
4985
  }
4947
4986
  }
4948
4987
  }
4949
- if (this._features.higherP2PBitrates) {
4988
+ if (this._features.higherP2PBitrates && !this._features.lowBandwidth) {
4950
4989
  bandwidth = bandwidth * 1.5;
4951
4990
  }
4952
4991
  this._forEachPeerConnection((session) => {
@@ -6125,7 +6164,7 @@ class VegaRtcManager {
6125
6164
  return;
6126
6165
  }
6127
6166
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
6128
- var _b;
6167
+ var _b, _c;
6129
6168
  try {
6130
6169
  const currentPaused = this._webcamPaused;
6131
6170
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
@@ -6163,6 +6202,9 @@ class VegaRtcManager {
6163
6202
  this._stopProducer(this._webcamProducer);
6164
6203
  this._webcamProducer = null;
6165
6204
  }
6205
+ if (this._features.lowBandwidth && this._screenVideoTrack) {
6206
+ (_c = this._webcamProducer) === null || _c === void 0 ? void 0 : _c.setMaxSpatialLayer(0);
6207
+ }
6166
6208
  }
6167
6209
  }))();
6168
6210
  });
@@ -6221,6 +6263,7 @@ class VegaRtcManager {
6221
6263
  return __awaiter(this, void 0, void 0, function* () {
6222
6264
  logger.info("_internalSendScreenVideo()");
6223
6265
  this._screenVideoProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
6266
+ var _a, _b;
6224
6267
  try {
6225
6268
  if (!this._screenVideoTrack || !this._sendTransport || this._screenVideoProducer) {
6226
6269
  this._screenVideoProducerPromise = null;
@@ -6246,6 +6289,9 @@ class VegaRtcManager {
6246
6289
  });
6247
6290
  if (this._screenVideoTrack !== this._screenVideoProducer.track)
6248
6291
  yield this._replaceScreenVideoTrack();
6292
+ if (this._features.lowBandwidth) {
6293
+ (_a = this._webcamProducer) === null || _a === void 0 ? void 0 : _a.setMaxSpatialLayer(0);
6294
+ }
6249
6295
  }
6250
6296
  catch (error) {
6251
6297
  logger.error("screenVideoProducer failed:%o", error);
@@ -6255,6 +6301,9 @@ class VegaRtcManager {
6255
6301
  if (!this._screenVideoTrack) {
6256
6302
  yield this._stopProducer(this._screenVideoProducer);
6257
6303
  this._screenVideoProducer = null;
6304
+ if (this._features.lowBandwidth) {
6305
+ (_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.setMaxSpatialLayer(Number.MAX_VALUE);
6306
+ }
6258
6307
  }
6259
6308
  }
6260
6309
  }))();
@@ -6417,6 +6466,7 @@ class VegaRtcManager {
6417
6466
  }
6418
6467
  }
6419
6468
  removeStream(streamId, _stream, requestedByClientId) {
6469
+ var _a;
6420
6470
  logger.info("removeStream() [streamId:%s, requestedByClientId:%s]", streamId, requestedByClientId);
6421
6471
  this._emitToSignal(PROTOCOL_REQUESTS.STOP_SCREENSHARE, {
6422
6472
  streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
@@ -6428,6 +6478,9 @@ class VegaRtcManager {
6428
6478
  this._stopProducer(this._screenAudioProducer);
6429
6479
  this._screenAudioProducer = null;
6430
6480
  this._screenAudioTrack = null;
6481
+ if (this._features.lowBandwidth) {
6482
+ (_a = this._webcamProducer) === null || _a === void 0 ? void 0 : _a.setMaxSpatialLayer(Number.MAX_VALUE);
6483
+ }
6431
6484
  }
6432
6485
  _onMicAnalyserScoreUpdated(data) {
6433
6486
  var _a, _b;
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.16.3",
4
+ "version": "1.17.1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {