livekit-client 1.6.5 → 1.6.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -12877,7 +12877,8 @@ var RoomEvent;
12877
12877
  */
12878
12878
  RoomEvent["SignalConnected"] = "signalConnected";
12879
12879
  /**
12880
- * Recording of a room has started/stopped.
12880
+ * Recording of a room has started/stopped. Room.isRecording will be updated too.
12881
+ * args: (isRecording: boolean)
12881
12882
  */
12882
12883
  RoomEvent["RecordingStatusChanged"] = "recordingStatusChanged";
12883
12884
  })(RoomEvent || (RoomEvent = {}));
@@ -13799,7 +13800,7 @@ var uaParser = {
13799
13800
  })(uaParser, uaParserExports);
13800
13801
  var UAParser = uaParserExports;
13801
13802
 
13802
- var version$1 = "1.6.5";
13803
+ var version$1 = "1.6.6";
13803
13804
 
13804
13805
  const version = version$1;
13805
13806
  const protocolVersion = 8;
@@ -15465,6 +15466,7 @@ class LocalVideoTrack extends LocalTrack {
15465
15466
  }
15466
15467
  this.prevStats = statsMap;
15467
15468
  };
15469
+ this.senderLock = new Mutex();
15468
15470
  }
15469
15471
  get isSimulcast() {
15470
15472
  if (this.sender && this.sender.getParameters().encodings.length > 1) {
@@ -15657,7 +15659,7 @@ class LocalVideoTrack extends LocalTrack {
15657
15659
  }
15658
15660
  } else if (simulcastCodecInfo.encodings) {
15659
15661
  livekitLogger.debug("try setPublishingLayersForSender ".concat(codec.codec));
15660
- await setPublishingLayersForSender(simulcastCodecInfo.sender, simulcastCodecInfo.encodings, codec.qualities);
15662
+ await setPublishingLayersForSender(simulcastCodecInfo.sender, simulcastCodecInfo.encodings, codec.qualities, this.senderLock);
15661
15663
  }
15662
15664
  }
15663
15665
  }
@@ -15687,7 +15689,7 @@ class LocalVideoTrack extends LocalTrack {
15687
15689
  if (!this.sender || !this.encodings) {
15688
15690
  return;
15689
15691
  }
15690
- await setPublishingLayersForSender(this.sender, this.encodings, qualities);
15692
+ await setPublishingLayersForSender(this.sender, this.encodings, qualities, this.senderLock);
15691
15693
  }
15692
15694
  async handleAppVisibilityChanged() {
15693
15695
  await super.handleAppVisibilityChanged();
@@ -15697,59 +15699,64 @@ class LocalVideoTrack extends LocalTrack {
15697
15699
  }
15698
15700
  }
15699
15701
  }
