livekit-client 2.0.4 → 2.0.6

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 (99) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +10 -8
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +10400 -9929
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.umd.js +1 -1
  8. package/dist/livekit-client.umd.js.map +1 -1
  9. package/dist/src/api/SignalClient.d.ts +2 -3
  10. package/dist/src/api/SignalClient.d.ts.map +1 -1
  11. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  12. package/dist/src/e2ee/worker/FrameCryptor.d.ts +1 -0
  13. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  14. package/dist/src/index.d.ts +1 -1
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/logger.d.ts +2 -2
  17. package/dist/src/logger.d.ts.map +1 -1
  18. package/dist/src/room/PCTransportManager.d.ts +1 -1
  19. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  20. package/dist/src/room/RTCEngine.d.ts +4 -4
  21. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  22. package/dist/src/room/RegionUrlProvider.d.ts +1 -1
  23. package/dist/src/room/RegionUrlProvider.d.ts.map +1 -1
  24. package/dist/src/room/Room.d.ts +1 -1
  25. package/dist/src/room/Room.d.ts.map +1 -1
  26. package/dist/src/room/participant/LocalParticipant.d.ts +1 -1
  27. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  28. package/dist/src/room/participant/Participant.d.ts +2 -3
  29. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  30. package/dist/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
  31. package/dist/src/room/participant/ParticipantTrackPermission.d.ts.map +1 -1
  32. package/dist/src/room/participant/RemoteParticipant.d.ts +5 -1
  33. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  34. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  35. package/dist/src/room/track/LocalTrackPublication.d.ts +1 -1
  36. package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
  37. package/dist/src/room/track/LocalVideoTrack.d.ts +1 -2
  38. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  39. package/dist/src/room/track/RemoteTrackPublication.d.ts +1 -1
  40. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  41. package/dist/src/room/track/Track.d.ts +1 -2
  42. package/dist/src/room/track/Track.d.ts.map +1 -1
  43. package/dist/src/room/track/TrackPublication.d.ts +2 -3
  44. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  45. package/dist/src/room/track/utils.d.ts +1 -1
  46. package/dist/src/room/track/utils.d.ts.map +1 -1
  47. package/dist/src/room/utils.d.ts +1 -1
  48. package/dist/src/room/utils.d.ts.map +1 -1
  49. package/dist/ts4.2/src/api/SignalClient.d.ts +2 -3
  50. package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +1 -0
  51. package/dist/ts4.2/src/index.d.ts +1 -1
  52. package/dist/ts4.2/src/logger.d.ts +2 -2
  53. package/dist/ts4.2/src/room/PCTransportManager.d.ts +1 -1
  54. package/dist/ts4.2/src/room/RTCEngine.d.ts +5 -5
  55. package/dist/ts4.2/src/room/RegionUrlProvider.d.ts +1 -1
  56. package/dist/ts4.2/src/room/Room.d.ts +1 -1
  57. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -1
  58. package/dist/ts4.2/src/room/participant/Participant.d.ts +2 -3
  59. package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
  60. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +5 -1
  61. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +1 -1
  62. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +1 -2
  63. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +1 -1
  64. package/dist/ts4.2/src/room/track/Track.d.ts +1 -2
  65. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +2 -3
  66. package/dist/ts4.2/src/room/track/utils.d.ts +1 -1
  67. package/dist/ts4.2/src/room/utils.d.ts +1 -1
  68. package/package.json +2 -2
  69. package/src/api/SignalClient.ts +19 -17
  70. package/src/connectionHelper/checks/websocket.ts +1 -1
  71. package/src/e2ee/E2eeManager.ts +1 -1
  72. package/src/e2ee/worker/FrameCryptor.ts +12 -6
  73. package/src/index.ts +1 -1
  74. package/src/logger.ts +21 -18
  75. package/src/room/PCTransportManager.ts +1 -1
  76. package/src/room/RTCEngine.ts +33 -31
  77. package/src/room/RegionUrlProvider.ts +1 -1
  78. package/src/room/Room.ts +36 -25
  79. package/src/room/participant/LocalParticipant.ts +4 -6
  80. package/src/room/participant/Participant.ts +4 -6
  81. package/src/room/participant/ParticipantTrackPermission.ts +1 -1
  82. package/src/room/participant/RemoteParticipant.ts +14 -2
  83. package/src/room/track/LocalAudioTrack.ts +5 -2
  84. package/src/room/track/LocalTrackPublication.ts +1 -1
  85. package/src/room/track/LocalVideoTrack.ts +11 -3
  86. package/src/room/track/RemoteTrackPublication.ts +7 -2
  87. package/src/room/track/Track.ts +6 -6
  88. package/src/room/track/TrackPublication.ts +7 -3
  89. package/src/room/track/facingMode.ts +2 -2
  90. package/src/room/track/utils.ts +19 -12
  91. package/src/room/utils.ts +4 -1
  92. package/dist/src/proto/livekit_models_pb.d.ts +0 -1405
  93. package/dist/src/proto/livekit_models_pb.d.ts.map +0 -1
  94. package/dist/src/proto/livekit_rtc_pb.d.ts +0 -1423
  95. package/dist/src/proto/livekit_rtc_pb.d.ts.map +0 -1
  96. package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +0 -1405
  97. package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +0 -1423
  98. package/src/proto/livekit_models_pb.ts +0 -2327
  99. package/src/proto/livekit_rtc_pb.ts +0 -2411
