livekit-client 2.13.5 → 2.13.7

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/src/room/Room.ts CHANGED
@@ -1301,10 +1301,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1301
1301
  */
1302
1302
  async switchActiveDevice(kind: MediaDeviceKind, deviceId: string, exact: boolean = true) {
1303
1303
  let success = true;
1304
- let needsUpdateWithoutTracks = false;
1304
+ let shouldTriggerImmediateDeviceChange = false;
1305
1305
  const deviceConstraint = exact ? { exact: deviceId } : deviceId;
1306
1306
  if (kind === 'audioinput') {
1307
- needsUpdateWithoutTracks = this.localParticipant.audioTrackPublications.size === 0;
1307
+ shouldTriggerImmediateDeviceChange = this.localParticipant.audioTrackPublications.size === 0;
1308
1308
  const prevDeviceId =
1309
1309
  this.getActiveDevice(kind) ?? this.options.audioCaptureDefaults!.deviceId;
1310
1310
  this.options.audioCaptureDefaults!.deviceId = deviceConstraint;
@@ -1319,8 +1319,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1319
1319
  this.options.audioCaptureDefaults!.deviceId = prevDeviceId;
1320
1320
  throw e;
1321
1321
  }
1322
+ const isMuted = tracks.some((t) => t.track?.isMuted ?? false);
1323
+ if (success && isMuted) shouldTriggerImmediateDeviceChange = true;
1322
1324
  } else if (kind === 'videoinput') {
1323
- needsUpdateWithoutTracks = this.localParticipant.videoTrackPublications.size === 0;
1325
+ shouldTriggerImmediateDeviceChange = this.localParticipant.videoTrackPublications.size === 0;
1324
1326
  const prevDeviceId =
1325
1327
  this.getActiveDevice(kind) ?? this.options.videoCaptureDefaults!.deviceId;
1326
1328
  this.options.videoCaptureDefaults!.deviceId = deviceConstraint;
@@ -1336,6 +1338,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1336
1338
  throw e;
1337
1339
  }
1338
1340
  } else if (kind === 'audiooutput') {
1341
+ shouldTriggerImmediateDeviceChange = true;
1339
1342
  if (
1340
1343
  (!supportsSetSinkId() && !this.options.webAudioMix) ||
1341
1344
  (this.options.webAudioMix && this.audioContext && !('setSinkId' in this.audioContext))
@@ -1367,12 +1370,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1367
1370
  throw e;
1368
1371
  }
1369
1372
  }
1370
- if (needsUpdateWithoutTracks || kind === 'audiooutput') {
1371
- // if there are not active tracks yet or we're switching audiooutput, we need to manually update the active device map here as changing audio output won't result in a track restart
1372
- this.localParticipant.activeDeviceMap.set(
1373
- kind,
1374
- (kind === 'audiooutput' && this.options.audioOutput?.deviceId) || deviceId,
1375
- );
1373
+
1374
+ if (shouldTriggerImmediateDeviceChange) {
1375
+ this.localParticipant.activeDeviceMap.set(kind, deviceId);
1376
1376
  this.emit(RoomEvent.ActiveDeviceChanged, kind, deviceId);
1377
1377
  }
1378
1378
 
@@ -7,12 +7,11 @@ import {
7
7
  } from '@livekit/protocol';
8
8
  import type { SignalClient } from '../../api/SignalClient';
9
9
  import type { StructuredLogger } from '../../logger';
10
- import { getBrowser } from '../../utils/browserParser';
11
10
  import { ScalabilityMode } from '../participant/publishUtils';
12
11
  import type { VideoSenderStats } from '../stats';
13
12
  import { computeBitrate, monitorFrequency } from '../stats';
14
13
  import type { LoggerOptions } from '../types';
15
- import { compareVersions, isFireFox, isMobile, isSVCCodec, isWeb } from '../utils';
14
+ import { isFireFox, isMobile, isSVCCodec, isWeb } from '../utils';
16
15
  import LocalTrack from './LocalTrack';
17
16
  import { Track, VideoQuality } from './Track';
18
17
  import type { VideoCaptureOptions, VideoCodec } from './options';
@@ -459,15 +458,18 @@ async function setPublishingLayersForSender(
459
458
  }
460
459
 
461
460
  let hasChanged = false;
462
- const browser = getBrowser();
463
- const closableSpatial =
464
- browser?.name === 'Chrome' && compareVersions(browser?.version, '133') > 0;
461
+
462
+ /* disable closable spatial layer as it has video blur / frozen issue with current server / client
463
+ 1. chrome 113: when switching to up layer with scalability Mode change, it will generate a
464
+ low resolution frame and recover very quickly, but noticable
465
+ 2. livekit sfu: additional pli request cause video frozen for a few frames, also noticable */
466
+ const closableSpatial = false;
465
467
  /* @ts-ignore */
466
468
  if (closableSpatial && encodings[0].scalabilityMode) {
467
469
  // svc dynacast encodings
468
470
  const encoding = encodings[0];
469
471
  /* @ts-ignore */
470
- const mode = new ScalabilityMode(encoding.scalabilityMode);
472
+ // const mode = new ScalabilityMode(encoding.scalabilityMode);
471
473
  let maxQuality = ProtoVideoQuality.OFF;
472
474
  qualities.forEach((q) => {
473
475
  if (q.enabled && (maxQuality === ProtoVideoQuality.OFF || q.quality > maxQuality)) {
@@ -480,25 +482,22 @@ async function setPublishingLayersForSender(
480
482
  encoding.active = false;
481
483
  hasChanged = true;
482
484
  }
483
- } else if (!encoding.active || mode.spatial !== maxQuality + 1) {
485
+ } else if (!encoding.active /* || mode.spatial !== maxQuality + 1*/) {
484
486
  hasChanged = true;
485
487
  encoding.active = true;
486
- /* @ts-ignore */
487
- const originalMode = new ScalabilityMode(senderEncodings[0].scalabilityMode);
488
+ /*
489
+ @ts-ignore
490
+ const originalMode = new ScalabilityMode(senderEncodings[0].scalabilityMode)
488
491
  mode.spatial = maxQuality + 1;
489
492
  mode.suffix = originalMode.suffix;
490
493
  if (mode.spatial === 1) {
491
494
  // no suffix for L1Tx
492
495
  mode.suffix = undefined;
493
496
  }
494
- /* @ts-ignore */
497
+ @ts-ignore
495
498
  encoding.scalabilityMode = mode.toString();
496
499
  encoding.scaleResolutionDownBy = 2 ** (2 - maxQuality);
497
- if (senderEncodings[0].maxBitrate) {
498
- encoding.maxBitrate =
499
- senderEncodings[0].maxBitrate /
500
- (encoding.scaleResolutionDownBy * encoding.scaleResolutionDownBy);
501
- }
500
+ */
502
501
  }
503
502
  } else {
504
503
  if (isSVC) {