15700
- async function setPublishingLayersForSender(sender, senderEncodings, qualities) {
15702
+ async function setPublishingLayersForSender(sender, senderEncodings, qualities, senderLock) {
15703
+ const unlock = await senderLock.lock();
15701
15704
  livekitLogger.debug('setPublishingLayersForSender', {
15702
15705
  sender,
15703
15706
  qualities,
15704
15707
  senderEncodings
15705
15708
  });
15706
- const params = sender.getParameters();
15707
- const {
15708
- encodings
15709
- } = params;
15710
- if (!encodings) {
15711
- return;
15712
- }
15713
- if (encodings.length !== senderEncodings.length) {
15714
- livekitLogger.warn('cannot set publishing layers, encodings mismatch');
15715
- return;
15716
- }
15717
- let hasChanged = false;
15718
- encodings.forEach((encoding, idx) => {
15719
- var _a;
15720
- let rid = (_a = encoding.rid) !== null && _a !== void 0 ? _a : '';
15721
- if (rid === '') {
15722
- rid = 'q';
15709
+ try {
15710
+ const params = sender.getParameters();
15711
+ const {
15712
+ encodings
15713
+ } = params;
15714
+ if (!encodings) {
15715
+ return;
15723
15716
  }
15724
- const quality = videoQualityForRid(rid);
15725
- const subscribedQuality = qualities.find(q => q.quality === quality);
15726
- if (!subscribedQuality) {
15717
+ if (encodings.length !== senderEncodings.length) {
15718
+ livekitLogger.warn('cannot set publishing layers, encodings mismatch');
15727
15719
  return;
15728
15720
  }
15729
- if (encoding.active !== subscribedQuality.enabled) {
15730
- hasChanged = true;
15731
- encoding.active = subscribedQuality.enabled;
15732
- livekitLogger.debug("setting layer ".concat(subscribedQuality.quality, " to ").concat(encoding.active ? 'enabled' : 'disabled'));
15733
- // FireFox does not support setting encoding.active to false, so we
15734
- // have a workaround of lowering its bitrate and resolution to the min.
15735
- if (isFireFox()) {
15736
- if (subscribedQuality.enabled) {
15737
- encoding.scaleResolutionDownBy = senderEncodings[idx].scaleResolutionDownBy;
15738
- encoding.maxBitrate = senderEncodings[idx].maxBitrate;
15739
- /* @ts-ignore */
15740
- encoding.maxFrameRate = senderEncodings[idx].maxFrameRate;
15741
- } else {
15742
- encoding.scaleResolutionDownBy = 4;
15743
- encoding.maxBitrate = 10;
15744
- /* @ts-ignore */
15745
- encoding.maxFrameRate = 2;
15721
+ let hasChanged = false;
15722
+ encodings.forEach((encoding, idx) => {
15723
+ var _a;
15724
+ let rid = (_a = encoding.rid) !== null && _a !== void 0 ? _a : '';
15725
+ if (rid === '') {
15726
+ rid = 'q';
15727
+ }
15728
+ const quality = videoQualityForRid(rid);
15729
+ const subscribedQuality = qualities.find(q => q.quality === quality);
15730
+ if (!subscribedQuality) {
15731
+ return;
15732
+ }
15733
+ if (encoding.active !== subscribedQuality.enabled) {
15734
+ hasChanged = true;
15735
+ encoding.active = subscribedQuality.enabled;
15736
+ livekitLogger.debug("setting layer ".concat(subscribedQuality.quality, " to ").concat(encoding.active ? 'enabled' : 'disabled'));
15737
+ // FireFox does not support setting encoding.active to false, so we
15738
+ // have a workaround of lowering its bitrate and resolution to the min.
15739
+ if (isFireFox()) {
15740
+ if (subscribedQuality.enabled) {
15741
+ encoding.scaleResolutionDownBy = senderEncodings[idx].scaleResolutionDownBy;
15742
+ encoding.maxBitrate = senderEncodings[idx].maxBitrate;
15743
+ /* @ts-ignore */
15744
+ encoding.maxFrameRate = senderEncodings[idx].maxFrameRate;
15745
+ } else {
15746
+ encoding.scaleResolutionDownBy = 4;
15747
+ encoding.maxBitrate = 10;
15748
+ /* @ts-ignore */
15749
+ encoding.maxFrameRate = 2;
15750
+ }
15746
15751
  }
15747
15752
  }
15753
+ });
15754
+ if (hasChanged) {
15755
+ params.encodings = encodings;
15756
+ await sender.setParameters(params);
15748
15757
  }
15749
- });
15750
- if (hasChanged) {
15751
- params.encodings = encodings;
15752
- await sender.setParameters(params);
15758
+ } finally {
15759
+ unlock();
15753
15760
  }
15754
15761
  }
15755
15762
  function videoQualityForRid(rid) {
@@ -17588,7 +17595,7 @@ class LocalParticipant extends Participant {
17588
17595
  }
17589
17596
  }
17590
17597
  } else if (update.subscribedQualities.length > 0) {
17591
- (_b = pub.videoTrack) === null || _b === void 0 ? void 0 : _b.setPublishingLayers(update.subscribedQualities);
17598
+ await ((_b = pub.videoTrack) === null || _b === void 0 ? void 0 : _b.setPublishingLayers(update.subscribedQualities));
17592
17599
  }
17593
17600
  };
17594
17601
  this.handleLocalTrackUnpublished = unpublished => {