@livekit/rtc-node 0.13.23 → 0.13.25
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/audio_filter.cjs +2 -2
- package/dist/audio_filter.cjs.map +1 -1
- package/dist/audio_filter.js +1 -1
- package/dist/audio_filter.js.map +1 -1
- package/dist/audio_frame.cjs +11 -7
- package/dist/audio_frame.cjs.map +1 -1
- package/dist/audio_frame.d.cts +3 -8
- package/dist/audio_frame.d.ts +3 -8
- package/dist/audio_frame.d.ts.map +1 -1
- package/dist/audio_frame.js +10 -6
- package/dist/audio_frame.js.map +1 -1
- package/dist/audio_mixer.cjs +11 -4
- package/dist/audio_mixer.cjs.map +1 -1
- package/dist/audio_mixer.d.cts +1 -6
- package/dist/audio_mixer.d.ts +1 -6
- package/dist/audio_mixer.d.ts.map +1 -1
- package/dist/audio_mixer.js +11 -4
- package/dist/audio_mixer.js.map +1 -1
- package/dist/audio_resampler.cjs +20 -12
- package/dist/audio_resampler.cjs.map +1 -1
- package/dist/audio_resampler.d.cts +6 -6
- package/dist/audio_resampler.d.ts +6 -6
- package/dist/audio_resampler.d.ts.map +1 -1
- package/dist/audio_resampler.js +12 -4
- package/dist/audio_resampler.js.map +1 -1
- package/dist/audio_source.cjs +11 -7
- package/dist/audio_source.cjs.map +1 -1
- package/dist/audio_source.d.cts +1 -7
- package/dist/audio_source.d.ts +1 -7
- package/dist/audio_source.d.ts.map +1 -1
- package/dist/audio_source.js +8 -3
- package/dist/audio_source.js.map +1 -1
- package/dist/audio_stream.cjs +17 -5
- package/dist/audio_stream.cjs.map +1 -1
- package/dist/audio_stream.d.cts +1 -14
- package/dist/audio_stream.d.ts +1 -14
- package/dist/audio_stream.d.ts.map +1 -1
- package/dist/audio_stream.js +16 -4
- package/dist/audio_stream.js.map +1 -1
- package/dist/data_streams/index.d.cts +2 -10
- package/dist/data_streams/index.d.ts +2 -10
- package/dist/data_streams/stream_reader.cjs +8 -0
- package/dist/data_streams/stream_reader.cjs.map +1 -1
- package/dist/data_streams/stream_reader.d.cts +2 -10
- package/dist/data_streams/stream_reader.d.ts +2 -10
- package/dist/data_streams/stream_reader.d.ts.map +1 -1
- package/dist/data_streams/stream_reader.js +8 -0
- package/dist/data_streams/stream_reader.js.map +1 -1
- package/dist/data_streams/stream_writer.d.cts +2 -10
- package/dist/data_streams/stream_writer.d.ts +2 -10
- package/dist/data_streams/types.cjs.map +1 -1
- package/dist/data_streams/types.d.cts +2 -10
- package/dist/data_streams/types.d.ts +2 -10
- package/dist/data_streams/types.d.ts.map +1 -1
- package/dist/e2ee.cjs +21 -21
- package/dist/e2ee.cjs.map +1 -1
- package/dist/e2ee.d.cts +1 -2
- package/dist/e2ee.d.ts +1 -2
- package/dist/e2ee.d.ts.map +1 -1
- package/dist/e2ee.js +2 -2
- package/dist/e2ee.js.map +1 -1
- package/dist/ffi_client.cjs +11 -12
- package/dist/ffi_client.cjs.map +1 -1
- package/dist/ffi_client.d.cts +3 -16
- package/dist/ffi_client.d.ts +3 -16
- package/dist/ffi_client.d.ts.map +1 -1
- package/dist/ffi_client.js +5 -3
- package/dist/ffi_client.js.map +1 -1
- package/dist/frame_processor.cjs +13 -2
- package/dist/frame_processor.cjs.map +1 -1
- package/dist/frame_processor.d.cts +5 -8
- package/dist/frame_processor.d.ts +5 -8
- package/dist/frame_processor.d.ts.map +1 -1
- package/dist/frame_processor.js +10 -1
- package/dist/frame_processor.js.map +1 -1
- package/dist/index.cjs +25 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -16
- package/dist/index.d.ts +3 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/log.cjs +1 -10
- package/dist/log.cjs.map +1 -1
- package/dist/log.d.cts +4 -0
- package/dist/log.d.ts +4 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +1 -10
- package/dist/log.js.map +1 -1
- package/dist/participant.cjs +38 -38
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +2 -15
- package/dist/participant.d.ts +2 -15
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +12 -12
- package/dist/participant.js.map +1 -1
- package/dist/room.cjs +48 -30
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +11 -16
- package/dist/room.d.ts +11 -16
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +44 -26
- package/dist/room.js.map +1 -1
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +1 -2
- package/dist/rpc.d.ts +1 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js.map +1 -1
- package/dist/{stream_reader-Ch2zvjU3.d.cts → stream_reader-CuG4b8Y-.d.cts} +1 -1
- package/dist/{stream_reader-DRyR29vo.d.ts → stream_reader-CuG4b8Y-.d.ts} +1 -1
- package/dist/track.cjs +3 -3
- package/dist/track.cjs.map +1 -1
- package/dist/track.d.cts +1 -14
- package/dist/track.d.ts +1 -14
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +1 -1
- package/dist/track.js.map +1 -1
- package/dist/track_publication.cjs +4 -4
- package/dist/track_publication.cjs.map +1 -1
- package/dist/track_publication.d.cts +1 -14
- package/dist/track_publication.d.ts +1 -14
- package/dist/track_publication.d.ts.map +1 -1
- package/dist/track_publication.js +2 -2
- package/dist/track_publication.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/video_frame.cjs +42 -42
- package/dist/video_frame.cjs.map +1 -1
- package/dist/video_frame.d.cts +1 -6
- package/dist/video_frame.d.ts +1 -6
- package/dist/video_frame.d.ts.map +1 -1
- package/dist/video_frame.js +2 -2
- package/dist/video_frame.js.map +1 -1
- package/dist/video_source.cjs +5 -5
- package/dist/video_source.cjs.map +1 -1
- package/dist/video_source.d.cts +1 -14
- package/dist/video_source.d.ts +1 -14
- package/dist/video_source.d.ts.map +1 -1
- package/dist/video_source.js +2 -2
- package/dist/video_source.js.map +1 -1
- package/dist/video_stream.cjs +12 -4
- package/dist/video_stream.cjs.map +1 -1
- package/dist/video_stream.d.cts +1 -14
- package/dist/video_stream.d.ts +1 -14
- package/dist/video_stream.d.ts.map +1 -1
- package/dist/video_stream.js +10 -2
- package/dist/video_stream.js.map +1 -1
- package/package.json +9 -35
- package/src/audio_filter.ts +2 -2
- package/src/audio_frame.ts +26 -7
- package/src/audio_mixer.ts +15 -4
- package/src/audio_resampler.ts +14 -4
- package/src/audio_source.ts +13 -5
- package/src/audio_stream.ts +21 -5
- package/src/data_streams/stream_reader.ts +19 -1
- package/src/data_streams/types.ts +1 -1
- package/src/e2ee.ts +3 -3
- package/src/ffi_client.ts +7 -5
- package/src/frame_processor.ts +21 -0
- package/src/index.ts +6 -5
- package/src/log.ts +14 -10
- package/src/participant.ts +17 -17
- package/src/room.ts +65 -38
- package/src/rpc.ts +1 -1
- package/src/tests/e2e.test.ts +517 -0
- package/src/track.ts +4 -4
- package/src/track_publication.ts +6 -6
- package/src/version.ts +1 -1
- package/src/video_frame.ts +3 -3
- package/src/video_source.ts +3 -3
- package/src/video_stream.ts +15 -3
- package/Cargo.toml +0 -25
- package/build.rs +0 -9
- package/dist/napi/native.cjs +0 -301
- package/dist/napi/native.d.cjs +0 -17
- package/dist/napi/native.d.cjs.map +0 -1
- package/dist/napi/native.d.d.cts +0 -21
- package/dist/napi/native.d.d.ts +0 -21
- package/dist/napi/native.d.js +0 -1
- package/dist/napi/native.d.js.map +0 -1
- package/dist/napi/native.d.ts +0 -19
- package/dist/napi/native.js +0 -15
- package/dist/native.cjs +0 -301
- package/dist/native.d.ts +0 -19
- package/dist/native.js +0 -15
- package/dist/proto/audio_frame_pb.cjs +0 -1357
- package/dist/proto/audio_frame_pb.cjs.map +0 -1
- package/dist/proto/audio_frame_pb.d.cts +0 -1183
- package/dist/proto/audio_frame_pb.d.ts +0 -1183
- package/dist/proto/audio_frame_pb.d.ts.map +0 -1
- package/dist/proto/audio_frame_pb.js +0 -1283
- package/dist/proto/audio_frame_pb.js.map +0 -1
- package/dist/proto/data_stream_pb.cjs +0 -1638
- package/dist/proto/data_stream_pb.cjs.map +0 -1
- package/dist/proto/data_stream_pb.d.cts +0 -1449
- package/dist/proto/data_stream_pb.d.ts +0 -1449
- package/dist/proto/data_stream_pb.d.ts.map +0 -1
- package/dist/proto/data_stream_pb.js +0 -1559
- package/dist/proto/data_stream_pb.js.map +0 -1
- package/dist/proto/e2ee_pb.cjs +0 -746
- package/dist/proto/e2ee_pb.cjs.map +0 -1
- package/dist/proto/e2ee_pb.d.cts +0 -653
- package/dist/proto/e2ee_pb.d.ts +0 -653
- package/dist/proto/e2ee_pb.d.ts.map +0 -1
- package/dist/proto/e2ee_pb.js +0 -696
- package/dist/proto/e2ee_pb.js.map +0 -1
- package/dist/proto/ffi_pb.cjs +0 -477
- package/dist/proto/ffi_pb.cjs.map +0 -1
- package/dist/proto/ffi_pb.d.cts +0 -1321
- package/dist/proto/ffi_pb.d.ts +0 -1321
- package/dist/proto/ffi_pb.d.ts.map +0 -1
- package/dist/proto/ffi_pb.js +0 -444
- package/dist/proto/ffi_pb.js.map +0 -1
- package/dist/proto/handle_pb.cjs +0 -53
- package/dist/proto/handle_pb.cjs.map +0 -1
- package/dist/proto/handle_pb.d.cts +0 -31
- package/dist/proto/handle_pb.d.ts +0 -31
- package/dist/proto/handle_pb.d.ts.map +0 -1
- package/dist/proto/handle_pb.js +0 -29
- package/dist/proto/handle_pb.js.map +0 -1
- package/dist/proto/participant_pb.cjs +0 -173
- package/dist/proto/participant_pb.cjs.map +0 -1
- package/dist/proto/participant_pb.d.cts +0 -218
- package/dist/proto/participant_pb.d.ts +0 -218
- package/dist/proto/participant_pb.d.ts.map +0 -1
- package/dist/proto/participant_pb.js +0 -145
- package/dist/proto/participant_pb.js.map +0 -1
- package/dist/proto/room_pb.cjs +0 -3374
- package/dist/proto/room_pb.cjs.map +0 -1
- package/dist/proto/room_pb.d.cts +0 -3028
- package/dist/proto/room_pb.d.ts +0 -3028
- package/dist/proto/room_pb.d.ts.map +0 -1
- package/dist/proto/room_pb.js +0 -3232
- package/dist/proto/room_pb.js.map +0 -1
- package/dist/proto/rpc_pb.cjs +0 -328
- package/dist/proto/rpc_pb.cjs.map +0 -1
- package/dist/proto/rpc_pb.d.cts +0 -267
- package/dist/proto/rpc_pb.d.ts +0 -267
- package/dist/proto/rpc_pb.d.ts.map +0 -1
- package/dist/proto/rpc_pb.js +0 -294
- package/dist/proto/rpc_pb.js.map +0 -1
- package/dist/proto/stats_pb.cjs +0 -1370
- package/dist/proto/stats_pb.cjs.map +0 -1
- package/dist/proto/stats_pb.d.cts +0 -1764
- package/dist/proto/stats_pb.d.ts +0 -1764
- package/dist/proto/stats_pb.d.ts.map +0 -1
- package/dist/proto/stats_pb.js +0 -1300
- package/dist/proto/stats_pb.js.map +0 -1
- package/dist/proto/track_pb.cjs +0 -630
- package/dist/proto/track_pb.cjs.map +0 -1
- package/dist/proto/track_pb.d.cts +0 -542
- package/dist/proto/track_pb.d.ts +0 -542
- package/dist/proto/track_pb.d.ts.map +0 -1
- package/dist/proto/track_pb.js +0 -584
- package/dist/proto/track_pb.js.map +0 -1
- package/dist/proto/track_publication_pb.cjs +0 -194
- package/dist/proto/track_publication_pb.cjs.map +0 -1
- package/dist/proto/track_publication_pb.d.cts +0 -135
- package/dist/proto/track_publication_pb.d.ts +0 -135
- package/dist/proto/track_publication_pb.d.ts.map +0 -1
- package/dist/proto/track_publication_pb.js +0 -164
- package/dist/proto/track_publication_pb.js.map +0 -1
- package/dist/proto/video_frame_pb.cjs +0 -723
- package/dist/proto/video_frame_pb.cjs.map +0 -1
- package/dist/proto/video_frame_pb.d.cts +0 -667
- package/dist/proto/video_frame_pb.d.ts +0 -667
- package/dist/proto/video_frame_pb.d.ts.map +0 -1
- package/dist/proto/video_frame_pb.js +0 -673
- package/dist/proto/video_frame_pb.js.map +0 -1
- package/src/lib.rs +0 -9
- package/src/napi/native.cjs +0 -301
- package/src/napi/native.d.ts +0 -19
- package/src/napi/native.js +0 -15
- package/src/nodejs.rs +0 -134
- package/src/proto/audio_frame_pb.ts +0 -2270
- package/src/proto/data_stream_pb.ts +0 -2674
- package/src/proto/e2ee_pb.ts +0 -1231
- package/src/proto/ffi_pb.ts +0 -1700
- package/src/proto/handle_pb.ts +0 -69
- package/src/proto/participant_pb.ts +0 -351
- package/src/proto/room_pb.ts +0 -5661
- package/src/proto/rpc_pb.ts +0 -539
- package/src/proto/stats_pb.ts +0 -3050
- package/src/proto/track_pb.ts +0 -1040
- package/src/proto/track_publication_pb.ts +0 -284
- package/src/proto/video_frame_pb.ts +0 -1236
package/src/room.ts
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { Mutex } from '@livekit/mutex';
|
|
5
|
+
import { EncryptionState, type EncryptionType } from '@livekit/rtc-ffi-bindings';
|
|
6
|
+
import type { FfiEvent } from '@livekit/rtc-ffi-bindings';
|
|
7
|
+
import type { DisconnectReason, OwnedParticipant } from '@livekit/rtc-ffi-bindings';
|
|
8
|
+
import type { DataStream_Trailer, DisconnectCallback } from '@livekit/rtc-ffi-bindings';
|
|
9
|
+
import {
|
|
10
|
+
type ConnectCallback,
|
|
11
|
+
ConnectRequest,
|
|
12
|
+
type ConnectResponse,
|
|
13
|
+
type ConnectionQuality,
|
|
14
|
+
ConnectionState,
|
|
15
|
+
ContinualGatheringPolicy,
|
|
16
|
+
type DataPacketKind,
|
|
17
|
+
type DataStream_Chunk,
|
|
18
|
+
type DataStream_Header,
|
|
19
|
+
type DisconnectResponse,
|
|
20
|
+
RoomOptions as FfiRoomOptions,
|
|
21
|
+
type IceServer,
|
|
22
|
+
IceTransportType,
|
|
23
|
+
type RoomInfo,
|
|
24
|
+
} from '@livekit/rtc-ffi-bindings';
|
|
25
|
+
import { TrackKind } from '@livekit/rtc-ffi-bindings';
|
|
5
26
|
import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';
|
|
6
27
|
import EventEmitter from 'events';
|
|
7
28
|
import { ByteStreamReader, TextStreamReader } from './data_streams/stream_reader.js';
|
|
@@ -18,27 +39,6 @@ import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
|
|
|
18
39
|
import { log } from './log.js';
|
|
19
40
|
import type { Participant } from './participant.js';
|
|
20
41
|
import { LocalParticipant, RemoteParticipant } from './participant.js';
|
|
21
|
-
import { EncryptionState, type EncryptionType } from './proto/e2ee_pb.js';
|
|
22
|
-
import type { FfiEvent } from './proto/ffi_pb.js';
|
|
23
|
-
import type { DisconnectReason, OwnedParticipant } from './proto/participant_pb.js';
|
|
24
|
-
import type { DataStream_Trailer, DisconnectCallback } from './proto/room_pb.js';
|
|
25
|
-
import {
|
|
26
|
-
type ConnectCallback,
|
|
27
|
-
ConnectRequest,
|
|
28
|
-
type ConnectResponse,
|
|
29
|
-
type ConnectionQuality,
|
|
30
|
-
ConnectionState,
|
|
31
|
-
ContinualGatheringPolicy,
|
|
32
|
-
type DataPacketKind,
|
|
33
|
-
type DataStream_Chunk,
|
|
34
|
-
type DataStream_Header,
|
|
35
|
-
type DisconnectResponse,
|
|
36
|
-
RoomOptions as FfiRoomOptions,
|
|
37
|
-
type IceServer,
|
|
38
|
-
IceTransportType,
|
|
39
|
-
type RoomInfo,
|
|
40
|
-
} from './proto/room_pb.js';
|
|
41
|
-
import { TrackKind } from './proto/track_pb.js';
|
|
42
42
|
import type { LocalTrack, RemoteTrack } from './track.js';
|
|
43
43
|
import { RemoteAudioTrack, RemoteVideoTrack } from './track.js';
|
|
44
44
|
import type { LocalTrackPublication, TrackPublication } from './track_publication.js';
|
|
@@ -96,6 +96,9 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
96
96
|
|
|
97
97
|
private preConnectEvents: FfiEvent[] = [];
|
|
98
98
|
|
|
99
|
+
private _token?: string;
|
|
100
|
+
private _serverUrl?: string;
|
|
101
|
+
|
|
99
102
|
e2eeManager?: E2EEManager;
|
|
100
103
|
connectionState: ConnectionState = ConnectionState.CONN_DISCONNECTED;
|
|
101
104
|
|
|
@@ -118,6 +121,16 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
118
121
|
return this.ffiHandle != undefined && this.connectionState != ConnectionState.CONN_DISCONNECTED;
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
/** @internal */
|
|
125
|
+
get token(): string | undefined {
|
|
126
|
+
return this._token;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** @internal */
|
|
130
|
+
get serverUrl(): string | undefined {
|
|
131
|
+
return this._serverUrl;
|
|
132
|
+
}
|
|
133
|
+
|
|
121
134
|
/**
|
|
122
135
|
* Gets the room's server ID. This ID is assigned by the LiveKit server
|
|
123
136
|
* and is unique for each room session.
|
|
@@ -155,7 +168,14 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
155
168
|
}
|
|
156
169
|
|
|
157
170
|
get creationTime(): Date {
|
|
158
|
-
|
|
171
|
+
// TODO: workaround for Rust SDK bug, remove after updating to:
|
|
172
|
+
// https://github.com/livekit/rust-sdks/pull/822
|
|
173
|
+
// check if creationTime looks like seconds (less than year 3000 in ms), convert to ms if needed
|
|
174
|
+
let creationTimeMs = Number(this.info?.creationTime ?? 0);
|
|
175
|
+
if (creationTimeMs > 0 && creationTimeMs < 1e12) {
|
|
176
|
+
creationTimeMs *= 1000;
|
|
177
|
+
}
|
|
178
|
+
return new Date(creationTimeMs);
|
|
159
179
|
}
|
|
160
180
|
|
|
161
181
|
get isRecording(): boolean {
|
|
@@ -217,6 +237,8 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
217
237
|
this.ffiHandle = new FfiHandle(cb.message.value.room!.handle!.id!);
|
|
218
238
|
this.e2eeManager = e2eeEnabled && new E2EEManager(this.ffiHandle.handle, e2eeOptions);
|
|
219
239
|
|
|
240
|
+
this._token = token;
|
|
241
|
+
this._serverUrl = url;
|
|
220
242
|
this.info = cb.message.value.room!.info;
|
|
221
243
|
this.connectionState = ConnectionState.CONN_CONNECTED;
|
|
222
244
|
this.localParticipant = new LocalParticipant(
|
|
@@ -362,7 +384,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
362
384
|
participant.info.disconnectReason = ev.value.disconnectReason;
|
|
363
385
|
this.emit(RoomEvent.ParticipantDisconnected, participant);
|
|
364
386
|
} else {
|
|
365
|
-
|
|
387
|
+
log.warn(`RoomEvent.ParticipantDisconnected: Could not find participant`);
|
|
366
388
|
}
|
|
367
389
|
} else if (ev.case == 'localTrackPublished') {
|
|
368
390
|
const publication = this.localParticipant.trackPublications.get(ev.value.trackSid!);
|
|
@@ -377,7 +399,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
377
399
|
publication.resolveFirstSubscription();
|
|
378
400
|
this.emit(RoomEvent.LocalTrackSubscribed, publication!.track!);
|
|
379
401
|
} else {
|
|
380
|
-
|
|
402
|
+
log.warn(`RoomEvent.LocalTrackSubscribed: Publication not found: ${ev.value.trackSid}`);
|
|
381
403
|
}
|
|
382
404
|
} else if (ev.case == 'trackPublished') {
|
|
383
405
|
const participant = this.remoteParticipants.get(ev.value.participantIdentity!);
|
|
@@ -385,7 +407,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
385
407
|
if (participant) {
|
|
386
408
|
participant.trackPublications.set(publication.sid!, publication);
|
|
387
409
|
} else {
|
|
388
|
-
|
|
410
|
+
log.warn(
|
|
389
411
|
`RoomEvent.TrackPublished: Could not find participant: ${ev.value.participantIdentity}`,
|
|
390
412
|
);
|
|
391
413
|
}
|
|
@@ -397,7 +419,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
397
419
|
if (publication) {
|
|
398
420
|
this.emit(RoomEvent.TrackUnpublished, publication, participant);
|
|
399
421
|
} else {
|
|
400
|
-
|
|
422
|
+
log.warn(`RoomEvent.TrackUnpublished: Could not find publication`);
|
|
401
423
|
}
|
|
402
424
|
} else if (ev.case == 'trackSubscribed') {
|
|
403
425
|
const ownedTrack = ev.value.track!;
|
|
@@ -416,7 +438,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
416
438
|
|
|
417
439
|
this.emit(RoomEvent.TrackSubscribed, publication.track!, publication, participant);
|
|
418
440
|
} catch (e: unknown) {
|
|
419
|
-
|
|
441
|
+
log.warn(`RoomEvent.TrackSubscribed: ${(e as Error).message}`);
|
|
420
442
|
}
|
|
421
443
|
} else if (ev.case == 'trackUnsubscribed') {
|
|
422
444
|
try {
|
|
@@ -429,7 +451,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
429
451
|
publication.subscribed = false;
|
|
430
452
|
this.emit(RoomEvent.TrackUnsubscribed, track, publication, participant);
|
|
431
453
|
} catch (e: unknown) {
|
|
432
|
-
|
|
454
|
+
log.warn(`RoomEvent.TrackUnsubscribed: ${(e as Error).message}`);
|
|
433
455
|
}
|
|
434
456
|
} else if (ev.case == 'trackSubscriptionFailed') {
|
|
435
457
|
try {
|
|
@@ -441,7 +463,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
441
463
|
ev.value.error,
|
|
442
464
|
);
|
|
443
465
|
} catch (e: unknown) {
|
|
444
|
-
|
|
466
|
+
log.warn(`RoomEvent.TrackSubscriptionFailed: ${(e as Error).message}`);
|
|
445
467
|
}
|
|
446
468
|
} else if (ev.case == 'trackMuted') {
|
|
447
469
|
try {
|
|
@@ -455,7 +477,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
455
477
|
}
|
|
456
478
|
this.emit(RoomEvent.TrackMuted, publication, participant);
|
|
457
479
|
} catch (e: unknown) {
|
|
458
|
-
|
|
480
|
+
log.warn(`RoomEvent.TrackMuted: ${(e as Error).message}`);
|
|
459
481
|
}
|
|
460
482
|
} else if (ev.case == 'trackUnmuted') {
|
|
461
483
|
try {
|
|
@@ -469,7 +491,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
469
491
|
}
|
|
470
492
|
this.emit(RoomEvent.TrackUnmuted, publication, participant);
|
|
471
493
|
} catch (e: unknown) {
|
|
472
|
-
|
|
494
|
+
log.warn(`RoomEvent.TrackUnmuted: ${(e as Error).message}`);
|
|
473
495
|
}
|
|
474
496
|
} else if (ev.case == 'activeSpeakersChanged') {
|
|
475
497
|
try {
|
|
@@ -478,7 +500,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
478
500
|
);
|
|
479
501
|
this.emit(RoomEvent.ActiveSpeakersChanged, activeSpeakers);
|
|
480
502
|
} catch (e: unknown) {
|
|
481
|
-
|
|
503
|
+
log.warn(`RoomEvent.ActiveSpeakersChanged: ${(e as Error).message}`);
|
|
482
504
|
}
|
|
483
505
|
} else if (ev.case == 'roomMetadataChanged') {
|
|
484
506
|
this.info.metadata = ev.value.metadata ?? '';
|
|
@@ -489,7 +511,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
489
511
|
participant.info.metadata = ev.value.metadata;
|
|
490
512
|
this.emit(RoomEvent.ParticipantMetadataChanged, participant.metadata, participant);
|
|
491
513
|
} catch (e: unknown) {
|
|
492
|
-
|
|
514
|
+
log.warn(`RoomEvent.ParticipantMetadataChanged: ${(e as Error).message}`);
|
|
493
515
|
}
|
|
494
516
|
} else if (ev.case == 'participantNameChanged') {
|
|
495
517
|
try {
|
|
@@ -497,7 +519,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
497
519
|
participant.info.name = ev.value.name;
|
|
498
520
|
this.emit(RoomEvent.ParticipantNameChanged, participant.name!, participant);
|
|
499
521
|
} catch (e: unknown) {
|
|
500
|
-
|
|
522
|
+
log.warn(`RoomEvent.ParticipantNameChanged: ${(e as Error).message}`);
|
|
501
523
|
}
|
|
502
524
|
} else if (ev.case == 'participantAttributesChanged') {
|
|
503
525
|
try {
|
|
@@ -520,14 +542,14 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
520
542
|
this.emit(RoomEvent.ParticipantAttributesChanged, changedAttributes, participant);
|
|
521
543
|
}
|
|
522
544
|
} catch (e: unknown) {
|
|
523
|
-
|
|
545
|
+
log.warn(`RoomEvent.ParticipantAttributesChanged: ${(e as Error).message}`);
|
|
524
546
|
}
|
|
525
547
|
} else if (ev.case == 'connectionQualityChanged') {
|
|
526
548
|
try {
|
|
527
549
|
const participant = this.requireParticipantByIdentity(ev.value.participantIdentity!);
|
|
528
550
|
this.emit(RoomEvent.ConnectionQualityChanged, ev.value.quality!, participant);
|
|
529
551
|
} catch (e: unknown) {
|
|
530
|
-
|
|
552
|
+
log.warn(`RoomEvent.ConnectionQualityChanged: ${(e as Error).message}`);
|
|
531
553
|
}
|
|
532
554
|
} else if (ev.case == 'chatMessage') {
|
|
533
555
|
const participant = this.retrieveParticipantByIdentity(ev.value.participantIdentity!);
|
|
@@ -612,8 +634,11 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
612
634
|
participant,
|
|
613
635
|
);
|
|
614
636
|
} catch (e: unknown) {
|
|
615
|
-
|
|
637
|
+
log.warn(`RoomEvent.ParticipantEncryptionStatusChanged: ${(e as Error).message}`);
|
|
616
638
|
}
|
|
639
|
+
} else if (ev.case === 'tokenRefreshed') {
|
|
640
|
+
this._token = ev.value.token;
|
|
641
|
+
this.emit('tokenRefreshed');
|
|
617
642
|
}
|
|
618
643
|
};
|
|
619
644
|
|
|
@@ -767,7 +792,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
767
792
|
const textBuffer = this.textStreamControllers.get(streamId);
|
|
768
793
|
if (textBuffer) {
|
|
769
794
|
textBuffer.controller.close();
|
|
770
|
-
this.
|
|
795
|
+
this.textStreamControllers.delete(streamId);
|
|
771
796
|
}
|
|
772
797
|
}
|
|
773
798
|
}
|
|
@@ -835,6 +860,7 @@ export type RoomCallbacks = {
|
|
|
835
860
|
roomSidChanged: (sid: string) => void;
|
|
836
861
|
roomUpdated: () => void;
|
|
837
862
|
moved: () => void;
|
|
863
|
+
tokenRefreshed: () => void;
|
|
838
864
|
};
|
|
839
865
|
|
|
840
866
|
export enum RoomEvent {
|
|
@@ -869,4 +895,5 @@ export enum RoomEvent {
|
|
|
869
895
|
Reconnected = 'reconnected',
|
|
870
896
|
RoomUpdated = 'roomUpdated',
|
|
871
897
|
Moved = 'moved',
|
|
898
|
+
TokenRefreshed = 'tokenRefreshed',
|
|
872
899
|
}
|
package/src/rpc.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import type { RpcError as RpcError_Proto } from '
|
|
4
|
+
import type { RpcError as RpcError_Proto } from '@livekit/rtc-ffi-bindings';
|
|
5
5
|
|
|
6
6
|
/** Parameters for initiating an RPC call */
|
|
7
7
|
export interface PerformRpcParams {
|