livekit-client 2.5.1 → 2.5.3

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 (48) 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 +4 -2
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +867 -425
  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/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  10. package/dist/src/room/PCTransportManager.d.ts +1 -0
  11. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  12. package/dist/src/room/Room.d.ts +7 -4
  13. package/dist/src/room/Room.d.ts.map +1 -1
  14. package/dist/src/room/events.d.ts +4 -1
  15. package/dist/src/room/events.d.ts.map +1 -1
  16. package/dist/src/room/participant/LocalParticipant.d.ts +11 -1
  17. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  18. package/dist/src/room/participant/Participant.d.ts +2 -1
  19. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  20. package/dist/src/room/track/LocalTrack.d.ts +1 -1
  21. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  22. package/dist/src/room/track/create.d.ts +7 -0
  23. package/dist/src/room/track/create.d.ts.map +1 -1
  24. package/dist/src/room/types.d.ts +6 -0
  25. package/dist/src/room/types.d.ts.map +1 -1
  26. package/dist/src/room/utils.d.ts +3 -2
  27. package/dist/src/room/utils.d.ts.map +1 -1
  28. package/dist/ts4.2/src/room/PCTransportManager.d.ts +1 -0
  29. package/dist/ts4.2/src/room/Room.d.ts +7 -4
  30. package/dist/ts4.2/src/room/events.d.ts +4 -1
  31. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +11 -1
  32. package/dist/ts4.2/src/room/participant/Participant.d.ts +2 -1
  33. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +1 -1
  34. package/dist/ts4.2/src/room/track/create.d.ts +7 -0
  35. package/dist/ts4.2/src/room/types.d.ts +6 -0
  36. package/dist/ts4.2/src/room/utils.d.ts +3 -2
  37. package/package.json +9 -9
  38. package/src/connectionHelper/checks/Checker.ts +1 -1
  39. package/src/e2ee/worker/FrameCryptor.ts +3 -1
  40. package/src/room/PCTransportManager.ts +12 -4
  41. package/src/room/Room.ts +67 -7
  42. package/src/room/events.ts +4 -0
  43. package/src/room/participant/LocalParticipant.ts +146 -52
  44. package/src/room/participant/Participant.ts +2 -1
  45. package/src/room/track/LocalTrack.ts +4 -2
  46. package/src/room/track/create.ts +27 -8
  47. package/src/room/types.ts +7 -0
  48. package/src/room/utils.ts +17 -2
@@ -215,7 +215,7 @@ export default abstract class LocalTrack<
215
215
  /**
216
216
  * @returns DeviceID of the device that is currently being used for this track
217
217
  */
