livekit-client 2.0.4 → 2.0.6
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 +10 -8
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +10400 -9929
- 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 +2 -3
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +1 -0
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/logger.d.ts +2 -2
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/room/PCTransportManager.d.ts +1 -1
- package/dist/src/room/PCTransportManager.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +4 -4
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/RegionUrlProvider.d.ts +1 -1
- package/dist/src/room/RegionUrlProvider.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +2 -3
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
- package/dist/src/room/participant/ParticipantTrackPermission.d.ts.map +1 -1
- package/dist/src/room/participant/RemoteParticipant.d.ts +5 -1
- package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrackPublication.d.ts +1 -1
- package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts +1 -2
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteTrackPublication.d.ts +1 -1
- package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/Track.d.ts +1 -2
- package/dist/src/room/track/Track.d.ts.map +1 -1
- package/dist/src/room/track/TrackPublication.d.ts +2 -3
- package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +1 -1
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +1 -1
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +2 -3
- package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +1 -0
- package/dist/ts4.2/src/index.d.ts +1 -1
- package/dist/ts4.2/src/logger.d.ts +2 -2
- package/dist/ts4.2/src/room/PCTransportManager.d.ts +1 -1
- package/dist/ts4.2/src/room/RTCEngine.d.ts +5 -5
- package/dist/ts4.2/src/room/RegionUrlProvider.d.ts +1 -1
- package/dist/ts4.2/src/room/Room.d.ts +1 -1
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -1
- package/dist/ts4.2/src/room/participant/Participant.d.ts +2 -3
- package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
- package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +5 -1
- package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +1 -1
- package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +1 -2
- package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +1 -1
- package/dist/ts4.2/src/room/track/Track.d.ts +1 -2
- package/dist/ts4.2/src/room/track/TrackPublication.d.ts +2 -3
- package/dist/ts4.2/src/room/track/utils.d.ts +1 -1
- package/dist/ts4.2/src/room/utils.d.ts +1 -1
- package/package.json +2 -2
- package/src/api/SignalClient.ts +19 -17
- package/src/connectionHelper/checks/websocket.ts +1 -1
- package/src/e2ee/E2eeManager.ts +1 -1
- package/src/e2ee/worker/FrameCryptor.ts +12 -6
- package/src/index.ts +1 -1
- package/src/logger.ts +21 -18
- package/src/room/PCTransportManager.ts +1 -1
- package/src/room/RTCEngine.ts +33 -31
- package/src/room/RegionUrlProvider.ts +1 -1
- package/src/room/Room.ts +36 -25
- package/src/room/participant/LocalParticipant.ts +4 -6
- package/src/room/participant/Participant.ts +4 -6
- package/src/room/participant/ParticipantTrackPermission.ts +1 -1
- package/src/room/participant/RemoteParticipant.ts +14 -2
- package/src/room/track/LocalAudioTrack.ts +5 -2
- package/src/room/track/LocalTrackPublication.ts +1 -1
- package/src/room/track/LocalVideoTrack.ts +11 -3
- package/src/room/track/RemoteTrackPublication.ts +7 -2
- package/src/room/track/Track.ts +6 -6
- package/src/room/track/TrackPublication.ts +7 -3
- package/src/room/track/facingMode.ts +2 -2
- package/src/room/track/utils.ts +19 -12
- package/src/room/utils.ts +4 -1
- package/dist/src/proto/livekit_models_pb.d.ts +0 -1405
- package/dist/src/proto/livekit_models_pb.d.ts.map +0 -1
- package/dist/src/proto/livekit_rtc_pb.d.ts +0 -1423
- package/dist/src/proto/livekit_rtc_pb.d.ts.map +0 -1
- package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +0 -1405
- package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +0 -1423
- package/src/proto/livekit_models_pb.ts +0 -2327
- package/src/proto/livekit_rtc_pb.ts +0 -2411
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { DataPacket_Kind, DisconnectReason } from '@livekit/protocol';
|
|
1
2
|
import { LogLevel, LoggerNames, getLogger, setLogExtension, setLogLevel } from './logger';
|
|
2
|
-
import { DataPacket_Kind, DisconnectReason } from './proto/livekit_models_pb';
|
|
3
3
|
import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
|
|
4
4
|
import Room, { ConnectionState } from './room/Room';
|
|
5
5
|
import LocalParticipant from './room/participant/LocalParticipant';
|
|
@@ -20,7 +20,7 @@ export declare enum LoggerNames {
|
|
|
20
20
|
E2EE = "lk-e2ee"
|
|
21
21
|
}
|
|
22
22
|
type LogLevelString = keyof typeof LogLevel;
|
|
23
|
-
export type StructuredLogger = {
|
|
23
|
+
export type StructuredLogger = log.Logger & {
|
|
24
24
|
trace: (msg: string, context?: object) => void;
|
|
25
25
|
debug: (msg: string, context?: object) => void;
|
|
26
26
|
info: (msg: string, context?: object) => void;
|
|
@@ -42,6 +42,6 @@ export type LogExtension = (level: LogLevel, msg: string, context?: object) => v
|
|
|
42
42
|
* use this to hook into the logging function to allow sending internal livekit logs to third party services
|
|
43
43
|
* if set, the browser logs will lose their stacktrace information (see https://github.com/pimterry/loglevel#writing-plugins)
|
|
44
44
|
*/
|
|
45
|
-
export declare function setLogExtension(extension: LogExtension, logger?:
|
|
45
|
+
export declare function setLogExtension(extension: LogExtension, logger?: StructuredLogger): void;
|
|
46
46
|
export declare const workerLogger: StructuredLogger;
|
|
47
47
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import type { AddTrackRequest, ConnectionQualityUpdate, JoinResponse, StreamStateUpdate, SubscriptionPermissionUpdate, SubscriptionResponse } from '@livekit/protocol';
|
|
2
|
+
import { DataPacket, DataPacket_Kind, DisconnectReason, ParticipantInfo, Room as RoomModel, SpeakerInfo, SubscribedQualityUpdate, TrackInfo, TrackUnpublishedResponse, UserPacket } from '@livekit/protocol';
|
|
1
3
|
import type TypedEventEmitter from 'typed-emitter';
|
|
2
4
|
import type { SignalOptions } from '../api/SignalClient';
|
|
3
5
|
import { SignalClient } from '../api/SignalClient';
|
|
4
6
|
import type { InternalRoomOptions } from '../options';
|
|
5
|
-
import { DataPacket, DataPacket_Kind, DisconnectReason, ParticipantInfo, Room as RoomModel, SpeakerInfo, TrackInfo, UserPacket } from '../proto/livekit_models_pb';
|
|
6
|
-
import type { AddTrackRequest, ConnectionQualityUpdate, JoinResponse, StreamStateUpdate, SubscriptionPermissionUpdate, SubscriptionResponse } from '../proto/livekit_rtc_pb';
|
|
7
|
-
import { SubscribedQualityUpdate, TrackUnpublishedResponse } from '../proto/livekit_rtc_pb';
|
|
8
7
|
import PCTransport from './PCTransport';
|
|
9
8
|
import { PCTransportManager } from './PCTransportManager';
|
|
10
9
|
import type { RegionUrlProvider } from './RegionUrlProvider';
|
|
@@ -63,8 +62,9 @@ export default class RTCEngine extends RTCEngine_base {
|
|
|
63
62
|
/** @internal */
|
|
64
63
|
get logContext(): {
|
|
65
64
|
room: string | undefined;
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
roomID: string | undefined;
|
|
66
|
+
participant: string | undefined;
|
|
67
|
+
pID: string | undefined;
|
|
68
68
|
};
|
|
69
69
|
join(url: string, token: string, opts: SignalOptions, abortSignal?: AbortSignal): Promise<JoinResponse>;
|
|
70
70
|
close(): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { DataPacket_Kind, DisconnectReason, ParticipantPermission, SubscriptionError } from '@livekit/protocol';
|
|
1
2
|
import type TypedEmitter from 'typed-emitter';
|
|
2
3
|
import 'webrtc-adapter';
|
|
3
4
|
import type { InternalRoomOptions, RoomConnectOptions, RoomOptions } from '../options';
|
|
4
|
-
import { DataPacket_Kind, DisconnectReason, ParticipantPermission, SubscriptionError } from '../proto/livekit_models_pb';
|
|
5
5
|
import RTCEngine from './RTCEngine';
|
|
6
6
|
import LocalParticipant from './participant/LocalParticipant';
|
|
7
7
|
import type Participant from './participant/Participant';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ParticipantInfo, ParticipantPermission } from '@livekit/protocol';
|
|
1
2
|
import type { InternalRoomOptions } from '../../options';
|
|
2
|
-
import { ParticipantInfo, ParticipantPermission } from '../../proto/livekit_models_pb';
|
|
3
3
|
import type RTCEngine from '../RTCEngine';
|
|
4
4
|
import LocalTrack from '../track/LocalTrack';
|
|
5
5
|
import LocalTrackPublication from '../track/LocalTrackPublication';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DataPacket_Kind, ParticipantInfo, ParticipantPermission, ConnectionQuality as ProtoQuality, SubscriptionError } from '@livekit/protocol';
|
|
1
2
|
import type TypedEmitter from 'typed-emitter';
|
|
2
3
|
import { StructuredLogger } from '../../logger';
|
|
3
|
-
import { DataPacket_Kind, ParticipantInfo, ParticipantPermission, ConnectionQuality as ProtoQuality, SubscriptionError } from '../../proto/livekit_models_pb';
|
|
4
4
|
import type LocalTrackPublication from '../track/LocalTrackPublication';
|
|
5
5
|
import type RemoteTrack from '../track/RemoteTrack';
|
|
6
6
|
import type RemoteTrackPublication from '../track/RemoteTrackPublication';
|
|
@@ -44,8 +44,7 @@ export default class Participant extends Participant_base {
|
|
|
44
44
|
protected log: StructuredLogger;
|
|
45
45
|
protected loggerOptions?: LoggerOptions;
|
|
46
46
|
protected get logContext(): {
|
|
47
|
-
|
|
48
|
-
participantId: string;
|
|
47
|
+
[x: string]: unknown;
|
|
49
48
|
};
|
|
50
49
|
get isEncrypted(): boolean;
|
|
51
50
|
get isAgent(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { ParticipantInfo } from '@livekit/protocol';
|
|
1
2
|
import type { SignalClient } from '../../api/SignalClient';
|
|
2
|
-
import type { ParticipantInfo } from '../../proto/livekit_models_pb';
|
|
3
3
|
import RemoteTrackPublication from '../track/RemoteTrackPublication';
|
|
4
4
|
import { Track } from '../track/Track';
|
|
5
5
|
import type { AudioOutputOptions } from '../track/options';
|
|
@@ -16,6 +16,10 @@ export default class RemoteParticipant extends Participant {
|
|
|
16
16
|
private audioOutput?;
|
|
17
17
|
/** @internal */
|
|
18
18
|
static fromParticipantInfo(signalClient: SignalClient, pi: ParticipantInfo): RemoteParticipant;
|
|
19
|
+
protected get logContext(): {
|
|
20
|
+
rpID: string;
|
|
21
|
+
remoteParticipant: string;
|
|
22
|
+
};
|
|
19
23
|
/** @internal */
|
|
20
24
|
constructor(signalClient: SignalClient, sid: string, identity?: string, name?: string, metadata?: string, loggerOptions?: LoggerOptions);
|
|
21
25
|
protected addTrackPublication(publication: RemoteTrackPublication): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { SubscribedCodec, SubscribedQuality, VideoLayer } from '@livekit/protocol';
|
|
1
2
|
import type { SignalClient } from '../../api/SignalClient';
|
|
2
|
-
import { VideoLayer } from '../../proto/livekit_models_pb';
|
|
3
|
-
import { SubscribedCodec, SubscribedQuality } from '../../proto/livekit_rtc_pb';
|
|
4
3
|
import type { VideoSenderStats } from '../stats';
|
|
5
4
|
import type { LoggerOptions } from '../types';
|
|
6
5
|
import LocalTrack from './LocalTrack';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SubscriptionError, TrackInfo } from '
|
|
1
|
+
import { SubscriptionError, TrackInfo } from '@livekit/protocol';
|
|
2
2
|
import type { LoggerOptions } from '../types';
|
|
3
3
|
import type RemoteTrack from './RemoteTrack';
|
|
4
4
|
import { Track, VideoQuality } from './Track';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { StreamState as ProtoStreamState, TrackSource, TrackType } from '@livekit/protocol';
|
|
1
2
|
import type TypedEventEmitter from 'typed-emitter';
|
|
2
3
|
import type { SignalClient } from '../../api/SignalClient';
|
|
3
4
|
import { StructuredLogger } from '../../logger';
|
|
4
|
-
import { TrackSource, TrackType } from '../../proto/livekit_models_pb';
|
|
5
|
-
import { StreamState as ProtoStreamState } from '../../proto/livekit_rtc_pb';
|
|
6
5
|
import type { LoggerOptions } from '../types';
|
|
7
6
|
import type { TrackProcessor } from './processor/types';
|
|
8
7
|
export declare enum VideoQuality {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { Encryption_Type } from '@livekit/protocol';
|
|
2
|
+
import type { SubscriptionError, TrackInfo, UpdateSubscription, UpdateTrackSettings } from '@livekit/protocol';
|
|
1
3
|
import type TypedEventEmitter from 'typed-emitter';
|
|
2
|
-
import { Encryption_Type } from '../../proto/livekit_models_pb';
|
|
3
|
-
import type { SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
|
|
4
|
-
import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
|
|
5
4
|
import type { LoggerOptions } from '../types';
|
|
6
5
|
import LocalAudioTrack from './LocalAudioTrack';
|
|
7
6
|
import LocalVideoTrack from './LocalVideoTrack';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TrackPublishedResponse } from '
|
|
1
|
+
import { TrackPublishedResponse } from '@livekit/protocol';
|
|
2
2
|
import { Track } from './Track';
|
|
3
3
|
import type { TrackPublication } from './TrackPublication';
|
|
4
4
|
import type { AudioCaptureOptions, CreateLocalTracksOptions, ScreenShareCaptureOptions, VideoCaptureOptions } from './options';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientInfo } from '
|
|
1
|
+
import { ClientInfo } from '@livekit/protocol';
|
|
2
2
|
import type LocalAudioTrack from './track/LocalAudioTrack';
|
|
3
3
|
import type RemoteAudioTrack from './track/RemoteAudioTrack';
|
|
4
4
|
import { VideoCodec } from './track/options';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livekit-client",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "JavaScript/TypeScript client SDK for LiveKit",
|
|
5
5
|
"main": "./dist/livekit-client.umd.js",
|
|
6
6
|
"unpkg": "./dist/livekit-client.umd.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"author": "David Zhao <david@davidzhao.com>",
|
|
37
37
|
"license": "Apache-2.0",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@
|
|
39
|
+
"@livekit/protocol": "1.10.4",
|
|
40
40
|
"events": "^3.3.0",
|
|
41
41
|
"loglevel": "^1.8.0",
|
|
42
42
|
"sdp-transform": "^2.14.1",
|
package/src/api/SignalClient.ts
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import { protoInt64 } from '@bufbuild/protobuf';
|
|
2
|
-
import log, { LoggerNames, getLogger } from '../logger';
|
|
3
|
-
import {
|
|
4
|
-
ClientInfo,
|
|
5
|
-
DisconnectReason,
|
|
6
|
-
ParticipantInfo,
|
|
7
|
-
ReconnectReason,
|
|
8
|
-
Room,
|
|
9
|
-
SpeakerInfo,
|
|
10
|
-
VideoLayer,
|
|
11
|
-
} from '../proto/livekit_models_pb';
|
|
12
1
|
import {
|
|
13
2
|
AddTrackRequest,
|
|
3
|
+
ClientInfo,
|
|
14
4
|
ConnectionQualityUpdate,
|
|
5
|
+
DisconnectReason,
|
|
15
6
|
JoinResponse,
|
|
16
7
|
LeaveRequest,
|
|
17
8
|
MuteTrackRequest,
|
|
9
|
+
ParticipantInfo,
|
|
18
10
|
Ping,
|
|
11
|
+
ReconnectReason,
|
|
19
12
|
ReconnectResponse,
|
|
13
|
+
Room,
|
|
20
14
|
SessionDescription,
|
|
21
15
|
SignalRequest,
|
|
22
16
|
SignalResponse,
|
|
23
17
|
SignalTarget,
|
|
24
18
|
SimulateScenario,
|
|
19
|
+
SpeakerInfo,
|
|
25
20
|
StreamStateUpdate,
|
|
26
21
|
SubscribedQualityUpdate,
|
|
27
22
|
SubscriptionPermission,
|
|
@@ -36,7 +31,10 @@ import {
|
|
|
36
31
|
UpdateSubscription,
|
|
37
32
|
UpdateTrackSettings,
|
|
38
33
|
UpdateVideoLayers,
|
|
39
|
-
|
|
34
|
+
VideoLayer,
|
|
35
|
+
protoInt64,
|
|
36
|
+
} from '@livekit/protocol';
|
|
37
|
+
import log, { LoggerNames, getLogger } from '../logger';
|
|
40
38
|
import { ConnectionError, ConnectionErrorReason } from '../room/errors';
|
|
41
39
|
import CriticalTimers from '../room/timers';
|
|
42
40
|
import type { LoggerOptions } from '../room/types';
|
|
@@ -216,7 +214,7 @@ export class SignalClient {
|
|
|
216
214
|
token: string,
|
|
217
215
|
sid?: string,
|
|
218
216
|
reason?: ReconnectReason,
|
|
219
|
-
): Promise<ReconnectResponse |
|
|
217
|
+
): Promise<ReconnectResponse | undefined> {
|
|
220
218
|
if (!this.options) {
|
|
221
219
|
this.log.warn(
|
|
222
220
|
'attempted to reconnect without signal options being set, ignoring',
|
|
@@ -242,7 +240,7 @@ export class SignalClient {
|
|
|
242
240
|
token: string,
|
|
243
241
|
opts: ConnectOpts,
|
|
244
242
|
abortSignal?: AbortSignal,
|
|
245
|
-
): Promise<JoinResponse | ReconnectResponse |
|
|
243
|
+
): Promise<JoinResponse | ReconnectResponse | undefined> {
|
|
246
244
|
this.connectOptions = opts;
|
|
247
245
|
url = toWebsocketUrl(url);
|
|
248
246
|
// strip trailing slash
|
|
@@ -252,7 +250,7 @@ export class SignalClient {
|
|
|
252
250
|
const clientInfo = getClientInfo();
|
|
253
251
|
const params = createConnectionParams(token, clientInfo, opts);
|
|
254
252
|
|
|
255
|
-
return new Promise<JoinResponse | ReconnectResponse |
|
|
253
|
+
return new Promise<JoinResponse | ReconnectResponse | undefined>(async (resolve, reject) => {
|
|
256
254
|
const unlock = await this.connectionLock.lock();
|
|
257
255
|
try {
|
|
258
256
|
const abortHandler = async () => {
|
|
@@ -356,9 +354,13 @@ export class SignalClient {
|
|
|
356
354
|
abortSignal?.removeEventListener('abort', abortHandler);
|
|
357
355
|
this.startPingInterval();
|
|
358
356
|
if (resp.message?.case === 'reconnect') {
|
|
359
|
-
resolve(resp.message
|
|
357
|
+
resolve(resp.message.value);
|
|
360
358
|
} else {
|
|
361
|
-
|
|
359
|
+
this.log.debug(
|
|
360
|
+
'declaring signal reconnected without reconnect response received',
|
|
361
|
+
this.logContext,
|
|
362
|
+
);
|
|
363
|
+
resolve(undefined);
|
|
362
364
|
shouldProcessMessage = true;
|
|
363
365
|
}
|
|
364
366
|
} else if (this.isEstablishingConnection && resp.message.case === 'leave') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ServerInfo_Edition } from '@livekit/protocol';
|
|
1
2
|
import { SignalClient } from '../../api/SignalClient';
|
|
2
|
-
import { ServerInfo_Edition } from '../../proto/livekit_models_pb';
|
|
3
3
|
import { Checker } from './Checker';
|
|
4
4
|
|
|
5
5
|
export class WebSocketCheck extends Checker {
|
package/src/e2ee/E2eeManager.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Encryption_Type, TrackInfo } from '@livekit/protocol';
|
|
1
2
|
import { EventEmitter } from 'events';
|
|
2
3
|
import type TypedEventEmitter from 'typed-emitter';
|
|
3
4
|
import log, { LogLevel, workerLogger } from '../logger';
|
|
4
|
-
import { Encryption_Type, TrackInfo } from '../proto/livekit_models_pb';
|
|
5
5
|
import type RTCEngine from '../room/RTCEngine';
|
|
6
6
|
import type Room from '../room/Room';
|
|
7
7
|
import { ConnectionState } from '../room/Room';
|
|
@@ -67,6 +67,8 @@ export class FrameCryptor extends BaseFrameCryptor {
|
|
|
67
67
|
|
|
68
68
|
private sifGuard: SifGuard;
|
|
69
69
|
|
|
70
|
+
private detectedCodec?: VideoCodec;
|
|
71
|
+
|
|
70
72
|
constructor(opts: {
|
|
71
73
|
keys: ParticipantKeyHandler;
|
|
72
74
|
participantIdentity: string;
|
|
@@ -85,8 +87,8 @@ export class FrameCryptor extends BaseFrameCryptor {
|
|
|
85
87
|
|
|
86
88
|
private get logContext() {
|
|
87
89
|
return {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
participant: this.participantIdentity,
|
|
91
|
+
mediaTrackId: this.trackId,
|
|
90
92
|
fallbackCodec: this.videoCodec,
|
|
91
93
|
};
|
|
92
94
|
}
|
|
@@ -229,7 +231,6 @@ export class FrameCryptor extends BaseFrameCryptor {
|
|
|
229
231
|
encodedFrame.timestamp,
|
|
230
232
|
);
|
|
231
233
|
let frameInfo = this.getUnencryptedBytes(encodedFrame);
|
|
232
|
-
workerLogger.debug('frameInfo for encoded frame', { ...frameInfo, ...this.logContext });
|
|
233
234
|
|
|
234
235
|
// Thіs is not encrypted and contains the VP8 payload descriptor or the Opus TOC byte.
|
|
235
236
|
const frameHeader = new Uint8Array(encodedFrame.data, 0, frameInfo.unencryptedBytes);
|
|
@@ -334,7 +335,6 @@ export class FrameCryptor extends BaseFrameCryptor {
|
|
|
334
335
|
const decodedFrame = await this.decryptFrame(encodedFrame, keyIndex);
|
|
335
336
|
this.keys.decryptionSuccess();
|
|
336
337
|
if (decodedFrame) {
|
|
337
|
-
workerLogger.debug('enqueue decrypted frame', this.logContext);
|
|
338
338
|
return controller.enqueue(decodedFrame);
|
|
339
339
|
}
|
|
340
340
|
} catch (error) {
|
|
@@ -375,7 +375,6 @@ export class FrameCryptor extends BaseFrameCryptor {
|
|
|
375
375
|
throw new TypeError(`no encryption key found for decryption of ${this.participantIdentity}`);
|
|
376
376
|
}
|
|
377
377
|
let frameInfo = this.getUnencryptedBytes(encodedFrame);
|
|
378
|
-
workerLogger.debug('frameInfo for decoded frame', { ...frameInfo, ...this.logContext });
|
|
379
378
|
|
|
380
379
|
// Construct frame trailer. Similar to the frame header described in
|
|
381
380
|
// https://tools.ietf.org/html/draft-omara-sframe-00#section-4.2
|
|
@@ -534,6 +533,14 @@ export class FrameCryptor extends BaseFrameCryptor {
|
|
|
534
533
|
var frameInfo = { unencryptedBytes: 0, isH264: false };
|
|
535
534
|
if (isVideoFrame(frame)) {
|
|
536
535
|
let detectedCodec = this.getVideoCodec(frame) ?? this.videoCodec;
|
|
536
|
+
if (detectedCodec !== this.detectedCodec) {
|
|
537
|
+
workerLogger.debug('detected different codec', {
|
|
538
|
+
detectedCodec,
|
|
539
|
+
oldCodec: this.detectedCodec,
|
|
540
|
+
...this.logContext,
|
|
541
|
+
});
|
|
542
|
+
this.detectedCodec = detectedCodec;
|
|
543
|
+
}
|
|
537
544
|
|
|
538
545
|
if (detectedCodec === 'av1' || detectedCodec === 'vp9') {
|
|
539
546
|
throw new Error(`${detectedCodec} is not yet supported for end to end encryption`);
|
|
@@ -591,7 +598,6 @@ export class FrameCryptor extends BaseFrameCryptor {
|
|
|
591
598
|
// @ts-expect-error payloadType is not yet part of the typescript definition and currently not supported in Safari
|
|
592
599
|
const payloadType = frame.getMetadata().payloadType;
|
|
593
600
|
const codec = payloadType ? this.rtpMap.get(payloadType) : undefined;
|
|
594
|
-
workerLogger.debug('reading codec from frame', { codec, ...this.logContext });
|
|
595
601
|
return codec;
|
|
596
602
|
}
|
|
597
603
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { DataPacket_Kind, DisconnectReason } from '@livekit/protocol';
|
|
1
2
|
import { LogLevel, LoggerNames, getLogger, setLogExtension, setLogLevel } from './logger';
|
|
2
|
-
import { DataPacket_Kind, DisconnectReason } from './proto/livekit_models_pb';
|
|
3
3
|
import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
|
|
4
4
|
import Room, { ConnectionState } from './room/Room';
|
|
5
5
|
import LocalParticipant from './room/participant/LocalParticipant';
|
package/src/logger.ts
CHANGED
|
@@ -24,7 +24,7 @@ export enum LoggerNames {
|
|
|
24
24
|
|
|
25
25
|
type LogLevelString = keyof typeof LogLevel;
|
|
26
26
|
|
|
27
|
-
export type StructuredLogger = {
|
|
27
|
+
export type StructuredLogger = log.Logger & {
|
|
28
28
|
trace: (msg: string, context?: object) => void;
|
|
29
29
|
debug: (msg: string, context?: object) => void;
|
|
30
30
|
info: (msg: string, context?: object) => void;
|
|
@@ -36,6 +36,7 @@ export type StructuredLogger = {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
let livekitLogger = log.getLogger('livekit');
|
|
39
|
+
const livekitLoggers = Object.values(LoggerNames).map((name) => log.getLogger(name));
|
|
39
40
|
|
|
40
41
|
livekitLogger.setDefaultLevel(LogLevel.info);
|
|
41
42
|
|
|
@@ -54,9 +55,7 @@ export function setLogLevel(level: LogLevel | LogLevelString, loggerName?: Logge
|
|
|
54
55
|
if (loggerName) {
|
|
55
56
|
log.getLogger(loggerName).setLevel(level);
|
|
56
57
|
}
|
|
57
|
-
for (const logger of
|
|
58
|
-
.filter(([logrName]) => logrName.startsWith('livekit'))
|
|
59
|
-
.map(([, logr]) => logr)) {
|
|
58
|
+
for (const logger of livekitLoggers) {
|
|
60
59
|
logger.setLevel(level);
|
|
61
60
|
}
|
|
62
61
|
}
|
|
@@ -67,24 +66,28 @@ export type LogExtension = (level: LogLevel, msg: string, context?: object) => v
|
|
|
67
66
|
* use this to hook into the logging function to allow sending internal livekit logs to third party services
|
|
68
67
|
* if set, the browser logs will lose their stacktrace information (see https://github.com/pimterry/loglevel#writing-plugins)
|
|
69
68
|
*/
|
|
70
|
-
export function setLogExtension(extension: LogExtension, logger
|
|
71
|
-
const
|
|
69
|
+
export function setLogExtension(extension: LogExtension, logger?: StructuredLogger) {
|
|
70
|
+
const loggers = logger ? [logger] : livekitLoggers;
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
const
|
|
72
|
+
loggers.forEach((logR) => {
|
|
73
|
+
const originalFactory = logR.methodFactory;
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
logR.methodFactory = (methodName, configLevel, loggerName) => {
|
|
76
|
+
const rawMethod = originalFactory(methodName, configLevel, loggerName);
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
const logLevel = LogLevel[methodName as LogLevelString];
|
|
79
|
+
const needLog = logLevel >= configLevel && logLevel < LogLevel.silent;
|
|
80
|
+
|
|
81
|
+
return (msg, context?: [msg: string, context: object]) => {
|
|
82
|
+
if (context) rawMethod(msg, context);
|
|
83
|
+
else rawMethod(msg);
|
|
84
|
+
if (needLog) {
|
|
85
|
+
extension(logLevel, msg, context);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
85
88
|
};
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
logR.setLevel(logR.getLevel());
|
|
90
|
+
});
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
export const workerLogger = log.getLogger('lk-e2ee') as StructuredLogger;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SignalTarget } from '@livekit/protocol';
|
|
1
2
|
import log, { LoggerNames, getLogger } from '../logger';
|
|
2
|
-
import { SignalTarget } from '../proto/livekit_rtc_pb';
|
|
3
3
|
import PCTransport, { PCEvents } from './PCTransport';
|
|
4
4
|
import { roomConnectOptionDefaults } from './defaults';
|
|
5
5
|
import { ConnectionError, ConnectionErrorReason } from './errors';
|
package/src/room/RTCEngine.ts
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import type { MediaAttributes } from 'sdp-transform';
|
|
3
|
-
import type TypedEventEmitter from 'typed-emitter';
|
|
4
|
-
import type { SignalOptions } from '../api/SignalClient';
|
|
5
|
-
import {
|
|
6
|
-
SignalClient,
|
|
7
|
-
SignalConnectionState,
|
|
8
|
-
toProtoSessionDescription,
|
|
9
|
-
} from '../api/SignalClient';
|
|
10
|
-
import log, { LoggerNames, getLogger } from '../logger';
|
|
11
|
-
import type { InternalRoomOptions } from '../options';
|
|
12
1
|
import {
|
|
2
|
+
type AddTrackRequest,
|
|
13
3
|
ClientConfigSetting,
|
|
14
4
|
ClientConfiguration,
|
|
5
|
+
type ConnectionQualityUpdate,
|
|
6
|
+
DataChannelInfo,
|
|
15
7
|
DataPacket,
|
|
16
8
|
DataPacket_Kind,
|
|
17
9
|
DisconnectReason,
|
|
18
|
-
ParticipantInfo,
|
|
19
|
-
ReconnectReason,
|
|
20
|
-
Room as RoomModel,
|
|
21
|
-
SpeakerInfo,
|
|
22
|
-
TrackInfo,
|
|
23
|
-
UserPacket,
|
|
24
|
-
} from '../proto/livekit_models_pb';
|
|
25
|
-
import {
|
|
26
|
-
type AddTrackRequest,
|
|
27
|
-
type ConnectionQualityUpdate,
|
|
28
|
-
DataChannelInfo,
|
|
29
10
|
type JoinResponse,
|
|
30
11
|
type LeaveRequest,
|
|
12
|
+
ParticipantInfo,
|
|
13
|
+
ReconnectReason,
|
|
31
14
|
type ReconnectResponse,
|
|
15
|
+
Room as RoomModel,
|
|
32
16
|
SignalTarget,
|
|
17
|
+
SpeakerInfo,
|
|
33
18
|
type StreamStateUpdate,
|
|
34
19
|
SubscribedQualityUpdate,
|
|
35
20
|
type SubscriptionPermissionUpdate,
|
|
36
21
|
type SubscriptionResponse,
|
|
37
22
|
SyncState,
|
|
23
|
+
TrackInfo,
|
|
38
24
|
type TrackPublishedResponse,
|
|
39
25
|
TrackUnpublishedResponse,
|
|
40
26
|
UpdateSubscription,
|
|
41
|
-
|
|
27
|
+
UserPacket,
|
|
28
|
+
} from '@livekit/protocol';
|
|
29
|
+
import { EventEmitter } from 'events';
|
|
30
|
+
import type { MediaAttributes } from 'sdp-transform';
|
|
31
|
+
import type TypedEventEmitter from 'typed-emitter';
|
|
32
|
+
import type { SignalOptions } from '../api/SignalClient';
|
|
33
|
+
import {
|
|
34
|
+
SignalClient,
|
|
35
|
+
SignalConnectionState,
|
|
36
|
+
toProtoSessionDescription,
|
|
37
|
+
} from '../api/SignalClient';
|
|
38
|
+
import log, { LoggerNames, getLogger } from '../logger';
|
|
39
|
+
import type { InternalRoomOptions } from '../options';
|
|
42
40
|
import PCTransport, { PCEvents } from './PCTransport';
|
|
43
41
|
import { PCTransportManager, PCTransportState } from './PCTransportManager';
|
|
44
42
|
import type { ReconnectContext, ReconnectPolicy } from './ReconnectPolicy';
|
|
@@ -205,8 +203,9 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
|
|
205
203
|
get logContext() {
|
|
206
204
|
return {
|
|
207
205
|
room: this.latestJoinResponse?.room?.name,
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
roomID: this.latestJoinResponse?.room?.sid,
|
|
207
|
+
participant: this.latestJoinResponse?.participant?.identity,
|
|
208
|
+
pID: this.latestJoinResponse?.participant?.sid,
|
|
210
209
|
};
|
|
211
210
|
}
|
|
212
211
|
|
|
@@ -1005,14 +1004,10 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
|
|
1005
1004
|
|
|
1006
1005
|
this.log.info(`resuming signal connection, attempt ${this.reconnectAttempts}`, this.logContext);
|
|
1007
1006
|
this.emit(EngineEvent.Resuming);
|
|
1008
|
-
|
|
1007
|
+
let res: ReconnectResponse | undefined;
|
|
1009
1008
|
try {
|
|
1010
1009
|
this.setupSignalClientCallbacks();
|
|
1011
|
-
|
|
1012
|
-
if (res) {
|
|
1013
|
-
const rtcConfig = this.makeRTCConfiguration(res);
|
|
1014
|
-
this.pcManager.updateConfiguration(rtcConfig);
|
|
1015
|
-
}
|
|
1010
|
+
res = await this.client.reconnect(this.url, this.token, this.participantSid, reason);
|
|
1016
1011
|
} catch (error) {
|
|
1017
1012
|
let message = '';
|
|
1018
1013
|
if (error instanceof Error) {
|
|
@@ -1029,6 +1024,13 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
|
|
1029
1024
|
}
|
|
1030
1025
|
this.emit(EngineEvent.SignalResumed);
|
|
1031
1026
|
|
|
1027
|
+
if (res) {
|
|
1028
|
+
const rtcConfig = this.makeRTCConfiguration(res);
|
|
1029
|
+
this.pcManager.updateConfiguration(rtcConfig);
|
|
1030
|
+
} else {
|
|
1031
|
+
this.log.warn('Did not receive reconnect response', this.logContext);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1032
1034
|
if (this.shouldFailNext) {
|
|
1033
1035
|
this.shouldFailNext = false;
|
|
1034
1036
|
throw new Error('simulated failure');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { RegionInfo, RegionSettings } from '@livekit/protocol';
|
|
1
2
|
import log from '../logger';
|
|
2
|
-
import type { RegionInfo, RegionSettings } from '../proto/livekit_rtc_pb';
|
|
3
3
|
import { ConnectionError, ConnectionErrorReason } from './errors';
|
|
4
4
|
import { isCloud } from './utils';
|
|
5
5
|
|