@livekit/rtc-node 0.13.29 → 0.13.30
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/audio_stream-B4hGVcKz.d.cts +498 -0
- package/dist/audio_stream-DEG1JKge.d.ts +498 -0
- package/dist/audio_stream.cjs +21 -6
- package/dist/audio_stream.cjs.map +1 -1
- package/dist/audio_stream.d.cts +12 -22
- package/dist/audio_stream.d.ts +12 -22
- package/dist/audio_stream.d.ts.map +1 -1
- package/dist/audio_stream.js +19 -5
- package/dist/audio_stream.js.map +1 -1
- package/dist/data_streams/index.d.cts +1 -1
- package/dist/data_streams/index.d.ts +1 -1
- package/dist/data_streams/stream_reader.d.cts +1 -1
- package/dist/data_streams/stream_reader.d.ts +1 -1
- package/dist/data_streams/stream_writer.d.cts +1 -1
- package/dist/data_streams/stream_writer.d.ts +1 -1
- package/dist/data_streams/types.d.cts +1 -1
- package/dist/data_streams/types.d.ts +1 -1
- package/dist/frame_processor.cjs +6 -0
- package/dist/frame_processor.cjs.map +1 -1
- package/dist/frame_processor.d.cts +2 -0
- package/dist/frame_processor.d.ts +2 -0
- package/dist/frame_processor.d.ts.map +1 -1
- package/dist/frame_processor.js +6 -0
- package/dist/frame_processor.js.map +1 -1
- package/dist/index.d.cts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/participant.cjs +6 -0
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +14 -153
- package/dist/participant.d.ts +14 -153
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +6 -0
- package/dist/participant.js.map +1 -1
- package/dist/room.cjs +28 -0
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +12 -221
- package/dist/room.d.ts +12 -221
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +28 -0
- package/dist/room.js.map +1 -1
- package/dist/track.cjs +123 -0
- package/dist/track.cjs.map +1 -1
- package/dist/track.d.cts +15 -42
- package/dist/track.d.ts +15 -42
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +123 -0
- package/dist/track.js.map +1 -1
- package/dist/track_publication.d.cts +14 -47
- package/dist/track_publication.d.ts +14 -47
- package/dist/{stream_reader-CuG4b8Y-.d.cts → types-_PdPVish.d.cts} +40 -40
- package/dist/{stream_reader-CuG4b8Y-.d.ts → types-_PdPVish.d.ts} +40 -40
- 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/dist/video_stream.d.cts +12 -2
- package/dist/video_stream.d.ts +12 -2
- package/package.json +3 -3
- package/src/audio_stream.ts +28 -4
- package/src/audio_stream_room_lifecycle.test.ts +753 -0
- package/src/bun_runtime.test.ts +27 -0
- package/src/frame_processor.ts +4 -0
- package/src/participant.ts +17 -0
- package/src/room.ts +44 -0
- package/src/track.ts +141 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import { UnderlyingSource } from 'node:stream/web';
|
|
2
|
+
import { AudioFrame } from './audio_frame.js';
|
|
3
|
+
import { FrameProcessor } from './frame_processor.js';
|
|
4
|
+
import * as _livekit_rtc_ffi_bindings from '@livekit/rtc-ffi-bindings';
|
|
5
|
+
import { FfiHandle, TrackPublicationInfo, OwnedTrackPublication, TrackKind, TrackSource, EncryptionType, ParticipantInfo, OwnedParticipant, ParticipantKind, ParticipantKindDetail, DisconnectReason, TrackPublishOptions, RoomInfo, ConnectionQuality, DataPacketKind, ConnectionState, IceTransportType, ContinualGatheringPolicy, IceServer, SimulateScenarioKind, RoomOptions as RoomOptions$1, TrackInfo, OwnedTrack, StreamState } from '@livekit/rtc-ffi-bindings';
|
|
6
|
+
import { AudioSource } from './audio_source.js';
|
|
7
|
+
import './ffi_client.js';
|
|
8
|
+
import { TypedEventEmitter } from '@livekit/typed-emitter';
|
|
9
|
+
import { B as BaseStreamInfo, c as ByteStreamOptions, T as TextStreamHandler, a as ByteStreamHandler } from './types-_PdPVish.js';
|
|
10
|
+
import { E2EEManager, E2EEOptions } from './e2ee.js';
|
|
11
|
+
import { Mutex } from '@livekit/mutex';
|
|
12
|
+
import { PathLike } from 'node:fs';
|
|
13
|
+
import { TextStreamWriter, ByteStreamWriter } from './data_streams/stream_writer.js';
|
|
14
|
+
import { PerformRpcParams, RpcInvocationData } from './rpc.js';
|
|
15
|
+
import { Transcription } from './transcription.js';
|
|
16
|
+
import { ChatMessage } from './types.js';
|
|
17
|
+
import { VideoSource } from './video_source.js';
|
|
18
|
+
|
|
19
|
+
declare abstract class TrackPublication {
|
|
20
|
+
/** @internal */
|
|
21
|
+
ffiHandle: FfiHandle;
|
|
22
|
+
/** @internal */
|
|
23
|
+
info?: TrackPublicationInfo;
|
|
24
|
+
track?: Track;
|
|
25
|
+
constructor(ownedInfo: OwnedTrackPublication);
|
|
26
|
+
get sid(): string | undefined;
|
|
27
|
+
get name(): string | undefined;
|
|
28
|
+
get kind(): TrackKind | undefined;
|
|
29
|
+
get source(): TrackSource | undefined;
|
|
30
|
+
get simulcasted(): boolean | undefined;
|
|
31
|
+
get width(): number | undefined;
|
|
32
|
+
get height(): number | undefined;
|
|
33
|
+
get mimeType(): string | undefined;
|
|
34
|
+
get muted(): boolean | undefined;
|
|
35
|
+
get encryptionType(): EncryptionType | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Update the publication's info in place. Used by the SDK when the
|
|
38
|
+
* server re-issues IDs / metadata for an existing publication (e.g.
|
|
39
|
+
* after a full reconnect). Application code holding a cached
|
|
40
|
+
* publication reference continues to read fresh values via the
|
|
41
|
+
* unchanged object identity.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
updateInfo(info: TrackPublicationInfo): void;
|
|
45
|
+
}
|
|
46
|
+
declare class LocalTrackPublication extends TrackPublication {
|
|
47
|
+
private firstSubscription;
|
|
48
|
+
private firstSubscriptionResolver;
|
|
49
|
+
constructor(ownedInfo: OwnedTrackPublication);
|
|
50
|
+
waitForSubscription(): Promise<void>;
|
|
51
|
+
/** @internal */
|
|
52
|
+
resolveFirstSubscription(): void;
|
|
53
|
+
}
|
|
54
|
+
declare class RemoteTrackPublication extends TrackPublication {
|
|
55
|
+
subscribed: boolean;
|
|
56
|
+
constructor(ownedInfo: OwnedTrackPublication);
|
|
57
|
+
setSubscribed(subscribed: boolean): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare abstract class Participant {
|
|
61
|
+
/** @internal */
|
|
62
|
+
info: ParticipantInfo;
|
|
63
|
+
/** @internal */
|
|
64
|
+
ffi_handle: FfiHandle;
|
|
65
|
+
trackPublications: Map<string, TrackPublication>;
|
|
66
|
+
constructor(owned_info: OwnedParticipant);
|
|
67
|
+
get sid(): string | undefined;
|
|
68
|
+
get name(): string | undefined;
|
|
69
|
+
get identity(): string;
|
|
70
|
+
get metadata(): string;
|
|
71
|
+
get attributes(): Record<string, string>;
|
|
72
|
+
get kind(): ParticipantKind;
|
|
73
|
+
get kindDetails(): ParticipantKindDetail[];
|
|
74
|
+
get disconnectReason(): DisconnectReason | undefined;
|
|
75
|
+
}
|
|
76
|
+
type DataPublishOptions = {
|
|
77
|
+
/**
|
|
78
|
+
* whether to send this as reliable or lossy.
|
|
79
|
+
* For data that you need delivery guarantee (such as chat messages), use Reliable.
|
|
80
|
+
* For data that should arrive as quickly as possible, but you are ok with dropped
|
|
81
|
+
* packets, use Lossy.
|
|
82
|
+
*/
|
|
83
|
+
reliable?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* the identities of participants who will receive the message, will be sent to every one if empty
|
|
86
|
+
*/
|
|
87
|
+
destination_identities?: string[];
|
|
88
|
+
/** the topic under which the message gets published */
|
|
89
|
+
topic?: string;
|
|
90
|
+
};
|
|
91
|
+
declare class LocalParticipant extends Participant {
|
|
92
|
+
private rpcHandlers;
|
|
93
|
+
private ffiEventLock;
|
|
94
|
+
private disconnectSignal;
|
|
95
|
+
trackPublications: Map<string, LocalTrackPublication>;
|
|
96
|
+
constructor(info: OwnedParticipant, ffiEventLock: Mutex, disconnectSignal: AbortSignal);
|
|
97
|
+
publishData(data: Uint8Array, options: DataPublishOptions): Promise<void>;
|
|
98
|
+
publishDtmf(code: number, digit: string): Promise<void>;
|
|
99
|
+
publishTranscription(transcription: Transcription): Promise<void>;
|
|
100
|
+
updateMetadata(metadata: string): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Returns a `StreamWriter` instance that allows to write individual chunks of text to a stream.
|
|
103
|
+
* Well suited for TTS and/or streaming LLM output. If you want to simply send a text then use sendText() instead
|
|
104
|
+
*/
|
|
105
|
+
streamText(options?: {
|
|
106
|
+
topic?: string;
|
|
107
|
+
attributes?: Record<string, string>;
|
|
108
|
+
destinationIdentities?: Array<string>;
|
|
109
|
+
streamId?: string;
|
|
110
|
+
senderIdentity?: string;
|
|
111
|
+
}): Promise<TextStreamWriter>;
|
|
112
|
+
sendText(text: string, options?: {
|
|
113
|
+
topic?: string;
|
|
114
|
+
attributes?: Record<string, string>;
|
|
115
|
+
destinationIdentities?: Array<string>;
|
|
116
|
+
streamId?: string;
|
|
117
|
+
}): Promise<BaseStreamInfo>;
|
|
118
|
+
streamBytes(options?: {
|
|
119
|
+
name?: string;
|
|
120
|
+
topic?: string;
|
|
121
|
+
attributes?: Record<string, string>;
|
|
122
|
+
destinationIdentities?: Array<string>;
|
|
123
|
+
streamId?: string;
|
|
124
|
+
mimeType?: string;
|
|
125
|
+
totalSize?: number;
|
|
126
|
+
}): Promise<ByteStreamWriter>;
|
|
127
|
+
/** Sends a file provided as PathLike to specified recipients */
|
|
128
|
+
sendFile(path: PathLike, options?: ByteStreamOptions): Promise<void>;
|
|
129
|
+
private sendStreamHeader;
|
|
130
|
+
private sendStreamChunk;
|
|
131
|
+
private sendStreamTrailer;
|
|
132
|
+
/**
|
|
133
|
+
* Sends a chat message to participants in the room
|
|
134
|
+
*
|
|
135
|
+
* @param text - The text content of the chat message.
|
|
136
|
+
* @param destinationIdentities - An optional array of recipient identities to whom the message will be sent. If omitted, the message is broadcast to all participants.
|
|
137
|
+
* @param senderIdentity - An optional identity of the sender. If omitted, the default sender identity is used.
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
sendChatMessage(text: string, destinationIdentities?: Array<string>, senderIdentity?: string): Promise<ChatMessage>;
|
|
141
|
+
/**
|
|
142
|
+
* @experimental
|
|
143
|
+
*/
|
|
144
|
+
editChatMessage(editText: string, originalMessage: ChatMessage, destinationIdentities?: Array<string>, senderIdentity?: string): Promise<ChatMessage>;
|
|
145
|
+
updateName(name: string): Promise<void>;
|
|
146
|
+
setAttributes(attributes: Record<string, string>): Promise<void>;
|
|
147
|
+
publishTrack(track: LocalTrack, options: TrackPublishOptions): Promise<LocalTrackPublication>;
|
|
148
|
+
unpublishTrack(trackSid: string, stopOnUnpublish?: boolean): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Initiate an RPC call to a remote participant.
|
|
151
|
+
* @param params - Parameters for initiating the RPC call, see {@link PerformRpcParams}
|
|
152
|
+
* @returns A promise that resolves with the response payload or rejects with an error.
|
|
153
|
+
* @throws Error on failure. Details in `message`.
|
|
154
|
+
*/
|
|
155
|
+
performRpc({ destinationIdentity, method, payload, responseTimeout, }: PerformRpcParams): Promise<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Establishes the participant as a receiver for calls of the specified RPC method.
|
|
158
|
+
* Will overwrite any existing callback for the same method.
|
|
159
|
+
*
|
|
160
|
+
* @param method - The name of the indicated RPC method
|
|
161
|
+
* @param handler - Will be invoked when an RPC request for this method is received
|
|
162
|
+
* @returns A promise that resolves when the method is successfully registered
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* room.localParticipant?.registerRpcMethod(
|
|
167
|
+
* 'greet',
|
|
168
|
+
* async (data: RpcInvocationData) => {
|
|
169
|
+
* console.log(`Received greeting from ${data.callerIdentity}: ${data.payload}`);
|
|
170
|
+
* return `Hello, ${data.callerIdentity}!`;
|
|
171
|
+
* }
|
|
172
|
+
* );
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* See {@link RpcInvocationData} for more details on invocation params.
|
|
176
|
+
*
|
|
177
|
+
* The handler should return a Promise that resolves to a string.
|
|
178
|
+
* If unable to respond within `responseTimeout`, the request will result in an error on the caller's side.
|
|
179
|
+
*
|
|
180
|
+
* You may throw errors of type `RpcError` with a string `message` in the handler,
|
|
181
|
+
* and they will be received on the caller's side with the message intact.
|
|
182
|
+
* Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as `1500` ("Application Error").
|
|
183
|
+
*/
|
|
184
|
+
registerRpcMethod(method: string, handler: (data: RpcInvocationData) => Promise<string>): void;
|
|
185
|
+
/**
|
|
186
|
+
* Unregisters a previously registered RPC method.
|
|
187
|
+
*
|
|
188
|
+
* @param method - The name of the RPC method to unregister
|
|
189
|
+
*/
|
|
190
|
+
unregisterRpcMethod(method: string): void;
|
|
191
|
+
/** @internal */
|
|
192
|
+
handleRpcMethodInvocation(invocationId: bigint, method: string, requestId: string, callerIdentity: string, payload: string, responseTimeout: number): Promise<void>;
|
|
193
|
+
}
|
|
194
|
+
declare class RemoteParticipant extends Participant {
|
|
195
|
+
trackPublications: Map<string, RemoteTrackPublication>;
|
|
196
|
+
constructor(owned_info: OwnedParticipant);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
interface RtcConfiguration {
|
|
200
|
+
iceTransportType: IceTransportType;
|
|
201
|
+
continualGatheringPolicy: ContinualGatheringPolicy;
|
|
202
|
+
iceServers: IceServer[];
|
|
203
|
+
}
|
|
204
|
+
declare const defaultRtcConfiguration: RtcConfiguration;
|
|
205
|
+
interface RoomOptions {
|
|
206
|
+
autoSubscribe: boolean;
|
|
207
|
+
dynacast: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* @deprecated Use `encryption` instead. See x for details
|
|
210
|
+
*/
|
|
211
|
+
e2ee?: E2EEOptions;
|
|
212
|
+
encryption?: E2EEOptions;
|
|
213
|
+
rtcConfig?: RtcConfiguration;
|
|
214
|
+
}
|
|
215
|
+
declare const defaultRoomOptions: RoomOptions$1;
|
|
216
|
+
declare const Room_base: new () => TypedEventEmitter<RoomCallbacks>;
|
|
217
|
+
declare class Room extends Room_base {
|
|
218
|
+
private info?;
|
|
219
|
+
private ffiHandle?;
|
|
220
|
+
/**
|
|
221
|
+
* used to ensure events are processed sequentially and allow for
|
|
222
|
+
* the local participant to acquire the lock while doing state updates related to FFI events
|
|
223
|
+
* before processing the next events
|
|
224
|
+
*/
|
|
225
|
+
private ffiEventLock;
|
|
226
|
+
private byteStreamControllers;
|
|
227
|
+
private textStreamControllers;
|
|
228
|
+
private byteStreamHandlers;
|
|
229
|
+
private textStreamHandlers;
|
|
230
|
+
private preConnectEvents;
|
|
231
|
+
private disconnectController;
|
|
232
|
+
private hasCleanedUp;
|
|
233
|
+
private _token?;
|
|
234
|
+
private _serverUrl?;
|
|
235
|
+
private _connectionState;
|
|
236
|
+
e2eeManager?: E2EEManager;
|
|
237
|
+
remoteParticipants: Map<string, RemoteParticipant>;
|
|
238
|
+
localParticipant?: LocalParticipant;
|
|
239
|
+
constructor();
|
|
240
|
+
get connectionState(): ConnectionState;
|
|
241
|
+
get name(): string | undefined;
|
|
242
|
+
get metadata(): string | undefined;
|
|
243
|
+
get isConnected(): boolean;
|
|
244
|
+
/** @internal */
|
|
245
|
+
get token(): string | undefined;
|
|
246
|
+
/** @internal */
|
|
247
|
+
get serverUrl(): string | undefined;
|
|
248
|
+
private sidPromise?;
|
|
249
|
+
/**
|
|
250
|
+
* Gets the room's server ID. This ID is assigned by the LiveKit server
|
|
251
|
+
* and is unique for each room session.
|
|
252
|
+
* SID is assigned asynchronously after connection.
|
|
253
|
+
* @returns Promise that resolves to the room's server ID, or empty string if not connected
|
|
254
|
+
*/
|
|
255
|
+
getSid(): Promise<string>;
|
|
256
|
+
getRtcStats(): Promise<_livekit_rtc_ffi_bindings.GetSessionStatsCallback_Result>;
|
|
257
|
+
get numParticipants(): number;
|
|
258
|
+
get numPublishers(): number;
|
|
259
|
+
get creationTime(): Date;
|
|
260
|
+
get isRecording(): boolean;
|
|
261
|
+
/**
|
|
262
|
+
* The time in seconds after which a room will be closed after the last
|
|
263
|
+
* participant has disconnected.
|
|
264
|
+
*/
|
|
265
|
+
get departureTimeout(): number;
|
|
266
|
+
/**
|
|
267
|
+
* The time in seconds after which an empty room will be automatically closed.
|
|
268
|
+
*/
|
|
269
|
+
get emptyTimeout(): number;
|
|
270
|
+
/**
|
|
271
|
+
* Connects to a LiveKit room using the provided URL and access token.
|
|
272
|
+
* @param url - The WebSocket URL of the LiveKit server
|
|
273
|
+
* @param token - A valid LiveKit access token for authentication
|
|
274
|
+
* @param opts - Optional room configuration options
|
|
275
|
+
* @throws ConnectError - if connection fails
|
|
276
|
+
*/
|
|
277
|
+
connect(url: string, token: string, opts?: RoomOptions): Promise<void>;
|
|
278
|
+
/**
|
|
279
|
+
* Disconnects from the room and cleans up all resources.
|
|
280
|
+
* This will stop all tracks and close the connection.
|
|
281
|
+
*/
|
|
282
|
+
disconnect(): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* Trigger a reconnection / chaos scenario for testing. Most useful in
|
|
285
|
+
* tests to deterministically force a Resume (signal-only reconnect that
|
|
286
|
+
* preserves the PeerConnection and existing publications) or a full
|
|
287
|
+
* reconnect (the SDK rebuilds the RtcSession and re-publishes existing
|
|
288
|
+
* local tracks; `RoomEvent.Reconnected` fires).
|
|
289
|
+
*/
|
|
290
|
+
simulateScenario(scenario: SimulateScenarioKind): Promise<void>;
|
|
291
|
+
private updateConnectionState;
|
|
292
|
+
private cleanupOnDisconnect;
|
|
293
|
+
/**
|
|
294
|
+
* Registers a handler for incoming text data streams on a specific topic.
|
|
295
|
+
* Text streams are used for receiving structured text data from other participants.
|
|
296
|
+
* @param topic - The topic to listen for text streams on
|
|
297
|
+
* @param callback - Function to handle incoming text stream data
|
|
298
|
+
* @throws Error - if a handler for this topic is already registered
|
|
299
|
+
*/
|
|
300
|
+
registerTextStreamHandler(topic: string, callback: TextStreamHandler): void;
|
|
301
|
+
unregisterTextStreamHandler(topic: string): void;
|
|
302
|
+
/**
|
|
303
|
+
* Registers a handler for incoming byte data streams on a specific topic.
|
|
304
|
+
* Byte streams are used for receiving binary data like files from other participants.
|
|
305
|
+
* @param topic - The topic to listen for byte streams on
|
|
306
|
+
* @param callback - Function to handle incoming byte stream data
|
|
307
|
+
* @throws Error - if a handler for this topic is already registered
|
|
308
|
+
*/
|
|
309
|
+
registerByteStreamHandler(topic: string, callback: ByteStreamHandler): void;
|
|
310
|
+
unregisterByteStreamHandler(topic: string): void;
|
|
311
|
+
private onFfiEvent;
|
|
312
|
+
private processFfiEvent;
|
|
313
|
+
private retrieveParticipantByIdentity;
|
|
314
|
+
private requireParticipantByIdentity;
|
|
315
|
+
private requireRemoteParticipant;
|
|
316
|
+
private requirePublicationOfParticipant;
|
|
317
|
+
private requirePublicationOfRemoteParticipant;
|
|
318
|
+
private createRemoteParticipant;
|
|
319
|
+
private handleStreamHeader;
|
|
320
|
+
private handleStreamChunk;
|
|
321
|
+
private handleStreamTrailer;
|
|
322
|
+
}
|
|
323
|
+
declare class ConnectError extends Error {
|
|
324
|
+
constructor(message: string);
|
|
325
|
+
}
|
|
326
|
+
type RoomCallbacks = {
|
|
327
|
+
participantConnected: (participant: RemoteParticipant) => void;
|
|
328
|
+
participantDisconnected: (participant: RemoteParticipant) => void;
|
|
329
|
+
localTrackPublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
|
|
330
|
+
localTrackUnpublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
|
|
331
|
+
/**
|
|
332
|
+
* Fired when the SDK auto-republished a local track during a full
|
|
333
|
+
* reconnect. The publication object's identity is preserved (the same
|
|
334
|
+
* instance is updated in place with the new server-assigned SIDs);
|
|
335
|
+
* `previousSid` is provided for callers that key external state on the
|
|
336
|
+
* old SID and need to reconcile.
|
|
337
|
+
*/
|
|
338
|
+
localTrackRepublished: (publication: LocalTrackPublication, previousSid: string, participant: LocalParticipant) => void;
|
|
339
|
+
localTrackSubscribed: (track: LocalTrack) => void;
|
|
340
|
+
trackPublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
|
|
341
|
+
trackUnpublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
|
|
342
|
+
trackSubscribed: (track: RemoteTrack, publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
|
|
343
|
+
trackUnsubscribed: (track: RemoteTrack, publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
|
|
344
|
+
trackSubscriptionFailed: (trackSid: string, participant: RemoteParticipant, reason?: string) => void;
|
|
345
|
+
trackMuted: (publication: TrackPublication, participant: Participant) => void;
|
|
346
|
+
trackUnmuted: (publication: TrackPublication, participant: Participant) => void;
|
|
347
|
+
activeSpeakersChanged: (speakers: Participant[]) => void;
|
|
348
|
+
roomMetadataChanged: (metadata: string) => void;
|
|
349
|
+
roomInfoUpdated: (info: RoomInfo) => void;
|
|
350
|
+
participantMetadataChanged: (metadata: string | undefined, participant: Participant) => void;
|
|
351
|
+
participantNameChanged: (name: string, participant: Participant) => void;
|
|
352
|
+
participantAttributesChanged: (changedAttributes: Record<string, string>, participant: Participant) => void;
|
|
353
|
+
participantEncryptionStatusChanged: (isEncrypted: boolean, participant: Participant) => void;
|
|
354
|
+
connectionQualityChanged: (quality: ConnectionQuality, participant: Participant) => void;
|
|
355
|
+
dataReceived: (payload: Uint8Array, participant?: RemoteParticipant, kind?: DataPacketKind, topic?: string, encryptionType?: EncryptionType) => void;
|
|
356
|
+
chatMessage: (message: ChatMessage, participant?: Participant) => void;
|
|
357
|
+
dtmfReceived: (code: number, digit: string, participant: RemoteParticipant) => void;
|
|
358
|
+
encryptionError: (error: Error) => void;
|
|
359
|
+
connectionStateChanged: (state: ConnectionState) => void;
|
|
360
|
+
connected: () => void;
|
|
361
|
+
disconnected: (reason: DisconnectReason) => void;
|
|
362
|
+
reconnecting: () => void;
|
|
363
|
+
reconnected: () => void;
|
|
364
|
+
roomSidChanged: (sid: string) => void;
|
|
365
|
+
roomUpdated: () => void;
|
|
366
|
+
moved: () => void;
|
|
367
|
+
tokenRefreshed: () => void;
|
|
368
|
+
};
|
|
369
|
+
declare enum RoomEvent {
|
|
370
|
+
ParticipantConnected = "participantConnected",
|
|
371
|
+
ParticipantDisconnected = "participantDisconnected",
|
|
372
|
+
LocalTrackPublished = "localTrackPublished",
|
|
373
|
+
LocalTrackUnpublished = "localTrackUnpublished",
|
|
374
|
+
LocalTrackRepublished = "localTrackRepublished",
|
|
375
|
+
LocalTrackSubscribed = "localTrackSubscribed",
|
|
376
|
+
TrackPublished = "trackPublished",
|
|
377
|
+
TrackUnpublished = "trackUnpublished",
|
|
378
|
+
TrackSubscribed = "trackSubscribed",
|
|
379
|
+
TrackUnsubscribed = "trackUnsubscribed",
|
|
380
|
+
TrackSubscriptionFailed = "trackSubscriptionFailed",
|
|
381
|
+
TrackMuted = "trackMuted",
|
|
382
|
+
TrackUnmuted = "trackUnmuted",
|
|
383
|
+
ActiveSpeakersChanged = "activeSpeakersChanged",
|
|
384
|
+
RoomMetadataChanged = "roomMetadataChanged",
|
|
385
|
+
RoomSidChanged = "roomSidChanged",
|
|
386
|
+
ParticipantMetadataChanged = "participantMetadataChanged",
|
|
387
|
+
ParticipantNameChanged = "participantNameChanged",
|
|
388
|
+
ParticipantAttributesChanged = "participantAttributesChanged",
|
|
389
|
+
ParticipantEncryptionStatusChanged = "participantEncryptionStatusChanged",
|
|
390
|
+
ConnectionQualityChanged = "connectionQualityChanged",
|
|
391
|
+
DataReceived = "dataReceived",
|
|
392
|
+
ChatMessage = "chatMessage",
|
|
393
|
+
DtmfReceived = "dtmfReceived",
|
|
394
|
+
EncryptionError = "encryptionError",
|
|
395
|
+
ConnectionStateChanged = "connectionStateChanged",
|
|
396
|
+
Connected = "connected",
|
|
397
|
+
Disconnected = "disconnected",
|
|
398
|
+
Reconnecting = "reconnecting",
|
|
399
|
+
Reconnected = "reconnected",
|
|
400
|
+
RoomUpdated = "roomUpdated",
|
|
401
|
+
Moved = "moved",
|
|
402
|
+
TokenRefreshed = "tokenRefreshed"
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
declare abstract class Track {
|
|
406
|
+
/** @internal */
|
|
407
|
+
info?: TrackInfo;
|
|
408
|
+
/** @internal */
|
|
409
|
+
ffi_handle: FfiHandle;
|
|
410
|
+
private roomRef;
|
|
411
|
+
private audioStreams;
|
|
412
|
+
private streamFinalizationRegistry;
|
|
413
|
+
private onRoomTokenRefreshed;
|
|
414
|
+
constructor(owned: OwnedTrack);
|
|
415
|
+
/** @internal */
|
|
416
|
+
resolveRoom(): Room | null;
|
|
417
|
+
/** @internal */
|
|
418
|
+
setRoom(room: Room | null): void;
|
|
419
|
+
/** @internal */
|
|
420
|
+
registerAudioStream(stream: AudioStreamSource): void;
|
|
421
|
+
/** @internal */
|
|
422
|
+
unregisterAudioStream(stream: AudioStreamSource): void;
|
|
423
|
+
private iterateStreams;
|
|
424
|
+
private pushProcessorMetadataToStream;
|
|
425
|
+
get sid(): string | undefined;
|
|
426
|
+
get name(): string | undefined;
|
|
427
|
+
get kind(): TrackKind | undefined;
|
|
428
|
+
get stream_state(): StreamState | undefined;
|
|
429
|
+
get muted(): boolean | undefined;
|
|
430
|
+
close(): Promise<void>;
|
|
431
|
+
}
|
|
432
|
+
declare class LocalAudioTrack extends Track {
|
|
433
|
+
private source?;
|
|
434
|
+
constructor(owned: OwnedTrack, source?: AudioSource);
|
|
435
|
+
static createAudioTrack(name: string, source: AudioSource): LocalAudioTrack;
|
|
436
|
+
close(closeSource?: boolean): Promise<void>;
|
|
437
|
+
}
|
|
438
|
+
declare class LocalVideoTrack extends Track {
|
|
439
|
+
private source?;
|
|
440
|
+
constructor(owned: OwnedTrack, source?: VideoSource);
|
|
441
|
+
static createVideoTrack(name: string, source: VideoSource): LocalVideoTrack;
|
|
442
|
+
close(closeSource?: boolean): Promise<void>;
|
|
443
|
+
}
|
|
444
|
+
declare class RemoteVideoTrack extends Track {
|
|
445
|
+
constructor(owned: OwnedTrack);
|
|
446
|
+
}
|
|
447
|
+
declare class RemoteAudioTrack extends Track {
|
|
448
|
+
constructor(owned: OwnedTrack);
|
|
449
|
+
}
|
|
450
|
+
type LocalTrack = LocalVideoTrack | LocalAudioTrack;
|
|
451
|
+
type RemoteTrack = RemoteVideoTrack | RemoteAudioTrack;
|
|
452
|
+
type AudioTrack = LocalAudioTrack | RemoteAudioTrack;
|
|
453
|
+
type VideoTrack = LocalVideoTrack | RemoteVideoTrack;
|
|
454
|
+
|
|
455
|
+
interface AudioStreamOptions {
|
|
456
|
+
noiseCancellation?: NoiseCancellationOptions | FrameProcessor<AudioFrame>;
|
|
457
|
+
/**
|
|
458
|
+
* When the audio stream closes, whether to run the {@link FrameProcessor}'s
|
|
459
|
+
* `close()` method. If `false`, the processor is left open so it can be
|
|
460
|
+
* reused with another {@link AudioStream}. Only relevant when
|
|
461
|
+
* `noiseCancellation` is a {@link FrameProcessor}. Defaults to `true`.
|
|
462
|
+
*/
|
|
463
|
+
autoCloseNoiseCancellation?: boolean;
|
|
464
|
+
sampleRate?: number;
|
|
465
|
+
numChannels?: number;
|
|
466
|
+
frameSizeMs?: number;
|
|
467
|
+
}
|
|
468
|
+
interface NoiseCancellationOptions {
|
|
469
|
+
moduleId: string;
|
|
470
|
+
options: Record<string, any>;
|
|
471
|
+
}
|
|
472
|
+
/** @internal */
|
|
473
|
+
declare class AudioStreamSource implements UnderlyingSource<AudioFrame> {
|
|
474
|
+
private controller?;
|
|
475
|
+
private ffiHandle;
|
|
476
|
+
private disposed;
|
|
477
|
+
private sampleRate;
|
|
478
|
+
private numChannels;
|
|
479
|
+
private legacyNcOptions?;
|
|
480
|
+
private frameProcessor;
|
|
481
|
+
private autoCloseProcessor;
|
|
482
|
+
private frameSizeMs?;
|
|
483
|
+
private track;
|
|
484
|
+
constructor(track: Track, sampleRateOrOptions?: number | AudioStreamOptions, numChannels?: number);
|
|
485
|
+
/** @internal */
|
|
486
|
+
get processor(): FrameProcessor<AudioFrame> | null;
|
|
487
|
+
private onEvent;
|
|
488
|
+
start(controller: ReadableStreamDefaultController<AudioFrame>): void;
|
|
489
|
+
cancel(): void;
|
|
490
|
+
}
|
|
491
|
+
declare class AudioStream extends ReadableStream<AudioFrame> {
|
|
492
|
+
constructor(track: Track);
|
|
493
|
+
constructor(track: Track, sampleRate: number);
|
|
494
|
+
constructor(track: Track, sampleRate: number, numChannels: number);
|
|
495
|
+
constructor(track: Track, options: AudioStreamOptions);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export { AudioStream as A, ConnectError as C, type DataPublishOptions as D, LocalAudioTrack as L, type NoiseCancellationOptions as N, Participant as P, RemoteAudioTrack as R, Track as T, type VideoTrack as V, type AudioTrack as a, LocalParticipant as b, type LocalTrack as c, LocalTrackPublication as d, LocalVideoTrack as e, RemoteParticipant as f, type RemoteTrack as g, RemoteTrackPublication as h, RemoteVideoTrack as i, Room as j, RoomEvent as k, type RoomOptions as l, type RtcConfiguration as m, TrackPublication as n, type RoomCallbacks as o, defaultRoomOptions as p, defaultRtcConfiguration as q, type AudioStreamOptions as r, AudioStreamSource as s };
|
package/dist/audio_stream.cjs
CHANGED
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var audio_stream_exports = {};
|
|
20
20
|
__export(audio_stream_exports, {
|
|
21
|
-
AudioStream: () => AudioStream
|
|
21
|
+
AudioStream: () => AudioStream,
|
|
22
|
+
AudioStreamSource: () => AudioStreamSource
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(audio_stream_exports);
|
|
24
25
|
var import_rtc_ffi_bindings = require("@livekit/rtc-ffi-bindings");
|
|
@@ -29,8 +30,9 @@ var import_log = require("./log.cjs");
|
|
|
29
30
|
class AudioStreamSource {
|
|
30
31
|
constructor(track, sampleRateOrOptions, numChannels) {
|
|
31
32
|
this.disposed = false;
|
|
33
|
+
this.frameProcessor = null;
|
|
34
|
+
this.autoCloseProcessor = true;
|
|
32
35
|
this.onEvent = (ev) => {
|
|
33
|
-
var _a;
|
|
34
36
|
if (!this.controller) {
|
|
35
37
|
throw new Error("Stream controller not initialized");
|
|
36
38
|
}
|
|
@@ -55,17 +57,22 @@ class AudioStreamSource {
|
|
|
55
57
|
this.controller.close();
|
|
56
58
|
if (!this.disposed) {
|
|
57
59
|
this.disposed = true;
|
|
60
|
+
this.track.unregisterAudioStream(this);
|
|
58
61
|
this.ffiHandle.dispose();
|
|
59
|
-
(
|
|
62
|
+
if (this.frameProcessor && this.autoCloseProcessor) {
|
|
63
|
+
this.frameProcessor.close();
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
66
|
break;
|
|
62
67
|
}
|
|
63
68
|
};
|
|
69
|
+
this.track = track;
|
|
64
70
|
if (sampleRateOrOptions !== void 0 && typeof sampleRateOrOptions !== "number") {
|
|
65
71
|
this.sampleRate = sampleRateOrOptions.sampleRate ?? 48e3;
|
|
66
72
|
this.numChannels = sampleRateOrOptions.numChannels ?? 1;
|
|
67
73
|
if ((0, import_frame_processor.isFrameProcessor)(sampleRateOrOptions.noiseCancellation)) {
|
|
68
74
|
this.frameProcessor = sampleRateOrOptions.noiseCancellation;
|
|
75
|
+
this.autoCloseProcessor = sampleRateOrOptions.autoCloseNoiseCancellation ?? true;
|
|
69
76
|
} else {
|
|
70
77
|
this.legacyNcOptions = sampleRateOrOptions.noiseCancellation;
|
|
71
78
|
}
|
|
@@ -93,17 +100,24 @@ class AudioStreamSource {
|
|
|
93
100
|
});
|
|
94
101
|
this.ffiHandle = new import_ffi_client.FfiHandle(res.stream.handle.id);
|
|
95
102
|
import_ffi_client.FfiClient.instance.on(import_ffi_client.FfiClientEvent.FfiEvent, this.onEvent);
|
|
103
|
+
track.registerAudioStream(this);
|
|
104
|
+
}
|
|
105
|
+
/** @internal */
|
|
106
|
+
get processor() {
|
|
107
|
+
return this.frameProcessor;
|
|
96
108
|
}
|
|
97
109
|
start(controller) {
|
|
98
110
|
this.controller = controller;
|
|
99
111
|
}
|
|
100
112
|
cancel() {
|
|
101
|
-
var _a;
|
|
102
113
|
import_ffi_client.FfiClient.instance.off(import_ffi_client.FfiClientEvent.FfiEvent, this.onEvent);
|
|
103
114
|
if (!this.disposed) {
|
|
104
115
|
this.disposed = true;
|
|
116
|
+
this.track.unregisterAudioStream(this);
|
|
105
117
|
this.ffiHandle.dispose();
|
|
106
|
-
(
|
|
118
|
+
if (this.frameProcessor && this.autoCloseProcessor) {
|
|
119
|
+
this.frameProcessor.close();
|
|
120
|
+
}
|
|
107
121
|
}
|
|
108
122
|
}
|
|
109
123
|
}
|
|
@@ -114,6 +128,7 @@ class AudioStream extends ReadableStream {
|
|
|
114
128
|
}
|
|
115
129
|
// Annotate the CommonJS export names for ESM import in node:
|
|
116
130
|
0 && (module.exports = {
|
|
117
|
-
AudioStream
|
|
131
|
+
AudioStream,
|
|
132
|
+
AudioStreamSource
|
|
118
133
|
});
|
|
119
134
|
//# sourceMappingURL=audio_stream.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/audio_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { NewAudioStreamResponse } from '@livekit/rtc-ffi-bindings';\nimport { AudioStreamType, NewAudioStreamRequest } from '@livekit/rtc-ffi-bindings';\nimport type { UnderlyingSource } from 'node:stream/web';\nimport { AudioFrame } from './audio_frame.js';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport { type FrameProcessor, isFrameProcessor } from './frame_processor.js';\nimport { log } from './log.js';\nimport type { Track } from './track.js';\n\nexport interface AudioStreamOptions {\n noiseCancellation?: NoiseCancellationOptions | FrameProcessor<AudioFrame>;\n sampleRate?: number;\n numChannels?: number;\n frameSizeMs?: number;\n}\n\nexport interface NoiseCancellationOptions {\n moduleId: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: Record<string, any>;\n}\n\
|
|
1
|
+
{"version":3,"sources":["../src/audio_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { NewAudioStreamResponse } from '@livekit/rtc-ffi-bindings';\nimport { AudioStreamType, NewAudioStreamRequest } from '@livekit/rtc-ffi-bindings';\nimport type { UnderlyingSource } from 'node:stream/web';\nimport { AudioFrame } from './audio_frame.js';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport { type FrameProcessor, isFrameProcessor } from './frame_processor.js';\nimport { log } from './log.js';\nimport type { Track } from './track.js';\n\nexport interface AudioStreamOptions {\n noiseCancellation?: NoiseCancellationOptions | FrameProcessor<AudioFrame>;\n /**\n * When the audio stream closes, whether to run the {@link FrameProcessor}'s\n * `close()` method. If `false`, the processor is left open so it can be\n * reused with another {@link AudioStream}. Only relevant when\n * `noiseCancellation` is a {@link FrameProcessor}. Defaults to `true`.\n */\n autoCloseNoiseCancellation?: boolean;\n sampleRate?: number;\n numChannels?: number;\n frameSizeMs?: number;\n}\n\nexport interface NoiseCancellationOptions {\n moduleId: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: Record<string, any>;\n}\n\n/** @internal */\nexport class AudioStreamSource implements UnderlyingSource<AudioFrame> {\n private controller?: ReadableStreamDefaultController<AudioFrame>;\n private ffiHandle: FfiHandle;\n private disposed = false;\n private sampleRate: number;\n private numChannels: number;\n private legacyNcOptions?: NoiseCancellationOptions;\n private frameProcessor: FrameProcessor<AudioFrame> | null = null;\n private autoCloseProcessor = true;\n private frameSizeMs?: number;\n private track: Track;\n\n constructor(\n track: Track,\n sampleRateOrOptions?: number | AudioStreamOptions,\n numChannels?: number,\n ) {\n this.track = track;\n if (sampleRateOrOptions !== undefined && typeof sampleRateOrOptions !== 'number') {\n this.sampleRate = sampleRateOrOptions.sampleRate ?? 48000;\n this.numChannels = sampleRateOrOptions.numChannels ?? 1;\n if (isFrameProcessor(sampleRateOrOptions.noiseCancellation)) {\n this.frameProcessor = sampleRateOrOptions.noiseCancellation;\n this.autoCloseProcessor = sampleRateOrOptions.autoCloseNoiseCancellation ?? true;\n } else {\n this.legacyNcOptions = sampleRateOrOptions.noiseCancellation;\n }\n this.frameSizeMs = sampleRateOrOptions.frameSizeMs;\n } else {\n this.sampleRate = (sampleRateOrOptions as number) ?? 48000;\n this.numChannels = numChannels ?? 1;\n }\n\n const req = new NewAudioStreamRequest({\n type: AudioStreamType.AUDIO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n sampleRate: this.sampleRate,\n numChannels: this.numChannels,\n frameSizeMs: this.frameSizeMs,\n ...(this.legacyNcOptions\n ? {\n audioFilterModuleId: this.legacyNcOptions.moduleId,\n audioFilterOptions: JSON.stringify(this.legacyNcOptions.options),\n }\n : {}),\n });\n\n const res = FfiClient.instance.request<NewAudioStreamResponse>({\n message: {\n case: 'newAudioStream',\n value: req,\n },\n });\n\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);\n\n FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);\n track.registerAudioStream(this);\n }\n\n /** @internal */\n get processor(): FrameProcessor<AudioFrame> | null {\n return this.frameProcessor;\n }\n\n private onEvent = (ev: FfiEvent) => {\n if (!this.controller) {\n throw new Error('Stream controller not initialized');\n }\n\n if (\n ev.message.case != 'audioStreamEvent' ||\n ev.message.value.streamHandle != this.ffiHandle.handle\n ) {\n return;\n }\n\n const streamEvent = ev.message.value.message;\n switch (streamEvent.case) {\n case 'frameReceived':\n let frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame!);\n if (this.frameProcessor && this.frameProcessor.isEnabled()) {\n try {\n frame = this.frameProcessor.process(frame);\n } catch (err: unknown) {\n log.warn(`Frame processing failed, passing through original frame: ${err}`);\n }\n }\n this.controller.enqueue(frame);\n break;\n case 'eos':\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.controller.close();\n // Dispose the native handle so the FD is released on stream end,\n // not just when cancel() is called explicitly by the consumer.\n // Guard against double-dispose if cancel() is called after EOS\n // while buffered frames are still in the ReadableStream queue.\n if (!this.disposed) {\n this.disposed = true;\n this.track.unregisterAudioStream(this);\n this.ffiHandle.dispose();\n if (this.frameProcessor && this.autoCloseProcessor) {\n this.frameProcessor.close();\n }\n }\n break;\n }\n };\n\n start(controller: ReadableStreamDefaultController<AudioFrame>) {\n this.controller = controller;\n }\n\n cancel() {\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n if (!this.disposed) {\n this.disposed = true;\n this.track.unregisterAudioStream(this);\n this.ffiHandle.dispose();\n // Also close the frame processor on cancel for symmetry with the EOS path,\n // so resources are released regardless of how the stream ends.\n if (this.frameProcessor && this.autoCloseProcessor) {\n this.frameProcessor.close();\n }\n }\n }\n}\n\nexport class AudioStream extends ReadableStream<AudioFrame> {\n constructor(track: Track);\n constructor(track: Track, sampleRate: number);\n constructor(track: Track, sampleRate: number, numChannels: number);\n constructor(track: Track, options: AudioStreamOptions);\n constructor(\n track: Track,\n sampleRateOrOptions?: number | AudioStreamOptions,\n numChannels?: number,\n ) {\n super(new AudioStreamSource(track, sampleRateOrOptions, numChannels));\n }\n}\n"],"mappings":"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","names":[]}
|
package/dist/audio_stream.d.cts
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import 'node:stream/web';
|
|
2
|
+
import './audio_frame.cjs';
|
|
3
|
+
import './frame_processor.cjs';
|
|
4
|
+
export { A as AudioStream, r as AudioStreamOptions, s as AudioStreamSource, N as NoiseCancellationOptions } from './audio_stream-B4hGVcKz.cjs';
|
|
4
5
|
import '@livekit/rtc-ffi-bindings';
|
|
5
6
|
import './video_frame.cjs';
|
|
6
7
|
import './audio_source.cjs';
|
|
7
8
|
import './ffi_client.cjs';
|
|
8
9
|
import '@livekit/typed-emitter';
|
|
10
|
+
import './types-_PdPVish.cjs';
|
|
11
|
+
import './e2ee.cjs';
|
|
12
|
+
import '@livekit/mutex';
|
|
13
|
+
import 'node:fs';
|
|
14
|
+
import './data_streams/stream_writer.cjs';
|
|
15
|
+
import './rpc.cjs';
|
|
16
|
+
import './transcription.cjs';
|
|
17
|
+
import './types.cjs';
|
|
9
18
|
import './video_source.cjs';
|
|
10
|
-
|
|
11
|
-
interface AudioStreamOptions {
|
|
12
|
-
noiseCancellation?: NoiseCancellationOptions | FrameProcessor<AudioFrame>;
|
|
13
|
-
sampleRate?: number;
|
|
14
|
-
numChannels?: number;
|
|
15
|
-
frameSizeMs?: number;
|
|
16
|
-
}
|
|
17
|
-
interface NoiseCancellationOptions {
|
|
18
|
-
moduleId: string;
|
|
19
|
-
options: Record<string, any>;
|
|
20
|
-
}
|
|
21
|
-
declare class AudioStream extends ReadableStream<AudioFrame> {
|
|
22
|
-
constructor(track: Track);
|
|
23
|
-
constructor(track: Track, sampleRate: number);
|
|
24
|
-
constructor(track: Track, sampleRate: number, numChannels: number);
|
|
25
|
-
constructor(track: Track, options: AudioStreamOptions);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { AudioStream, type AudioStreamOptions, type NoiseCancellationOptions };
|