livekit-client 1.14.1 → 1.14.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 +25 -44
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +399 -196
- 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/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/utils.d.ts +0 -1
- package/dist/src/e2ee/utils.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/proto/livekit_models_pb.d.ts +87 -11
- package/dist/src/proto/livekit_models_pb.d.ts.map +1 -1
- package/dist/src/proto/livekit_rtc_pb.d.ts +0 -4
- package/dist/src/proto/livekit_rtc_pb.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts +20 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +1 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/defaults.d.ts +1 -0
- package/dist/src/room/defaults.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/timers.d.ts +1 -1
- package/dist/src/room/timers.d.ts.map +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts +3 -3
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts +2 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +0 -1
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +2 -1
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/utils/cloneDeep.d.ts +2 -0
- package/dist/src/utils/cloneDeep.d.ts.map +1 -0
- package/dist/ts4.2/src/e2ee/utils.d.ts +0 -1
- package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +87 -11
- package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +0 -4
- package/dist/ts4.2/src/room/PCTransport.d.ts +20 -1
- package/dist/ts4.2/src/room/RTCEngine.d.ts +1 -1
- package/dist/ts4.2/src/room/defaults.d.ts +1 -0
- package/dist/ts4.2/src/room/events.d.ts +1 -1
- package/dist/ts4.2/src/room/timers.d.ts +1 -1
- package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +1 -1
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +3 -3
- package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +2 -1
- package/dist/ts4.2/src/room/track/options.d.ts +0 -1
- package/dist/ts4.2/src/room/track/utils.d.ts +1 -0
- package/dist/ts4.2/src/utils/cloneDeep.d.ts +2 -0
- package/package.json +14 -14
- package/src/connectionHelper/checks/webrtc.ts +1 -1
- package/src/e2ee/E2eeManager.ts +2 -1
- package/src/e2ee/utils.ts +0 -10
- package/src/e2ee/worker/FrameCryptor.ts +13 -14
- package/src/e2ee/worker/ParticipantKeyHandler.ts +4 -5
- package/src/e2ee/worker/e2ee.worker.ts +3 -1
- package/src/proto/livekit_models_pb.ts +140 -15
- package/src/proto/livekit_rtc_pb.ts +1 -7
- package/src/room/PCTransport.ts +116 -1
- package/src/room/RTCEngine.ts +49 -85
- package/src/room/Room.ts +10 -9
- package/src/room/defaults.ts +4 -2
- package/src/room/events.ts +1 -1
- package/src/room/participant/LocalParticipant.ts +44 -56
- package/src/room/track/LocalAudioTrack.ts +1 -1
- package/src/room/track/LocalTrack.ts +8 -5
- package/src/room/track/LocalVideoTrack.ts +2 -1
- package/src/room/track/options.ts +0 -7
- package/src/room/track/utils.ts +17 -8
- package/src/utils/cloneDeep.test.ts +54 -0
- package/src/utils/cloneDeep.ts +11 -0
@@ -284,7 +284,8 @@ export default class LocalVideoTrack extends LocalTrack {
|
|
284
284
|
|
285
285
|
/**
|
286
286
|
* @internal
|
287
|
-
* Sets codecs that should be publishing
|
287
|
+
* Sets codecs that should be publishing, returns new codecs that have not yet
|
288
|
+
* been published
|
288
289
|
*/
|
289
290
|
async setPublishingCodecs(codecs: SubscribedCodec[]): Promise<VideoCodec[]> {
|
290
291
|
log.debug('setting publishing codecs', {
|
@@ -301,13 +301,6 @@ export function isBackupCodec(codec: string): codec is BackupVideoCodec {
|
|
301
301
|
return !!backupCodecs.find((backup) => backup === codec);
|
302
302
|
}
|
303
303
|
|
304
|
-
export function isCodecEqual(c1: string | undefined, c2: string | undefined): boolean {
|
305
|
-
return (
|
306
|
-
c1?.toLowerCase().replace(/audio\/|video\//y, '') ===
|
307
|
-
c2?.toLowerCase().replace(/audio\/|video\//y, '')
|
308
|
-
);
|
309
|
-
}
|
310
|
-
|
311
304
|
/**
|
312
305
|
* scalability modes for svc.
|
313
306
|
*/
|
package/src/room/track/utils.ts
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
import { cloneDeep } from '../../utils/cloneDeep';
|
1
2
|
import { isSafari, sleep } from '../utils';
|
2
3
|
import { Track } from './Track';
|
3
|
-
import
|
4
|
-
AudioCaptureOptions,
|
5
|
-
CreateLocalTracksOptions,
|
6
|
-
ScreenShareCaptureOptions,
|
7
|
-
VideoCaptureOptions,
|
4
|
+
import {
|
5
|
+
type AudioCaptureOptions,
|
6
|
+
type CreateLocalTracksOptions,
|
7
|
+
type ScreenShareCaptureOptions,
|
8
|
+
type VideoCaptureOptions,
|
9
|
+
VideoCodec,
|
10
|
+
videoCodecs,
|
8
11
|
} from './options';
|
9
12
|
import type { AudioTrack } from './types';
|
10
13
|
|
@@ -13,9 +16,7 @@ export function mergeDefaultOptions(
|
|
13
16
|
audioDefaults?: AudioCaptureOptions,
|
14
17
|
videoDefaults?: VideoCaptureOptions,
|
15
18
|
): CreateLocalTracksOptions {
|
16
|
-
const opts: CreateLocalTracksOptions = {
|
17
|
-
...options,
|
18
|
-
};
|
19
|
+
const opts: CreateLocalTracksOptions = cloneDeep(options) ?? {};
|
19
20
|
if (opts.audio === true) opts.audio = {};
|
20
21
|
if (opts.video === true) opts.video = {};
|
21
22
|
|
@@ -181,3 +182,11 @@ export function screenCaptureToDisplayMediaStreamOptions(
|
|
181
182
|
systemAudio: options.systemAudio,
|
182
183
|
};
|
183
184
|
}
|
185
|
+
|
186
|
+
export function mimeTypeToVideoCodecString(mimeType: string) {
|
187
|
+
const codec = mimeType.split('/')[1].toLowerCase() as VideoCodec;
|
188
|
+
if (!videoCodecs.includes(codec)) {
|
189
|
+
throw Error(`Video codec not supported: ${codec}`);
|
190
|
+
}
|
191
|
+
return codec;
|
192
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
2
|
+
import { cloneDeep } from './cloneDeep';
|
3
|
+
|
4
|
+
describe('cloneDeep', () => {
|
5
|
+
beforeEach(() => {
|
6
|
+
global.structuredClone = vi.fn((val) => {
|
7
|
+
return JSON.parse(JSON.stringify(val));
|
8
|
+
});
|
9
|
+
});
|
10
|
+
|
11
|
+
afterEach(() => {
|
12
|
+
vi.restoreAllMocks();
|
13
|
+
});
|
14
|
+
|
15
|
+
it('should clone a simple object', () => {
|
16
|
+
const structuredCloneSpy = vi.spyOn(global, 'structuredClone');
|
17
|
+
|
18
|
+
const original = { name: 'John', age: 30 };
|
19
|
+
const cloned = cloneDeep(original);
|
20
|
+
|
21
|
+
expect(cloned).toEqual(original);
|
22
|
+
expect(cloned).not.toBe(original);
|
23
|
+
expect(structuredCloneSpy).toHaveBeenCalledTimes(1);
|
24
|
+
});
|
25
|
+
|
26
|
+
it('should clone an object with nested properties', () => {
|
27
|
+
const structuredCloneSpy = vi.spyOn(global, 'structuredClone');
|
28
|
+
|
29
|
+
const original = { name: 'John', age: 30, children: [{ name: 'Mark', age: 7 }] };
|
30
|
+
const cloned = cloneDeep(original);
|
31
|
+
|
32
|
+
expect(cloned).toEqual(original);
|
33
|
+
expect(cloned).not.toBe(original);
|
34
|
+
expect(cloned?.children).not.toBe(original.children);
|
35
|
+
expect(structuredCloneSpy).toHaveBeenCalledTimes(1);
|
36
|
+
});
|
37
|
+
|
38
|
+
it('should use JSON namespace as a fallback', () => {
|
39
|
+
const structuredCloneSpy = vi.spyOn(global, 'structuredClone');
|
40
|
+
const serializeSpy = vi.spyOn(JSON, 'stringify');
|
41
|
+
const deserializeSpy = vi.spyOn(JSON, 'parse');
|
42
|
+
|
43
|
+
global.structuredClone = undefined as any;
|
44
|
+
|
45
|
+
const original = { name: 'John', age: 30 };
|
46
|
+
const cloned = cloneDeep(original);
|
47
|
+
|
48
|
+
expect(cloned).toEqual(original);
|
49
|
+
expect(cloned).not.toBe(original);
|
50
|
+
expect(structuredCloneSpy).not.toHaveBeenCalled();
|
51
|
+
expect(serializeSpy).toHaveBeenCalledTimes(1);
|
52
|
+
expect(deserializeSpy).toHaveBeenCalledTimes(1);
|
53
|
+
});
|
54
|
+
});
|