livekit-client 1.12.0 → 1.12.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +19 -1
- 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 +442 -334
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +12303 -14499
- 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 -2
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/connectionHelper/ConnectionCheck.d.ts +3 -2
- package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/Checker.d.ts +3 -2
- package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/webrtc.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts +4 -2
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/KeyProvider.d.ts +4 -2
- package/dist/src/e2ee/KeyProvider.d.ts.map +1 -1
- package/dist/src/e2ee/constants.d.ts +1 -0
- 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 +4 -3
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +21 -2
- package/dist/src/e2ee/worker/ParticipantKeyHandler.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/proto/livekit_models_pb.d.ts +1264 -0
- package/dist/src/proto/livekit_models_pb.d.ts.map +1 -0
- package/dist/src/proto/livekit_rtc_pb.d.ts +1373 -0
- package/dist/src/proto/livekit_rtc_pb.d.ts.map +1 -0
- package/dist/src/room/PCTransport.d.ts +2 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +9 -5
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/RegionUrlProvider.d.ts +4 -1
- package/dist/src/room/RegionUrlProvider.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +15 -11
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +2 -2
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +5 -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 +8 -7
- package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
- package/dist/src/room/timers.d.ts +5 -4
- package/dist/src/room/timers.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts +3 -0
- package/dist/src/room/track/LocalTrack.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 +2 -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 +6 -4
- package/dist/src/room/track/Track.d.ts.map +1 -1
- package/dist/src/room/track/TrackPublication.d.ts +7 -5
- package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/create.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +7 -0
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +5 -1
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +3 -1
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/src/test/mocks.d.ts +4 -3
- package/dist/src/test/mocks.d.ts.map +1 -1
- package/dist/src/utils/browserParser.d.ts +2 -0
- package/dist/src/utils/browserParser.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +2 -2
- package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +3 -2
- package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +3 -2
- package/dist/ts4.2/src/e2ee/E2eeManager.d.ts +4 -2
- package/dist/ts4.2/src/e2ee/KeyProvider.d.ts +4 -2
- package/dist/ts4.2/src/e2ee/constants.d.ts +1 -0
- package/dist/ts4.2/src/e2ee/types.d.ts +1 -0
- package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +4 -3
- package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +21 -2
- package/dist/ts4.2/src/index.d.ts +1 -1
- package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +1264 -0
- package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +1373 -0
- package/dist/ts4.2/src/room/PCTransport.d.ts +2 -1
- package/dist/ts4.2/src/room/RTCEngine.d.ts +9 -5
- package/dist/ts4.2/src/room/RegionUrlProvider.d.ts +4 -1
- package/dist/ts4.2/src/room/Room.d.ts +15 -11
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +2 -2
- package/dist/ts4.2/src/room/participant/Participant.d.ts +5 -3
- package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
- package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +8 -7
- package/dist/ts4.2/src/room/timers.d.ts +5 -4
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +3 -0
- package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +1 -1
- package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +2 -2
- package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +1 -1
- package/dist/ts4.2/src/room/track/Track.d.ts +6 -4
- package/dist/ts4.2/src/room/track/TrackPublication.d.ts +7 -5
- package/dist/ts4.2/src/room/track/options.d.ts +7 -0
- package/dist/ts4.2/src/room/track/utils.d.ts +5 -1
- package/dist/ts4.2/src/room/utils.d.ts +3 -1
- package/dist/ts4.2/src/test/mocks.d.ts +4 -3
- package/dist/ts4.2/src/utils/browserParser.d.ts +2 -0
- package/package.json +10 -10
- package/src/api/SignalClient.ts +104 -101
- package/src/connectionHelper/ConnectionCheck.ts +3 -2
- package/src/connectionHelper/checks/Checker.ts +3 -3
- package/src/connectionHelper/checks/webrtc.ts +66 -2
- package/src/connectionHelper/checks/websocket.ts +4 -0
- package/src/e2ee/E2eeManager.ts +4 -3
- package/src/e2ee/KeyProvider.ts +3 -2
- package/src/e2ee/constants.ts +4 -0
- package/src/e2ee/types.ts +1 -0
- package/src/e2ee/worker/FrameCryptor.test.ts +1 -3
- package/src/e2ee/worker/FrameCryptor.ts +14 -16
- package/src/e2ee/worker/ParticipantKeyHandler.ts +48 -2
- package/src/e2ee/worker/e2ee.worker.ts +12 -6
- package/src/index.ts +1 -1
- package/src/proto/livekit_models_pb.ts +2096 -0
- package/src/proto/livekit_rtc_pb.ts +2332 -0
- package/src/room/PCTransport.ts +1 -1
- package/src/room/RTCEngine.ts +24 -18
- package/src/room/RegionUrlProvider.ts +11 -2
- package/src/room/Room.test.ts +1 -0
- package/src/room/Room.ts +175 -86
- package/src/room/participant/LocalParticipant.ts +43 -59
- package/src/room/participant/Participant.ts +6 -4
- package/src/room/participant/ParticipantTrackPermission.ts +3 -3
- package/src/room/participant/RemoteParticipant.ts +24 -21
- package/src/room/participant/publishUtils.test.ts +1 -0
- package/src/room/track/LocalTrack.ts +24 -9
- package/src/room/track/LocalTrackPublication.ts +1 -1
- package/src/room/track/LocalVideoTrack.test.ts +2 -1
- package/src/room/track/LocalVideoTrack.ts +22 -22
- package/src/room/track/RemoteTrackPublication.ts +12 -7
- package/src/room/track/RemoteVideoTrack.test.ts +5 -4
- package/src/room/track/Track.ts +9 -6
- package/src/room/track/TrackPublication.ts +7 -5
- package/src/room/track/create.ts +18 -17
- package/src/room/track/facingMode.test.ts +1 -0
- package/src/room/track/options.ts +6 -0
- package/src/room/track/utils.test.ts +1 -0
- package/src/room/track/utils.ts +44 -2
- package/src/room/utils.test.ts +16 -0
- package/src/room/utils.ts +20 -4
- package/src/test/mocks.ts +7 -5
- package/src/utils/AsyncQueue.test.ts +1 -0
- package/src/utils/browserParser.test.ts +33 -3
- package/src/utils/browserParser.ts +5 -0
- package/dist/src/proto/google/protobuf/timestamp.d.ts +0 -146
- package/dist/src/proto/google/protobuf/timestamp.d.ts.map +0 -1
- package/dist/src/proto/livekit_models.d.ts +0 -2399
- package/dist/src/proto/livekit_models.d.ts.map +0 -1
- package/dist/src/proto/livekit_rtc.d.ts +0 -14352
- package/dist/src/proto/livekit_rtc.d.ts.map +0 -1
- package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +0 -150
- package/dist/ts4.2/src/proto/livekit_models.d.ts +0 -2659
- package/dist/ts4.2/src/proto/livekit_rtc.d.ts +0 -15764
- package/src/proto/google/protobuf/timestamp.ts +0 -230
- package/src/proto/livekit_models.ts +0 -4006
- package/src/proto/livekit_rtc.ts +0 -4672
package/src/room/PCTransport.ts
CHANGED
package/src/room/RTCEngine.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import EventEmitter from '
|
1
|
+
import { EventEmitter } from 'events';
|
2
2
|
import type { MediaAttributes } from 'sdp-transform';
|
3
|
-
import
|
3
|
+
import type TypedEventEmitter from 'typed-emitter';
|
4
4
|
import type { SignalOptions } from '../api/SignalClient';
|
5
|
+
import { SignalClient } from '../api/SignalClient';
|
5
6
|
import log from '../logger';
|
6
7
|
import type { InternalRoomOptions } from '../options';
|
7
8
|
import {
|
@@ -16,7 +17,7 @@ import {
|
|
16
17
|
SpeakerInfo,
|
17
18
|
TrackInfo,
|
18
19
|
UserPacket,
|
19
|
-
} from '../proto/
|
20
|
+
} from '../proto/livekit_models_pb';
|
20
21
|
import {
|
21
22
|
AddTrackRequest,
|
22
23
|
ConnectionQualityUpdate,
|
@@ -28,10 +29,10 @@ import {
|
|
28
29
|
SubscriptionPermissionUpdate,
|
29
30
|
SubscriptionResponse,
|
30
31
|
TrackPublishedResponse,
|
31
|
-
} from '../proto/
|
32
|
+
} from '../proto/livekit_rtc_pb';
|
32
33
|
import PCTransport, { PCEvents } from './PCTransport';
|
33
34
|
import type { ReconnectContext, ReconnectPolicy } from './ReconnectPolicy';
|
34
|
-
import { RegionUrlProvider } from './RegionUrlProvider';
|
35
|
+
import type { RegionUrlProvider } from './RegionUrlProvider';
|
35
36
|
import { roomConnectOptionDefaults } from './defaults';
|
36
37
|
import {
|
37
38
|
ConnectionError,
|
@@ -49,7 +50,6 @@ import { Track } from './track/Track';
|
|
49
50
|
import type { TrackPublishOptions, VideoCodec } from './track/options';
|
50
51
|
import {
|
51
52
|
Mutex,
|
52
|
-
isCloud,
|
53
53
|
isVideoCodec,
|
54
54
|
isWeb,
|
55
55
|
sleep,
|
@@ -72,7 +72,7 @@ enum PCState {
|
|
72
72
|
}
|
73
73
|
|
74
74
|
/** @internal */
|
75
|
-
export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
75
|
+
export default class RTCEngine extends (EventEmitter as new () => TypedEventEmitter<EngineEventCallbacks>) {
|
76
76
|
publisher?: PCTransport;
|
77
77
|
|
78
78
|
subscriber?: PCTransport;
|
@@ -122,7 +122,7 @@ export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
|
122
122
|
// this is helpful to know if we need to restart ICE on the publisher connection
|
123
123
|
private hasPublished: boolean = false;
|
124
124
|
|
125
|
-
// keep join info around for reconnect
|
125
|
+
// keep join info around for reconnect, this could be a region url
|
126
126
|
private url?: string;
|
127
127
|
|
128
128
|
private token?: string;
|
@@ -358,6 +358,11 @@ export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
|
358
358
|
return getConnectedAddress(this.primaryPC);
|
359
359
|
}
|
360
360
|
|
361
|
+
/* @internal */
|
362
|
+
setRegionUrlProvider(provider: RegionUrlProvider) {
|
363
|
+
this.regionUrlProvider = provider;
|
364
|
+
}
|
365
|
+
|
361
366
|
private configure(joinResponse: JoinResponse) {
|
362
367
|
// already configured
|
363
368
|
if (this.publisher || this.subscriber) {
|
@@ -628,12 +633,12 @@ export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
|
628
633
|
log.error('unsupported data type', message.data);
|
629
634
|
return;
|
630
635
|
}
|
631
|
-
const dp = DataPacket.
|
632
|
-
if (dp.value
|
636
|
+
const dp = DataPacket.fromBinary(new Uint8Array(buffer));
|
637
|
+
if (dp.value?.case === 'speaker') {
|
633
638
|
// dispatch speaker updates
|
634
|
-
this.emit(EngineEvent.ActiveSpeakersUpdate, dp.value.
|
635
|
-
} else if (dp.value
|
636
|
-
this.emit(EngineEvent.DataPacketReceived, dp.value.
|
639
|
+
this.emit(EngineEvent.ActiveSpeakersUpdate, dp.value.value.speakers);
|
640
|
+
} else if (dp.value?.case === 'user') {
|
641
|
+
this.emit(EngineEvent.DataPacketReceived, dp.value.value, dp.kind);
|
637
642
|
}
|
638
643
|
} finally {
|
639
644
|
unlock();
|
@@ -843,8 +848,10 @@ export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
|
843
848
|
log.debug(`reconnecting in ${delay}ms`);
|
844
849
|
|
845
850
|
this.clearReconnectTimeout();
|
846
|
-
if (this.
|
847
|
-
|
851
|
+
if (this.token && this.regionUrlProvider) {
|
852
|
+
// token may have been refreshed, we do not want to recreate the regionUrlProvider
|
853
|
+
// since the current engine may have inherited a regional url
|
854
|
+
this.regionUrlProvider.updateToken(this.token);
|
848
855
|
}
|
849
856
|
this.reconnectTimeout = CriticalTimers.setTimeout(
|
850
857
|
() => this.attemptReconnect(disconnectReason),
|
@@ -1114,13 +1121,12 @@ export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
|
1114
1121
|
};
|
1115
1122
|
this.once(EngineEvent.Restarted, onRestarted);
|
1116
1123
|
this.once(EngineEvent.Disconnected, onDisconnected);
|
1117
|
-
this.once(EngineEvent.Closing, onDisconnected);
|
1118
1124
|
});
|
1119
1125
|
};
|
1120
1126
|
|
1121
1127
|
/* @internal */
|
1122
1128
|
async sendDataPacket(packet: DataPacket, kind: DataPacket_Kind) {
|
1123
|
-
const msg =
|
1129
|
+
const msg = packet.toBinary();
|
1124
1130
|
|
1125
1131
|
// make sure we do have a data connection
|
1126
1132
|
await this.ensurePublisherConnected(kind);
|
@@ -1241,7 +1247,7 @@ export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
|
1241
1247
|
this.hasPublished = true;
|
1242
1248
|
|
1243
1249
|
const handleClosed = () => {
|
1244
|
-
log.
|
1250
|
+
log.debug('engine disconnected while negotiation was ongoing');
|
1245
1251
|
cleanup();
|
1246
1252
|
resolve();
|
1247
1253
|
return;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import log from '../logger';
|
2
|
-
import type { RegionInfo, RegionSettings } from '../proto/
|
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
|
|
@@ -21,10 +21,18 @@ export class RegionUrlProvider {
|
|
21
21
|
this.token = token;
|
22
22
|
}
|
23
23
|
|
24
|
+
updateToken(token: string) {
|
25
|
+
this.token = token;
|
26
|
+
}
|
27
|
+
|
24
28
|
isCloud() {
|
25
29
|
return isCloud(this.serverUrl);
|
26
30
|
}
|
27
31
|
|
32
|
+
getServerUrl() {
|
33
|
+
return this.serverUrl;
|
34
|
+
}
|
35
|
+
|
28
36
|
async getNextBestRegionUrl(abortSignal?: AbortSignal) {
|
29
37
|
if (!this.isCloud()) {
|
30
38
|
throw Error('region availability is only supported for LiveKit Cloud domains');
|
@@ -49,7 +57,8 @@ export class RegionUrlProvider {
|
|
49
57
|
this.attemptedRegions = [];
|
50
58
|
}
|
51
59
|
|
52
|
-
|
60
|
+
/* @internal */
|
61
|
+
async fetchRegionSettings(signal?: AbortSignal) {
|
53
62
|
const regionSettingsResponse = await fetch(`${getCloudConfigUrl(this.serverUrl)}/regions`, {
|
54
63
|
headers: { authorization: `Bearer ${this.token}` },
|
55
64
|
signal,
|
package/src/room/Room.test.ts
CHANGED