@livekit/rtc-node 0.13.3 → 0.13.5
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/data_streams/index.cjs +25 -0
- package/dist/data_streams/index.cjs.map +1 -0
- package/dist/data_streams/index.d.cts +11 -0
- package/dist/data_streams/index.d.ts +11 -0
- package/dist/data_streams/index.d.ts.map +1 -0
- package/dist/data_streams/index.js +3 -0
- package/dist/data_streams/index.js.map +1 -0
- package/dist/data_streams/stream_reader.cjs +141 -0
- package/dist/data_streams/stream_reader.cjs.map +1 -0
- package/dist/data_streams/stream_reader.d.cts +10 -0
- package/dist/data_streams/stream_reader.d.ts +10 -0
- package/dist/data_streams/stream_reader.d.ts.map +1 -0
- package/dist/data_streams/stream_reader.js +116 -0
- package/dist/data_streams/stream_reader.js.map +1 -0
- package/dist/data_streams/stream_writer.cjs +51 -0
- package/dist/data_streams/stream_writer.cjs.map +1 -0
- package/dist/data_streams/stream_writer.d.cts +26 -0
- package/dist/data_streams/stream_writer.d.ts +26 -0
- package/dist/data_streams/stream_writer.d.ts.map +1 -0
- package/dist/data_streams/stream_writer.js +26 -0
- package/dist/data_streams/stream_writer.js.map +1 -0
- package/dist/data_streams/types.cjs +17 -0
- package/dist/data_streams/types.cjs.map +1 -0
- package/dist/data_streams/types.d.cts +10 -0
- package/dist/data_streams/types.d.ts +10 -0
- package/dist/data_streams/types.d.ts.map +1 -0
- package/dist/data_streams/types.js +1 -0
- package/dist/data_streams/types.js.map +1 -0
- package/dist/index.cjs +7 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/log.cjs +42 -0
- package/dist/log.cjs.map +1 -0
- package/dist/log.d.cts +7 -0
- package/dist/log.d.ts +7 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +18 -0
- package/dist/log.js.map +1 -0
- package/dist/napi/native.d.cjs.map +1 -1
- package/dist/napi/native.d.ts +5 -5
- package/dist/native.d.ts +5 -5
- package/dist/participant.cjs +249 -16
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +40 -6
- package/dist/participant.d.ts +40 -6
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +252 -5
- package/dist/participant.js.map +1 -1
- package/dist/proto/ffi_pb.cjs +14 -3
- package/dist/proto/ffi_pb.cjs.map +1 -1
- package/dist/proto/ffi_pb.d.cts +81 -7
- package/dist/proto/ffi_pb.d.ts +81 -7
- package/dist/proto/ffi_pb.d.ts.map +1 -1
- package/dist/proto/ffi_pb.js +15 -4
- package/dist/proto/ffi_pb.js.map +1 -1
- package/dist/proto/room_pb.cjs +488 -30
- package/dist/proto/room_pb.cjs.map +1 -1
- package/dist/proto/room_pb.d.cts +412 -50
- package/dist/proto/room_pb.d.ts +412 -50
- package/dist/proto/room_pb.d.ts.map +1 -1
- package/dist/proto/room_pb.js +471 -29
- package/dist/proto/room_pb.js.map +1 -1
- package/dist/proto/video_frame_pb.cjs.map +1 -1
- package/dist/proto/video_frame_pb.d.cts +3 -0
- package/dist/proto/video_frame_pb.d.ts +3 -0
- package/dist/proto/video_frame_pb.d.ts.map +1 -1
- package/dist/proto/video_frame_pb.js.map +1 -1
- package/dist/room.cjs +121 -0
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +17 -2
- package/dist/room.d.ts +17 -2
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +122 -0
- package/dist/room.js.map +1 -1
- package/dist/types-B28ZM-Ci.d.cts +88 -0
- package/dist/types-BDnbvXeD.d.ts +88 -0
- package/dist/utils.cjs +61 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +7 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +35 -0
- package/dist/utils.js.map +1 -0
- 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_frame.cjs +2 -0
- package/dist/video_frame.cjs.map +1 -1
- package/dist/video_frame.d.ts.map +1 -1
- package/dist/video_frame.js +2 -0
- package/dist/video_frame.js.map +1 -1
- package/package.json +9 -7
- package/src/data_streams/index.ts +7 -0
- package/src/data_streams/stream_reader.ts +159 -0
- package/src/data_streams/stream_writer.ts +36 -0
- package/src/data_streams/types.ts +55 -0
- package/src/index.ts +1 -0
- package/src/log.ts +25 -0
- package/src/napi/native.d.ts +5 -5
- package/src/participant.ts +337 -29
- package/src/proto/ffi_pb.ts +86 -1
- package/src/proto/room_pb.ts +788 -68
- package/src/proto/video_frame_pb.ts +3 -0
- package/src/room.ts +141 -0
- package/src/utils.test.ts +51 -0
- package/src/utils.ts +42 -0
- package/src/version.ts +1 -1
- package/src/video_frame.ts +2 -0
package/src/participant.ts
CHANGED
|
@@ -1,33 +1,59 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import { Mutex } from '@livekit/mutex';
|
|
5
|
+
import type { PathLike } from 'node:fs';
|
|
6
|
+
import { open, stat } from 'node:fs/promises';
|
|
7
|
+
import {
|
|
8
|
+
type ByteStreamInfo,
|
|
9
|
+
type ByteStreamOptions,
|
|
10
|
+
ByteStreamWriter,
|
|
11
|
+
type TextStreamInfo,
|
|
12
|
+
TextStreamWriter,
|
|
13
|
+
} from './data_streams/index.js';
|
|
4
14
|
import { FfiClient, FfiHandle } from './ffi_client.js';
|
|
15
|
+
import { log } from './log.js';
|
|
5
16
|
import {
|
|
6
17
|
DisconnectReason,
|
|
7
18
|
type OwnedParticipant,
|
|
8
19
|
type ParticipantInfo,
|
|
9
|
-
|
|
20
|
+
ParticipantKind,
|
|
10
21
|
} from './proto/participant_pb.js';
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
import {
|
|
23
|
+
DataStream_ByteHeader,
|
|
24
|
+
DataStream_Chunk,
|
|
25
|
+
DataStream_Header,
|
|
26
|
+
DataStream_OperationType,
|
|
27
|
+
DataStream_TextHeader,
|
|
28
|
+
DataStream_Trailer,
|
|
29
|
+
type PublishDataCallback,
|
|
30
|
+
type PublishDataResponse,
|
|
31
|
+
type PublishSipDtmfCallback,
|
|
32
|
+
type PublishSipDtmfResponse,
|
|
33
|
+
type PublishTrackCallback,
|
|
34
|
+
type PublishTrackResponse,
|
|
35
|
+
type PublishTranscriptionCallback,
|
|
36
|
+
type PublishTranscriptionResponse,
|
|
37
|
+
type SendChatMessageCallback,
|
|
38
|
+
type SendChatMessageResponse,
|
|
39
|
+
type SendStreamChunkCallback,
|
|
40
|
+
SendStreamChunkRequest,
|
|
41
|
+
type SendStreamChunkResponse,
|
|
42
|
+
type SendStreamHeaderCallback,
|
|
43
|
+
SendStreamHeaderRequest,
|
|
44
|
+
type SendStreamHeaderResponse,
|
|
45
|
+
type SendStreamTrailerCallback,
|
|
46
|
+
SendStreamTrailerRequest,
|
|
47
|
+
type SendStreamTrailerResponse,
|
|
48
|
+
type SetLocalAttributesCallback,
|
|
49
|
+
type SetLocalAttributesResponse,
|
|
50
|
+
type SetLocalMetadataCallback,
|
|
51
|
+
type SetLocalMetadataResponse,
|
|
52
|
+
type SetLocalNameCallback,
|
|
53
|
+
type SetLocalNameResponse,
|
|
54
|
+
type TrackPublishOptions,
|
|
55
|
+
type UnpublishTrackCallback,
|
|
56
|
+
type UnpublishTrackResponse,
|
|
31
57
|
} from './proto/room_pb.js';
|
|
32
58
|
import { ChatMessage as ChatMessageModel } from './proto/room_pb.js';
|
|
33
59
|
import {
|
|
@@ -62,6 +88,9 @@ import type { RemoteTrackPublication, TrackPublication } from './track_publicati
|
|
|
62
88
|
import { LocalTrackPublication } from './track_publication.js';
|
|
63
89
|
import type { Transcription } from './transcription.js';
|
|
64
90
|
import type { ChatMessage } from './types.js';
|
|
91
|
+
import { numberToBigInt, splitUtf8 } from './utils.js';
|
|
92
|
+
|
|
93
|
+
const STREAM_CHUNK_SIZE = 15_000;
|
|
65
94
|
|
|
66
95
|
export abstract class Participant {
|
|
67
96
|
/** @internal */
|
|
@@ -85,20 +114,20 @@ export abstract class Participant {
|
|
|
85
114
|
return this.info.name;
|
|
86
115
|
}
|
|
87
116
|
|
|
88
|
-
get identity(): string
|
|
89
|
-
return this.info.identity;
|
|
117
|
+
get identity(): string {
|
|
118
|
+
return this.info.identity ?? '';
|
|
90
119
|
}
|
|
91
120
|
|
|
92
|
-
get metadata(): string
|
|
93
|
-
return this.info.metadata;
|
|
121
|
+
get metadata(): string {
|
|
122
|
+
return this.info.metadata ?? '';
|
|
94
123
|
}
|
|
95
124
|
|
|
96
|
-
get attributes(): Record<string, string>
|
|
97
|
-
return this.info.attributes;
|
|
125
|
+
get attributes(): Record<string, string> {
|
|
126
|
+
return this.info.attributes ?? {};
|
|
98
127
|
}
|
|
99
128
|
|
|
100
|
-
get kind(): ParticipantKind
|
|
101
|
-
return this.info.kind;
|
|
129
|
+
get kind(): ParticipantKind {
|
|
130
|
+
return this.info.kind ?? ParticipantKind.STANDARD;
|
|
102
131
|
}
|
|
103
132
|
|
|
104
133
|
get disconnectReason(): DisconnectReason | undefined {
|
|
@@ -219,6 +248,285 @@ export class LocalParticipant extends Participant {
|
|
|
219
248
|
});
|
|
220
249
|
}
|
|
221
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Returns a `StreamWriter` instance that allows to write individual chunks of text to a stream.
|
|
253
|
+
* Well suited for TTS and/or streaming LLM output. If you want to simply send a text then use sendText() instead
|
|
254
|
+
*/
|
|
255
|
+
async streamText(options?: {
|
|
256
|
+
topic?: string;
|
|
257
|
+
attributes?: Record<string, string>;
|
|
258
|
+
destinationIdentities?: Array<string>;
|
|
259
|
+
streamId?: string;
|
|
260
|
+
}): Promise<TextStreamWriter> {
|
|
261
|
+
const senderIdentity = this.identity;
|
|
262
|
+
const streamId = options?.streamId ?? crypto.randomUUID();
|
|
263
|
+
const destinationIdentities = options?.destinationIdentities;
|
|
264
|
+
|
|
265
|
+
const info: TextStreamInfo = {
|
|
266
|
+
streamId: streamId,
|
|
267
|
+
mimeType: 'text/plain',
|
|
268
|
+
topic: options?.topic ?? '',
|
|
269
|
+
timestamp: Date.now(),
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const headerReq = new SendStreamHeaderRequest({
|
|
273
|
+
senderIdentity,
|
|
274
|
+
destinationIdentities,
|
|
275
|
+
localParticipantHandle: this.ffi_handle.handle,
|
|
276
|
+
header: new DataStream_Header({
|
|
277
|
+
streamId,
|
|
278
|
+
mimeType: info.mimeType,
|
|
279
|
+
topic: info.topic,
|
|
280
|
+
timestamp: numberToBigInt(info.timestamp),
|
|
281
|
+
attributes: options?.attributes,
|
|
282
|
+
contentHeader: {
|
|
283
|
+
case: 'textHeader',
|
|
284
|
+
value: new DataStream_TextHeader({
|
|
285
|
+
operationType: DataStream_OperationType.CREATE,
|
|
286
|
+
version: 0,
|
|
287
|
+
replyToStreamId: '',
|
|
288
|
+
generated: false,
|
|
289
|
+
}),
|
|
290
|
+
},
|
|
291
|
+
}),
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
await this.sendStreamHeader(headerReq);
|
|
295
|
+
|
|
296
|
+
let nextChunkId = 0;
|
|
297
|
+
const localHandle = this.ffi_handle.handle;
|
|
298
|
+
const sendTrailer = this.sendStreamTrailer;
|
|
299
|
+
const sendChunk = this.sendStreamChunk;
|
|
300
|
+
|
|
301
|
+
const writableStream = new WritableStream<string>({
|
|
302
|
+
// Implement the sink
|
|
303
|
+
async write(text) {
|
|
304
|
+
for (const textByteChunk of splitUtf8(text, STREAM_CHUNK_SIZE)) {
|
|
305
|
+
const chunkRequest = new SendStreamChunkRequest({
|
|
306
|
+
senderIdentity,
|
|
307
|
+
localParticipantHandle: localHandle,
|
|
308
|
+
destinationIdentities,
|
|
309
|
+
chunk: new DataStream_Chunk({
|
|
310
|
+
content: textByteChunk,
|
|
311
|
+
streamId,
|
|
312
|
+
chunkIndex: numberToBigInt(nextChunkId),
|
|
313
|
+
}),
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
await sendChunk(chunkRequest);
|
|
317
|
+
nextChunkId += 1;
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
async close() {
|
|
321
|
+
const trailerReq = new SendStreamTrailerRequest({
|
|
322
|
+
senderIdentity,
|
|
323
|
+
localParticipantHandle: localHandle,
|
|
324
|
+
destinationIdentities,
|
|
325
|
+
trailer: new DataStream_Trailer({
|
|
326
|
+
streamId,
|
|
327
|
+
reason: '',
|
|
328
|
+
}),
|
|
329
|
+
});
|
|
330
|
+
await sendTrailer(trailerReq);
|
|
331
|
+
},
|
|
332
|
+
abort(err) {
|
|
333
|
+
log.error('Sink error:', err);
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
const writer = new TextStreamWriter(writableStream, info);
|
|
338
|
+
|
|
339
|
+
return writer;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async sendText(
|
|
343
|
+
text: string,
|
|
344
|
+
options?: {
|
|
345
|
+
topic?: string;
|
|
346
|
+
attributes?: Record<string, string>;
|
|
347
|
+
destinationIdentities?: Array<string>;
|
|
348
|
+
streamId?: string;
|
|
349
|
+
},
|
|
350
|
+
) {
|
|
351
|
+
const writer = await this.streamText(options);
|
|
352
|
+
await writer.write(text);
|
|
353
|
+
await writer.close();
|
|
354
|
+
return writer.info;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async streamBytes(options?: {
|
|
358
|
+
name?: string;
|
|
359
|
+
topic?: string;
|
|
360
|
+
attributes?: Record<string, string>;
|
|
361
|
+
destinationIdentities?: Array<string>;
|
|
362
|
+
streamId?: string;
|
|
363
|
+
mimeType?: string;
|
|
364
|
+
totalSize?: number;
|
|
365
|
+
}) {
|
|
366
|
+
const senderIdentity = this.identity;
|
|
367
|
+
const streamId = options?.streamId ?? crypto.randomUUID();
|
|
368
|
+
const destinationIdentities = options?.destinationIdentities;
|
|
369
|
+
|
|
370
|
+
const info: ByteStreamInfo = {
|
|
371
|
+
streamId: streamId,
|
|
372
|
+
mimeType: options?.mimeType ?? 'application/octet-stream',
|
|
373
|
+
topic: options?.topic ?? '',
|
|
374
|
+
timestamp: Date.now(),
|
|
375
|
+
attributes: options?.attributes,
|
|
376
|
+
totalSize: options?.totalSize,
|
|
377
|
+
name: options?.name ?? 'unknown',
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
const headerReq = new SendStreamHeaderRequest({
|
|
381
|
+
senderIdentity,
|
|
382
|
+
destinationIdentities,
|
|
383
|
+
localParticipantHandle: this.ffi_handle.handle,
|
|
384
|
+
header: new DataStream_Header({
|
|
385
|
+
streamId,
|
|
386
|
+
mimeType: info.mimeType,
|
|
387
|
+
topic: info.topic,
|
|
388
|
+
timestamp: numberToBigInt(info.timestamp),
|
|
389
|
+
attributes: info.attributes,
|
|
390
|
+
totalLength: numberToBigInt(info.totalSize),
|
|
391
|
+
contentHeader: {
|
|
392
|
+
case: 'byteHeader',
|
|
393
|
+
value: new DataStream_ByteHeader({
|
|
394
|
+
name: info.name,
|
|
395
|
+
}),
|
|
396
|
+
},
|
|
397
|
+
}),
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
await this.sendStreamHeader(headerReq);
|
|
401
|
+
|
|
402
|
+
let chunkId = 0;
|
|
403
|
+
const localHandle = this.ffi_handle.handle;
|
|
404
|
+
const sendTrailer = this.sendStreamTrailer;
|
|
405
|
+
const sendChunk = this.sendStreamChunk;
|
|
406
|
+
const writeMutex = new Mutex();
|
|
407
|
+
|
|
408
|
+
const writableStream = new WritableStream<Uint8Array>({
|
|
409
|
+
async write(chunk) {
|
|
410
|
+
const unlock = await writeMutex.lock();
|
|
411
|
+
|
|
412
|
+
let byteOffset = 0;
|
|
413
|
+
try {
|
|
414
|
+
while (byteOffset < chunk.byteLength) {
|
|
415
|
+
const subChunk = chunk.slice(byteOffset, byteOffset + STREAM_CHUNK_SIZE);
|
|
416
|
+
const chunkRequest = new SendStreamChunkRequest({
|
|
417
|
+
senderIdentity,
|
|
418
|
+
localParticipantHandle: localHandle,
|
|
419
|
+
destinationIdentities,
|
|
420
|
+
chunk: new DataStream_Chunk({
|
|
421
|
+
content: subChunk,
|
|
422
|
+
streamId,
|
|
423
|
+
chunkIndex: numberToBigInt(chunkId),
|
|
424
|
+
}),
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
await sendChunk(chunkRequest);
|
|
428
|
+
chunkId += 1;
|
|
429
|
+
byteOffset += subChunk.byteLength;
|
|
430
|
+
}
|
|
431
|
+
} finally {
|
|
432
|
+
unlock();
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
async close() {
|
|
436
|
+
const trailerReq = new SendStreamTrailerRequest({
|
|
437
|
+
senderIdentity,
|
|
438
|
+
localParticipantHandle: localHandle,
|
|
439
|
+
destinationIdentities,
|
|
440
|
+
trailer: new DataStream_Trailer({
|
|
441
|
+
streamId,
|
|
442
|
+
reason: '',
|
|
443
|
+
}),
|
|
444
|
+
});
|
|
445
|
+
await sendTrailer(trailerReq);
|
|
446
|
+
},
|
|
447
|
+
abort(err) {
|
|
448
|
+
log.error('Sink error:', err);
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
const byteWriter = new ByteStreamWriter(writableStream, info);
|
|
453
|
+
|
|
454
|
+
return byteWriter;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** Sends a file provided as PathLike to specified recipients */
|
|
458
|
+
async sendFile(path: PathLike, options?: ByteStreamOptions) {
|
|
459
|
+
const fileStats = await stat(path);
|
|
460
|
+
const file = await open(path);
|
|
461
|
+
try {
|
|
462
|
+
const stream: ReadableStream<Uint8Array> = file.readableWebStream({ type: 'bytes' });
|
|
463
|
+
const streamId = crypto.randomUUID();
|
|
464
|
+
const destinationIdentities = options?.destinationIdentities;
|
|
465
|
+
|
|
466
|
+
const writer = await this.streamBytes({
|
|
467
|
+
streamId: streamId,
|
|
468
|
+
name: options?.name,
|
|
469
|
+
totalSize: fileStats.size,
|
|
470
|
+
destinationIdentities,
|
|
471
|
+
topic: options?.topic,
|
|
472
|
+
mimeType: options?.mimeType,
|
|
473
|
+
attributes: options?.attributes,
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
for await (const chunk of stream) {
|
|
477
|
+
await writer.write(chunk);
|
|
478
|
+
}
|
|
479
|
+
await writer.close();
|
|
480
|
+
} finally {
|
|
481
|
+
await file.close();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
private async sendStreamHeader(req: SendStreamHeaderRequest) {
|
|
486
|
+
const type = 'sendStreamHeader';
|
|
487
|
+
const res = FfiClient.instance.request<SendStreamHeaderResponse>({
|
|
488
|
+
message: { case: type, value: req },
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
const cb = await FfiClient.instance.waitFor<SendStreamHeaderCallback>((ev) => {
|
|
492
|
+
return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
if (cb.error) {
|
|
496
|
+
throw new Error(cb.error);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
private async sendStreamChunk(req: SendStreamChunkRequest) {
|
|
501
|
+
const type = 'sendStreamChunk';
|
|
502
|
+
const res = FfiClient.instance.request<SendStreamChunkResponse>({
|
|
503
|
+
message: { case: type, value: req },
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
const cb = await FfiClient.instance.waitFor<SendStreamChunkCallback>((ev) => {
|
|
507
|
+
return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
if (cb.error) {
|
|
511
|
+
throw new Error(cb.error);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
private async sendStreamTrailer(req: SendStreamTrailerRequest) {
|
|
516
|
+
const type = 'sendStreamTrailer';
|
|
517
|
+
const res = FfiClient.instance.request<SendStreamTrailerResponse>({
|
|
518
|
+
message: { case: type, value: req },
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
const cb = await FfiClient.instance.waitFor<SendStreamTrailerCallback>((ev) => {
|
|
522
|
+
return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
if (cb.error) {
|
|
526
|
+
throw new Error(cb.error);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
222
530
|
/**
|
|
223
531
|
* Sends a chat message to participants in the room
|
|
224
532
|
*
|
package/src/proto/ffi_pb.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
|
|
21
21
|
import { Message, proto2 } from "@bufbuild/protobuf";
|
|
22
|
-
import { ConnectCallback, ConnectRequest, ConnectResponse, DisconnectCallback, DisconnectRequest, DisconnectResponse, EditChatMessageRequest, GetSessionStatsCallback, GetSessionStatsRequest, GetSessionStatsResponse, PublishDataCallback, PublishDataRequest, PublishDataResponse, PublishSipDtmfCallback, PublishSipDtmfRequest, PublishSipDtmfResponse, PublishTrackCallback, PublishTrackRequest, PublishTrackResponse, PublishTranscriptionCallback, PublishTranscriptionRequest, PublishTranscriptionResponse, RoomEvent, SendChatMessageCallback, SendChatMessageRequest, SendChatMessageResponse, SetLocalAttributesCallback, SetLocalAttributesRequest, SetLocalAttributesResponse, SetLocalMetadataCallback, SetLocalMetadataRequest, SetLocalMetadataResponse, SetLocalNameCallback, SetLocalNameRequest, SetLocalNameResponse, SetSubscribedRequest, SetSubscribedResponse, UnpublishTrackCallback, UnpublishTrackRequest, UnpublishTrackResponse } from "./room_pb.js";
|
|
22
|
+
import { ConnectCallback, ConnectRequest, ConnectResponse, DisconnectCallback, DisconnectRequest, DisconnectResponse, EditChatMessageRequest, GetSessionStatsCallback, GetSessionStatsRequest, GetSessionStatsResponse, PublishDataCallback, PublishDataRequest, PublishDataResponse, PublishSipDtmfCallback, PublishSipDtmfRequest, PublishSipDtmfResponse, PublishTrackCallback, PublishTrackRequest, PublishTrackResponse, PublishTranscriptionCallback, PublishTranscriptionRequest, PublishTranscriptionResponse, RoomEvent, SendChatMessageCallback, SendChatMessageRequest, SendChatMessageResponse, SendStreamChunkCallback, SendStreamChunkRequest, SendStreamChunkResponse, SendStreamHeaderCallback, SendStreamHeaderRequest, SendStreamHeaderResponse, SendStreamTrailerCallback, SendStreamTrailerRequest, SendStreamTrailerResponse, SetDataChannelBufferedAmountLowThresholdRequest, SetDataChannelBufferedAmountLowThresholdResponse, SetLocalAttributesCallback, SetLocalAttributesRequest, SetLocalAttributesResponse, SetLocalMetadataCallback, SetLocalMetadataRequest, SetLocalMetadataResponse, SetLocalNameCallback, SetLocalNameRequest, SetLocalNameResponse, SetSubscribedRequest, SetSubscribedResponse, UnpublishTrackCallback, UnpublishTrackRequest, UnpublishTrackResponse } from "./room_pb.js";
|
|
23
23
|
import { CreateAudioTrackRequest, CreateAudioTrackResponse, CreateVideoTrackRequest, CreateVideoTrackResponse, EnableRemoteTrackRequest, EnableRemoteTrackResponse, GetStatsCallback, GetStatsRequest, GetStatsResponse, LocalTrackMuteRequest, LocalTrackMuteResponse, TrackEvent } from "./track_pb.js";
|
|
24
24
|
import { CaptureVideoFrameRequest, CaptureVideoFrameResponse, NewVideoSourceRequest, NewVideoSourceResponse, NewVideoStreamRequest, NewVideoStreamResponse, VideoConvertRequest, VideoConvertResponse, VideoStreamEvent, VideoStreamFromParticipantRequest, VideoStreamFromParticipantResponse } from "./video_frame_pb.js";
|
|
25
25
|
import { AudioStreamEvent, AudioStreamFromParticipantRequest, AudioStreamFromParticipantResponse, CaptureAudioFrameCallback, CaptureAudioFrameRequest, CaptureAudioFrameResponse, ClearAudioBufferRequest, ClearAudioBufferResponse, FlushSoxResamplerRequest, FlushSoxResamplerResponse, NewAudioResamplerRequest, NewAudioResamplerResponse, NewAudioSourceRequest, NewAudioSourceResponse, NewAudioStreamRequest, NewAudioStreamResponse, NewSoxResamplerRequest, NewSoxResamplerResponse, PushSoxResamplerRequest, PushSoxResamplerResponse, RemixAndResampleRequest, RemixAndResampleResponse } from "./audio_frame_pb.js";
|
|
@@ -339,6 +339,34 @@ export class FfiRequest extends Message<FfiRequest> {
|
|
|
339
339
|
*/
|
|
340
340
|
value: UpdateRemoteTrackPublicationDimensionRequest;
|
|
341
341
|
case: "updateRemoteTrackPublicationDimension";
|
|
342
|
+
} | {
|
|
343
|
+
/**
|
|
344
|
+
* Data Streams
|
|
345
|
+
*
|
|
346
|
+
* @generated from field: livekit.proto.SendStreamHeaderRequest send_stream_header = 44;
|
|
347
|
+
*/
|
|
348
|
+
value: SendStreamHeaderRequest;
|
|
349
|
+
case: "sendStreamHeader";
|
|
350
|
+
} | {
|
|
351
|
+
/**
|
|
352
|
+
* @generated from field: livekit.proto.SendStreamChunkRequest send_stream_chunk = 45;
|
|
353
|
+
*/
|
|
354
|
+
value: SendStreamChunkRequest;
|
|
355
|
+
case: "sendStreamChunk";
|
|
356
|
+
} | {
|
|
357
|
+
/**
|
|
358
|
+
* @generated from field: livekit.proto.SendStreamTrailerRequest send_stream_trailer = 46;
|
|
359
|
+
*/
|
|
360
|
+
value: SendStreamTrailerRequest;
|
|
361
|
+
case: "sendStreamTrailer";
|
|
362
|
+
} | {
|
|
363
|
+
/**
|
|
364
|
+
* Data Channel
|
|
365
|
+
*
|
|
366
|
+
* @generated from field: livekit.proto.SetDataChannelBufferedAmountLowThresholdRequest set_data_channel_buffered_amount_low_threshold = 47;
|
|
367
|
+
*/
|
|
368
|
+
value: SetDataChannelBufferedAmountLowThresholdRequest;
|
|
369
|
+
case: "setDataChannelBufferedAmountLowThreshold";
|
|
342
370
|
} | { case: undefined; value?: undefined } = { case: undefined };
|
|
343
371
|
|
|
344
372
|
constructor(data?: PartialMessage<FfiRequest>) {
|
|
@@ -391,6 +419,10 @@ export class FfiRequest extends Message<FfiRequest> {
|
|
|
391
419
|
{ no: 41, name: "rpc_method_invocation_response", kind: "message", T: RpcMethodInvocationResponseRequest, oneof: "message" },
|
|
392
420
|
{ no: 42, name: "enable_remote_track_publication", kind: "message", T: EnableRemoteTrackPublicationRequest, oneof: "message" },
|
|
393
421
|
{ no: 43, name: "update_remote_track_publication_dimension", kind: "message", T: UpdateRemoteTrackPublicationDimensionRequest, oneof: "message" },
|
|
422
|
+
{ no: 44, name: "send_stream_header", kind: "message", T: SendStreamHeaderRequest, oneof: "message" },
|
|
423
|
+
{ no: 45, name: "send_stream_chunk", kind: "message", T: SendStreamChunkRequest, oneof: "message" },
|
|
424
|
+
{ no: 46, name: "send_stream_trailer", kind: "message", T: SendStreamTrailerRequest, oneof: "message" },
|
|
425
|
+
{ no: 47, name: "set_data_channel_buffered_amount_low_threshold", kind: "message", T: SetDataChannelBufferedAmountLowThresholdRequest, oneof: "message" },
|
|
394
426
|
]);
|
|
395
427
|
|
|
396
428
|
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FfiRequest {
|
|
@@ -677,6 +709,34 @@ export class FfiResponse extends Message<FfiResponse> {
|
|
|
677
709
|
*/
|
|
678
710
|
value: UpdateRemoteTrackPublicationDimensionResponse;
|
|
679
711
|
case: "updateRemoteTrackPublicationDimension";
|
|
712
|
+
} | {
|
|
713
|
+
/**
|
|
714
|
+
* Data Streams
|
|
715
|
+
*
|
|
716
|
+
* @generated from field: livekit.proto.SendStreamHeaderResponse send_stream_header = 43;
|
|
717
|
+
*/
|
|
718
|
+
value: SendStreamHeaderResponse;
|
|
719
|
+
case: "sendStreamHeader";
|
|
720
|
+
} | {
|
|
721
|
+
/**
|
|
722
|
+
* @generated from field: livekit.proto.SendStreamChunkResponse send_stream_chunk = 44;
|
|
723
|
+
*/
|
|
724
|
+
value: SendStreamChunkResponse;
|
|
725
|
+
case: "sendStreamChunk";
|
|
726
|
+
} | {
|
|
727
|
+
/**
|
|
728
|
+
* @generated from field: livekit.proto.SendStreamTrailerResponse send_stream_trailer = 45;
|
|
729
|
+
*/
|
|
730
|
+
value: SendStreamTrailerResponse;
|
|
731
|
+
case: "sendStreamTrailer";
|
|
732
|
+
} | {
|
|
733
|
+
/**
|
|
734
|
+
* Data Channel
|
|
735
|
+
*
|
|
736
|
+
* @generated from field: livekit.proto.SetDataChannelBufferedAmountLowThresholdResponse set_data_channel_buffered_amount_low_threshold = 46;
|
|
737
|
+
*/
|
|
738
|
+
value: SetDataChannelBufferedAmountLowThresholdResponse;
|
|
739
|
+
case: "setDataChannelBufferedAmountLowThreshold";
|
|
680
740
|
} | { case: undefined; value?: undefined } = { case: undefined };
|
|
681
741
|
|
|
682
742
|
constructor(data?: PartialMessage<FfiResponse>) {
|
|
@@ -728,6 +788,10 @@ export class FfiResponse extends Message<FfiResponse> {
|
|
|
728
788
|
{ no: 40, name: "rpc_method_invocation_response", kind: "message", T: RpcMethodInvocationResponseResponse, oneof: "message" },
|
|
729
789
|
{ no: 41, name: "enable_remote_track_publication", kind: "message", T: EnableRemoteTrackPublicationResponse, oneof: "message" },
|
|
730
790
|
{ no: 42, name: "update_remote_track_publication_dimension", kind: "message", T: UpdateRemoteTrackPublicationDimensionResponse, oneof: "message" },
|
|
791
|
+
{ no: 43, name: "send_stream_header", kind: "message", T: SendStreamHeaderResponse, oneof: "message" },
|
|
792
|
+
{ no: 44, name: "send_stream_chunk", kind: "message", T: SendStreamChunkResponse, oneof: "message" },
|
|
793
|
+
{ no: 45, name: "send_stream_trailer", kind: "message", T: SendStreamTrailerResponse, oneof: "message" },
|
|
794
|
+
{ no: 46, name: "set_data_channel_buffered_amount_low_threshold", kind: "message", T: SetDataChannelBufferedAmountLowThresholdResponse, oneof: "message" },
|
|
731
795
|
]);
|
|
732
796
|
|
|
733
797
|
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FfiResponse {
|
|
@@ -896,6 +960,24 @@ export class FfiEvent extends Message<FfiEvent> {
|
|
|
896
960
|
*/
|
|
897
961
|
value: RpcMethodInvocationEvent;
|
|
898
962
|
case: "rpcMethodInvocation";
|
|
963
|
+
} | {
|
|
964
|
+
/**
|
|
965
|
+
* @generated from field: livekit.proto.SendStreamHeaderCallback send_stream_header = 25;
|
|
966
|
+
*/
|
|
967
|
+
value: SendStreamHeaderCallback;
|
|
968
|
+
case: "sendStreamHeader";
|
|
969
|
+
} | {
|
|
970
|
+
/**
|
|
971
|
+
* @generated from field: livekit.proto.SendStreamChunkCallback send_stream_chunk = 26;
|
|
972
|
+
*/
|
|
973
|
+
value: SendStreamChunkCallback;
|
|
974
|
+
case: "sendStreamChunk";
|
|
975
|
+
} | {
|
|
976
|
+
/**
|
|
977
|
+
* @generated from field: livekit.proto.SendStreamTrailerCallback send_stream_trailer = 27;
|
|
978
|
+
*/
|
|
979
|
+
value: SendStreamTrailerCallback;
|
|
980
|
+
case: "sendStreamTrailer";
|
|
899
981
|
} | { case: undefined; value?: undefined } = { case: undefined };
|
|
900
982
|
|
|
901
983
|
constructor(data?: PartialMessage<FfiEvent>) {
|
|
@@ -929,6 +1011,9 @@ export class FfiEvent extends Message<FfiEvent> {
|
|
|
929
1011
|
{ no: 22, name: "chat_message", kind: "message", T: SendChatMessageCallback, oneof: "message" },
|
|
930
1012
|
{ no: 23, name: "perform_rpc", kind: "message", T: PerformRpcCallback, oneof: "message" },
|
|
931
1013
|
{ no: 24, name: "rpc_method_invocation", kind: "message", T: RpcMethodInvocationEvent, oneof: "message" },
|
|
1014
|
+
{ no: 25, name: "send_stream_header", kind: "message", T: SendStreamHeaderCallback, oneof: "message" },
|
|
1015
|
+
{ no: 26, name: "send_stream_chunk", kind: "message", T: SendStreamChunkCallback, oneof: "message" },
|
|
1016
|
+
{ no: 27, name: "send_stream_trailer", kind: "message", T: SendStreamTrailerCallback, oneof: "message" },
|
|
932
1017
|
]);
|
|
933
1018
|
|
|
934
1019
|
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FfiEvent {
|