livekit-client 2.14.0 → 2.15.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.
Files changed (31) hide show
  1. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  2. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  3. package/dist/livekit-client.esm.mjs +96 -33
  4. package/dist/livekit-client.esm.mjs.map +1 -1
  5. package/dist/livekit-client.umd.js +1 -1
  6. package/dist/livekit-client.umd.js.map +1 -1
  7. package/dist/src/room/PCTransport.d.ts.map +1 -1
  8. package/dist/src/room/Room.d.ts.map +1 -1
  9. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  10. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  11. package/dist/src/room/track/RemoteTrackPublication.d.ts +12 -3
  12. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  13. package/dist/src/room/track/options.d.ts +1 -1
  14. package/dist/src/room/track/options.d.ts.map +1 -1
  15. package/dist/src/room/track/utils.d.ts +3 -1
  16. package/dist/src/room/track/utils.d.ts.map +1 -1
  17. package/dist/src/room/utils.d.ts +1 -0
  18. package/dist/src/room/utils.d.ts.map +1 -1
  19. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +12 -3
  20. package/dist/ts4.2/src/room/track/options.d.ts +2 -1
  21. package/dist/ts4.2/src/room/track/utils.d.ts +3 -1
  22. package/dist/ts4.2/src/room/utils.d.ts +1 -0
  23. package/package.json +11 -11
  24. package/src/room/PCTransport.ts +3 -4
  25. package/src/room/Room.ts +2 -0
  26. package/src/room/participant/RemoteParticipant.ts +1 -0
  27. package/src/room/participant/publishUtils.ts +1 -0
  28. package/src/room/track/RemoteTrackPublication.ts +91 -32
  29. package/src/room/track/options.ts +1 -1
  30. package/src/room/track/utils.ts +12 -1
  31. package/src/room/utils.ts +18 -0
@@ -4414,6 +4414,18 @@ const VideoLayer = /* @__PURE__ */proto3.makeMessageType("livekit.VideoLayer", (
4414
4414
  kind: "scalar",
4415
4415
  T: 13
4416
4416
  /* ScalarType.UINT32 */
4417
+ }, {
4418
+ no: 6,
4419
+ name: "spatial_layer",
4420
+ kind: "scalar",
4421
+ T: 5
4422
+ /* ScalarType.INT32 */
4423
+ }, {
4424
+ no: 7,
4425
+ name: "rid",
4426
+ kind: "scalar",
4427
+ T: 9
4428
+ /* ScalarType.STRING */
4417
4429
  }]);
