@livekit/rtc-node 0.13.21 → 0.13.22

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 (50) hide show
  1. package/dist/async_queue.cjs +80 -0
  2. package/dist/async_queue.cjs.map +1 -0
  3. package/dist/async_queue.d.cts +30 -0
  4. package/dist/async_queue.d.ts +30 -0
  5. package/dist/async_queue.d.ts.map +1 -0
  6. package/dist/async_queue.js +56 -0
  7. package/dist/async_queue.js.map +1 -0
  8. package/dist/audio_mixer.cjs +281 -0
  9. package/dist/audio_mixer.cjs.map +1 -0
  10. package/dist/audio_mixer.d.cts +121 -0
  11. package/dist/audio_mixer.d.ts +121 -0
  12. package/dist/audio_mixer.d.ts.map +1 -0
  13. package/dist/audio_mixer.js +256 -0
  14. package/dist/audio_mixer.js.map +1 -0
  15. package/dist/index.cjs +3 -0
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +2 -0
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +2 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/participant.cjs +4 -4
  23. package/dist/participant.cjs.map +1 -1
  24. package/dist/participant.d.cts +2 -2
  25. package/dist/participant.d.ts +2 -2
  26. package/dist/participant.d.ts.map +1 -1
  27. package/dist/participant.js +4 -4
  28. package/dist/participant.js.map +1 -1
  29. package/dist/room.cjs +276 -278
  30. package/dist/room.cjs.map +1 -1
  31. package/dist/room.d.cts +1 -1
  32. package/dist/room.d.ts +1 -1
  33. package/dist/room.d.ts.map +1 -1
  34. package/dist/room.js +276 -278
  35. package/dist/room.js.map +1 -1
  36. package/dist/version.cjs +1 -1
  37. package/dist/version.cjs.map +1 -1
  38. package/dist/version.d.cts +1 -1
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/dist/version.js.map +1 -1
  42. package/package.json +9 -8
  43. package/src/async_queue.test.ts +250 -0
  44. package/src/async_queue.ts +80 -0
  45. package/src/audio_mixer.test.ts +167 -0
  46. package/src/audio_mixer.ts +407 -0
  47. package/src/index.ts +1 -0
  48. package/src/participant.ts +5 -5
  49. package/src/room.ts +286 -289
  50. package/src/version.ts +1 -1