218
- async getDeviceId(): Promise<string | undefined> {
218
+ async getDeviceId(normalize = true): Promise<string | undefined> {
219
219
  // screen share doesn't have a usable device id
220
220
  if (this.source === Track.Source.ScreenShare) {
221
221
  return;
@@ -223,7 +223,9 @@ export default abstract class LocalTrack<
223
223
  const { deviceId, groupId } = this._mediaStreamTrack.getSettings();
224
224
  const kind = this.kind === Track.Kind.Audio ? 'audioinput' : 'videoinput';
225
225
 
226
- return DeviceManager.getInstance().normalizeDeviceId(kind, deviceId, groupId);
226
+ return normalize
227
+ ? DeviceManager.getInstance().normalizeDeviceId(kind, deviceId, groupId)
228
+ : deviceId;
227
229
  }
228
230
 
229
231
  async mute() {
@@ -14,13 +14,32 @@ import type {
14
14
  VideoCaptureOptions,
15
15
  } from './options';
16
16
  import { ScreenSharePresets } from './options';
17
- import type { TrackProcessor } from './processor/types';
17
+ import type {
18
+ AudioProcessorOptions,
19
+ TrackProcessor,
20
+ VideoProcessorOptions,
21
+ } from './processor/types';
18
22
  import {
19
23
  constraintsForOptions,
20
24
  mergeDefaultOptions,
21
25
  screenCaptureToDisplayMediaStreamOptions,
22
26
  } from './utils';
23
27
 
28
+ /** @internal */
29
+ export function extractProcessorsFromOptions(options: CreateLocalTracksOptions) {
30
+ let audioProcessor: TrackProcessor<Track.Kind.Audio, AudioProcessorOptions> | undefined;
31
+ let videoProcessor: TrackProcessor<Track.Kind.Video, VideoProcessorOptions> | undefined;
32
+
33
+ if (typeof options.audio === 'object' && options.audio.processor) {
34
+ audioProcessor = options.audio.processor;
35
+ }
36
+ if (typeof options.video === 'object' && options.video.processor) {
37
+ videoProcessor = options.video.processor;
38
+ }
39
+
40
+ return { audioProcessor, videoProcessor };
41
+ }
42
+
24
43
  /**
25
44
  * Creates a local video and audio track at the same time. When acquiring both
26
45
  * audio and video tracks together, it'll display a single permission prompt to
@@ -35,6 +54,7 @@ export async function createLocalTracks(
35
54
  options.audio ??= true;
36
55
  options.video ??= true;
37
56
 
57
+ const { audioProcessor, videoProcessor } = extractProcessorsFromOptions(options);
38
58
  const opts = mergeDefaultOptions(options, audioDefaults, videoDefaults);
39
59
  const constraints = constraintsForOptions(opts);
40
60
 
@@ -55,7 +75,7 @@ export async function createLocalTracks(
55
75
  return Promise.all(
56
76
  stream.getTracks().map(async (mediaStreamTrack) => {
57
77
  const isAudio = mediaStreamTrack.kind === 'audio';
58
- let trackOptions = isAudio ? options!.audio : options!.video;
78
+ let trackOptions = isAudio ? opts!.audio : opts!.video;
59
79
  if (typeof trackOptions === 'boolean' || !trackOptions) {
60
80
  trackOptions = {};
61
81
  }
@@ -80,13 +100,12 @@ export async function createLocalTracks(
80
100
  track.source = Track.Source.Microphone;
81
101
  }
82
102
  track.mediaStream = stream;
83
- if (trackOptions.processor) {
84
- if (track instanceof LocalAudioTrack) {
85
- await track.setProcessor(trackOptions.processor as TrackProcessor<Track.Kind.Audio>);
86
- } else if (track instanceof LocalVideoTrack) {
87
- await track.setProcessor(trackOptions.processor as TrackProcessor<Track.Kind.Video>);
88
- }
103
+ if (track instanceof LocalAudioTrack && audioProcessor) {
104
+ await track.setProcessor(audioProcessor);
105
+ } else if (track instanceof LocalVideoTrack && videoProcessor) {
106
+ await track.setProcessor(videoProcessor);
89
107
  }
108
+
90
109
  return track;
91
110
  }),
92
111
  );
package/src/room/types.ts CHANGED
@@ -68,3 +68,10 @@ export interface TranscriptionSegment {
68
68
  firstReceivedTime: number;
69
69
  lastReceivedTime: number;
70
70
  }
71
+
72
+ export interface ChatMessage {
73
+ id: string;
74
+ timestamp: number;
75
+ message: string;
76
+ editTimestamp?: number;
77
+ }
package/src/room/utils.ts CHANGED
@@ -1,4 +1,9 @@
1
- import { ClientInfo, ClientInfo_SDK, Transcription as TranscriptionModel } from '@livekit/protocol';
1
+ import {
2
+ ChatMessage as ChatMessageModel,
3
+ ClientInfo,
4
+ ClientInfo_SDK,
5
+ Transcription as TranscriptionModel,
6
+ } from '@livekit/protocol';
2
7
  import { getBrowser } from '../utils/browserParser';
3
8
  import { protocolVersion, version } from '../version';
4
9
  import CriticalTimers from './timers';
@@ -6,7 +11,7 @@ import type LocalAudioTrack from './track/LocalAudioTrack';
6
11
  import type RemoteAudioTrack from './track/RemoteAudioTrack';
7
12
  import { VideoCodec, videoCodecs } from './track/options';
8
13
  import { getNewAudioContext } from './track/utils';
9
- import type { LiveKitReactNativeInfo, TranscriptionSegment } from './types';
14
+ import type { ChatMessage, LiveKitReactNativeInfo, TranscriptionSegment } from './types';
10
15
 
11
16
  const separator = '|';
12
17
  export const ddExtensionURI =
@@ -554,3 +559,13 @@ export function extractTranscriptionSegments(
554
559
  };
555
560
  });
556
561
  }
562
+
563
+ export function extractChatMessage(msg: ChatMessageModel): ChatMessage {
564
+ const { id, timestamp, message, editTimestamp } = msg;
565
+ return {
566
+ id,
567
+ timestamp: Number.parseInt(timestamp.toString()),
568
+ editTimestamp: editTimestamp ? Number.parseInt(editTimestamp.toString()) : undefined,
569
+ message,
570
+ };
571
+ }