livekit-client 0.16.5 → 0.17.1
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/api/RequestQueue.js +6 -6
- package/dist/api/RequestQueue.js.map +1 -1
- package/dist/api/SignalClient.d.ts +3 -0
- package/dist/api/SignalClient.js +24 -3
- package/dist/api/SignalClient.js.map +1 -1
- package/dist/connect.js +1 -1
- package/dist/connect.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +7 -2
- package/dist/proto/livekit_models.d.ts +33 -0
- package/dist/proto/livekit_models.js +213 -3
- package/dist/proto/livekit_models.js.map +1 -1
- package/dist/proto/livekit_rtc.d.ts +15 -1
- package/dist/proto/livekit_rtc.js +128 -2
- package/dist/proto/livekit_rtc.js.map +1 -1
- package/dist/room/RTCEngine.d.ts +21 -6
- package/dist/room/RTCEngine.js +13 -8
- package/dist/room/RTCEngine.js.map +1 -1
- package/dist/room/Room.d.ts +43 -6
- package/dist/room/Room.js +81 -59
- package/dist/room/Room.js.map +1 -1
- package/dist/room/events.d.ts +14 -2
- package/dist/room/events.js +16 -4
- package/dist/room/events.js.map +1 -1
- package/dist/room/participant/LocalParticipant.d.ts +3 -1
- package/dist/room/participant/LocalParticipant.js +17 -1
- package/dist/room/participant/LocalParticipant.js.map +1 -1
- package/dist/room/participant/Participant.d.ts +30 -4
- package/dist/room/participant/Participant.js +2 -2
- package/dist/room/participant/Participant.js.map +1 -1
- package/dist/room/participant/RemoteParticipant.d.ts +5 -5
- package/dist/room/participant/RemoteParticipant.js +3 -3
- package/dist/room/participant/RemoteParticipant.js.map +1 -1
- package/dist/room/participant/publishUtils.d.ts +6 -0
- package/dist/room/participant/publishUtils.js +65 -24
- package/dist/room/participant/publishUtils.js.map +1 -1
- package/dist/room/participant/publishUtils.test.js +35 -5
- package/dist/room/participant/publishUtils.test.js.map +1 -1
- package/dist/room/track/LocalAudioTrack.d.ts +2 -0
- package/dist/room/track/LocalAudioTrack.js +23 -0
- package/dist/room/track/LocalAudioTrack.js.map +1 -1
- package/dist/room/track/LocalTrack.d.ts +4 -0
- package/dist/room/track/LocalTrack.js +34 -0
- package/dist/room/track/LocalTrack.js.map +1 -1
- package/dist/room/track/LocalVideoTrack.d.ts +1 -0
- package/dist/room/track/LocalVideoTrack.js +13 -0
- package/dist/room/track/LocalVideoTrack.js.map +1 -1
- package/dist/room/track/RemoteTrack.d.ts +1 -0
- package/dist/room/track/RemoteTrack.js +1 -0
- package/dist/room/track/RemoteTrack.js.map +1 -1
- package/dist/room/track/RemoteVideoTrack.d.ts +4 -2
- package/dist/room/track/RemoteVideoTrack.js +23 -8
- package/dist/room/track/RemoteVideoTrack.js.map +1 -1
- package/dist/room/track/Track.d.ts +20 -4
- package/dist/room/track/Track.js +20 -1
- package/dist/room/track/Track.js.map +1 -1
- package/dist/room/track/defaults.js +2 -2
- package/dist/room/track/defaults.js.map +1 -1
- package/dist/room/track/options.d.ts +65 -15
- package/dist/room/track/options.js +38 -0
- package/dist/room/track/options.js.map +1 -1
- package/dist/room/track/types.d.ts +15 -4
- package/dist/room/track/utils.d.ts +10 -0
- package/dist/room/track/utils.js +46 -1
- package/dist/room/track/utils.js.map +1 -1
- package/dist/room/utils.d.ts +1 -0
- package/dist/room/utils.js +5 -1
- package/dist/room/utils.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/src/api/RequestQueue.ts +7 -7
- package/src/api/SignalClient.ts +31 -4
- package/src/connect.ts +1 -1
- package/src/index.ts +1 -1
- package/src/options.ts +12 -3
- package/src/proto/livekit_models.ts +249 -0
- package/src/proto/livekit_rtc.ts +155 -0
- package/src/room/RTCEngine.ts +43 -11
- package/src/room/Room.ts +152 -66
- package/src/room/events.ts +16 -2
- package/src/room/participant/LocalParticipant.ts +23 -4
- package/src/room/participant/Participant.ts +39 -4
- package/src/room/participant/RemoteParticipant.ts +10 -8
- package/src/room/participant/publishUtils.test.ts +46 -6
- package/src/room/participant/publishUtils.ts +72 -27
- package/src/room/track/LocalAudioTrack.ts +19 -1
- package/src/room/track/LocalTrack.ts +36 -0
- package/src/room/track/LocalVideoTrack.ts +9 -1
- package/src/room/track/RemoteTrack.ts +2 -0
- package/src/room/track/RemoteVideoTrack.ts +22 -9
- package/src/room/track/Track.ts +29 -3
- package/src/room/track/defaults.ts +2 -2
- package/src/room/track/options.ts +55 -3
- package/src/room/track/types.ts +16 -4
- package/src/room/track/utils.ts +39 -0
- package/src/room/utils.ts +4 -0
- package/src/version.ts +1 -1
@@ -33,6 +33,20 @@ export interface TrackPublishDefaults {
|
|
33
33
|
*/
|
34
34
|
simulcast?: boolean;
|
35
35
|
|
36
|
+
/**
|
37
|
+
* custom video simulcast layers for camera tracks, defaults to h180, h360, h540
|
38
|
+
* You can specify up to two custom layers that will be used instead of
|
39
|
+
* the LiveKit default layers.
|
40
|
+
* Note: the layers need to be ordered from lowest to highest quality
|
41
|
+
*/
|
42
|
+
videoSimulcastLayers?: Array<VideoPreset>;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* custom video simulcast layers for screen tracks
|
46
|
+
* Note: the layers need to be ordered from lowest to highest quality
|
47
|
+
*/
|
48
|
+
screenShareSimulcastLayers?: Array<VideoPreset>;
|
49
|
+
|
36
50
|
/**
|
37
51
|
* For local tracks, stop the underlying MediaStreamTrack when the track is muted (or paused)
|
38
52
|
* on some platforms, this option is necessary to disable the microphone recording indicator.
|
@@ -202,28 +216,66 @@ export namespace AudioPresets {
|
|
202
216
|
* Sane presets for video resolution/encoding
|
203
217
|
*/
|
204
218
|
export const VideoPresets = {
|
219
|
+
h90: new VideoPreset(160, 90, 60_000, 15),
|
220
|
+
h180: new VideoPreset(320, 180, 120_000, 15),
|
221
|
+
h216: new VideoPreset(384, 216, 180_000, 15),
|
222
|
+
h360: new VideoPreset(640, 360, 300_000, 20),
|
223
|
+
h540: new VideoPreset(960, 540, 600_000, 25),
|
224
|
+
h720: new VideoPreset(1280, 720, 2_000_000, 30),
|
225
|
+
h1080: new VideoPreset(1920, 1080, 3_000_000, 30),
|
226
|
+
h1440: new VideoPreset(2560, 1440, 5_000_000, 30),
|
227
|
+
h2160: new VideoPreset(3840, 2160, 8_000_000, 30),
|
228
|
+
/** @deprecated */
|
205
229
|
qvga: new VideoPreset(320, 180, 120_000, 10),
|
230
|
+
/** @deprecated */
|
206
231
|
vga: new VideoPreset(640, 360, 300_000, 20),
|
232
|
+
/** @deprecated */
|
207
233
|
qhd: new VideoPreset(960, 540, 600_000, 25),
|
234
|
+
/** @deprecated */
|
208
235
|
hd: new VideoPreset(1280, 720, 2_000_000, 30),
|
236
|
+
/** @deprecated */
|
209
237
|
fhd: new VideoPreset(1920, 1080, 3_000_000, 30),
|
210
|
-
};
|
238
|
+
} as const;
|
211
239
|
|
212
240
|
/**
|
213
241
|
* Four by three presets
|
214
242
|
*/
|
215
243
|
export const VideoPresets43 = {
|
244
|
+
h120: new VideoPreset(160, 120, 80_000, 15),
|
245
|
+
h180: new VideoPreset(240, 180, 100_000, 15),
|
246
|
+
h240: new VideoPreset(320, 240, 150_000, 15),
|
247
|
+
h360: new VideoPreset(480, 360, 225_000, 20),
|
248
|
+
h480: new VideoPreset(640, 480, 300_000, 20),
|
249
|
+
h540: new VideoPreset(720, 540, 450_000, 25),
|
250
|
+
h720: new VideoPreset(960, 720, 1_500_000, 30),
|
251
|
+
h1080: new VideoPreset(1440, 1080, 2_500_000, 30),
|
252
|
+
h1440: new VideoPreset(1920, 1440, 3_500_000, 30),
|
253
|
+
/** @deprecated */
|
216
254
|
qvga: new VideoPreset(240, 180, 90_000, 10),
|
255
|
+
/** @deprecated */
|
217
256
|
vga: new VideoPreset(480, 360, 225_000, 20),
|
257
|
+
/** @deprecated */
|
218
258
|
qhd: new VideoPreset(720, 540, 450_000, 25),
|
259
|
+
/** @deprecated */
|
219
260
|
hd: new VideoPreset(960, 720, 1_500_000, 30),
|
261
|
+
/** @deprecated */
|
220
262
|
fhd: new VideoPreset(1440, 1080, 2_800_000, 30),
|
221
|
-
};
|
263
|
+
} as const;
|
222
264
|
|
223
265
|
export const ScreenSharePresets = {
|
266
|
+
h360fps3: new VideoPreset(640, 360, 200_000, 3),
|
267
|
+
h720fps5: new VideoPreset(1280, 720, 400_000, 5),
|
268
|
+
h720fps15: new VideoPreset(1280, 720, 1_000_000, 15),
|
269
|
+
h1080fps15: new VideoPreset(1920, 1080, 1_500_000, 15),
|
270
|
+
h1080fps30: new VideoPreset(1920, 1080, 3_000_000, 30),
|
271
|
+
/** @deprecated */
|
224
272
|
vga: new VideoPreset(640, 360, 200_000, 3),
|
273
|
+
/** @deprecated */
|
225
274
|
hd_8: new VideoPreset(1280, 720, 400_000, 5),
|
275
|
+
/** @deprecated */
|
226
276
|
hd_15: new VideoPreset(1280, 720, 1_000_000, 15),
|
277
|
+
/** @deprecated */
|
227
278
|
fhd_15: new VideoPreset(1920, 1080, 1_500_000, 15),
|
279
|
+
/** @deprecated */
|
228
280
|
fhd_30: new VideoPreset(1920, 1080, 3_000_000, 30),
|
229
|
-
};
|
281
|
+
} as const;
|
package/src/room/track/types.ts
CHANGED
@@ -1,8 +1,20 @@
|
|
1
|
-
import LocalAudioTrack from './LocalAudioTrack';
|
2
|
-
import LocalVideoTrack from './LocalVideoTrack';
|
3
|
-
import RemoteAudioTrack from './RemoteAudioTrack';
|
4
|
-
import RemoteVideoTrack from './RemoteVideoTrack';
|
1
|
+
import type LocalAudioTrack from './LocalAudioTrack';
|
2
|
+
import type LocalVideoTrack from './LocalVideoTrack';
|
3
|
+
import type RemoteAudioTrack from './RemoteAudioTrack';
|
4
|
+
import type RemoteVideoTrack from './RemoteVideoTrack';
|
5
5
|
|
6
6
|
export type RemoteTrack = RemoteAudioTrack | RemoteVideoTrack;
|
7
7
|
export type AudioTrack = RemoteAudioTrack | LocalAudioTrack;
|
8
8
|
export type VideoTrack = RemoteVideoTrack | LocalVideoTrack;
|
9
|
+
|
10
|
+
export type AdaptiveStreamSettings = {
|
11
|
+
/**
|
12
|
+
* Set a custom pixel density, defaults to 1
|
13
|
+
* When streaming videos on a ultra high definition screen this setting
|
14
|
+
* let's you account for the devicePixelRatio of those screens.
|
15
|
+
* Set it to `screen` to use the actual pixel density of the screen
|
16
|
+
* Note: this might significantly increase the bandwidth consumed by people
|
17
|
+
* streaming on high definition screens.
|
18
|
+
*/
|
19
|
+
pixelDensity?: number | 'screen'
|
20
|
+
};
|
package/src/room/track/utils.ts
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
import { sleep } from '../utils';
|
1
2
|
import {
|
2
3
|
AudioCaptureOptions, CreateLocalTracksOptions,
|
3
4
|
VideoCaptureOptions,
|
4
5
|
} from './options';
|
6
|
+
import { AudioTrack } from './types';
|
5
7
|
|
6
8
|
export function mergeDefaultOptions(
|
7
9
|
options?: CreateLocalTracksOptions,
|
@@ -74,3 +76,40 @@ export function constraintsForOptions(options: CreateLocalTracksOptions): MediaS
|
|
74
76
|
}
|
75
77
|
return constraints;
|
76
78
|
}
|
79
|
+
/**
|
80
|
+
* This function detects silence on a given [[Track]] instance.
|
81
|
+
* Returns true if the track seems to be entirely silent.
|
82
|
+
*/
|
83
|
+
export async function detectSilence(
|
84
|
+
track: AudioTrack,
|
85
|
+
timeOffset = 200,
|
86
|
+
): Promise<boolean> {
|
87
|
+
const ctx = getNewAudioContext();
|
88
|
+
if (ctx) {
|
89
|
+
const analyser = ctx.createAnalyser();
|
90
|
+
analyser.fftSize = 2048;
|
91
|
+
|
92
|
+
const bufferLength = analyser.frequencyBinCount;
|
93
|
+
const dataArray = new Uint8Array(bufferLength);
|
94
|
+
const source = ctx.createMediaStreamSource(new MediaStream([track.mediaStreamTrack]));
|
95
|
+
|
96
|
+
source.connect(analyser);
|
97
|
+
await sleep(timeOffset);
|
98
|
+
analyser.getByteTimeDomainData(dataArray);
|
99
|
+
const someNoise = dataArray.some((sample) => sample !== 128 && sample !== 0);
|
100
|
+
ctx.close();
|
101
|
+
return !someNoise;
|
102
|
+
}
|
103
|
+
return false;
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* @internal
|
108
|
+
*/
|
109
|
+
export function getNewAudioContext(): AudioContext | void {
|
110
|
+
// @ts-ignore
|
111
|
+
const AudioContext = window.AudioContext || window.webkitAudioContext;
|
112
|
+
if (AudioContext) {
|
113
|
+
return new AudioContext();
|
114
|
+
}
|
115
|
+
}
|
package/src/room/utils.ts
CHANGED
@@ -23,6 +23,10 @@ export function isSafari(): boolean {
|
|
23
23
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
24
24
|
}
|
25
25
|
|
26
|
+
export function isMobile(): boolean {
|
27
|
+
return /Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent);
|
28
|
+
}
|
29
|
+
|
26
30
|
function roDispatchCallback(entries: ResizeObserverEntry[]) {
|
27
31
|
for (const entry of entries) {
|
28
32
|
(entry.target as ObservableMediaElement).handleResize(entry);
|
package/src/version.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const version = '0.
|
1
|
+
export const version = '0.17.1';
|
2
2
|
export const protocolVersion = 6;
|