@@ -0,0 +1,167 @@
1
+ // SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { describe, expect, it } from 'vitest';
5
+ import { AudioFrame } from './audio_frame.js';
6
+ import { AudioMixer } from './audio_mixer.js';
7
+
8
+ // Helper to create a mock audio stream that yields frames
9
+ async function* createMockAudioStream(
10
+ frameCount: number,
11
+ sampleRate: number,
12
+ numChannels: number,
13
+ samplesPerChannel: number,
14
+ value: number,
15
+ ): AsyncGenerator<AudioFrame> {
16
+ for (let i = 0; i < frameCount; i++) {
17
+ const data = new Int16Array(numChannels * samplesPerChannel);
18
+ // Fill with a specific value
19
+ for (let j = 0; j < data.length; j++) {
20
+ data[j] = value;
21
+ }
22
+ yield new AudioFrame(data, sampleRate, numChannels, samplesPerChannel);
23
+ // Small delay to simulate real stream
24
+ await new Promise((resolve) => setTimeout(resolve, 1));
25
+ }
26
+ }
27
+
28
+ describe('AudioMixer', () => {
29
+ it('mixes two audio streams', async () => {
30
+ const sampleRate = 48000;
31
+ const numChannels = 1;
32
+ const samplesPerChannel = 480; // 10ms at 48kHz
33
+ const mixer = new AudioMixer(sampleRate, numChannels, {
34
+ blocksize: samplesPerChannel,
35
+ });
36
+
37
+ // Create two streams with different values
38
+ const stream1 = createMockAudioStream(3, sampleRate, numChannels, samplesPerChannel, 100);
39
+ const stream2 = createMockAudioStream(3, sampleRate, numChannels, samplesPerChannel, 200);
40
+
41
+ mixer.addStream(stream1);
42
+ mixer.addStream(stream2);
43
+
44
+ // Collect first frame
45
+ const frames: AudioFrame[] = [];
46
+ for await (const frame of mixer) {
47
+ frames.push(frame);
48
+ if (frames.length >= 1) {
49
+ break;
50
+ }
51
+ }
52
+
53
+ await mixer.aclose();
54
+
55
+ expect(frames.length).toBe(1);
56
+ const frame = frames[0]!;
57
+ expect(frame.sampleRate).toBe(sampleRate);
58
+ expect(frame.channels).toBe(numChannels);
59
+ expect(frame.samplesPerChannel).toBe(samplesPerChannel);
60
+
61
+ // Each sample should be 100 + 200 = 300
62
+ for (let i = 0; i < frame.data.length; i++) {
63
+ expect(frame.data[i]).toBe(300);
64
+ }
65
+ });
66
+
67
+ it('handles stream removal', async () => {
68
+ const sampleRate = 48000;
69
+ const numChannels = 1;
70
+ const samplesPerChannel = 480;
71
+ const mixer = new AudioMixer(sampleRate, numChannels, {
72
+ blocksize: samplesPerChannel,
73
+ });
74
+
75
+ const stream1 = createMockAudioStream(10, sampleRate, numChannels, samplesPerChannel, 100);
76
+ const stream2 = createMockAudioStream(10, sampleRate, numChannels, samplesPerChannel, 200);
77
+
78
+ mixer.addStream(stream1);
79
+ mixer.addStream(stream2);
80
+
81
+ // Get one frame
82
+ const iterator = mixer[Symbol.asyncIterator]();
83
+ const result1 = await iterator.next();
84
+ expect(result1.done).toBe(false);
85
+ expect(result1.value?.data[0]).toBe(300);
86
+
87
+ // Remove one stream
88
+ mixer.removeStream(stream2);
89
+
90
+ // Next frame should only have stream1's value
91
+ const result2 = await iterator.next();
92
+ expect(result2.done).toBe(false);
93
+ // Note: there might be buffered data, so this test is simplified
94
+
95
+ await mixer.aclose();
96
+ });
97
+
98
+ it('handles empty mixer', async () => {
99
+ const sampleRate = 48000;
100
+ const numChannels = 1;
101
+ const mixer = new AudioMixer(sampleRate, numChannels);
102
+
103
+ // Signal end without adding any streams
104
+ mixer.endInput();
105
+
106
+ const frames: AudioFrame[] = [];
107
+ for await (const frame of mixer) {
108
+ frames.push(frame);
109
+ }
110
+
111
+ expect(frames.length).toBe(0);
112
+ });
113
+
114
+ it('clips audio values to int16 range', async () => {
115
+ const sampleRate = 48000;
116
+ const numChannels = 1;
117
+ const samplesPerChannel = 480;
118
+ const mixer = new AudioMixer(sampleRate, numChannels, {
119
+ blocksize: samplesPerChannel,
120
+ });
121
+
122
+ // Create streams with values that will overflow
123
+ const stream1 = createMockAudioStream(2, sampleRate, numChannels, samplesPerChannel, 20000);
124
+ const stream2 = createMockAudioStream(2, sampleRate, numChannels, samplesPerChannel, 20000);
125
+
126
+ mixer.addStream(stream1);
127
+ mixer.addStream(stream2);
128
+
129
+ const iterator = mixer[Symbol.asyncIterator]();
130
+ const result = await iterator.next();
131
+
132
+ await mixer.aclose();
133
+
134
+ expect(result.done).toBe(false);
135
+ // 20000 + 20000 = 40000, which should be clipped to 32767
136
+ for (let i = 0; i < result.value!.data.length; i++) {
137
+ expect(result.value!.data[i]).toBe(32767);
138
+ }
139
+ });
140
+
141
+ it('handles exhausted streams', async () => {
142
+ const sampleRate = 48000;
143
+ const numChannels = 1;
144
+ const samplesPerChannel = 480;
145
+ const mixer = new AudioMixer(sampleRate, numChannels, {
146
+ blocksize: samplesPerChannel,
147
+ });
148
+
149
+ // Short stream
150
+ const stream = createMockAudioStream(2, sampleRate, numChannels, samplesPerChannel, 100);
151
+
152
+ mixer.addStream(stream);
153
+
154
+ const frames: AudioFrame[] = [];
155
+ for await (const frame of mixer) {
156
+ frames.push(frame);
157
+ if (frames.length >= 3) {
158
+ break;
159
+ }
160
+ }
161
+
162
+ await mixer.aclose();
163
+
164
+ // Should get at least 2 frames (stream exhausts after 2)
165
+ expect(frames.length).toBeGreaterThanOrEqual(2);
166
+ });
167
+ });
@@ -0,0 +1,407 @@
1
+ // SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { AsyncQueue } from './async_queue.js';
5
+ import { AudioFrame } from './audio_frame.js';
6
+
7
+ // Re-export AsyncQueue for backward compatibility
8
+ export { AsyncQueue } from './async_queue.js';
9
+
10
+ // Define types for async iteration (since lib: es2015 doesn't include them)
11
+ type AudioStream = {
12
+ [Symbol.asyncIterator](): {
13
+ next(): Promise<IteratorResult<AudioFrame>>;
14
+ };
15
+ };
16
+
17
+ interface Contribution {
18
+ stream: AudioStream;
19
+ data: Int16Array;
20
+ buffer: Int16Array;
21
+ hadData: boolean;
22
+ exhausted: boolean;
23
+ }
24
+
25
+ export interface AudioMixerOptions {
26
+ /**
27
+ * The size of the audio block (in samples) for mixing.
28
+ * If not provided, defaults to sampleRate / 10 (100ms).
29
+ */
30
+ blocksize?: number;
31
+
32
+ /**
33
+ * The maximum wait time in milliseconds for each stream to provide
34
+ * audio data before timing out. Defaults to 100 ms.
35
+ */
36
+ streamTimeoutMs?: number;
37
+
38
+ /**
39
+ * The maximum number of mixed frames to store in the output queue.
40
+ * Defaults to 100.
41
+ */
42
+ capacity?: number;
43
+ }
44
+
45
+ /**
46
+ * AudioMixer combines multiple async audio streams into a single output stream.
47
+ *
48
+ * The mixer accepts multiple async audio streams and mixes them into a single output stream.
49
+ * Each output frame is generated with a fixed chunk size determined by the blocksize (in samples).
50
+ * If blocksize is not provided (or 0), it defaults to 100ms.
51
+ *
52
+ * Each input stream is processed in parallel, accumulating audio data until at least one chunk
53
+ * of samples is available. If an input stream does not provide data within the specified timeout,
54
+ * a warning is logged. The mixer can be closed immediately
55
+ * (dropping unconsumed frames) or allowed to flush remaining data using endInput().
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const mixer = new AudioMixer(48000, 2);
60
+ * mixer.addStream(stream1);
61
+ * mixer.addStream(stream2);
62
+ *
63
+ * for await (const frame of mixer) {
64
+ * // Process mixed audio frame
65
+ * }
66
+ * ```
67
+ */
68
+ export class AudioMixer {
69
+ private streams: Set<AudioStream>;
70
+ private buffers: Map<AudioStream, Int16Array>;
71
+ private streamIterators: Map<AudioStream, { next(): Promise<IteratorResult<AudioFrame>> }>;
72
+ private sampleRate: number;
73
+ private numChannels: number;
74
+ private chunkSize: number;
75
+ private streamTimeoutMs: number;
76
+ private queue: AsyncQueue<AudioFrame>;
77
+ private streamSignal: AsyncQueue<void>; // Signals when streams are added
78
+ private ending: boolean;
79
+ private mixerTask?: Promise<void>;
80
+ private closed: boolean;
81
+
82
+ /**
83
+ * Initialize the AudioMixer.
84
+ *
85
+ * @param sampleRate - The audio sample rate in Hz.
86
+ * @param numChannels - The number of audio channels.
87
+ * @param options - Optional configuration for the mixer.
88
+ */
89
+ constructor(sampleRate: number, numChannels: number, options: AudioMixerOptions = {}) {
90
+ this.streams = new Set();
91
+ this.buffers = new Map();
92
+ this.streamIterators = new Map();
93
+ this.sampleRate = sampleRate;
94
+ this.numChannels = numChannels;
95
+ this.chunkSize =
96
+ options.blocksize && options.blocksize > 0 ? options.blocksize : Math.floor(sampleRate / 10);
97
+ this.streamTimeoutMs = options.streamTimeoutMs ?? 100;
98
+ this.queue = new AsyncQueue<AudioFrame>(options.capacity ?? 100);
99
+ this.streamSignal = new AsyncQueue<void>(1); // there should only be one mixer
100
+ this.ending = false;
101
+ this.closed = false;
102
+
103
+ // Start the mixer task
104
+ this.mixerTask = this.mixer();
105
+ }
106
+
107
+ /**
108
+ * Add an audio stream to the mixer.
109
+ *
110
+ * The stream is added to the internal set of streams and an empty buffer is initialized for it,
111
+ * if not already present.
112
+ *
113
+ * @param stream - An async iterable that produces AudioFrame objects.
114
+ * @throws Error if the mixer has been closed.
115
+ */
116
+ addStream(stream: AudioStream): void {
117
+ if (this.ending) {
118
+ throw new Error('Cannot add stream after mixer has been closed');
119
+ }
120
+
121
+ this.streams.add(stream);
122
+ if (!this.buffers.has(stream)) {
123
+ this.buffers.set(stream, new Int16Array(0));
124
+ }
125
+
126
+ // Signal that a stream was added (non-blocking)
127
+ this.streamSignal.put(undefined).catch(() => {
128
+ // Ignore errors if signal queue is closed
129
+ });
130
+ }
131
+
132
+ /**
133
+ * Remove an audio stream from the mixer.
134
+ *
135
+ * This method removes the specified stream and its associated buffer from the mixer.
136
+ *
137
+ * @param stream - The audio stream to remove.
138
+ */
139
+ removeStream(stream: AudioStream): void {
140
+ this.streams.delete(stream);
141
+ this.buffers.delete(stream);
142
+ this.streamIterators.delete(stream);
143
+ }
144
+
145
+ /**
146
+ * Returns an async iterator for the mixed audio frames.
147
+ */
148
+ [Symbol.asyncIterator]() {
149
+ return {
150
+ next: async (): Promise<IteratorResult<AudioFrame>> => {
151
+ const frame = await this.getNextFrame();
152
+ if (frame === null) {
153
+ return { done: true, value: undefined };
154
+ }
155
+ return { done: false, value: frame };
156
+ },
157
+ };
158
+ }
159
+
160
+ /**
161
+ * Immediately stop mixing and close the mixer.
162
+ *
163
+ * This stops the mixing task, and any unconsumed output in the queue may be dropped.
164
+ */
165
+ async aclose(): Promise<void> {
166
+ if (this.closed) {
167
+ return;
168
+ }
169
+ this.closed = true;
170
+ this.ending = true;
171
+
172
+ // Close both queues to wake up any waiting operations
173
+ this.streamSignal.close();
174
+ this.queue.close();
175
+
176
+ await this.mixerTask;
177
+ }
178
+
179
+ /**
180
+ * Signal that no more streams will be added.
181
+ *
182
+ * This method marks the mixer as closed so that it flushes any remaining buffered output before ending.
183
+ * Note that existing streams will still be processed until exhausted.
184
+ */
185
+ endInput(): void {
186
+ this.ending = true;
187
+ }
188
+
189
+ private async getNextFrame(): Promise<AudioFrame | null> {
190
+ while (true) {
191
+ // Try to get an item from the queue (non-blocking)
192
+ const frame = this.queue.get();
193
+
194
+ if (frame !== undefined) {
195
+ return frame;
196
+ }
197
+
198
+ // Check if mixer is closed or ending
199
+ if (this.queue.closed || (this.ending && this.streams.size === 0)) {
200
+ return null;
201
+ }
202
+
203
+ // Queue is empty but mixer is still running - wait for an item to be added
204
+ await this.queue.waitForItem();
205
+ }
206
+ }
207
+
208
+ private async mixer(): Promise<void> {
209
+ // Main mixing loop that continuously processes streams and produces output frames
210
+ while (true) {
211
+ // If we're in ending mode and there are no more streams, exit
212
+ if (this.ending && this.streams.size === 0) {
213
+ break;
214
+ }
215
+
216
+ if (this.streams.size === 0) {
217
+ // Wait for a stream to be added (signal queue will have an item)
218
+ await this.streamSignal.waitForItem();
219
+ // Consume the signal
220
+ this.streamSignal.get();
221
+ continue;
222
+ }
223
+
224
+ // Process all streams in parallel
225
+ const streamArray = Array.from(this.streams);
226
+ const promises = streamArray.map((stream) => this.getContribution(stream));
227
+ const results = await Promise.all(
228
+ promises.map((p) =>
229
+ p
230
+ .then((value) => ({ status: 'fulfilled' as const, value }))
231
+ .catch((reason) => ({ status: 'rejected' as const, reason })),
232
+ ),
233
+ );
234
+
235
+ const contributions: Int16Array[] = [];
236
+ let anyData = false;
237
+ const removals: AudioStream[] = [];
238
+
239
+ for (const result of results) {
240
+ if (result.status !== 'fulfilled') {
241
+ console.warn('AudioMixer: Stream contribution failed:', result.reason);
242
+ continue;
243
+ }
244
+
245
+ const contrib = result.value;
246
+ contributions.push(contrib.data);
247
+ this.buffers.set(contrib.stream, contrib.buffer);
248
+
249
+ if (contrib.hadData) {
250
+ anyData = true;
251
+ }
252
+
253
+ // Mark exhausted streams with no remaining buffer for removal
254
+ if (contrib.exhausted && contrib.buffer.length === 0) {
255
+ removals.push(contrib.stream);
256
+ }
257
+ }
258
+
259
+ // Remove exhausted streams
260
+ for (const stream of removals) {
261
+ this.removeStream(stream);
262
+ }
263
+
264
+ if (!anyData) {
265
+ // No data available from any stream, wait briefly before trying again
266
+ await this.sleep(1);
267
+ continue;
268
+ }
269
+
270
+ // Mix the audio data
271
+ const mixed = this.mixAudio(contributions);
272
+ const frame = new AudioFrame(mixed, this.sampleRate, this.numChannels, this.chunkSize);
273
+
274
+ if (this.closed) {
275
+ break;
276
+ }
277
+
278
+ try {
279
+ // Add mixed frame to output queue
280
+ await this.queue.put(frame);
281
+ } catch {
282
+ // Queue closed while trying to add frame
283
+ break;
284
+ }
285
+ }
286
+
287
+ // Close the queue to signal end of stream
288
+ this.queue.close();
289
+ }
290
+
291
+ private async getContribution(stream: AudioStream): Promise<Contribution> {
292
+ let buf = this.buffers.get(stream) ?? new Int16Array(0);
293
+ const initialBufferLength = buf.length;
294
+ let exhausted = false;
295
+ let receivedDataInThisCall = false;
296
+
297
+ // Get or create iterator for this stream
298
+ let iterator = this.streamIterators.get(stream);
299
+ if (!iterator) {
300
+ iterator = stream[Symbol.asyncIterator]();
301
+ this.streamIterators.set(stream, iterator);
302
+ }
303
+
304
+ // Accumulate data until we have at least chunkSize samples
305
+ while (buf.length < this.chunkSize * this.numChannels && !exhausted && !this.closed) {
306
+ try {
307
+ const result = await Promise.race([iterator.next(), this.timeout(this.streamTimeoutMs)]);
308
+
309
+ if (result === 'timeout') {
310
+ console.warn(`AudioMixer: stream timeout after ${this.streamTimeoutMs}ms`);
311
+ break;
312
+ }
313
+
314
+ if (result.done) {
315
+ exhausted = true;
316
+ break;
317
+ }
318
+
319
+ const frame = result.value;
320
+ const newData = frame.data;
321
+
322
+ // Mark that we received data in this call
323
+ receivedDataInThisCall = true;
324
+
325
+ // Concatenate buffers
326
+ if (buf.length === 0) {
327
+ buf = newData;
328
+ } else {
329
+ const combined = new Int16Array(buf.length + newData.length);
330
+ combined.set(buf);
331
+ combined.set(newData, buf.length);
332
+ buf = combined;
333
+ }
334
+ } catch (error) {
335
+ console.error(`AudioMixer: Error reading from stream:`, error);
336
+ exhausted = true;
337
+ break;
338
+ }
339
+ }
340
+
341
+ // Extract contribution and update buffer
342
+ let contrib: Int16Array;
343
+ const samplesNeeded = this.chunkSize * this.numChannels;
344
+
345
+ if (buf.length >= samplesNeeded) {
346
+ // Extract the needed samples and keep the remainder in the buffer
347
+ contrib = buf.subarray(0, samplesNeeded);
348
+ buf = buf.subarray(samplesNeeded);
349
+ } else {
350
+ // Pad with zeros if we don't have enough data
351
+ const padded = new Int16Array(samplesNeeded);
352
+ padded.set(buf);
353
+ contrib = padded;
354
+ buf = new Int16Array(0);
355
+ }
356
+
357
+ // hadData means: we had data at start OR we received data during this call OR we have data remaining
358
+ const hadData = initialBufferLength > 0 || receivedDataInThisCall || buf.length > 0;
359
+
360
+ return {
361
+ stream,
362
+ data: contrib,
363
+ buffer: buf,
364
+ hadData,
365
+ exhausted,
366
+ };
367
+ }
368
+
369
+ private mixAudio(contributions: Int16Array[]): Int16Array {
370
+ if (contributions.length === 0) {
371
+ return new Int16Array(this.chunkSize * this.numChannels);
372
+ }
373
+
374
+ const length = this.chunkSize * this.numChannels;
375
+ const mixed = new Int16Array(length);
376
+
377
+ // Sum all contributions
378
+ for (const contrib of contributions) {
379
+ for (let i = 0; i < length; i++) {
380
+ const val = contrib[i];
381
+ if (val !== undefined) {
382
+ mixed[i] = (mixed[i] ?? 0) + val;
383
+ }
384
+ }
385
+ }
386
+
387
+ // Clip to Int16 range
388
+ for (let i = 0; i < length; i++) {
389
+ const val = mixed[i] ?? 0;
390
+ if (val > 32767) {
391
+ mixed[i] = 32767;
392
+ } else if (val < -32768) {
393
+ mixed[i] = -32768;
394
+ }
395
+ }
396
+
397
+ return mixed;
398
+ }
399
+
400
+ private sleep(ms: number): Promise<void> {
401
+ return new Promise((resolve) => setTimeout(resolve, ms));
402
+ }
403
+
404
+ private timeout(ms: number): Promise<'timeout'> {
405
+ return new Promise((resolve) => setTimeout(() => resolve('timeout'), ms));
406
+ }
407
+ }
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export { AudioSource } from './audio_source.js';
8
8
  export { AudioStream } from './audio_stream.js';