package/src/room/Room.ts CHANGED
@@ -1,40 +1,38 @@
1
- import { protoInt64 } from '@bufbuild/protobuf';
2
- import { EventEmitter } from 'events';
3
- import type TypedEmitter from 'typed-emitter';
4
- import 'webrtc-adapter';
5
- import { EncryptionEvent } from '../e2ee';
6
- import { E2EEManager } from '../e2ee/E2eeManager';
7
- import log, { LoggerNames, getLogger } from '../logger';
8
- import type {
9
- InternalRoomConnectOptions,
10
- InternalRoomOptions,
11
- RoomConnectOptions,
12
- RoomOptions,
13
- } from '../options';
14
1
  import {
2
+ ConnectionQualityUpdate,
15
3
  DataPacket_Kind,
16
4
  DisconnectReason,
5
+ JoinResponse,
6
+ LeaveRequest,
17
7
  ParticipantInfo,
18
8
  ParticipantInfo_State,
19
9
  ParticipantPermission,
20
10
  Room as RoomModel,
21
11
  ServerInfo,
12
+ SimulateScenario,
22
13
  SpeakerInfo,
14
+ StreamStateUpdate,
23
15
  SubscriptionError,
16
+ SubscriptionPermissionUpdate,
17
+ SubscriptionResponse,
24
18
  TrackInfo,
25
19
  TrackSource,
26
20
  TrackType,
27
21
  UserPacket,
28
- } from '../proto/livekit_models_pb';
29
- import {
30
- ConnectionQualityUpdate,
31
- JoinResponse,
32
- LeaveRequest,
33
- SimulateScenario,
34
- StreamStateUpdate,
35
- SubscriptionPermissionUpdate,
36
- SubscriptionResponse,
37
- } from '../proto/livekit_rtc_pb';
22
+ protoInt64,
23
+ } from '@livekit/protocol';
24
+ import { EventEmitter } from 'events';
25
+ import type TypedEmitter from 'typed-emitter';
26
+ import 'webrtc-adapter';
27
+ import { EncryptionEvent } from '../e2ee';
28
+ import { E2EEManager } from '../e2ee/E2eeManager';
29
+ import log, { LoggerNames, getLogger } from '../logger';
30
+ import type {
31
+ InternalRoomConnectOptions,
32
+ InternalRoomOptions,
33
+ RoomConnectOptions,
34
+ RoomOptions,
35
+ } from '../options';
38
36
  import { getBrowser } from '../utils/browserParser';
39
37
  import DeviceManager from './DeviceManager';
40
38
  import RTCEngine from './RTCEngine';
@@ -69,7 +67,9 @@ import {
69
67
  Mutex,
70
68
  createDummyVideoStreamTrack,
71
69
  getEmptyAudioStreamTrack,
70
+ isBrowserSupported,
72
71
  isCloud,
72
+ isReactNative,
73
73
  isWeb,
74
74
  supportsSetSinkId,
75
75
  toHttpUrl,
@@ -247,8 +247,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
247
247
  private get logContext() {
248
248
  return {
249
249
  room: this.name,
250
- roomSid: this.roomInfo?.sid,
251
- identity: this.localParticipant.identity,
250
+ roomID: this.roomInfo?.sid,
251
+ participant: this.localParticipant.identity,
252
+ pID: this.localParticipant.sid,
252
253
  };
253
254
  }
254
255
 
@@ -415,6 +416,16 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
415
416
  }
