livekit-client 2.0.3 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) 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 +11 -8
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +166 -77
  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 +1 -1
  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/types.d.ts +2 -0
  13. package/dist/src/e2ee/types.d.ts.map +1 -1
  14. package/dist/src/e2ee/worker/FrameCryptor.d.ts +1 -0
  15. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  16. package/dist/src/index.d.ts +2 -2
  17. package/dist/src/index.d.ts.map +1 -1
  18. package/dist/src/logger.d.ts +4 -2
  19. package/dist/src/logger.d.ts.map +1 -1
  20. package/dist/src/room/DeviceManager.d.ts.map +1 -1
  21. package/dist/src/room/RTCEngine.d.ts +4 -2
  22. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  23. package/dist/src/room/Room.d.ts.map +1 -1
  24. package/dist/src/room/events.d.ts +2 -1
  25. package/dist/src/room/events.d.ts.map +1 -1
  26. package/dist/src/room/participant/Participant.d.ts +1 -2
  27. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  28. package/dist/src/room/participant/RemoteParticipant.d.ts +4 -0
  29. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  30. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  31. package/dist/src/room/track/LocalTrack.d.ts +3 -1
  32. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  33. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  34. package/dist/src/room/track/options.d.ts +10 -0
  35. package/dist/src/room/track/options.d.ts.map +1 -1
  36. package/dist/src/room/track/types.d.ts +4 -0
  37. package/dist/src/room/track/types.d.ts.map +1 -1
  38. package/dist/src/room/track/utils.d.ts.map +1 -1
  39. package/dist/src/room/utils.d.ts.map +1 -1
  40. package/dist/ts4.2/src/api/SignalClient.d.ts +1 -1
  41. package/dist/ts4.2/src/e2ee/types.d.ts +2 -0
  42. package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +1 -0
  43. package/dist/ts4.2/src/index.d.ts +2 -2
  44. package/dist/ts4.2/src/logger.d.ts +4 -2
  45. package/dist/ts4.2/src/room/RTCEngine.d.ts +4 -2
  46. package/dist/ts4.2/src/room/events.d.ts +2 -1
  47. package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -2
  48. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +4 -0
  49. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +3 -1
  50. package/dist/ts4.2/src/room/track/options.d.ts +10 -0
  51. package/dist/ts4.2/src/room/track/types.d.ts +4 -0
  52. package/package.json +1 -1
  53. package/src/api/SignalClient.ts +10 -5
  54. package/src/e2ee/E2eeManager.ts +2 -1
  55. package/src/e2ee/types.ts +2 -0
  56. package/src/e2ee/worker/FrameCryptor.ts +12 -6
  57. package/src/e2ee/worker/e2ee.worker.ts +1 -0
  58. package/src/index.ts +2 -1
  59. package/src/logger.ts +23 -18
  60. package/src/room/DeviceManager.ts +10 -1
  61. package/src/room/RTCEngine.ts +26 -8
  62. package/src/room/Room.ts +26 -2
  63. package/src/room/events.ts +1 -0
  64. package/src/room/participant/LocalParticipant.ts +4 -4
  65. package/src/room/participant/Participant.ts +0 -2
  66. package/src/room/participant/RemoteParticipant.ts +8 -0
  67. package/src/room/track/LocalAudioTrack.ts +10 -0
  68. package/src/room/track/LocalTrack.ts +20 -3
  69. package/src/room/track/LocalVideoTrack.ts +15 -1
  70. package/src/room/track/options.ts +41 -8
  71. package/src/room/track/types.ts +5 -0
  72. package/src/room/track/utils.ts +18 -11
  73. package/src/room/utils.ts +3 -0
@@ -257,6 +257,15 @@ export interface VideoEncoding {
257
257
  priority?: RTCPriorityType;
258
258
  }
259
259
 
260
+ export interface VideoPresetOptions {
261
+ width: number;
262
+ height: number;
263
+ aspectRatio?: number;
264
+ maxBitrate: number;
265
+ maxFramerate?: number;
266
+ priority?: RTCPriorityType;
267
+ }
268
+
260
269
  export class VideoPreset {
261
270
  encoding: VideoEncoding;
262
271
 
@@ -264,20 +273,44 @@ export class VideoPreset {
264
273
 
265
274
  height: number;
266
275
 
276
+ aspectRatio?: number;
277
+
278
+ constructor(videoPresetOptions: VideoPresetOptions);
267
279
  constructor(
268
280
  width: number,
269
281
  height: number,
270
282
  maxBitrate: number,
271
283
  maxFramerate?: number,
272
284
  priority?: RTCPriorityType,
285
+ );
286
+ constructor(
287
+ widthOrOptions: number | VideoPresetOptions,
288
+ height?: number,
289
+ maxBitrate?: number,
290
+ maxFramerate?: number,
291
+ priority?: RTCPriorityType,
273
292
  ) {
274
- this.width = width;
275
- this.height = height;
276
- this.encoding = {
277
- maxBitrate,
278
- maxFramerate,
279
- priority,
280
- };
293
+ if (typeof widthOrOptions === 'object') {
294
+ this.width = widthOrOptions.width;
295
+ this.height = widthOrOptions.height;
296
+ this.aspectRatio = widthOrOptions.aspectRatio;
297
+ this.encoding = {
298
+ maxBitrate: widthOrOptions.maxBitrate,
299
+ maxFramerate: widthOrOptions.maxFramerate,
300
+ priority: widthOrOptions.priority,
301
+ };
302
+ } else if (height !== undefined && maxBitrate !== undefined) {
303
+ this.width = widthOrOptions;
304
+ this.height = height;
305
+ this.aspectRatio = widthOrOptions / height;
306
+ this.encoding = {
307
+ maxBitrate,
308
+ maxFramerate,
309
+ priority,
310
+ };
311
+ } else {
312
+ throw new TypeError('Unsupported options: provide at least width, height and maxBitrate');
313
+ }
281
314
  }
282
315
 
283
316
  get resolution(): VideoResolution {
@@ -285,7 +318,7 @@ export class VideoPreset {
285
318
  width: this.width,
286
319
  height: this.height,
287
320
  frameRate: this.encoding.maxFramerate,
288
- aspectRatio: this.width / this.height,
321
+ aspectRatio: this.aspectRatio,
289
322
  };
290
323
  }
291
324
  }
@@ -23,3 +23,8 @@ export type AdaptiveStreamSettings = {
23
23
  */
24
24
  pauseVideoInBackground?: boolean;
25
25
  };
26
+
27
+ export interface ReplaceTrackOptions {
28
+ userProvidedTrack?: boolean;
29
+ stopProcessor?: boolean;
30
+ }
@@ -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
@@ -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