livekit-client 1.11.4 → 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 +4749 -4055
- 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 +1 -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 -0
- 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 +7 -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/LocalTrack.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/options.d.ts +2 -2
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +9 -0
- 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 +1 -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 -0
- package/dist/ts4.2/src/room/events.d.ts +14 -2
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +7 -2
- package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -0
- package/dist/ts4.2/src/room/track/TrackPublication.d.ts +3 -0
- package/dist/ts4.2/src/room/track/options.d.ts +6 -6
- package/dist/ts4.2/src/room/track/utils.d.ts +9 -0
- 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 +1 -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 +77 -22
- package/src/room/defaults.ts +1 -1
- package/src/room/events.ts +14 -0
- package/src/room/participant/LocalParticipant.ts +52 -8
- package/src/room/participant/Participant.ts +4 -0
- package/src/room/track/LocalTrack.ts +5 -4
- package/src/room/track/RemoteVideoTrack.ts +2 -2
- package/src/room/track/TrackPublication.ts +9 -1
- package/src/room/track/options.ts +3 -2
- package/src/room/track/utils.ts +27 -0
- package/src/room/utils.ts +5 -0
- package/src/room/worker.d.ts +4 -0
- package/src/test/MockMediaStreamTrack.ts +1 -0
@@ -56,9 +56,10 @@ export default abstract class LocalTrack extends Track {
|
|
56
56
|
this.muteLock = new Mutex();
|
57
57
|
this.pauseUpstreamLock = new Mutex();
|
58
58
|
this.processorLock = new Mutex();
|
59
|
+
this.setMediaStreamTrack(mediaTrack, true);
|
60
|
+
|
59
61
|
// added to satisfy TS compiler, constraints are synced with MediaStreamTrack
|
60
62
|
this._constraints = mediaTrack.getConstraints();
|
61
|
-
this.setMediaStreamTrack(mediaTrack);
|
62
63
|
if (constraints) {
|
63
64
|
this._constraints = constraints;
|
64
65
|
}
|
@@ -97,8 +98,8 @@ export default abstract class LocalTrack extends Track {
|
|
97
98
|
return this.processor?.processedTrack ?? this._mediaStreamTrack;
|
98
99
|
}
|
99
100
|
|
100
|
-
private async setMediaStreamTrack(newTrack: MediaStreamTrack) {
|
101
|
-
if (newTrack === this._mediaStreamTrack) {
|
101
|
+
private async setMediaStreamTrack(newTrack: MediaStreamTrack, force?: boolean) {
|
102
|
+
if (newTrack === this._mediaStreamTrack && !force) {
|
102
103
|
return;
|
103
104
|
}
|
104
105
|
if (this._mediaStreamTrack) {
|
@@ -109,7 +110,7 @@ export default abstract class LocalTrack extends Track {
|
|
109
110
|
this._mediaStreamTrack.removeEventListener('ended', this.handleEnded);
|
110
111
|
this._mediaStreamTrack.removeEventListener('mute', this.pauseUpstream);
|
111
112
|
this._mediaStreamTrack.removeEventListener('unmute', this.resumeUpstream);
|
112
|
-
if (!this.providedByUser) {
|
113
|
+
if (!this.providedByUser && this._mediaStreamTrack !== newTrack) {
|
113
114
|
this._mediaStreamTrack.stop();
|
114
115
|
}
|
115
116
|
}
|
@@ -123,6 +123,7 @@ export default class RemoteVideoTrack extends RemoteTrack {
|
|
123
123
|
}
|
124
124
|
this.elementInfos = this.elementInfos.filter((info) => info !== elementInfo);
|
125
125
|
this.updateVisibility();
|
126
|
+
this.debouncedHandleResize();
|
126
127
|
}
|
127
128
|
|
128
129
|
detach(): HTMLMediaElement[];
|
@@ -195,9 +196,8 @@ export default class RemoteVideoTrack extends RemoteTrack {
|
|
195
196
|
private stopObservingElement(element: HTMLMediaElement) {
|
196
197
|
const stopElementInfos = this.elementInfos.filter((info) => info.element === element);
|
197
198
|
for (const info of stopElementInfos) {
|
198
|
-
|
199
|
+
this.stopObservingElementInfo(info);
|
199
200
|
}
|
200
|
-
this.elementInfos = this.elementInfos.filter((info) => info.element !== element);
|
201
201
|
}
|
202
202
|
|
203
203
|
protected async handleAppVisibilityChanged() {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
2
2
|
import log from '../../logger';
|
3
|
+
import { Encryption_Type } from '../../proto/livekit_models';
|
3
4
|
import type { SubscriptionError, TrackInfo } from '../../proto/livekit_models';
|
4
5
|
import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc';
|
5
6
|
import { TrackEvent } from '../events';
|
@@ -35,6 +36,8 @@ export class TrackPublication extends EventEmitter<PublicationEventCallbacks> {
|
|
35
36
|
|
36
37
|
protected metadataMuted: boolean = false;
|
37
38
|
|
39
|
+
protected encryption: Encryption_Type = Encryption_Type.NONE;
|
40
|
+
|
38
41
|
constructor(kind: Track.Kind, id: string, name: string) {
|
39
42
|
super();
|
40
43
|
this.kind = kind;
|
@@ -71,6 +74,10 @@ export class TrackPublication extends EventEmitter<PublicationEventCallbacks> {
|
|
71
74
|
return this.track !== undefined;
|
72
75
|
}
|
73
76
|
|
77
|
+
get isEncrypted(): boolean {
|
78
|
+
return this.encryption !== Encryption_Type.NONE;
|
79
|
+
}
|
80
|
+
|
74
81
|
/**
|
75
82
|
* an [AudioTrack] if this publication holds an audio track
|
76
83
|
*/
|
@@ -110,8 +117,9 @@ export class TrackPublication extends EventEmitter<PublicationEventCallbacks> {
|
|
110
117
|
};
|
111
118
|
this.simulcasted = info.simulcast;
|
112
119
|
}
|
120
|
+
this.encryption = info.encryption;
|
113
121
|
this.trackInfo = info;
|
114
|
-
log.
|
122
|
+
log.debug('update publication info', { info });
|
115
123
|
}
|
116
124
|
}
|
117
125
|
|
@@ -272,10 +272,11 @@ export interface AudioPreset {
|
|
272
272
|
priority?: RTCPriorityType;
|
273
273
|
}
|
274
274
|
|
275
|
-
const codecs = ['vp8', 'h264', 'vp9', 'av1'] as const;
|
276
275
|
const backupCodecs = ['vp8', 'h264'] as const;
|
277
276
|
|
278
|
-
export
|
277
|
+
export const videoCodecs = ['vp8', 'h264', 'vp9', 'av1'] as const;
|
278
|
+
|
279
|
+
export type VideoCodec = (typeof videoCodecs)[number];
|
279
280
|
|
280
281
|
export type BackupVideoCodec = (typeof backupCodecs)[number];
|
281
282
|
|
package/src/room/track/utils.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { sleep } from '../utils';
|
2
|
+
import { Track } from './Track';
|
2
3
|
import type { AudioCaptureOptions, CreateLocalTracksOptions, VideoCaptureOptions } from './options';
|
3
4
|
import type { AudioTrack } from './types';
|
4
5
|
|
@@ -112,3 +113,29 @@ export function getNewAudioContext(): AudioContext | void {
|
|
112
113
|
return new AudioContext({ latencyHint: 'interactive' });
|
113
114
|
}
|
114
115
|
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
* @internal
|
119
|
+
*/
|
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;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
/**
|
131
|
+
* @internal
|
132
|
+
*/
|
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 {
|
139
|
+
return undefined;
|
140
|
+
}
|
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;
|