livekit-client 2.15.3 → 2.15.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/README.md +2 -2
- package/dist/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +329 -124
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +868 -548
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +0 -46
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/naluUtils.d.ts +27 -0
- package/dist/src/e2ee/worker/naluUtils.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +6 -10
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts +20 -0
- package/dist/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts.map +1 -0
- package/dist/src/room/{StreamReader.d.ts → data-stream/incoming/StreamReader.d.ts} +32 -6
- package/dist/src/room/data-stream/incoming/StreamReader.d.ts.map +1 -0
- package/dist/src/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts +27 -0
- package/dist/src/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts.map +1 -0
- package/dist/src/room/{StreamWriter.d.ts → data-stream/outgoing/StreamWriter.d.ts} +1 -1
- package/dist/src/room/data-stream/outgoing/StreamWriter.d.ts.map +1 -0
- package/dist/src/room/errors.d.ts +13 -0
- package/dist/src/room/errors.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +33 -20
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts +8 -2
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/record.d.ts.map +1 -1
- package/dist/src/room/types.d.ts +17 -1
- package/dist/src/room/types.d.ts.map +1 -1
- package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +0 -46
- package/dist/ts4.2/src/e2ee/worker/naluUtils.d.ts +27 -0
- package/dist/ts4.2/src/index.d.ts +2 -2
- package/dist/ts4.2/src/room/Room.d.ts +6 -10
- package/dist/ts4.2/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts +20 -0
- package/dist/ts4.2/src/room/{StreamReader.d.ts → data-stream/incoming/StreamReader.d.ts} +32 -6
- package/dist/ts4.2/src/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts +27 -0
- package/dist/ts4.2/src/room/{StreamWriter.d.ts → data-stream/outgoing/StreamWriter.d.ts} +1 -1
- package/dist/ts4.2/src/room/errors.d.ts +13 -0
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +33 -20
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +8 -2
- package/dist/ts4.2/src/room/types.d.ts +17 -1
- package/package.json +1 -1
- package/src/api/SignalClient.ts +6 -0
- package/src/e2ee/worker/FrameCryptor.ts +48 -139
- package/src/e2ee/worker/naluUtils.ts +328 -0
- package/src/index.ts +2 -2
- package/src/room/Room.ts +94 -207
- package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +247 -0
- package/src/room/data-stream/incoming/StreamReader.ts +317 -0
- package/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts +316 -0
- package/src/room/{StreamWriter.ts → data-stream/outgoing/StreamWriter.ts} +1 -1
- package/src/room/errors.ts +34 -0
- package/src/room/participant/LocalParticipant.ts +48 -299
- package/src/room/track/LocalAudioTrack.ts +2 -2
- package/src/room/track/LocalTrack.ts +75 -49
- package/src/room/track/record.ts +15 -2
- package/src/room/types.ts +22 -1
- package/src/room/utils.ts +3 -3
- package/dist/src/room/StreamReader.d.ts.map +0 -1
- package/dist/src/room/StreamWriter.d.ts.map +0 -1
- package/src/room/StreamReader.ts +0 -170
package/src/room/track/record.ts
CHANGED
@@ -51,11 +51,24 @@ export class LocalTrackRecorder<T extends LocalTrack> extends RecorderBase {
|
|
51
51
|
start: (controller) => {
|
52
52
|
streamController = controller;
|
53
53
|
dataListener = async (event: BlobEvent) => {
|
54
|
-
|
54
|
+
let data: Uint8Array;
|
55
|
+
|
56
|
+
if (event.data.arrayBuffer) {
|
57
|
+
const arrayBuffer = await event.data.arrayBuffer();
|
58
|
+
data = new Uint8Array(arrayBuffer);
|
59
|
+
|
60
|
+
// @ts-expect-error react-native passes over Uint8Arrays directly
|
61
|
+
} else if (event.data.byteArray) {
|
62
|
+
// @ts-expect-error
|
63
|
+
data = event.data.byteArray as Uint8Array;
|
64
|
+
} else {
|
65
|
+
throw new Error('no data available!');
|
66
|
+
}
|
67
|
+
|
55
68
|
if (isClosed()) {
|
56
69
|
return;
|
57
70
|
}
|
58
|
-
controller.enqueue(
|
71
|
+
controller.enqueue(data);
|
59
72
|
};
|
60
73
|
this.addEventListener('dataavailable', dataListener);
|
61
74
|
},
|
package/src/room/types.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import type { DataStream_Chunk } from '@livekit/protocol';
|
1
|
+
import type { DataStream_Chunk, Encryption_Type } from '@livekit/protocol';
|
2
|
+
import type { Future } from './utils';
|
2
3
|
|
3
4
|
export type SimulationOptions = {
|
4
5
|
publish?: {
|
@@ -35,6 +36,24 @@ export interface StreamTextOptions {
|
|
35
36
|
attributes?: Record<string, string>;
|
36
37
|
}
|
37
38
|
|
39
|
+
export type StreamBytesOptions = {
|
40
|
+
name?: string;
|
41
|
+
topic?: string;
|
42
|
+
attributes?: Record<string, string>;
|
43
|
+
destinationIdentities?: Array<string>;
|
44
|
+
streamId?: string;
|
45
|
+
mimeType?: string;
|
46
|
+
totalSize?: number;
|
47
|
+
};
|
48
|
+
|
49
|
+
export type SendFileOptions = Pick<
|
50
|
+
StreamBytesOptions,
|
51
|
+
'topic' | 'mimeType' | 'destinationIdentities'
|
52
|
+
> & {
|
53
|
+
onProgress?: (progress: number) => void;
|
54
|
+
encryptionType?: Encryption_Type.NONE;
|
55
|
+
};
|
56
|
+
|
38
57
|
export type DataPublishOptions = {
|
39
58
|
/**
|
40
59
|
* whether to send this as reliable or lossy.
|
@@ -105,6 +124,8 @@ export interface StreamController<T extends DataStream_Chunk> {
|
|
105
124
|
controller: ReadableStreamDefaultController<T>;
|
106
125
|
startTime: number;
|
107
126
|
endTime?: number;
|
127
|
+
sendingParticipantIdentity: string;
|
128
|
+
outOfBandFailureRejectingFuture: Future<never>;
|
108
129
|
}
|
109
130
|
|
110
131
|
export interface BaseStreamInfo {
|
package/src/room/utils.ts
CHANGED
@@ -141,7 +141,7 @@ export function isSVCCodec(codec?: string): boolean {
|
|
141
141
|
}
|
142
142
|
|
143
143
|
export function supportsSetSinkId(elm?: HTMLMediaElement): boolean {
|
144
|
-
if (!document) {
|
144
|
+
if (!document || isSafariBased()) {
|
145
145
|
return false;
|
146
146
|
}
|
147
147
|
if (!elm) {
|
@@ -538,13 +538,13 @@ export function unwrapConstraint(constraint: ConstrainDOMString | ConstrainULong
|
|
538
538
|
if (Array.isArray(constraint)) {
|
539
539
|
return constraint[0];
|
540
540
|
}
|
541
|
-
if (constraint.exact) {
|
541
|
+
if (constraint.exact !== undefined) {
|
542
542
|
if (Array.isArray(constraint.exact)) {
|
543
543
|
return constraint.exact[0];
|
544
544
|
}
|
545
545
|
return constraint.exact;
|
546
546
|
}
|
547
|
-
if (constraint.ideal) {
|
547
|
+
if (constraint.ideal !== undefined) {
|
548
548
|
if (Array.isArray(constraint.ideal)) {
|
549
549
|
return constraint.ideal[0];
|
550
550
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"StreamReader.d.ts","sourceRoot":"","sources":["../../../src/room/StreamReader.ts"],"names":[],"mappings":"AAAA,OAAO,K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c,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI;IAOnF,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxB,KAAK;CAKZ;AAED,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,MAAM,EAAE,cAAc,CAAC;CAAG;AAEjF,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,UAAU,EAAE,cAAc,CAAC;CAAG"}
|
package/src/room/StreamReader.ts
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
import type { DataStream_Chunk } from '@livekit/protocol';
|
2
|
-
import type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types';
|
3
|
-
import { bigIntToNumber } from './utils';
|
4
|
-
|
5
|
-
abstract class BaseStreamReader<T extends BaseStreamInfo> {
|
6
|
-
protected reader: ReadableStream<DataStream_Chunk>;
|
7
|
-
|
8
|
-
protected totalByteSize?: number;
|
9
|
-
|
10
|
-
protected _info: T;
|
11
|
-
|
12
|
-
protected bytesReceived: number;
|
13
|
-
|
14
|
-
get info() {
|
15
|
-
return this._info;
|
16
|
-
}
|
17
|
-
|
18
|
-
constructor(info: T, stream: ReadableStream<DataStream_Chunk>, totalByteSize?: number) {
|
19
|
-
this.reader = stream;
|
20
|
-
this.totalByteSize = totalByteSize;
|
21
|
-
this._info = info;
|
22
|
-
this.bytesReceived = 0;
|
23
|
-
}
|
24
|
-
|
25
|
-
protected abstract handleChunkReceived(chunk: DataStream_Chunk): void;
|
26
|
-
|
27
|
-
onProgress?: (progress: number | undefined) => void;
|
28
|
-
|
29
|
-
abstract readAll(): Promise<string | Array<Uint8Array>>;
|
30
|
-
}
|
31
|
-
|
32
|
-
export class ByteStreamReader extends BaseStreamReader<ByteStreamInfo> {
|
33
|
-
protected handleChunkReceived(chunk: DataStream_Chunk) {
|
34
|
-
this.bytesReceived += chunk.content.byteLength;
|
35
|
-
const currentProgress = this.totalByteSize
|
36
|
-
? this.bytesReceived / this.totalByteSize
|
37
|
-
: undefined;
|
38
|
-
this.onProgress?.(currentProgress);
|
39
|
-
}
|
40
|
-
|
41
|
-
onProgress?: (progress: number | undefined) => void;
|
42
|
-
|
43
|
-
[Symbol.asyncIterator]() {
|
44
|
-
const reader = this.reader.getReader();
|
45
|
-
|
46
|
-
return {
|
47
|
-
next: async (): Promise<IteratorResult<Uint8Array>> => {
|
48
|
-
try {
|
49
|
-
const { done, value } = await reader.read();
|
50
|
-
if (done) {
|
51
|
-
return { done: true, value: undefined as any };
|
52
|
-
} else {
|
53
|
-
this.handleChunkReceived(value);
|
54
|
-
return { done: false, value: value.content };
|
55
|
-
}
|
56
|
-
} catch (error) {
|
57
|
-
// TODO handle errors
|
58
|
-
return { done: true, value: undefined };
|
59
|
-
}
|
60
|
-
},
|
61
|
-
|
62
|
-
async return(): Promise<IteratorResult<Uint8Array>> {
|
63
|
-
reader.releaseLock();
|
64
|
-
return { done: true, value: undefined };
|
65
|
-
},
|
66
|
-
};
|
67
|
-
}
|
68
|
-
|
69
|
-
async readAll(): Promise<Array<Uint8Array>> {
|
70
|
-
let chunks: Set<Uint8Array> = new Set();
|
71
|
-
for await (const chunk of this) {
|
72
|
-
chunks.add(chunk);
|
73
|
-
}
|
74
|
-
return Array.from(chunks);
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
/**
|
79
|
-
* A class to read chunks from a ReadableStream and provide them in a structured format.
|
80
|
-
*/
|
81
|
-
export class TextStreamReader extends BaseStreamReader<TextStreamInfo> {
|
82
|
-
private receivedChunks: Map<number, DataStream_Chunk>;
|
83
|
-
|
84
|
-
/**
|
85
|
-
* A TextStreamReader instance can be used as an AsyncIterator that returns the entire string
|
86
|
-
* that has been received up to the current point in time.
|
87
|
-
*/
|
88
|
-
constructor(
|
89
|
-
info: TextStreamInfo,
|
90
|
-
stream: ReadableStream<DataStream_Chunk>,
|
91
|
-
totalChunkCount?: number,
|
92
|
-
) {
|
93
|
-
super(info, stream, totalChunkCount);
|
94
|
-
this.receivedChunks = new Map();
|
95
|
-
}
|
96
|
-
|
97
|
-
protected handleChunkReceived(chunk: DataStream_Chunk) {
|
98
|
-
const index = bigIntToNumber(chunk.chunkIndex);
|
99
|
-
const previousChunkAtIndex = this.receivedChunks.get(index);
|
100
|
-
if (previousChunkAtIndex && previousChunkAtIndex.version > chunk.version) {
|
101
|
-
// we have a newer version already, dropping the old one
|
102
|
-
return;
|
103
|
-
}
|
104
|
-
this.receivedChunks.set(index, chunk);
|
105
|
-
this.bytesReceived += chunk.content.byteLength;
|
106
|
-
const currentProgress = this.totalByteSize
|
107
|
-
? this.bytesReceived / this.totalByteSize
|
108
|
-
: undefined;
|
109
|
-
this.onProgress?.(currentProgress);
|
110
|
-
}
|
111
|
-
|
112
|
-
/**
|
113
|
-
* @param progress - progress of the stream between 0 and 1. Undefined for streams of unknown size
|
114
|
-
*/
|
115
|
-
onProgress?: (progress: number | undefined) => void;
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Async iterator implementation to allow usage of `for await...of` syntax.
|
119
|
-
* Yields structured chunks from the stream.
|
120
|
-
*
|
121
|
-
*/
|
122
|
-
[Symbol.asyncIterator]() {
|
123
|
-
const reader = this.reader.getReader();
|
124
|
-
const decoder = new TextDecoder();
|
125
|
-
|
126
|
-
return {
|
127
|
-
next: async (): Promise<IteratorResult<string>> => {
|
128
|
-
try {
|
129
|
-
const { done, value } = await reader.read();
|
130
|
-
if (done) {
|
131
|
-
return { done: true, value: undefined };
|
132
|
-
} else {
|
133
|
-
this.handleChunkReceived(value);
|
134
|
-
|
135
|
-
return {
|
136
|
-
done: false,
|
137
|
-
value: decoder.decode(value.content),
|
138
|
-
};
|
139
|
-
}
|
140
|
-
} catch (error) {
|
141
|
-
// TODO handle errors
|
142
|
-
return { done: true, value: undefined };
|
143
|
-
}
|
144
|
-
},
|
145
|
-
|
146
|
-
async return(): Promise<IteratorResult<string>> {
|
147
|
-
reader.releaseLock();
|
148
|
-
return { done: true, value: undefined };
|
149
|
-
},
|
150
|
-
};
|
151
|
-
}
|
152
|
-
|
153
|
-
async readAll(): Promise<string> {
|
154
|
-
let finalString: string = '';
|
155
|
-
for await (const chunk of this) {
|
156
|
-
finalString += chunk;
|
157
|
-
}
|
158
|
-
return finalString;
|
159
|
-
}
|
160
|
-
}
|
161
|
-
|
162
|
-
export type ByteStreamHandler = (
|
163
|
-
reader: ByteStreamReader,
|
164
|
-
participantInfo: { identity: string },
|
165
|
-
) => void;
|
166
|
-
|
167
|
-
export type TextStreamHandler = (
|
168
|
-
reader: TextStreamReader,
|
169
|
-
participantInfo: { identity: string },
|
170
|
-
) => void;
|