9
9
  export type { NoiseCancellationOptions } from './audio_stream.js';
10
10
  export { AudioFilter } from './audio_filter.js';
11
+ export { AudioMixer, type AudioMixerOptions } from './audio_mixer.js';
11
12
  export * from './data_streams/index.js';
12
13
  export { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';
13
14
  export type { E2EEOptions, KeyProviderOptions } from './e2ee.js';
@@ -155,13 +155,13 @@ export type DataPublishOptions = {
155
155
  export class LocalParticipant extends Participant {
156
156
  private rpcHandlers: Map<string, (data: RpcInvocationData) => Promise<string>> = new Map();
157
157
 
158
- private roomEventLock: Mutex;
158
+ private ffiEventLock: Mutex;
159
159
 
160
160
  trackPublications: Map<string, LocalTrackPublication> = new Map();
161
161
 
162
- constructor(info: OwnedParticipant, roomEventLock: Mutex) {
162
+ constructor(info: OwnedParticipant, ffiEventLock: Mutex) {
163
163
  super(info);
164
- this.roomEventLock = roomEventLock;
164
+ this.ffiEventLock = ffiEventLock;
165
165
  }
166
166
 
167
167
  async publishData(data: Uint8Array, options: DataPublishOptions) {
@@ -662,7 +662,7 @@ export class LocalParticipant extends Participant {
662
662
  options: options,
663
663
  });
664
664
 
665
- const unlock = await this.roomEventLock.lock();
665
+ const unlock = await this.ffiEventLock.lock();
666
666
 
667
667
  const res = FfiClient.instance.request<PublishTrackResponse>({
668
668
  message: { case: 'publishTrack', value: req },
@@ -690,7 +690,7 @@ export class LocalParticipant extends Participant {
690
690
  }
691
691
 
692
692
  async unpublishTrack(trackSid: string, stopOnUnpublish?: boolean) {
693
- const unlock = await this.roomEventLock.lock();
693
+ const unlock = await this.ffiEventLock.lock();
694
694
  try {
695
695
  const req = new UnpublishTrackRequest({
696
696
  localParticipantHandle: this.ffi_handle.handle,