livekit-client 2.1.5 → 2.2.0
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/livekit-client.esm.mjs +149 -64
- 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/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +2 -2
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +4 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +12 -1
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +6 -3
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/participant/RemoteParticipant.d.ts +3 -3
- package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/create.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +9 -0
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/ts4.2/src/index.d.ts +2 -2
- package/dist/ts4.2/src/room/RTCEngine.d.ts +2 -2
- package/dist/ts4.2/src/room/Room.d.ts +4 -1
- package/dist/ts4.2/src/room/events.d.ts +12 -1
- package/dist/ts4.2/src/room/participant/Participant.d.ts +7 -3
- package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +3 -3
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +1 -1
- package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +1 -1
- package/dist/ts4.2/src/room/track/options.d.ts +9 -0
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/room/RTCEngine.ts +23 -6
- package/src/room/Room.ts +39 -10
- package/src/room/events.ts +14 -1
- package/src/room/participant/LocalParticipant.ts +36 -25
- package/src/room/participant/Participant.ts +14 -1
- package/src/room/participant/RemoteParticipant.ts +17 -4
- package/src/room/participant/publishUtils.ts +4 -0
- package/src/room/track/LocalTrack.ts +13 -9
- package/src/room/track/LocalVideoTrack.ts +4 -1
- package/src/room/track/create.ts +37 -27
- package/src/room/track/options.ts +15 -0
package/src/room/track/create.ts
CHANGED
@@ -14,6 +14,7 @@ import type {
|
|
14
14
|
VideoCaptureOptions,
|
15
15
|
} from './options';
|
16
16
|
import { ScreenSharePresets } from './options';
|
17
|
+
import type { TrackProcessor } from './processor/types';
|
17
18
|
import {
|
18
19
|
constraintsForOptions,
|
19
20
|
mergeDefaultOptions,
|
@@ -51,35 +52,44 @@ export async function createLocalTracks(
|
|
51
52
|
}
|
52
53
|
|
53
54
|
const stream = await mediaPromise;
|
54
|
-
return
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
trackOptions
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
return Promise.all(
|
56
|
+
stream.getTracks().map(async (mediaStreamTrack) => {
|
57
|
+
const isAudio = mediaStreamTrack.kind === 'audio';
|
58
|
+
let trackOptions = isAudio ? options!.audio : options!.video;
|
59
|
+
if (typeof trackOptions === 'boolean' || !trackOptions) {
|
60
|
+
trackOptions = {};
|
61
|
+
}
|
62
|
+
let trackConstraints: MediaTrackConstraints | undefined;
|
63
|
+
const conOrBool = isAudio ? constraints.audio : constraints.video;
|
64
|
+
if (typeof conOrBool !== 'boolean') {
|
65
|
+
trackConstraints = conOrBool;
|
66
|
+
}
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
// update the constraints with the device id the user gave permissions to in the permission prompt
|
69
|
+
// otherwise each track restart (e.g. mute - unmute) will try to initialize the device again -> causing additional permission prompts
|
70
|
+
if (trackConstraints) {
|
71
|
+
trackConstraints.deviceId = mediaStreamTrack.getSettings().deviceId;
|
72
|
+
} else {
|
73
|
+
trackConstraints = { deviceId: mediaStreamTrack.getSettings().deviceId };
|
74
|
+
}
|
73
75
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
const track = mediaTrackToLocalTrack(mediaStreamTrack, trackConstraints);
|
77
|
+
if (track.kind === Track.Kind.Video) {
|
78
|
+
track.source = Track.Source.Camera;
|
79
|
+
} else if (track.kind === Track.Kind.Audio) {
|
80
|
+
track.source = Track.Source.Microphone;
|
81
|
+
}
|
82
|
+
track.mediaStream = stream;
|
83
|
+
if (trackOptions.processor) {
|
84
|
+
if (track instanceof LocalAudioTrack) {
|
85
|
+
await track.setProcessor(trackOptions.processor as TrackProcessor<Track.Kind.Audio>);
|
86
|
+
} else if (track instanceof LocalVideoTrack) {
|
87
|
+
await track.setProcessor(trackOptions.processor as TrackProcessor<Track.Kind.Video>);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
return track;
|
91
|
+
}),
|
92
|
+
);
|
83
93
|
}
|
84
94
|
|
85
95
|
/**
|
@@ -1,4 +1,9 @@
|
|
1
1
|
import type { Track } from './Track';
|
2
|
+
import type {
|
3
|
+
AudioProcessorOptions,
|
4
|
+
TrackProcessor,
|
5
|
+
VideoProcessorOptions,
|
6
|
+
} from './processor/types';
|
2
7
|
|
3
8
|
export interface TrackPublishDefaults {
|
4
9
|
/**
|
@@ -152,6 +157,11 @@ export interface VideoCaptureOptions {
|
|
152
157
|
facingMode?: 'user' | 'environment' | 'left' | 'right';
|
153
158
|
|
154
159
|
resolution?: VideoResolution;
|
160
|
+
|
161
|
+
/**
|
162
|
+
* initialize the track with a given processor
|
163
|
+
*/
|
164
|
+
processor?: TrackProcessor<Track.Kind.Video, VideoProcessorOptions>;
|
155
165
|
}
|
156
166
|
|
157
167
|
export interface ScreenShareCaptureOptions {
|
@@ -245,6 +255,11 @@ export interface AudioCaptureOptions {
|
|
245
255
|
* sample size or range of sample sizes which are acceptable and/or required.
|
246
256
|
*/
|
247
257
|
sampleSize?: ConstrainULong;
|
258
|
+
|
259
|
+
/**
|
260
|
+
* initialize the track with a given processor
|
261
|
+
*/
|
262
|
+
processor?: TrackProcessor<Track.Kind.Audio, AudioProcessorOptions>;
|
248
263
|
}
|
249
264
|
|
250
265
|
export interface AudioOutputOptions {
|