416
417
 
417
418
  connect = async (url: string, token: string, opts?: RoomConnectOptions): Promise<void> => {
419
+ if (!isBrowserSupported()) {
420
+ if (isReactNative()) {
421
+ throw Error("WebRTC isn't detected, have you called registerGlobals?");
422
+ } else {
423
+ throw Error(
424
+ "LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.",
425
+ );
426
+ }
427
+ }
428
+
418
429
  // In case a disconnect called happened right before the connect call, make sure the disconnect is completed first by awaiting its lock
419
430
  const unlockDisconnect = await this.disconnectLock.lock();
420
431
 
@@ -1,18 +1,16 @@
1
- import type { InternalRoomOptions } from '../../options';
2
1
  import {
2
+ AddTrackRequest,
3
3
  DataPacket,
4
4
  DataPacket_Kind,
5
5
  Encryption_Type,
6
6
  ParticipantInfo,
7
7
  ParticipantPermission,
8
- UserPacket,
9
- } from '../../proto/livekit_models_pb';
10
- import {
11
- AddTrackRequest,
12
8
  SimulcastCodec,
13
9
  SubscribedQualityUpdate,
14
10
  TrackUnpublishedResponse,
15
- } from '../../proto/livekit_rtc_pb';
11
+ UserPacket,
12
+ } from '@livekit/protocol';
13
+ import type { InternalRoomOptions } from '../../options';
16
14
  import { PCTransportState } from '../PCTransportManager';
17
15
  import type RTCEngine from '../RTCEngine';
18
16
  import { defaultVideoCodec } from '../defaults';
@@ -1,13 +1,13 @@
1
- import { EventEmitter } from 'events';
2
- import type TypedEmitter from 'typed-emitter';
3
- import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger';
4
1
  import {
5
2
  DataPacket_Kind,
6
3
  ParticipantInfo,
7
4
  ParticipantPermission,
8
5
  ConnectionQuality as ProtoQuality,
9
6
  SubscriptionError,
10
- } from '../../proto/livekit_models_pb';
7
+ } from '@livekit/protocol';
8
+ import { EventEmitter } from 'events';
9
+ import type TypedEmitter from 'typed-emitter';
10
+ import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger';
11
11
  import { ParticipantEvent, TrackEvent } from '../events';
12
12
  import LocalAudioTrack from '../track/LocalAudioTrack';
13
13
  import type LocalTrackPublication from '../track/LocalTrackPublication';
