livekit-client 2.0.7 → 2.0.9
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.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +33 -9
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +70 -41
- 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/e2ee/constants.d.ts +0 -1
- package/dist/src/e2ee/constants.d.ts.map +1 -1
- package/dist/src/e2ee/types.d.ts +1 -0
- package/dist/src/e2ee/types.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
- package/dist/src/index.d.ts +7 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/ts4.2/src/e2ee/constants.d.ts +0 -1
- package/dist/ts4.2/src/e2ee/types.d.ts +1 -0
- package/dist/ts4.2/src/index.d.ts +7 -6
- package/package.json +1 -1
- package/src/e2ee/constants.ts +1 -5
- package/src/e2ee/types.ts +1 -0
- package/src/e2ee/worker/FrameCryptor.ts +12 -0
- package/src/e2ee/worker/ParticipantKeyHandler.ts +4 -2
- package/src/e2ee/worker/e2ee.worker.ts +24 -3
- package/src/index.ts +32 -29
- package/src/room/PCTransport.ts +6 -18
- package/src/room/RTCEngine.ts +4 -3
- package/src/room/participant/LocalParticipant.ts +21 -6
- package/src/room/participant/publishUtils.ts +38 -11
- package/src/room/track/LocalTrack.ts +11 -9
@@ -1,4 +1,5 @@
|
|
1
1
|
import log from '../../logger';
|
2
|
+
import { getBrowser } from '../../utils/browserParser';
|
2
3
|
import { TrackInvalidError } from '../errors';
|
3
4
|
import LocalAudioTrack from '../track/LocalAudioTrack';
|
4
5
|
import LocalVideoTrack from '../track/LocalVideoTrack';
|
@@ -11,7 +12,14 @@ import type {
|
|
11
12
|
} from '../track/options';
|
12
13
|
import { ScreenSharePresets, VideoPreset, VideoPresets, VideoPresets43 } from '../track/options';
|
13
14
|
import type { LoggerOptions } from '../types';
|
14
|
-
import {
|
15
|
+
import {
|
16
|
+
compareVersions,
|
17
|
+
getReactNativeOs,
|
18
|
+
isFireFox,
|
19
|
+
isReactNative,
|
20
|
+
isSVCCodec,
|
21
|
+
isSafari,
|
22
|
+
} from '../utils';
|
15
23
|
|
16
24
|
/** @internal */
|
17
25
|
export function mediaTrackToLocalTrack(
|
@@ -125,8 +133,6 @@ export function computeVideoEncodings(
|
|
125
133
|
);
|
126
134
|
|
127
135
|
if (scalabilityMode && isSVCCodec(videoCodec)) {
|
128
|
-
log.debug(`using svc with scalabilityMode ${scalabilityMode}`);
|
129
|
-
|
130
136
|
const sm = new ScalabilityMode(scalabilityMode);
|
131
137
|
|
132
138
|
const encodings: RTCRtpEncodingParameters[] = [];
|
@@ -134,17 +140,37 @@ export function computeVideoEncodings(
|
|
134
140
|
if (sm.spatial > 3) {
|
135
141
|
throw new Error(`unsupported scalabilityMode: ${scalabilityMode}`);
|
136
142
|
}
|
137
|
-
|
143
|
+
// Before M113 in Chrome, defining multiple encodings with an SVC codec indicated
|
144
|
+
// that SVC mode should be used. Safari still works this way.
|
145
|
+
// This is a bit confusing but is due to how libwebrtc interpreted the encodings field
|
146
|
+
// before M113.
|
147
|
+
// Announced here: https://groups.google.com/g/discuss-webrtc/c/-QQ3pxrl-fw?pli=1
|
148
|
+
const browser = getBrowser();
|
149
|
+
if (
|
150
|
+
isSafari() ||
|
151
|
+
(browser?.name === 'Chrome' && compareVersions(browser?.version, '113') < 0)
|
152
|
+
) {
|
153
|
+
for (let i = 0; i < sm.spatial; i += 1) {
|
154
|
+
// in legacy SVC, scaleResolutionDownBy cannot be set
|
155
|
+
encodings.push({
|
156
|
+
rid: videoRids[2 - i],
|
157
|
+
maxBitrate: videoEncoding.maxBitrate / 3 ** i,
|
158
|
+
maxFramerate: original.encoding.maxFramerate,
|
159
|
+
});
|
160
|
+
}
|
161
|
+
// legacy SVC, scalabilityMode is set only on the first encoding
|
162
|
+
/* @ts-ignore */
|
163
|
+
encodings[0].scalabilityMode = scalabilityMode;
|
164
|
+
} else {
|
138
165
|
encodings.push({
|
139
|
-
|
140
|
-
maxBitrate: videoEncoding.maxBitrate / 3 ** i,
|
141
|
-
/* @ts-ignore */
|
166
|
+
maxBitrate: videoEncoding.maxBitrate,
|
142
167
|
maxFramerate: original.encoding.maxFramerate,
|
168
|
+
/* @ts-ignore */
|
169
|
+
scalabilityMode: scalabilityMode,
|
143
170
|
});
|
144
171
|
}
|
145
|
-
|
146
|
-
|
147
|
-
log.debug('encodings', encodings);
|
172
|
+
|
173
|
+
log.debug(`using svc encoding`, { encodings });
|
148
174
|
return encodings;
|
149
175
|
}
|
150
176
|
|
@@ -174,7 +200,7 @@ export function computeVideoEncodings(
|
|
174
200
|
// to disable when CPU constrained.
|
175
201
|
// So encodings should be ordered in increasing spatial
|
176
202
|
// resolution order.
|
177
|
-
// 2.
|
203
|
+
// 2. livekit-server translates rids into layers. So, all encodings
|
178
204
|
// should have the base layer `q` and then more added
|
179
205
|
// based on other conditions.
|
180
206
|
const size = Math.max(width, height);
|
@@ -246,6 +272,7 @@ export function determineAppropriateEncoding(
|
|
246
272
|
break;
|
247
273
|
}
|
248
274
|
}
|
275
|
+
|
249
276
|
// presets are based on the assumption of vp8 as a codec
|
250
277
|
// for other codecs we adjust the maxBitrate if no specific videoEncoding has been provided
|
251
278
|
// users should override these with ones that are optimized for their use case
|
@@ -448,6 +448,13 @@ export default abstract class LocalTrack<
|
|
448
448
|
const unlock = await this.processorLock.lock();
|
449
449
|
try {
|
450
450
|
this.log.debug('setting up processor', this.logContext);
|
451
|
+
const processorOptions = {
|
452
|
+
kind: this.kind,
|
453
|
+
track: this._mediaStreamTrack,
|
454
|
+
element: this.processorElement,
|
455
|
+
audioContext: this.audioContext,
|
456
|
+
};
|
457
|
+
await processor.init(processorOptions);
|
451
458
|
if (this.processor) {
|
452
459
|
await this.stopProcessor();
|
453
460
|
}
|
@@ -466,14 +473,6 @@ export default abstract class LocalTrack<
|
|
466
473
|
this.log.error('failed to play processor element', { ...this.logContext, error }),
|
467
474
|
);
|
468
475
|
|
469
|
-
const processorOptions = {
|
470
|
-
kind: this.kind,
|
471
|
-
track: this._mediaStreamTrack,
|
472
|
-
element: this.processorElement,
|
473
|
-
audioContext: this.audioContext,
|
474
|
-
};
|
475
|
-
|
476
|
-
await processor.init(processorOptions);
|
477
476
|
this.processor = processor;
|
478
477
|
if (this.processor.processedTrack) {
|
479
478
|
for (const el of this.attachedElements) {
|
@@ -510,7 +509,10 @@ export default abstract class LocalTrack<
|
|
510
509
|
this.processor = undefined;
|
511
510
|
this.processorElement?.remove();
|
512
511
|
this.processorElement = undefined;
|
513
|
-
|
512
|
+
// apply original track constraints in case the processor changed them
|
513
|
+
await this._mediaStreamTrack.applyConstraints(this._constraints);
|
514
|
+
// force re-setting of the mediaStreamTrack on the sender
|
515
|
+
await this.setMediaStreamTrack(this._mediaStreamTrack, true);
|
514
516
|
this.emit(TrackEvent.TrackProcessorUpdate);
|
515
517
|
}
|
516
518
|
|