@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.
- package/dist/async_queue.cjs +80 -0
- package/dist/async_queue.cjs.map +1 -0
- package/dist/async_queue.d.cts +30 -0
- package/dist/async_queue.d.ts +30 -0
- package/dist/async_queue.d.ts.map +1 -0
- package/dist/async_queue.js +56 -0
- package/dist/async_queue.js.map +1 -0
- package/dist/audio_mixer.cjs +281 -0
- package/dist/audio_mixer.cjs.map +1 -0
- package/dist/audio_mixer.d.cts +121 -0
- package/dist/audio_mixer.d.ts +121 -0
- package/dist/audio_mixer.d.ts.map +1 -0
- package/dist/audio_mixer.js +256 -0
- package/dist/audio_mixer.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/participant.cjs +4 -4
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +2 -2
- package/dist/participant.d.ts +2 -2
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +4 -4
- package/dist/participant.js.map +1 -1
- package/dist/room.cjs +276 -278
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +1 -1
- package/dist/room.d.ts +1 -1
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +276 -278
- package/dist/room.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +9 -8
- package/src/async_queue.test.ts +250 -0
- package/src/async_queue.ts +80 -0
- package/src/audio_mixer.test.ts +167 -0
- package/src/audio_mixer.ts +407 -0
- package/src/index.ts +1 -0
- package/src/participant.ts +5 -5
- package/src/room.ts +286 -289
- package/src/version.ts +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { AudioFrame } from './audio_frame.js';
|
|
2
|
+
export { AsyncQueue } from './async_queue.js';
|
|
3
|
+
import './proto/audio_frame_pb.js';
|
|
4
|
+
import '@bufbuild/protobuf';
|
|
5
|
+
import './proto/track_pb.js';
|
|
6
|
+
import './proto/stats_pb.js';
|
|
7
|
+
import './proto/e2ee_pb.js';
|
|
8
|
+
import './proto/handle_pb.js';
|
|
9
|
+
|
|
10
|
+
type AudioStream = {
|
|
11
|
+
[Symbol.asyncIterator](): {
|
|
12
|
+
next(): Promise<IteratorResult<AudioFrame>>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
interface AudioMixerOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The size of the audio block (in samples) for mixing.
|
|
18
|
+
* If not provided, defaults to sampleRate / 10 (100ms).
|
|
19
|
+
*/
|
|
20
|
+
blocksize?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The maximum wait time in milliseconds for each stream to provide
|
|
23
|
+
* audio data before timing out. Defaults to 100 ms.
|
|
24
|
+
*/
|
|
25
|
+
streamTimeoutMs?: number;
|
|
26
|
+
/**
|
|
27
|
+
* The maximum number of mixed frames to store in the output queue.
|
|
28
|
+
* Defaults to 100.
|
|
29
|
+
*/
|
|
30
|
+
capacity?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* AudioMixer combines multiple async audio streams into a single output stream.
|
|
34
|
+
*
|
|
35
|
+
* The mixer accepts multiple async audio streams and mixes them into a single output stream.
|
|
36
|
+
* Each output frame is generated with a fixed chunk size determined by the blocksize (in samples).
|
|
37
|
+
* If blocksize is not provided (or 0), it defaults to 100ms.
|
|
38
|
+
*
|
|
39
|
+
* Each input stream is processed in parallel, accumulating audio data until at least one chunk
|
|
40
|
+
* of samples is available. If an input stream does not provide data within the specified timeout,
|
|
41
|
+
* a warning is logged. The mixer can be closed immediately
|
|
42
|
+
* (dropping unconsumed frames) or allowed to flush remaining data using endInput().
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const mixer = new AudioMixer(48000, 2);
|
|
47
|
+
* mixer.addStream(stream1);
|
|
48
|
+
* mixer.addStream(stream2);
|
|
49
|
+
*
|
|
50
|
+
* for await (const frame of mixer) {
|
|
51
|
+
* // Process mixed audio frame
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare class AudioMixer {
|
|
56
|
+
private streams;
|
|
57
|
+
private buffers;
|
|
58
|
+
private streamIterators;
|
|
59
|
+
private sampleRate;
|
|
60
|
+
private numChannels;
|
|
61
|
+
private chunkSize;
|
|
62
|
+
private streamTimeoutMs;
|
|
63
|
+
private queue;
|
|
64
|
+
private streamSignal;
|
|
65
|
+
private ending;
|
|
66
|
+
private mixerTask?;
|
|
67
|
+
private closed;
|
|
68
|
+
/**
|
|
69
|
+
* Initialize the AudioMixer.
|
|
70
|
+
*
|
|
71
|
+
* @param sampleRate - The audio sample rate in Hz.
|
|
72
|
+
* @param numChannels - The number of audio channels.
|
|
73
|
+
* @param options - Optional configuration for the mixer.
|
|
74
|
+
*/
|
|
75
|
+
constructor(sampleRate: number, numChannels: number, options?: AudioMixerOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Add an audio stream to the mixer.
|
|
78
|
+
*
|
|
79
|
+
* The stream is added to the internal set of streams and an empty buffer is initialized for it,
|
|
80
|
+
* if not already present.
|
|
81
|
+
*
|
|
82
|
+
* @param stream - An async iterable that produces AudioFrame objects.
|
|
83
|
+
* @throws Error if the mixer has been closed.
|
|
84
|
+
*/
|
|
85
|
+
addStream(stream: AudioStream): void;
|
|
86
|
+
/**
|
|
87
|
+
* Remove an audio stream from the mixer.
|
|
88
|
+
*
|
|
89
|
+
* This method removes the specified stream and its associated buffer from the mixer.
|
|
90
|
+
*
|
|
91
|
+
* @param stream - The audio stream to remove.
|
|
92
|
+
*/
|
|
93
|
+
removeStream(stream: AudioStream): void;
|
|
94
|
+
/**
|
|
95
|
+
* Returns an async iterator for the mixed audio frames.
|
|
96
|
+
*/
|
|
97
|
+
[Symbol.asyncIterator](): {
|
|
98
|
+
next: () => Promise<IteratorResult<AudioFrame>>;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Immediately stop mixing and close the mixer.
|
|
102
|
+
*
|
|
103
|
+
* This stops the mixing task, and any unconsumed output in the queue may be dropped.
|
|
104
|
+
*/
|
|
105
|
+
aclose(): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Signal that no more streams will be added.
|
|
108
|
+
*
|
|
109
|
+
* This method marks the mixer as closed so that it flushes any remaining buffered output before ending.
|
|
110
|
+
* Note that existing streams will still be processed until exhausted.
|
|
111
|
+
*/
|
|
112
|
+
endInput(): void;
|
|
113
|
+
private getNextFrame;
|
|
114
|
+
private mixer;
|
|
115
|
+
private getContribution;
|
|
116
|
+
private mixAudio;
|
|
117
|
+
private sleep;
|
|
118
|
+
private timeout;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { AudioMixer, type AudioMixerOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio_mixer.d.ts","sourceRoot":"","sources":["../src/audio_mixer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,KAAK,WAAW,GAAG;IACjB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI;QACxB,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;KAC7C,CAAC;CACH,CAAC;AAUF,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,eAAe,CAAoE;IAC3F,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,KAAK,CAAyB;IACtC,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,SAAS,CAAC,CAAgB;IAClC,OAAO,CAAC,MAAM,CAAU;IAExB;;;;;;OAMG;gBACS,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB;IAkBpF;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAgBpC;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAMvC;;OAEG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC;oBAEF,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;;IAUvD;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAc7B;;;;;OAKG;IACH,QAAQ,IAAI,IAAI;YAIF,YAAY;YAmBZ,KAAK;YAmFL,eAAe;IA8E7B,OAAO,CAAC,QAAQ;IA+BhB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,OAAO;CAGhB"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { AsyncQueue } from "./async_queue.js";
|
|
2
|
+
import { AudioFrame } from "./audio_frame.js";
|
|
3
|
+
import { AsyncQueue as AsyncQueue2 } from "./async_queue.js";
|
|
4
|
+
class AudioMixer {
|
|
5
|
+
/**
|
|
6
|
+
* Initialize the AudioMixer.
|
|
7
|
+
*
|
|
8
|
+
* @param sampleRate - The audio sample rate in Hz.
|
|
9
|
+
* @param numChannels - The number of audio channels.
|
|
10
|
+
* @param options - Optional configuration for the mixer.
|
|
11
|
+
*/
|
|
12
|
+
constructor(sampleRate, numChannels, options = {}) {
|
|
13
|
+
this.streams = /* @__PURE__ */ new Set();
|
|
14
|
+
this.buffers = /* @__PURE__ */ new Map();
|
|
15
|
+
this.streamIterators = /* @__PURE__ */ new Map();
|
|
16
|
+
this.sampleRate = sampleRate;
|
|
17
|
+
this.numChannels = numChannels;
|
|
18
|
+
this.chunkSize = options.blocksize && options.blocksize > 0 ? options.blocksize : Math.floor(sampleRate / 10);
|
|
19
|
+
this.streamTimeoutMs = options.streamTimeoutMs ?? 100;
|
|
20
|
+
this.queue = new AsyncQueue(options.capacity ?? 100);
|
|
21
|
+
this.streamSignal = new AsyncQueue(1);
|
|
22
|
+
this.ending = false;
|
|
23
|
+
this.closed = false;
|
|
24
|
+
this.mixerTask = this.mixer();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Add an audio stream to the mixer.
|
|
28
|
+
*
|
|
29
|
+
* The stream is added to the internal set of streams and an empty buffer is initialized for it,
|
|
30
|
+
* if not already present.
|
|
31
|
+
*
|
|
32
|
+
* @param stream - An async iterable that produces AudioFrame objects.
|
|
33
|
+
* @throws Error if the mixer has been closed.
|
|
34
|
+
*/
|
|
35
|
+
addStream(stream) {
|
|
36
|
+
if (this.ending) {
|
|
37
|
+
throw new Error("Cannot add stream after mixer has been closed");
|
|
38
|
+
}
|
|
39
|
+
this.streams.add(stream);
|
|
40
|
+
if (!this.buffers.has(stream)) {
|
|
41
|
+
this.buffers.set(stream, new Int16Array(0));
|
|
42
|
+
}
|
|
43
|
+
this.streamSignal.put(void 0).catch(() => {
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Remove an audio stream from the mixer.
|
|
48
|
+
*
|
|
49
|
+
* This method removes the specified stream and its associated buffer from the mixer.
|
|
50
|
+
*
|
|
51
|
+
* @param stream - The audio stream to remove.
|
|
52
|
+
*/
|
|
53
|
+
removeStream(stream) {
|
|
54
|
+
this.streams.delete(stream);
|
|
55
|
+
this.buffers.delete(stream);
|
|
56
|
+
this.streamIterators.delete(stream);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns an async iterator for the mixed audio frames.
|
|
60
|
+
*/
|
|
61
|
+
[Symbol.asyncIterator]() {
|
|
62
|
+
return {
|
|
63
|
+
next: async () => {
|
|
64
|
+
const frame = await this.getNextFrame();
|
|
65
|
+
if (frame === null) {
|
|
66
|
+
return { done: true, value: void 0 };
|
|
67
|
+
}
|
|
68
|
+
return { done: false, value: frame };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Immediately stop mixing and close the mixer.
|
|
74
|
+
*
|
|
75
|
+
* This stops the mixing task, and any unconsumed output in the queue may be dropped.
|
|
76
|
+
*/
|
|
77
|
+
async aclose() {
|
|
78
|
+
if (this.closed) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.closed = true;
|
|
82
|
+
this.ending = true;
|
|
83
|
+
this.streamSignal.close();
|
|
84
|
+
this.queue.close();
|
|
85
|
+
await this.mixerTask;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Signal that no more streams will be added.
|
|
89
|
+
*
|
|
90
|
+
* This method marks the mixer as closed so that it flushes any remaining buffered output before ending.
|
|
91
|
+
* Note that existing streams will still be processed until exhausted.
|
|
92
|
+
*/
|
|
93
|
+
endInput() {
|
|
94
|
+
this.ending = true;
|
|
95
|
+
}
|
|
96
|
+
async getNextFrame() {
|
|
97
|
+
while (true) {
|
|
98
|
+
const frame = this.queue.get();
|
|
99
|
+
if (frame !== void 0) {
|
|
100
|
+
return frame;
|
|
101
|
+
}
|
|
102
|
+
if (this.queue.closed || this.ending && this.streams.size === 0) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
await this.queue.waitForItem();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async mixer() {
|
|
109
|
+
while (true) {
|
|
110
|
+
if (this.ending && this.streams.size === 0) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
if (this.streams.size === 0) {
|
|
114
|
+
await this.streamSignal.waitForItem();
|
|
115
|
+
this.streamSignal.get();
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const streamArray = Array.from(this.streams);
|
|
119
|
+
const promises = streamArray.map((stream) => this.getContribution(stream));
|
|
120
|
+
const results = await Promise.all(
|
|
121
|
+
promises.map(
|
|
122
|
+
(p) => p.then((value) => ({ status: "fulfilled", value })).catch((reason) => ({ status: "rejected", reason }))
|
|
123
|
+
)
|
|
124
|
+
);
|
|
125
|
+
const contributions = [];
|
|
126
|
+
let anyData = false;
|
|
127
|
+
const removals = [];
|
|
128
|
+
for (const result of results) {
|
|
129
|
+
if (result.status !== "fulfilled") {
|
|
130
|
+
console.warn("AudioMixer: Stream contribution failed:", result.reason);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const contrib = result.value;
|
|
134
|
+
contributions.push(contrib.data);
|
|
135
|
+
this.buffers.set(contrib.stream, contrib.buffer);
|
|
136
|
+
if (contrib.hadData) {
|
|
137
|
+
anyData = true;
|
|
138
|
+
}
|
|
139
|
+
if (contrib.exhausted && contrib.buffer.length === 0) {
|
|
140
|
+
removals.push(contrib.stream);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
for (const stream of removals) {
|
|
144
|
+
this.removeStream(stream);
|
|
145
|
+
}
|
|
146
|
+
if (!anyData) {
|
|
147
|
+
await this.sleep(1);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const mixed = this.mixAudio(contributions);
|
|
151
|
+
const frame = new AudioFrame(mixed, this.sampleRate, this.numChannels, this.chunkSize);
|
|
152
|
+
if (this.closed) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
await this.queue.put(frame);
|
|
157
|
+
} catch {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
this.queue.close();
|
|
162
|
+
}
|
|
163
|
+
async getContribution(stream) {
|
|
164
|
+
let buf = this.buffers.get(stream) ?? new Int16Array(0);
|
|
165
|
+
const initialBufferLength = buf.length;
|
|
166
|
+
let exhausted = false;
|
|
167
|
+
let receivedDataInThisCall = false;
|
|
168
|
+
let iterator = this.streamIterators.get(stream);
|
|
169
|
+
if (!iterator) {
|
|
170
|
+
iterator = stream[Symbol.asyncIterator]();
|
|
171
|
+
this.streamIterators.set(stream, iterator);
|
|
172
|
+
}
|
|
173
|
+
while (buf.length < this.chunkSize * this.numChannels && !exhausted && !this.closed) {
|
|
174
|
+
try {
|
|
175
|
+
const result = await Promise.race([iterator.next(), this.timeout(this.streamTimeoutMs)]);
|
|
176
|
+
if (result === "timeout") {
|
|
177
|
+
console.warn(`AudioMixer: stream timeout after ${this.streamTimeoutMs}ms`);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
if (result.done) {
|
|
181
|
+
exhausted = true;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
const frame = result.value;
|
|
185
|
+
const newData = frame.data;
|
|
186
|
+
receivedDataInThisCall = true;
|
|
187
|
+
if (buf.length === 0) {
|
|
188
|
+
buf = newData;
|
|
189
|
+
} else {
|
|
190
|
+
const combined = new Int16Array(buf.length + newData.length);
|
|
191
|
+
combined.set(buf);
|
|
192
|
+
combined.set(newData, buf.length);
|
|
193
|
+
buf = combined;
|
|
194
|
+
}
|
|
195
|
+
} catch (error) {
|
|
196
|
+
console.error(`AudioMixer: Error reading from stream:`, error);
|
|
197
|
+
exhausted = true;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
let contrib;
|
|
202
|
+
const samplesNeeded = this.chunkSize * this.numChannels;
|
|
203
|
+
if (buf.length >= samplesNeeded) {
|
|
204
|
+
contrib = buf.subarray(0, samplesNeeded);
|
|
205
|
+
buf = buf.subarray(samplesNeeded);
|
|
206
|
+
} else {
|
|
207
|
+
const padded = new Int16Array(samplesNeeded);
|
|
208
|
+
padded.set(buf);
|
|
209
|
+
contrib = padded;
|
|
210
|
+
buf = new Int16Array(0);
|
|
211
|
+
}
|
|
212
|
+
const hadData = initialBufferLength > 0 || receivedDataInThisCall || buf.length > 0;
|
|
213
|
+
return {
|
|
214
|
+
stream,
|
|
215
|
+
data: contrib,
|
|
216
|
+
buffer: buf,
|
|
217
|
+
hadData,
|
|
218
|
+
exhausted
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
mixAudio(contributions) {
|
|
222
|
+
if (contributions.length === 0) {
|
|
223
|
+
return new Int16Array(this.chunkSize * this.numChannels);
|
|
224
|
+
}
|
|
225
|
+
const length = this.chunkSize * this.numChannels;
|
|
226
|
+
const mixed = new Int16Array(length);
|
|
227
|
+
for (const contrib of contributions) {
|
|
228
|
+
for (let i = 0; i < length; i++) {
|
|
229
|
+
const val = contrib[i];
|
|
230
|
+
if (val !== void 0) {
|
|
231
|
+
mixed[i] = (mixed[i] ?? 0) + val;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
for (let i = 0; i < length; i++) {
|
|
236
|
+
const val = mixed[i] ?? 0;
|
|
237
|
+
if (val > 32767) {
|
|
238
|
+
mixed[i] = 32767;
|
|
239
|
+
} else if (val < -32768) {
|
|
240
|
+
mixed[i] = -32768;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return mixed;
|
|
244
|
+
}
|
|
245
|
+
sleep(ms) {
|
|
246
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
247
|
+
}
|
|
248
|
+
timeout(ms) {
|
|
249
|
+
return new Promise((resolve) => setTimeout(() => resolve("timeout"), ms));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
export {
|
|
253
|
+
AsyncQueue2 as AsyncQueue,
|
|
254
|
+
AudioMixer
|
|
255
|
+
};
|
|
256
|
+
//# sourceMappingURL=audio_mixer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/audio_mixer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { AsyncQueue } from './async_queue.js';\nimport { AudioFrame } from './audio_frame.js';\n\n// Re-export AsyncQueue for backward compatibility\nexport { AsyncQueue } from './async_queue.js';\n\n// Define types for async iteration (since lib: es2015 doesn't include them)\ntype AudioStream = {\n [Symbol.asyncIterator](): {\n next(): Promise<IteratorResult<AudioFrame>>;\n };\n};\n\ninterface Contribution {\n stream: AudioStream;\n data: Int16Array;\n buffer: Int16Array;\n hadData: boolean;\n exhausted: boolean;\n}\n\nexport interface AudioMixerOptions {\n /**\n * The size of the audio block (in samples) for mixing.\n * If not provided, defaults to sampleRate / 10 (100ms).\n */\n blocksize?: number;\n\n /**\n * The maximum wait time in milliseconds for each stream to provide\n * audio data before timing out. Defaults to 100 ms.\n */\n streamTimeoutMs?: number;\n\n /**\n * The maximum number of mixed frames to store in the output queue.\n * Defaults to 100.\n */\n capacity?: number;\n}\n\n/**\n * AudioMixer combines multiple async audio streams into a single output stream.\n *\n * The mixer accepts multiple async audio streams and mixes them into a single output stream.\n * Each output frame is generated with a fixed chunk size determined by the blocksize (in samples).\n * If blocksize is not provided (or 0), it defaults to 100ms.\n *\n * Each input stream is processed in parallel, accumulating audio data until at least one chunk\n * of samples is available. If an input stream does not provide data within the specified timeout,\n * a warning is logged. The mixer can be closed immediately\n * (dropping unconsumed frames) or allowed to flush remaining data using endInput().\n *\n * @example\n * ```typescript\n * const mixer = new AudioMixer(48000, 2);\n * mixer.addStream(stream1);\n * mixer.addStream(stream2);\n *\n * for await (const frame of mixer) {\n * // Process mixed audio frame\n * }\n * ```\n */\nexport class AudioMixer {\n private streams: Set<AudioStream>;\n private buffers: Map<AudioStream, Int16Array>;\n private streamIterators: Map<AudioStream, { next(): Promise<IteratorResult<AudioFrame>> }>;\n private sampleRate: number;\n private numChannels: number;\n private chunkSize: number;\n private streamTimeoutMs: number;\n private queue: AsyncQueue<AudioFrame>;\n private streamSignal: AsyncQueue<void>; // Signals when streams are added\n private ending: boolean;\n private mixerTask?: Promise<void>;\n private closed: boolean;\n\n /**\n * Initialize the AudioMixer.\n *\n * @param sampleRate - The audio sample rate in Hz.\n * @param numChannels - The number of audio channels.\n * @param options - Optional configuration for the mixer.\n */\n constructor(sampleRate: number, numChannels: number, options: AudioMixerOptions = {}) {\n this.streams = new Set();\n this.buffers = new Map();\n this.streamIterators = new Map();\n this.sampleRate = sampleRate;\n this.numChannels = numChannels;\n this.chunkSize =\n options.blocksize && options.blocksize > 0 ? options.blocksize : Math.floor(sampleRate / 10);\n this.streamTimeoutMs = options.streamTimeoutMs ?? 100;\n this.queue = new AsyncQueue<AudioFrame>(options.capacity ?? 100);\n this.streamSignal = new AsyncQueue<void>(1); // there should only be one mixer\n this.ending = false;\n this.closed = false;\n\n // Start the mixer task\n this.mixerTask = this.mixer();\n }\n\n /**\n * Add an audio stream to the mixer.\n *\n * The stream is added to the internal set of streams and an empty buffer is initialized for it,\n * if not already present.\n *\n * @param stream - An async iterable that produces AudioFrame objects.\n * @throws Error if the mixer has been closed.\n */\n addStream(stream: AudioStream): void {\n if (this.ending) {\n throw new Error('Cannot add stream after mixer has been closed');\n }\n\n this.streams.add(stream);\n if (!this.buffers.has(stream)) {\n this.buffers.set(stream, new Int16Array(0));\n }\n\n // Signal that a stream was added (non-blocking)\n this.streamSignal.put(undefined).catch(() => {\n // Ignore errors if signal queue is closed\n });\n }\n\n /**\n * Remove an audio stream from the mixer.\n *\n * This method removes the specified stream and its associated buffer from the mixer.\n *\n * @param stream - The audio stream to remove.\n */\n removeStream(stream: AudioStream): void {\n this.streams.delete(stream);\n this.buffers.delete(stream);\n this.streamIterators.delete(stream);\n }\n\n /**\n * Returns an async iterator for the mixed audio frames.\n */\n [Symbol.asyncIterator]() {\n return {\n next: async (): Promise<IteratorResult<AudioFrame>> => {\n const frame = await this.getNextFrame();\n if (frame === null) {\n return { done: true, value: undefined };\n }\n return { done: false, value: frame };\n },\n };\n }\n\n /**\n * Immediately stop mixing and close the mixer.\n *\n * This stops the mixing task, and any unconsumed output in the queue may be dropped.\n */\n async aclose(): Promise<void> {\n if (this.closed) {\n return;\n }\n this.closed = true;\n this.ending = true;\n\n // Close both queues to wake up any waiting operations\n this.streamSignal.close();\n this.queue.close();\n\n await this.mixerTask;\n }\n\n /**\n * Signal that no more streams will be added.\n *\n * This method marks the mixer as closed so that it flushes any remaining buffered output before ending.\n * Note that existing streams will still be processed until exhausted.\n */\n endInput(): void {\n this.ending = true;\n }\n\n private async getNextFrame(): Promise<AudioFrame | null> {\n while (true) {\n // Try to get an item from the queue (non-blocking)\n const frame = this.queue.get();\n\n if (frame !== undefined) {\n return frame;\n }\n\n // Check if mixer is closed or ending\n if (this.queue.closed || (this.ending && this.streams.size === 0)) {\n return null;\n }\n\n // Queue is empty but mixer is still running - wait for an item to be added\n await this.queue.waitForItem();\n }\n }\n\n private async mixer(): Promise<void> {\n // Main mixing loop that continuously processes streams and produces output frames\n while (true) {\n // If we're in ending mode and there are no more streams, exit\n if (this.ending && this.streams.size === 0) {\n break;\n }\n\n if (this.streams.size === 0) {\n // Wait for a stream to be added (signal queue will have an item)\n await this.streamSignal.waitForItem();\n // Consume the signal\n this.streamSignal.get();\n continue;\n }\n\n // Process all streams in parallel\n const streamArray = Array.from(this.streams);\n const promises = streamArray.map((stream) => this.getContribution(stream));\n const results = await Promise.all(\n promises.map((p) =>\n p\n .then((value) => ({ status: 'fulfilled' as const, value }))\n .catch((reason) => ({ status: 'rejected' as const, reason })),\n ),\n );\n\n const contributions: Int16Array[] = [];\n let anyData = false;\n const removals: AudioStream[] = [];\n\n for (const result of results) {\n if (result.status !== 'fulfilled') {\n console.warn('AudioMixer: Stream contribution failed:', result.reason);\n continue;\n }\n\n const contrib = result.value;\n contributions.push(contrib.data);\n this.buffers.set(contrib.stream, contrib.buffer);\n\n if (contrib.hadData) {\n anyData = true;\n }\n\n // Mark exhausted streams with no remaining buffer for removal\n if (contrib.exhausted && contrib.buffer.length === 0) {\n removals.push(contrib.stream);\n }\n }\n\n // Remove exhausted streams\n for (const stream of removals) {\n this.removeStream(stream);\n }\n\n if (!anyData) {\n // No data available from any stream, wait briefly before trying again\n await this.sleep(1);\n continue;\n }\n\n // Mix the audio data\n const mixed = this.mixAudio(contributions);\n const frame = new AudioFrame(mixed, this.sampleRate, this.numChannels, this.chunkSize);\n\n if (this.closed) {\n break;\n }\n\n try {\n // Add mixed frame to output queue\n await this.queue.put(frame);\n } catch {\n // Queue closed while trying to add frame\n break;\n }\n }\n\n // Close the queue to signal end of stream\n this.queue.close();\n }\n\n private async getContribution(stream: AudioStream): Promise<Contribution> {\n let buf = this.buffers.get(stream) ?? new Int16Array(0);\n const initialBufferLength = buf.length;\n let exhausted = false;\n let receivedDataInThisCall = false;\n\n // Get or create iterator for this stream\n let iterator = this.streamIterators.get(stream);\n if (!iterator) {\n iterator = stream[Symbol.asyncIterator]();\n this.streamIterators.set(stream, iterator);\n }\n\n // Accumulate data until we have at least chunkSize samples\n while (buf.length < this.chunkSize * this.numChannels && !exhausted && !this.closed) {\n try {\n const result = await Promise.race([iterator.next(), this.timeout(this.streamTimeoutMs)]);\n\n if (result === 'timeout') {\n console.warn(`AudioMixer: stream timeout after ${this.streamTimeoutMs}ms`);\n break;\n }\n\n if (result.done) {\n exhausted = true;\n break;\n }\n\n const frame = result.value;\n const newData = frame.data;\n\n // Mark that we received data in this call\n receivedDataInThisCall = true;\n\n // Concatenate buffers\n if (buf.length === 0) {\n buf = newData;\n } else {\n const combined = new Int16Array(buf.length + newData.length);\n combined.set(buf);\n combined.set(newData, buf.length);\n buf = combined;\n }\n } catch (error) {\n console.error(`AudioMixer: Error reading from stream:`, error);\n exhausted = true;\n break;\n }\n }\n\n // Extract contribution and update buffer\n let contrib: Int16Array;\n const samplesNeeded = this.chunkSize * this.numChannels;\n\n if (buf.length >= samplesNeeded) {\n // Extract the needed samples and keep the remainder in the buffer\n contrib = buf.subarray(0, samplesNeeded);\n buf = buf.subarray(samplesNeeded);\n } else {\n // Pad with zeros if we don't have enough data\n const padded = new Int16Array(samplesNeeded);\n padded.set(buf);\n contrib = padded;\n buf = new Int16Array(0);\n }\n\n // hadData means: we had data at start OR we received data during this call OR we have data remaining\n const hadData = initialBufferLength > 0 || receivedDataInThisCall || buf.length > 0;\n\n return {\n stream,\n data: contrib,\n buffer: buf,\n hadData,\n exhausted,\n };\n }\n\n private mixAudio(contributions: Int16Array[]): Int16Array {\n if (contributions.length === 0) {\n return new Int16Array(this.chunkSize * this.numChannels);\n }\n\n const length = this.chunkSize * this.numChannels;\n const mixed = new Int16Array(length);\n\n // Sum all contributions\n for (const contrib of contributions) {\n for (let i = 0; i < length; i++) {\n const val = contrib[i];\n if (val !== undefined) {\n mixed[i] = (mixed[i] ?? 0) + val;\n }\n }\n }\n\n // Clip to Int16 range\n for (let i = 0; i < length; i++) {\n const val = mixed[i] ?? 0;\n if (val > 32767) {\n mixed[i] = 32767;\n } else if (val < -32768) {\n mixed[i] = -32768;\n }\n }\n\n return mixed;\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n private timeout(ms: number): Promise<'timeout'> {\n return new Promise((resolve) => setTimeout(() => resolve('timeout'), ms));\n }\n}\n"],"mappings":"AAGA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAG3B,SAAS,cAAAA,mBAAkB;AA4DpB,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBtB,YAAY,YAAoB,aAAqB,UAA6B,CAAC,GAAG;AACpF,SAAK,UAAU,oBAAI,IAAI;AACvB,SAAK,UAAU,oBAAI,IAAI;AACvB,SAAK,kBAAkB,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I,QAAQ,QAAW;AACrB,gBAAM,CAAC,KAAK,MAAM,CAAC,KAAK,KAAK;AAAA,QAC/B;AAAA,MACF;AAAA,IACF;AAGA,aAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,YAAM,MAAM,MAAM,CAAC,KAAK;AACxB,UAAI,MAAM,OAAO;AACf,cAAM,CAAC,IAAI;AAAA,MACb,WAAW,MAAM,QAAQ;AACvB,cAAM,CAAC,IAAI;AAAA,MACb;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,MAAM,IAA2B;AACvC,WAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,EACzD;AAAA,EAEQ,QAAQ,IAAgC;AAC9C,WAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,MAAM,QAAQ,SAAS,GAAG,EAAE,CAAC;AAAA,EAC1E;AACF;","names":["AsyncQueue"]}
|
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var index_exports = {};
|
|
|
21
21
|
__export(index_exports, {
|
|
22
22
|
AudioFilter: () => import_audio_filter.AudioFilter,
|
|
23
23
|
AudioFrame: () => import_audio_frame.AudioFrame,
|
|
24
|
+
AudioMixer: () => import_audio_mixer.AudioMixer,
|
|
24
25
|
AudioResampler: () => import_audio_resampler.AudioResampler,
|
|
25
26
|
AudioResamplerQuality: () => import_audio_resampler.AudioResamplerQuality,
|
|
26
27
|
AudioSource: () => import_audio_source.AudioSource,
|
|
@@ -72,6 +73,7 @@ var import_audio_resampler = require("./audio_resampler.cjs");
|
|
|
72
73
|
var import_audio_source = require("./audio_source.cjs");
|
|
73
74
|
var import_audio_stream = require("./audio_stream.cjs");
|
|
74
75
|
var import_audio_filter = require("./audio_filter.cjs");
|
|
76
|
+
var import_audio_mixer = require("./audio_mixer.cjs");
|
|
75
77
|
__reExport(index_exports, require("./data_streams/index.cjs"), module.exports);
|
|
76
78
|
var import_e2ee = require("./e2ee.cjs");
|
|
77
79
|
var import_ffi_client = require("./ffi_client.cjs");
|
|
@@ -92,6 +94,7 @@ var import_video_stream = require("./video_stream.cjs");
|
|
|
92
94
|
0 && (module.exports = {
|
|
93
95
|
AudioFilter,
|
|
94
96
|
AudioFrame,
|
|
97
|
+
AudioMixer,
|
|
95
98
|
AudioResampler,
|
|
96
99
|
AudioResamplerQuality,
|
|
97
100
|
AudioSource,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { AudioSource } from './audio_source.js';\nexport { AudioStream } from './audio_stream.js';\nexport type { NoiseCancellationOptions } from './audio_stream.js';\nexport { AudioFilter } from './audio_filter.js';\nexport * from './data_streams/index.js';\nexport { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport { dispose } from './ffi_client.js';\nexport { LocalParticipant, Participant, RemoteParticipant } from './participant.js';\nexport { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';\nexport { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';\nexport {\n ConnectionQuality,\n ConnectionState,\n ContinualGatheringPolicy,\n DataPacketKind,\n IceServer,\n IceTransportType,\n TrackPublishOptions,\n} from './proto/room_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';\nexport { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';\nexport {\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n Track,\n type AudioTrack,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n} from './track.js';\nexport {\n LocalTrackPublication,\n RemoteTrackPublication,\n TrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport type { ChatMessage } from './types.js';\nexport { VideoFrame } from './video_frame.js';\nexport { VideoSource } from './video_source.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,yBAA+C;AAC/C,6BAAsD;AACtD,0BAA4B;AAC5B,0BAA4B;AAE5B,0BAA4B;AAC5B,0BAAc,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { AudioSource } from './audio_source.js';\nexport { AudioStream } from './audio_stream.js';\nexport type { NoiseCancellationOptions } from './audio_stream.js';\nexport { AudioFilter } from './audio_filter.js';\nexport { AudioMixer, type AudioMixerOptions } from './audio_mixer.js';\nexport * from './data_streams/index.js';\nexport { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport { dispose } from './ffi_client.js';\nexport { LocalParticipant, Participant, RemoteParticipant } from './participant.js';\nexport { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';\nexport { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';\nexport {\n ConnectionQuality,\n ConnectionState,\n ContinualGatheringPolicy,\n DataPacketKind,\n IceServer,\n IceTransportType,\n TrackPublishOptions,\n} from './proto/room_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';\nexport { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';\nexport {\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n Track,\n type AudioTrack,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n} from './track.js';\nexport {\n LocalTrackPublication,\n RemoteTrackPublication,\n TrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport type { ChatMessage } from './types.js';\nexport { VideoFrame } from './video_frame.js';\nexport { VideoSource } from './video_source.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,yBAA+C;AAC/C,6BAAsD;AACtD,0BAA4B;AAC5B,0BAA4B;AAE5B,0BAA4B;AAC5B,yBAAmD;AACnD,0BAAc,oCAXd;AAYA,kBAAuD;AAEvD,wBAAwB;AACxB,yBAAiE;AACjE,qBAAgD;AAChD,4BAAkD;AAClD,qBAQO;AACP,sBAAoD;AACpD,4BAA2D;AAC3D,kBAAuF;AACvF,iBAAwE;AACxE,mBAUO;AACP,+BAIO;AAGP,yBAA2B;AAC3B,0BAA4B;AAC5B,0BAAkD;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ export { AudioResampler, AudioResamplerQuality } from './audio_resampler.cjs';
|
|
|
3
3
|
export { AudioSource } from './audio_source.cjs';
|
|
4
4
|
export { AudioStream, NoiseCancellationOptions } from './audio_stream.cjs';
|
|
5
5
|
export { AudioFilter } from './audio_filter.cjs';
|
|
6
|
+
export { AudioMixer, AudioMixerOptions } from './audio_mixer.cjs';
|
|
6
7
|
export { a as BaseStreamInfo, f as ByteStreamHandler, b as ByteStreamInfo, e as ByteStreamOptions, B as ByteStreamReader, D as DataStreamOptions, S as StreamController, g as TextStreamHandler, c as TextStreamInfo, d as TextStreamOptions, T as TextStreamReader } from './stream_reader-Ch2zvjU3.cjs';
|
|
7
8
|
export { ByteStreamWriter, TextStreamWriter } from './data_streams/stream_writer.cjs';
|
|
8
9
|
export { E2EEManager, E2EEOptions, FrameCryptor, KeyProvider, KeyProviderOptions } from './e2ee.cjs';
|
|
@@ -26,6 +27,7 @@ export { livekitDispose as dispose } from './napi/native.d.cjs';
|
|
|
26
27
|
import './proto/audio_frame_pb.cjs';
|
|
27
28
|
import '@bufbuild/protobuf';
|
|
28
29
|
import './proto/handle_pb.cjs';
|
|
30
|
+
import './async_queue.cjs';
|
|
29
31
|
import '@livekit/typed-emitter';
|
|
30
32
|
import './proto/ffi_pb.cjs';
|
|
31
33
|
import './proto/rpc_pb.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';
|
|
|
3
3
|
export { AudioSource } from './audio_source.js';
|
|
4
4
|
export { AudioStream, NoiseCancellationOptions } from './audio_stream.js';
|
|
5
5
|
export { AudioFilter } from './audio_filter.js';
|
|
6
|
+
export { AudioMixer, AudioMixerOptions } from './audio_mixer.js';
|
|
6
7
|
export { a as BaseStreamInfo, f as ByteStreamHandler, b as ByteStreamInfo, e as ByteStreamOptions, B as ByteStreamReader, D as DataStreamOptions, S as StreamController, g as TextStreamHandler, c as TextStreamInfo, d as TextStreamOptions, T as TextStreamReader } from './stream_reader-DRyR29vo.js';
|
|
7
8
|
export { ByteStreamWriter, TextStreamWriter } from './data_streams/stream_writer.js';
|
|
8
9
|
export { E2EEManager, E2EEOptions, FrameCryptor, KeyProvider, KeyProviderOptions } from './e2ee.js';
|
|
@@ -26,6 +27,7 @@ export { livekitDispose as dispose } from './napi/native.d.js';
|
|
|
26
27
|
import './proto/audio_frame_pb.js';
|
|
27
28
|
import '@bufbuild/protobuf';
|
|
28
29
|
import './proto/handle_pb.js';
|
|
30
|
+
import './async_queue.js';
|
|
29
31
|
import '@livekit/typed-emitter';
|
|
30
32
|
import './proto/ffi_pb.js';
|
|
31
33
|
import './proto/rpc_pb.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAA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K,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACnG,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACnF,OAAO,EACL,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { AudioResampler, AudioResamplerQuality } from "./audio_resampler.js";
|
|
|
3
3
|
import { AudioSource } from "./audio_source.js";
|
|
4
4
|
import { AudioStream } from "./audio_stream.js";
|
|
5
5
|
import { AudioFilter } from "./audio_filter.js";
|
|
6
|
+
import { AudioMixer } from "./audio_mixer.js";
|
|
6
7
|
export * from "./data_streams/index.js";
|
|
7
8
|
import { E2EEManager, FrameCryptor, KeyProvider } from "./e2ee.js";
|
|
8
9
|
import { dispose } from "./ffi_client.js";
|
|
@@ -40,6 +41,7 @@ import { VideoStream } from "./video_stream.js";
|
|
|
40
41
|
export {
|
|
41
42
|
AudioFilter,
|
|
42
43
|
AudioFrame,
|
|
44
|
+
AudioMixer,
|
|
43
45
|
AudioResampler,
|
|
44
46
|
AudioResamplerQuality,
|
|
45
47
|
AudioSource,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { AudioSource } from './audio_source.js';\nexport { AudioStream } from './audio_stream.js';\nexport type { NoiseCancellationOptions } from './audio_stream.js';\nexport { AudioFilter } from './audio_filter.js';\nexport * from './data_streams/index.js';\nexport { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport { dispose } from './ffi_client.js';\nexport { LocalParticipant, Participant, RemoteParticipant } from './participant.js';\nexport { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';\nexport { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';\nexport {\n ConnectionQuality,\n ConnectionState,\n ContinualGatheringPolicy,\n DataPacketKind,\n IceServer,\n IceTransportType,\n TrackPublishOptions,\n} from './proto/room_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';\nexport { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';\nexport {\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n Track,\n type AudioTrack,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n} from './track.js';\nexport {\n LocalTrackPublication,\n RemoteTrackPublication,\n TrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport type { ChatMessage } from './types.js';\nexport { VideoFrame } from './video_frame.js';\nexport { VideoSource } from './video_source.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\n"],"mappings":"AAIA,SAAS,YAAY,0BAA0B;AAC/C,SAAS,gBAAgB,6BAA6B;AACtD,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAE5B,SAAS,mBAAmB;AAC5B,cAAc;AACd,SAAS,aAAa,cAAc,mBAAmB;AAEvD,SAAS,eAAe;AACxB,SAAS,kBAAkB,aAAa,yBAAyB;AACjE,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,kBAAkB,uBAAuB;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,iBAAiB,YAAY,qBAAqB;AAC3D,SAAS,cAAc,MAAM,iBAA0D;AACvF,SAAS,gBAA+D;AACxE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,mBAAyC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { AudioSource } from './audio_source.js';\nexport { AudioStream } from './audio_stream.js';\nexport type { NoiseCancellationOptions } from './audio_stream.js';\nexport { AudioFilter } from './audio_filter.js';\nexport { AudioMixer, type AudioMixerOptions } from './audio_mixer.js';\nexport * from './data_streams/index.js';\nexport { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport { dispose } from './ffi_client.js';\nexport { LocalParticipant, Participant, RemoteParticipant } from './participant.js';\nexport { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';\nexport { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';\nexport {\n ConnectionQuality,\n ConnectionState,\n ContinualGatheringPolicy,\n DataPacketKind,\n IceServer,\n IceTransportType,\n TrackPublishOptions,\n} from './proto/room_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';\nexport { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';\nexport {\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n Track,\n type AudioTrack,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n} from './track.js';\nexport {\n LocalTrackPublication,\n RemoteTrackPublication,\n TrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport type { ChatMessage } from './types.js';\nexport { VideoFrame } from './video_frame.js';\nexport { VideoSource } from './video_source.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\n"],"mappings":"AAIA,SAAS,YAAY,0BAA0B;AAC/C,SAAS,gBAAgB,6BAA6B;AACtD,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAE5B,SAAS,mBAAmB;AAC5B,SAAS,kBAA0C;AACnD,cAAc;AACd,SAAS,aAAa,cAAc,mBAAmB;AAEvD,SAAS,eAAe;AACxB,SAAS,kBAAkB,aAAa,yBAAyB;AACjE,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,kBAAkB,uBAAuB;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,iBAAiB,YAAY,qBAAqB;AAC3D,SAAS,cAAc,MAAM,iBAA0D;AACvF,SAAS,gBAA+D;AACxE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,mBAAyC;","names":[]}
|
package/dist/participant.cjs
CHANGED
|
@@ -67,11 +67,11 @@ class Participant {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
class LocalParticipant extends Participant {
|
|
70
|
-
constructor(info,
|
|
70
|
+
constructor(info, ffiEventLock) {
|
|
71
71
|
super(info);
|
|
72
72
|
this.rpcHandlers = /* @__PURE__ */ new Map();
|
|
73
73
|
this.trackPublications = /* @__PURE__ */ new Map();
|
|
74
|
-
this.
|
|
74
|
+
this.ffiEventLock = ffiEventLock;
|
|
75
75
|
}
|
|
76
76
|
async publishData(data, options) {
|
|
77
77
|
const req = new import_room_pb.PublishDataRequest({
|
|
@@ -472,7 +472,7 @@ class LocalParticipant extends Participant {
|
|
|
472
472
|
trackHandle: track.ffi_handle.handle,
|
|
473
473
|
options
|
|
474
474
|
});
|
|
475
|
-
const unlock = await this.
|
|
475
|
+
const unlock = await this.ffiEventLock.lock();
|
|
476
476
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
477
477
|
message: { case: "publishTrack", value: req }
|
|
478
478
|
});
|
|
@@ -495,7 +495,7 @@ class LocalParticipant extends Participant {
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
async unpublishTrack(trackSid, stopOnUnpublish) {
|
|
498
|
-
const unlock = await this.
|
|
498
|
+
const unlock = await this.ffiEventLock.lock();
|
|
499
499
|
try {
|
|
500
500
|
const req = new import_room_pb.UnpublishTrackRequest({
|
|
501
501
|
localParticipantHandle: this.ffi_handle.handle,
|