@@ -88,8 +88,6 @@ export default class Participant extends (EventEmitter as new () => TypedEmitter
88
88
  protected get logContext() {
89
89
  return {
90
90
  ...this.loggerOptions?.loggerContextCb?.(),
91
- participantSid: this.sid,
92
- participantId: this.identity,
93
91
  };
94
92
  }
95
93
 
@@ -1,4 +1,4 @@
1
- import { TrackPermission } from '../../proto/livekit_rtc_pb';
1
+ import { TrackPermission } from '@livekit/protocol';
2
2
 
3
3
  export interface ParticipantTrackPermission {
4
4
  /**
@@ -1,6 +1,10 @@
1
+ import type {
2
+ ParticipantInfo,
3
+ SubscriptionError,
4
+ UpdateSubscription,
5
+ UpdateTrackSettings,
6
+ } from '@livekit/protocol';
1
7
  import type { SignalClient } from '../../api/SignalClient';
2
- import type { ParticipantInfo, SubscriptionError } from '../../proto/livekit_models_pb';
3
- import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
4
8
  import { ParticipantEvent, TrackEvent } from '../events';
5
9
  import RemoteAudioTrack from '../track/RemoteAudioTrack';
6
10
  import type RemoteTrack from '../track/RemoteTrack';
@@ -33,6 +37,14 @@ export default class RemoteParticipant extends Participant {
33
37
  return new RemoteParticipant(signalClient, pi.sid, pi.identity, pi.name, pi.metadata);
34
38
  }
35
39
 
40
+ protected get logContext() {
41
+ return {
42
+ ...super.logContext,
43
+ rpID: this.sid,
44
+ remoteParticipant: this.identity,
45
+ };
46
+ }
47
+
36
48
  /** @internal */
37
49
  constructor(
38
50
  signalClient: SignalClient,
@@ -36,7 +36,10 @@ export default class LocalAudioTrack extends LocalTrack<Track.Kind.Audio> {
36
36
  }
37
37
 
38
38
  async setDeviceId(deviceId: ConstrainDOMString): Promise<boolean> {
39
- if (this._constraints.deviceId === deviceId) {
39
+ if (
40
+ this._constraints.deviceId === deviceId &&
41
+ this._mediaStreamTrack.getSettings().deviceId === unwrapConstraint(deviceId)
42
+ ) {
40
43
  return true;
41
44
  }
42
45
  this._constraints.deviceId = deviceId;
@@ -44,7 +47,7 @@ export default class LocalAudioTrack extends LocalTrack<Track.Kind.Audio> {
44
47
  await this.restartTrack();
45
48
  }
46
49
  return (
47
- this.isMuted || unwrapConstraint(deviceId) === this.mediaStreamTrack.getSettings().deviceId
50
+ this.isMuted || unwrapConstraint(deviceId) === this._mediaStreamTrack.getSettings().deviceId
48
51
  );
49
52
  }
50
53
 
@@ -1,4 +1,4 @@
1
- import type { TrackInfo } from '../../proto/livekit_models_pb';
1
+ import type { TrackInfo } from '@livekit/protocol';
2
2
  import { TrackEvent } from '../events';
3
3
  import type { LoggerOptions } from '../types';
4
4
  import type LocalAudioTrack from './LocalAudioTrack';
@@ -1,7 +1,11 @@
1
+ import {
2
+ VideoQuality as ProtoVideoQuality,
3
+ SubscribedCodec,
4
+ SubscribedQuality,
5
+ VideoLayer,
6
+ } from '@livekit/protocol';
1
7
  import type { SignalClient } from '../../api/SignalClient';
2
8
  import type { StructuredLogger } from '../../logger';
3
- import { VideoQuality as ProtoVideoQuality, VideoLayer } from '../../proto/livekit_models_pb';
4
- import { SubscribedCodec, SubscribedQuality } from '../../proto/livekit_rtc_pb';
5
9
  import { ScalabilityMode } from '../participant/publishUtils';
6
10
  import type { VideoSenderStats } from '../stats';
7
11
  import { computeBitrate, monitorFrequency } from '../stats';
@@ -424,7 +428,11 @@ async function setPublishingLayersForSender(
424
428
  }
425
429
 
426
430
  if (encodings.length !== senderEncodings.length) {
427
- log.warn('cannot set publishing layers, encodings mismatch');
431
+ log.warn('cannot set publishing layers, encodings mismatch', {
432
+ ...logContext,
433
+ encodings,
434
+ senderEncodings,
435
+ });
428
436
  return;
429
437
  }
430
438
 
@@ -1,5 +1,10 @@
1
- import { ParticipantTracks, SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
2
- import { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
1
+ import {
2
+ ParticipantTracks,
3
+ SubscriptionError,
4
+ TrackInfo,
5
+ UpdateSubscription,
6
+ UpdateTrackSettings,
7
+ } from '@livekit/protocol';
3
8
  import { TrackEvent } from '../events';
4
9
  import type { LoggerOptions } from '../types';
5
10
  import type RemoteTrack from './RemoteTrack';
@@ -1,13 +1,13 @@
1
- import { EventEmitter } from 'events';
2
- import type TypedEventEmitter from 'typed-emitter';
3
- import type { SignalClient } from '../../api/SignalClient';
4
- import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger';
5
1
  import {
6
2
  VideoQuality as ProtoQuality,
3
+ StreamState as ProtoStreamState,
7
4
  TrackSource,
8
5
  TrackType,
9
- } from '../../proto/livekit_models_pb';
10
- import { StreamState as ProtoStreamState } from '../../proto/livekit_rtc_pb';
6
+ } from '@livekit/protocol';
7
+ import { EventEmitter } from 'events';
8
+ import type TypedEventEmitter from 'typed-emitter';
9
+ import type { SignalClient } from '../../api/SignalClient';
10
+ import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger';
11
11
  import { TrackEvent } from '../events';
12
12
  import type { LoggerOptions } from '../types';
13
13
  import { isFireFox, isSafari, isWeb } from '../utils';
@@ -1,9 +1,13 @@
1
+ import { Encryption_Type } from '@livekit/protocol';
2
+ import type {
3
+ SubscriptionError,
4
+ TrackInfo,
5
+ UpdateSubscription,
6
+ UpdateTrackSettings,
7
+ } from '@livekit/protocol';
1
8
  import { EventEmitter } from 'events';
2
9
  import type TypedEventEmitter from 'typed-emitter';
3
10
  import log, { LoggerNames, getLogger } from '../../logger';
4
- import { Encryption_Type } from '../../proto/livekit_models_pb';
5
- import type { SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
6
- import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
7
11
  import { TrackEvent } from '../events';
8
12
  import type { LoggerOptions } from '../types';
9
13
  import LocalAudioTrack from './LocalAudioTrack';
@@ -47,7 +47,7 @@ export function facingModeFromLocalTrack(
47
47
  // 1. Try to get facingMode from track settings.
48
48
  if ('facingMode' in trackSettings) {
49
49
  const rawFacingMode = trackSettings.facingMode;
50
- log.debug('rawFacingMode', { rawFacingMode });
50
+ log.trace('rawFacingMode', { rawFacingMode });
51
51
  if (rawFacingMode && typeof rawFacingMode === 'string' && isFacingModeValue(rawFacingMode)) {
52
52
  result = { facingMode: rawFacingMode, confidence: 'high' };
53
53
  }
@@ -55,7 +55,7 @@ export function facingModeFromLocalTrack(
55
55
 
56
56
  // 2. If we don't have a high confidence we try to get the facing mode from the device label.
57
57
  if (['low', 'medium'].includes(result.confidence)) {
58
- log.debug(`Try to get facing mode from device label: (${track.label})`);
58
+ log.trace(`Try to get facing mode from device label: (${track.label})`);
59
59
  const labelAnalysisResult = facingModeFromDeviceLabel(track.label);
60
60
  if (labelAnalysisResult !== undefined) {
61
61
  result = labelAnalysisResult;
@@ -1,4 +1,4 @@
1
- import { TrackPublishedResponse } from '../../proto/livekit_rtc_pb';
1
+ import { TrackPublishedResponse } from '@livekit/protocol';
2
2
  import { cloneDeep } from '../../utils/cloneDeep';
3
3
  import { isSafari, sleep } from '../utils';
4
4
  import { Track } from './Track';
@@ -214,20 +214,27 @@ export function getTrackPublicationInfo<T extends TrackPublication>(
214
214
  export function getLogContextFromTrack(track: Track | TrackPublication): Record<string, unknown> {
215
215
  if (track instanceof Track) {
216
216
  return {
217
- trackSid: track.sid,
218
- trackSource: track.source,
219
- trackMuted: track.isMuted,
220
- trackEnabled: track.mediaStreamTrack.enabled,
221
- trackKind: track.kind,
217
+ trackID: track.sid,
218
+ source: track.source,
219
+ muted: track.isMuted,
220
+ enabled: track.mediaStreamTrack.enabled,
221
+ kind: track.kind,
222
+ streamID: track.mediaStreamID,
223
+ streamTrackID: track.mediaStreamTrack.id,
222
224
  };
223
225
  } else {
224
226
  return {
225
- trackSid: track.trackSid,
226
- trackName: track.trackName,
227
- track: track.track ? getLogContextFromTrack(track.track) : undefined,
228
- trackEnabled: track.isEnabled,
229
- trackEncrypted: track.isEncrypted,
230
- trackMimeType: track.mimeType,
227
+ trackID: track.trackSid,
228
+ enabled: track.isEnabled,
229
+ muted: track.isMuted,
230
+ trackInfo: {
231
+ mimeType: track.mimeType,
232
+ name: track.trackName,
233
+ encrypted: track.isEncrypted,
234
+ kind: track.kind,
235
+ source: track.source,
236
+ ...(track.track ? getLogContextFromTrack(track.track) : {}),
237
+ },
231
238
  };
232
239
  }
233
240
  }
package/src/room/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ClientInfo, ClientInfo_SDK } from '../proto/livekit_models_pb';
1
+ import { ClientInfo, ClientInfo_SDK } from '@livekit/protocol';
2
2
  import type { DetectableBrowser } from '../utils/browserParser';
3
3
  import { getBrowser } from '../utils/browserParser';
4
4
  import { protocolVersion, version } from '../version';
@@ -133,6 +133,9 @@ export function supportsSetCodecPreferences(transceiver: RTCRtpTransceiver): boo
133
133
  }
134
134
 
135
135
  export function isBrowserSupported() {
136
+ if (typeof RTCPeerConnection === 'undefined') {
137
+ return false;
138
+ }
136
139
  return supportsTransceiver() || supportsAddTrack();
137
140
  }
138
141