4418
4430
  const DataPacket = /* @__PURE__ */proto3.makeMessageType("livekit.DataPacket", () => [{
4419
4431
  no: 1,
@@ -4963,6 +4975,9 @@ const ClientInfo_SDK = /* @__PURE__ */proto3.makeEnum("livekit.ClientInfo.SDK",
4963
4975
  }, {
4964
4976
  no: 13,
4965
4977
  name: "UNREAL"
4978
+ }, {
4979
+ no: 14,
4980
+ name: "ESP32"
4966
4981
  }]);
4967
4982
  const ClientConfiguration = /* @__PURE__ */proto3.makeMessageType("livekit.ClientConfiguration", () => [{
4968
4983
  no: 1,
@@ -11349,7 +11364,7 @@ function getOSVersion(ua) {
11349
11364
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
11350
11365
  }
11351
11366
 
11352
- var version$1 = "2.14.0";
11367
+ var version$1 = "2.15.1";
11353
11368
 
11354
11369
  const version = version$1;
11355
11370
  const protocolVersion = 16;
@@ -11783,7 +11798,7 @@ class VideoPreset {
11783
11798
  }
11784
11799
  }
11785
11800
  const backupCodecs = ['vp8', 'h264'];
11786
- const videoCodecs = ['vp8', 'h264', 'vp9', 'av1'];
11801
+ const videoCodecs = ['vp8', 'h264', 'vp9', 'av1', 'h265'];
11787
11802
  function isBackupCodec(codec) {
11788
11803
  return !!backupCodecs.find(backup => backup === codec);
11789
11804
  }
@@ -12682,6 +12697,13 @@ function getTrackSourceFromProto(source) {
12682
12697
  return Track.Source.Unknown;
12683
12698
  }
12684
12699
  }
12700
+ function areDimensionsSmaller(a, b) {
12701
+ return a.width * a.height < b.width * b.height;
12702
+ }
12703
+ function layerDimensionsFor(trackInfo, quality) {
12704
+ var _a;
12705
+ return (_a = trackInfo.layers) === null || _a === void 0 ? void 0 : _a.find(l => l.quality === quality);
12706
+ }
12685
12707
 
12686
12708
  /**
12687
12709
  * @experimental
@@ -14952,9 +14974,6 @@ class PCTransport extends eventsExports.EventEmitter {
14952
14974
  var _a;
14953
14975
  const unlock = yield this.offerLock.lock();
14954
14976
  try {
14955
- // increase the offer id at the start to ensure the offer is always > 0 so that we can use 0 as a default value for legacy behavior
14956
- const offerId = this.latestOfferId + 1;
14957
- this.latestOfferId = offerId;
14958
14977
  if (this.onOffer === undefined) {
14959
14978
  return;
14960
14979
  }
@@ -14980,6 +14999,9 @@ class PCTransport extends eventsExports.EventEmitter {
14980
14999
  }
14981
15000
  // actually negotiate
14982
15001
  this.log.debug('starting to negotiate', this.logContext);
15002
+ // increase the offer id at the start to ensure the offer is always > 0 so that we can use 0 as a default value for legacy behavior
15003
+ const offerId = this.latestOfferId + 1;
15004
+ this.latestOfferId = offerId;
14983
15005
  const offer = yield this.pc.createOffer(options);
14984
15006
  this.log.debug('original offer', Object.assign({
14985
15007
  sdp: offer.sdp
@@ -16825,6 +16847,7 @@ function determineAppropriateEncoding(isScreenShare, width, height, codec) {
16825
16847
  if (codec) {
16826
16848
  switch (codec) {
16827
16849
  case 'av1':
16850
+ case 'h265':
16828
16851
  encoding = Object.assign({}, encoding);
16829
16852
  encoding.maxBitrate = encoding.maxBitrate * 0.7;
16830
16853
  break;
@@ -22404,20 +22427,20 @@ class RemoteTrackPublication extends TrackPublication {
22404
22427
  this.track = undefined;
22405
22428
  /** @internal */
22406
22429
  this.allowed = true;
22407
- this.disabled = false;
22408
- this.currentVideoQuality = VideoQuality.HIGH;
22430
+ this.requestedDisabled = undefined;
22431
+ this.visible = true;
22409
22432
  this.handleEnded = track => {
22410
22433
  this.setTrack(undefined);
22411
22434
  this.emit(TrackEvent.Ended, track);
22412
22435
  };
22413
22436
  this.handleVisibilityChange = visible => {
22414
22437
  this.log.debug("adaptivestream video visibility ".concat(this.trackSid, ", visible=").concat(visible), this.logContext);
22415
- this.disabled = !visible;
22438
+ this.visible = visible;
22416
22439
  this.emitTrackUpdate();
22417
22440
  };
22418
22441
  this.handleVideoDimensionsChange = dimensions => {
22419
22442
  this.log.debug("adaptivestream video dimensions ".concat(dimensions.width, "x").concat(dimensions.height), this.logContext);
22420
- this.videoDimensions = dimensions;
22443
+ this.videoDimensionsAdaptiveStream = dimensions;
22421
22444
  this.emitTrackUpdate();
22422
22445
  };
22423
22446
  this.subscribed = autoSubscribe;
@@ -22476,7 +22499,7 @@ class RemoteTrackPublication extends TrackPublication {
22476
22499
  return this.subscribed !== false;
22477
22500
  }
22478
22501
  get isEnabled() {
22479
- return !this.disabled;
22502
+ return this.requestedDisabled !== undefined ? !this.requestedDisabled : this.isAdaptiveStream ? this.visible : true;
22480
22503
  }
22481
22504
  get isLocal() {
22482
22505
  return false;
@@ -22488,10 +22511,10 @@ class RemoteTrackPublication extends TrackPublication {
22488
22511
  * @param enabled
22489
22512
  */
22490
22513
  setEnabled(enabled) {
22491
- if (!this.isManualOperationAllowed() || this.disabled === !enabled) {
22514
+ if (!this.isManualOperationAllowed() || this.requestedDisabled === !enabled) {
22492
22515
  return;
22493
22516
  }
22494
- this.disabled = !enabled;
22517
+ this.requestedDisabled = !enabled;
22495
22518
  this.emitTrackUpdate();
22496
22519
  }
22497
22520
  /**
@@ -22502,25 +22525,32 @@ class RemoteTrackPublication extends TrackPublication {
22502
22525
  * optimize for uninterrupted video
22503
22526
  */
22504
22527
  setVideoQuality(quality) {
22505
- if (!this.isManualOperationAllowed() || this.currentVideoQuality === quality) {
22528
+ if (!this.isManualOperationAllowed() || this.requestedMaxQuality === quality) {
22506
22529
  return;
22507
22530
  }
22508
- this.currentVideoQuality = quality;
22509
- this.videoDimensions = undefined;
22531
+ this.requestedMaxQuality = quality;
22532
+ this.requestedVideoDimensions = undefined;
22510
22533
  this.emitTrackUpdate();
22511
22534
  }
22535
+ /**
22536
+ * Explicitly set the video dimensions for this track.
22537
+ *
22538
+ * This will take precedence over adaptive stream dimensions.
22539
+ *
22540
+ * @param dimensions The video dimensions to set.
22541
+ */
22512
22542
  setVideoDimensions(dimensions) {
22513
22543
  var _a, _b;
22514
22544
  if (!this.isManualOperationAllowed()) {
22515
22545
  return;
22516
22546
  }
22517
- if (((_a = this.videoDimensions) === null || _a === void 0 ? void 0 : _a.width) === dimensions.width && ((_b = this.videoDimensions) === null || _b === void 0 ? void 0 : _b.height) === dimensions.height) {
22547
+ if (((_a = this.requestedVideoDimensions) === null || _a === void 0 ? void 0 : _a.width) === dimensions.width && ((_b = this.requestedVideoDimensions) === null || _b === void 0 ? void 0 : _b.height) === dimensions.height) {
22518
22548
  return;
22519
22549
  }
22520
22550
  if (isRemoteVideoTrack(this.track)) {
22521
- this.videoDimensions = dimensions;
22551
+ this.requestedVideoDimensions = dimensions;
22522
22552
  }
22523
- this.currentVideoQuality = undefined;
22553
+ this.requestedMaxQuality = undefined;
22524
22554
  this.emitTrackUpdate();
22525
22555
  }
22526
22556
  setVideoFPS(fps) {
@@ -22537,7 +22567,8 @@ class RemoteTrackPublication extends TrackPublication {
22537
22567
  this.emitTrackUpdate();
22538
22568
  }
22539
22569
  get videoQuality() {
22540
- return this.currentVideoQuality;
22570
+ var _a;
22571
+ return (_a = this.requestedMaxQuality) !== null && _a !== void 0 ? _a : VideoQuality.HIGH;
22541
22572
  }
22542
22573
  /** @internal */
22543
22574
  setTrack(track) {
@@ -22604,10 +22635,6 @@ class RemoteTrackPublication extends TrackPublication {
22604
22635
  }
22605
22636
  }
22606
22637
  isManualOperationAllowed() {
22607
- if (this.kind === Track.Kind.Video && this.isAdaptiveStream) {
22608
- this.log.warn('adaptive stream is enabled, cannot change video track settings', this.logContext);
22609
- return false;
22610
- }
22611
22638
  if (!this.isDesired) {
22612
22639
  this.log.warn('cannot update track settings when not subscribed', this.logContext);
22613
22640
  return false;
@@ -22621,17 +22648,46 @@ class RemoteTrackPublication extends TrackPublication {
22621
22648
  emitTrackUpdate() {
22622
22649
  const settings = new UpdateTrackSettings({
22623
22650
  trackSids: [this.trackSid],
22624
- disabled: this.disabled,
22651
+ disabled: !this.isEnabled,
22625
22652
  fps: this.fps
22626
22653
  });
22627
- if (this.videoDimensions) {
22628
- settings.width = Math.ceil(this.videoDimensions.width);
22629
- settings.height = Math.ceil(this.videoDimensions.height);
22630
- } else if (this.currentVideoQuality !== undefined) {
22631
- settings.quality = this.currentVideoQuality;
22632
- } else {
22633
- // defaults to high quality
22634
- settings.quality = VideoQuality.HIGH;
22654
+ if (this.kind === Track.Kind.Video) {
22655
+ let minDimensions = this.requestedVideoDimensions;
22656
+ if (this.videoDimensionsAdaptiveStream !== undefined) {
22657
+ if (minDimensions) {
22658
+ // check whether the adaptive stream dimensions are smaller than the requested dimensions and use smaller one
22659
+ const smallerAdaptive = areDimensionsSmaller(this.videoDimensionsAdaptiveStream, minDimensions);
22660
+ if (smallerAdaptive) {
22661
+ this.log.debug('using adaptive stream dimensions instead of requested', Object.assign(Object.assign({}, this.logContext), this.videoDimensionsAdaptiveStream));
22662
+ minDimensions = this.videoDimensionsAdaptiveStream;
22663
+ }
22664
+ } else if (this.requestedMaxQuality !== undefined && this.trackInfo) {
22665
+ // check whether adaptive stream dimensions are smaller than the max quality layer and use smaller one
22666
+ const maxQualityLayer = layerDimensionsFor(this.trackInfo, this.requestedMaxQuality);
22667
+ if (maxQualityLayer && areDimensionsSmaller(this.videoDimensionsAdaptiveStream, maxQualityLayer)) {
22668
+ this.log.debug('using adaptive stream dimensions instead of max quality layer', Object.assign(Object.assign({}, this.logContext), this.videoDimensionsAdaptiveStream));
22669
+ minDimensions = this.videoDimensionsAdaptiveStream;
22670
+ }
22671
+ } else {
22672
+ this.log.debug('using adaptive stream dimensions', Object.assign(Object.assign({}, this.logContext), this.videoDimensionsAdaptiveStream));
22673
+ minDimensions = this.videoDimensionsAdaptiveStream;
22674
+ }
22675
+ }
22676
+ if (minDimensions) {
22677
+ settings.width = Math.ceil(minDimensions.width);
22678
+ settings.height = Math.ceil(minDimensions.height);
22679
+ } else if (this.requestedMaxQuality !== undefined) {
22680
+ this.log.debug('using requested max quality', Object.assign(Object.assign({}, this.logContext), {
22681
+ quality: this.requestedMaxQuality
22682
+ }));
22683
+ settings.quality = this.requestedMaxQuality;
22684
+ } else {
22685
+ this.log.debug('using default quality', Object.assign(Object.assign({}, this.logContext), {
22686
+ quality: VideoQuality.HIGH
22687
+ }));
22688
+ // defaults to high quality
22689
+ settings.quality = VideoQuality.HIGH;
22690
+ }
22635
22691
  }
22636
22692
  this.emit(TrackEvent.UpdateSettings, settings);
22637
22693
  }
@@ -22662,7 +22718,9 @@ class RemoteParticipant extends Participant {
22662
22718
  super.addTrackPublication(publication);
22663
22719
  // register action events
22664
22720
  publication.on(TrackEvent.UpdateSettings, settings => {
22665
- this.log.debug('send update settings', Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(publication)));
22721
+ this.log.debug('send update settings', Object.assign(Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(publication)), {
22722
+ settings
22723
+ }));
22666
22724
  this.signalClient.sendUpdateTrackSettings(settings);
22667
22725
  });
22668
22726
  publication.on(TrackEvent.UpdateSubscription, sub => {
@@ -24201,6 +24259,11 @@ class Room extends eventsExports.EventEmitter {
24201
24259
  _this3.options.videoCaptureDefaults.deviceId = prevDeviceId;
24202
24260
  throw e;
24203
24261
  }
24262
+ const isMuted = tracks.some(t => {
24263
+ var _a, _b;
24264
+ return (_b = (_a = t.track) === null || _a === void 0 ? void 0 : _a.isMuted) !== null && _b !== void 0 ? _b : false;
24265
+ });
24266
+ if (success && isMuted) shouldTriggerImmediateDeviceChange = true;
24204
24267
  } else if (kind === 'audiooutput') {
24205
24268
  shouldTriggerImmediateDeviceChange = true;
24206
24269
  if (!supportsSetSinkId() && !_this3.options.webAudioMix || _this3.options.webAudioMix && _this3.audioContext && !('setSinkId' in _this3.audioContext)) {