livekit-client 1.11.3 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -3
- package/dist/livekit-client.e2ee.worker.js +2 -0
- package/dist/livekit-client.e2ee.worker.js.map +1 -0
- package/dist/livekit-client.e2ee.worker.mjs +1525 -0
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -0
- package/dist/livekit-client.esm.mjs +1462 -660
- 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 +4 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/turn.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts +45 -0
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -0
- package/dist/src/e2ee/KeyProvider.d.ts +42 -0
- package/dist/src/e2ee/KeyProvider.d.ts.map +1 -0
- package/dist/src/e2ee/constants.d.ts +14 -0
- package/dist/src/e2ee/constants.d.ts.map +1 -0
- package/dist/src/e2ee/errors.d.ts +11 -0
- package/dist/src/e2ee/errors.d.ts.map +1 -0
- package/dist/src/e2ee/index.d.ts +4 -0
- package/dist/src/e2ee/index.d.ts.map +1 -0
- package/dist/src/e2ee/types.d.ts +129 -0
- package/dist/src/e2ee/types.d.ts.map +1 -0
- package/dist/src/e2ee/utils.d.ts +24 -0
- package/dist/src/e2ee/utils.d.ts.map +1 -0
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +175 -0
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -0
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +46 -0
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -0
- package/dist/src/e2ee/worker/e2ee.worker.d.ts +2 -0
- package/dist/src/e2ee/worker/e2ee.worker.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/logger.d.ts +4 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/options.d.ts +5 -0
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/proto/livekit_models.d.ts +2 -2
- package/dist/src/proto/livekit_models.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts +3 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +17 -3
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +10 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +14 -2
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +9 -2
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +1 -0
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts +3 -2
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/TrackPublication.d.ts +3 -0
- package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/facingMode.d.ts +41 -0
- package/dist/src/room/track/facingMode.d.ts.map +1 -0
- package/dist/src/room/track/options.d.ts +2 -2
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +5 -35
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +2 -0
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/src/test/MockMediaStreamTrack.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +4 -1
- package/dist/ts4.2/src/e2ee/E2eeManager.d.ts +45 -0
- package/dist/ts4.2/src/e2ee/KeyProvider.d.ts +42 -0
- package/dist/ts4.2/src/e2ee/constants.d.ts +14 -0
- package/dist/ts4.2/src/e2ee/errors.d.ts +11 -0
- package/dist/ts4.2/src/e2ee/index.d.ts +4 -0
- package/dist/ts4.2/src/e2ee/types.d.ts +129 -0
- package/dist/ts4.2/src/e2ee/utils.d.ts +24 -0
- package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +175 -0
- package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +46 -0
- package/dist/ts4.2/src/e2ee/worker/e2ee.worker.d.ts +2 -0
- package/dist/ts4.2/src/index.d.ts +2 -0
- package/dist/ts4.2/src/logger.d.ts +4 -1
- package/dist/ts4.2/src/options.d.ts +5 -0
- package/dist/ts4.2/src/proto/livekit_models.d.ts +2 -2
- package/dist/ts4.2/src/room/PCTransport.d.ts +3 -1
- package/dist/ts4.2/src/room/RTCEngine.d.ts +17 -3
- package/dist/ts4.2/src/room/Room.d.ts +10 -1
- package/dist/ts4.2/src/room/events.d.ts +14 -2
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +9 -2
- package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -0
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +3 -2
- package/dist/ts4.2/src/room/track/TrackPublication.d.ts +3 -0
- package/dist/ts4.2/src/room/track/facingMode.d.ts +41 -0
- package/dist/ts4.2/src/room/track/options.d.ts +6 -6
- package/dist/ts4.2/src/room/track/utils.d.ts +5 -35
- package/dist/ts4.2/src/room/utils.d.ts +2 -0
- package/package.json +17 -7
- package/src/api/SignalClient.ts +28 -9
- package/src/connectionHelper/checks/turn.ts +1 -0
- package/src/connectionHelper/checks/websocket.ts +1 -0
- package/src/e2ee/E2eeManager.ts +374 -0
- package/src/e2ee/KeyProvider.ts +77 -0
- package/src/e2ee/constants.ts +40 -0
- package/src/e2ee/errors.ts +16 -0
- package/src/e2ee/index.ts +3 -0
- package/src/e2ee/types.ts +160 -0
- package/src/e2ee/utils.ts +127 -0
- package/src/e2ee/worker/FrameCryptor.test.ts +21 -0
- package/src/e2ee/worker/FrameCryptor.ts +614 -0
- package/src/e2ee/worker/ParticipantKeyHandler.ts +129 -0
- package/src/e2ee/worker/e2ee.worker.ts +217 -0
- package/src/e2ee/worker/tsconfig.json +6 -0
- package/src/index.ts +2 -0
- package/src/logger.ts +10 -2
- package/src/options.ts +6 -0
- package/src/proto/livekit_models.ts +12 -12
- package/src/room/PCTransport.ts +39 -9
- package/src/room/RTCEngine.ts +127 -34
- package/src/room/Room.ts +83 -30
- package/src/room/defaults.ts +1 -1
- package/src/room/events.ts +14 -0
- package/src/room/participant/LocalParticipant.ts +82 -10
- package/src/room/participant/Participant.ts +4 -0
- package/src/room/track/LocalAudioTrack.ts +11 -4
- package/src/room/track/LocalTrack.ts +50 -43
- package/src/room/track/LocalVideoTrack.ts +5 -3
- package/src/room/track/RemoteVideoTrack.ts +2 -2
- package/src/room/track/TrackPublication.ts +9 -1
- package/src/room/track/facingMode.test.ts +30 -0
- package/src/room/track/facingMode.ts +103 -0
- package/src/room/track/options.ts +3 -2
- package/src/room/track/utils.test.ts +1 -30
- package/src/room/track/utils.ts +16 -91
- package/src/room/utils.ts +5 -0
- package/src/room/worker.d.ts +4 -0
- package/src/test/MockMediaStreamTrack.ts +1 -0
package/src/room/track/utils.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { sleep } from '../utils';
|
2
|
-
import
|
3
|
-
import LocalTrack from './LocalTrack';
|
2
|
+
import { Track } from './Track';
|
4
3
|
import type { AudioCaptureOptions, CreateLocalTracksOptions, VideoCaptureOptions } from './options';
|
5
4
|
import type { AudioTrack } from './types';
|
6
5
|
|
@@ -115,102 +114,28 @@ export function getNewAudioContext(): AudioContext | void {
|
|
115
114
|
}
|
116
115
|
}
|
117
116
|
|
118
|
-
type FacingMode = NonNullable<VideoCaptureOptions['facingMode']>;
|
119
|
-
type FacingModeFromLocalTrackOptions = {
|
120
|
-
/**
|
121
|
-
* If no facing mode can be determined, this value will be used.
|
122
|
-
* @defaultValue 'user'
|
123
|
-
*/
|
124
|
-
defaultFacingMode?: FacingMode;
|
125
|
-
};
|
126
|
-
type FacingModeFromLocalTrackReturnValue = {
|
127
|
-
/**
|
128
|
-
* The (probable) facingMode of the track.
|
129
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/facingMode | MDN docs on facingMode}
|
130
|
-
*/
|
131
|
-
facingMode: FacingMode;
|
132
|
-
/**
|
133
|
-
* The confidence that the returned facingMode is correct.
|
134
|
-
*/
|
135
|
-
confidence: 'high' | 'medium' | 'low';
|
136
|
-
};
|
137
|
-
|
138
117
|
/**
|
139
|
-
*
|
140
|
-
*
|
141
|
-
* @remarks
|
142
|
-
* There is no property supported by all browsers to detect whether a video track originated from a user- or environment-facing camera device.
|
143
|
-
* For this reason, we use the `facingMode` property when available, but will fall back on a string-based analysis of the device label to determine the facing mode.
|
144
|
-
* If both methods fail, the default facing mode will be used.
|
145
|
-
*
|
146
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/facingMode | MDN docs on facingMode}
|
147
|
-
* @experimental
|
118
|
+
* @internal
|
148
119
|
*/
|
149
|
-
export function
|
150
|
-
|
151
|
-
|
152
|
-
)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
facingMode: options.defaultFacingMode ?? 'user',
|
157
|
-
confidence: 'low',
|
158
|
-
};
|
159
|
-
|
160
|
-
// 1. Try to get facingMode from track settings.
|
161
|
-
if ('facingMode' in trackSettings) {
|
162
|
-
const rawFacingMode = trackSettings.facingMode;
|
163
|
-
log.debug('rawFacingMode', { rawFacingMode });
|
164
|
-
if (rawFacingMode && typeof rawFacingMode === 'string' && isFacingModeValue(rawFacingMode)) {
|
165
|
-
result = { facingMode: rawFacingMode, confidence: 'high' };
|
166
|
-
}
|
167
|
-
}
|
168
|
-
|
169
|
-
// 2. If we don't have a high confidence we try to get the facing mode from the device label.
|
170
|
-
if (['low', 'medium'].includes(result.confidence)) {
|
171
|
-
log.debug(`Try to get facing mode from device label: (${track.label})`);
|
172
|
-
const labelAnalysisResult = facingModeFromDeviceLabel(track.label);
|
173
|
-
if (labelAnalysisResult !== undefined) {
|
174
|
-
result = labelAnalysisResult;
|
175
|
-
}
|
120
|
+
export function kindToSource(kind: MediaDeviceKind) {
|
121
|
+
if (kind === 'audioinput') {
|
122
|
+
return Track.Source.Microphone;
|
123
|
+
} else if (kind === 'videoinput') {
|
124
|
+
return Track.Source.Camera;
|
125
|
+
} else {
|
126
|
+
return Track.Source.Unknown;
|
176
127
|
}
|
177
|
-
|
178
|
-
return result;
|
179
128
|
}
|
180
129
|
|
181
|
-
const knownDeviceLabels = new Map<string, FacingModeFromLocalTrackReturnValue>([
|
182
|
-
['obs virtual camera', { facingMode: 'environment', confidence: 'medium' }],
|
183
|
-
]);
|
184
|
-
const knownDeviceLabelSections = new Map<string, FacingModeFromLocalTrackReturnValue>([
|
185
|
-
['iphone', { facingMode: 'environment', confidence: 'medium' }],
|
186
|
-
['ipad', { facingMode: 'environment', confidence: 'medium' }],
|
187
|
-
]);
|
188
130
|
/**
|
189
|
-
*
|
190
|
-
*
|
191
|
-
* @experimental
|
131
|
+
* @internal
|
192
132
|
*/
|
193
|
-
export function
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
133
|
+
export function sourceToKind(source: Track.Source): MediaDeviceKind | undefined {
|
134
|
+
if (source === Track.Source.Microphone) {
|
135
|
+
return 'audioinput';
|
136
|
+
} else if (source === Track.Source.Camera) {
|
137
|
+
return 'videoinput';
|
138
|
+
} else {
|
199
139
|
return undefined;
|
200
140
|
}
|
201
|
-
|
202
|
-
// Can we match against widely known device labels.
|
203
|
-
if (knownDeviceLabels.has(label)) {
|
204
|
-
return knownDeviceLabels.get(label);
|
205
|
-
}
|
206
|
-
|
207
|
-
// Can we match against sections of the device label.
|
208
|
-
return Array.from(knownDeviceLabelSections.entries()).find(([section]) =>
|
209
|
-
label.includes(section),
|
210
|
-
)?.[1];
|
211
|
-
}
|
212
|
-
|
213
|
-
function isFacingModeValue(item: string): item is FacingMode {
|
214
|
-
const allowedValues: FacingMode[] = ['user', 'environment', 'left', 'right'];
|
215
|
-
return item === undefined || allowedValues.includes(item as FacingMode);
|
216
141
|
}
|
package/src/room/utils.ts
CHANGED
@@ -4,6 +4,7 @@ import type { DetectableBrowser } from '../utils/browserParser';
|
|
4
4
|
import { protocolVersion, version } from '../version';
|
5
5
|
import type LocalAudioTrack from './track/LocalAudioTrack';
|
6
6
|
import type RemoteAudioTrack from './track/RemoteAudioTrack';
|
7
|
+
import { VideoCodec, videoCodecs } from './track/options';
|
7
8
|
import { getNewAudioContext } from './track/utils';
|
8
9
|
import type { LiveKitReactNativeInfo } from './types';
|
9
10
|
|
@@ -456,6 +457,10 @@ export class Mutex {
|
|
456
457
|
}
|
457
458
|
}
|
458
459
|
|
460
|
+
export function isVideoCodec(maybeCodec: string): maybeCodec is VideoCodec {
|
461
|
+
return videoCodecs.includes(maybeCodec as VideoCodec);
|
462
|
+
}
|
463
|
+
|
459
464
|
export function unwrapConstraint(constraint: ConstrainDOMString): string {
|
460
465
|
if (typeof constraint === 'string') {
|
461
466
|
return constraint;
|