livekit-client 2.18.9 → 2.19.0
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 +5609 -644
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +3553 -2813
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.pt.worker.js +2 -0
- package/dist/livekit-client.pt.worker.js.map +1 -0
- package/dist/livekit-client.pt.worker.mjs +5834 -0
- package/dist/livekit-client.pt.worker.mjs.map +1 -0
- 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 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts +8 -7
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/types.d.ts +35 -8
- package/dist/src/e2ee/types.d.ts.map +1 -1
- package/dist/src/e2ee/utils.d.ts +5 -5
- package/dist/src/e2ee/utils.d.ts.map +1 -1
- package/dist/src/e2ee/worker/DataCryptor.d.ts +5 -5
- package/dist/src/e2ee/worker/DataCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +21 -4
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/naluUtils.d.ts +1 -1
- package/dist/src/e2ee/worker/naluUtils.d.ts.map +1 -1
- package/dist/src/e2ee/worker/sifPayload.d.ts +7 -7
- package/dist/src/e2ee/worker/sifPayload.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/options.d.ts +7 -0
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/packetTrailer/PacketTrailerManager.d.ts +49 -0
- package/dist/src/packetTrailer/PacketTrailerManager.d.ts.map +1 -0
- package/dist/src/packetTrailer/packetTrailer.d.ts +32 -0
- package/dist/src/packetTrailer/packetTrailer.d.ts.map +1 -0
- package/dist/src/packetTrailer/types.d.ts +57 -0
- package/dist/src/packetTrailer/types.d.ts.map +1 -0
- package/dist/src/packetTrailer/utils.d.ts +9 -0
- package/dist/src/packetTrailer/utils.d.ts.map +1 -0
- package/dist/src/packetTrailer/worker/packetTrailer.worker.d.ts +2 -0
- package/dist/src/packetTrailer/worker/packetTrailer.worker.d.ts.map +1 -0
- package/dist/src/room/RTCEngine.d.ts +2 -4
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +7 -3
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/data-track/RemoteDataTrack.d.ts +5 -1
- package/dist/src/room/data-track/RemoteDataTrack.d.ts.map +1 -1
- package/dist/src/room/data-track/depacketizer.d.ts +12 -4
- package/dist/src/room/data-track/depacketizer.d.ts.map +1 -1
- package/dist/src/room/data-track/frame.d.ts +3 -3
- package/dist/src/room/data-track/frame.d.ts.map +1 -1
- package/dist/src/room/data-track/incoming/IncomingDataTrackManager.d.ts +3 -1
- package/dist/src/room/data-track/incoming/IncomingDataTrackManager.d.ts.map +1 -1
- package/dist/src/room/data-track/incoming/pipeline.d.ts +4 -1
- package/dist/src/room/data-track/incoming/pipeline.d.ts.map +1 -1
- package/dist/src/room/data-track/outgoing/types.d.ts +2 -2
- package/dist/src/room/data-track/outgoing/types.d.ts.map +1 -1
- package/dist/src/room/data-track/packet/extensions.d.ts +4 -4
- package/dist/src/room/data-track/packet/extensions.d.ts.map +1 -1
- package/dist/src/room/data-track/packet/index.d.ts +5 -5
- package/dist/src/room/data-track/packet/index.d.ts.map +1 -1
- package/dist/src/room/data-track/packet/serializable.d.ts +1 -1
- package/dist/src/room/data-track/packet/serializable.d.ts.map +1 -1
- package/dist/src/room/data-track/types.d.ts +7 -0
- package/dist/src/room/data-track/types.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +2 -2
- package/dist/src/room/participant/LocalParticipant.d.ts +8 -14
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +1 -1
- package/dist/src/room/participant/Participant.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/rpc/client/RpcClientManager.d.ts +39 -0
- package/dist/src/room/rpc/client/RpcClientManager.d.ts.map +1 -0
- package/dist/src/room/rpc/client/events.d.ts +8 -0
- package/dist/src/room/rpc/client/events.d.ts.map +1 -0
- package/dist/src/room/rpc/index.d.ts +6 -0
- package/dist/src/room/rpc/index.d.ts.map +1 -0
- package/dist/src/room/rpc/server/RpcServerManager.d.ts +44 -0
- package/dist/src/room/rpc/server/RpcServerManager.d.ts.map +1 -0
- package/dist/src/room/rpc/server/events.d.ts +8 -0
- package/dist/src/room/rpc/server/events.d.ts.map +1 -0
- package/dist/src/room/{rpc.d.ts → rpc/utils.d.ts} +34 -4
- package/dist/src/room/rpc/utils.d.ts.map +1 -0
- package/dist/src/room/track/PacketTrailerExtractor.d.ts +19 -0
- package/dist/src/room/track/PacketTrailerExtractor.d.ts.map +1 -0
- package/dist/src/room/track/RemoteVideoTrack.d.ts +16 -0
- package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/Track.d.ts +1 -1
- package/dist/src/room/track/Track.d.ts.map +1 -1
- package/dist/src/room/track/create.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +10 -0
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +4 -3
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/src/test/MockMediaStreamTrack.d.ts.map +1 -1
- package/dist/src/utils/dataPacketBuffer.d.ts +1 -1
- package/dist/src/utils/dataPacketBuffer.d.ts.map +1 -1
- package/dist/src/version.d.ts +9 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/ts4.2/api/SignalClient.d.ts +2 -1
- package/dist/ts4.2/e2ee/E2eeManager.d.ts +8 -7
- package/dist/ts4.2/e2ee/types.d.ts +35 -8
- package/dist/ts4.2/e2ee/utils.d.ts +5 -5
- package/dist/ts4.2/e2ee/worker/DataCryptor.d.ts +5 -5
- package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +21 -4
- package/dist/ts4.2/e2ee/worker/naluUtils.d.ts +1 -1
- package/dist/ts4.2/e2ee/worker/sifPayload.d.ts +7 -7
- package/dist/ts4.2/index.d.ts +5 -1
- package/dist/ts4.2/options.d.ts +7 -0
- package/dist/ts4.2/packetTrailer/PacketTrailerManager.d.ts +49 -0
- package/dist/ts4.2/packetTrailer/packetTrailer.d.ts +32 -0
- package/dist/ts4.2/packetTrailer/types.d.ts +57 -0
- package/dist/ts4.2/packetTrailer/utils.d.ts +9 -0
- package/dist/ts4.2/packetTrailer/worker/packetTrailer.worker.d.ts +2 -0
- package/dist/ts4.2/room/RTCEngine.d.ts +2 -4
- package/dist/ts4.2/room/Room.d.ts +7 -3
- package/dist/ts4.2/room/data-track/RemoteDataTrack.d.ts +5 -1
- package/dist/ts4.2/room/data-track/depacketizer.d.ts +12 -4
- package/dist/ts4.2/room/data-track/frame.d.ts +3 -3
- package/dist/ts4.2/room/data-track/incoming/IncomingDataTrackManager.d.ts +3 -1
- package/dist/ts4.2/room/data-track/incoming/pipeline.d.ts +4 -1
- package/dist/ts4.2/room/data-track/outgoing/types.d.ts +2 -2
- package/dist/ts4.2/room/data-track/packet/extensions.d.ts +4 -4
- package/dist/ts4.2/room/data-track/packet/index.d.ts +5 -5
- package/dist/ts4.2/room/data-track/packet/serializable.d.ts +1 -1
- package/dist/ts4.2/room/data-track/types.d.ts +7 -0
- package/dist/ts4.2/room/events.d.ts +2 -2
- package/dist/ts4.2/room/participant/LocalParticipant.d.ts +8 -14
- package/dist/ts4.2/room/participant/Participant.d.ts +1 -1
- package/dist/ts4.2/room/participant/RemoteParticipant.d.ts +5 -1
- package/dist/ts4.2/room/rpc/client/RpcClientManager.d.ts +43 -0
- package/dist/ts4.2/room/rpc/client/events.d.ts +8 -0
- package/dist/ts4.2/room/rpc/index.d.ts +7 -0
- package/dist/ts4.2/room/rpc/server/RpcServerManager.d.ts +44 -0
- package/dist/ts4.2/room/rpc/server/events.d.ts +8 -0
- package/dist/ts4.2/room/{rpc.d.ts → rpc/utils.d.ts} +34 -4
- package/dist/ts4.2/room/track/PacketTrailerExtractor.d.ts +19 -0
- package/dist/ts4.2/room/track/RemoteVideoTrack.d.ts +16 -0
- package/dist/ts4.2/room/track/Track.d.ts +1 -1
- package/dist/ts4.2/room/track/options.d.ts +10 -0
- package/dist/ts4.2/room/utils.d.ts +4 -3
- package/dist/ts4.2/utils/dataPacketBuffer.d.ts +1 -1
- package/dist/ts4.2/version.d.ts +9 -1
- package/package.json +24 -16
- package/src/api/SignalClient.test.ts +102 -10
- package/src/api/SignalClient.ts +4 -2
- package/src/api/WebSocketStream.test.ts +0 -1
- package/src/e2ee/E2eeManager.ts +82 -30
- package/src/e2ee/types.ts +37 -8
- package/src/e2ee/utils.ts +7 -6
- package/src/e2ee/worker/DataCryptor.ts +6 -6
- package/src/e2ee/worker/FrameCryptor.test.ts +177 -4
- package/src/e2ee/worker/FrameCryptor.ts +94 -14
- package/src/e2ee/worker/ParticipantKeyHandler.test.ts +4 -4
- package/src/e2ee/worker/e2ee.worker.ts +13 -5
- package/src/e2ee/worker/naluUtils.ts +4 -4
- package/src/e2ee/worker/sifPayload.ts +10 -8
- package/src/index.ts +7 -0
- package/src/options.ts +8 -0
- package/src/packetTrailer/PacketTrailerManager.test.ts +172 -0
- package/src/packetTrailer/PacketTrailerManager.ts +250 -0
- package/src/packetTrailer/packetTrailer.test.ts +174 -0
- package/src/packetTrailer/packetTrailer.ts +276 -0
- package/src/packetTrailer/types.ts +75 -0
- package/src/packetTrailer/utils.test.ts +105 -0
- package/src/packetTrailer/utils.ts +50 -0
- package/src/packetTrailer/worker/packetTrailer.worker.ts +155 -0
- package/src/packetTrailer/worker/tsconfig.json +14 -0
- package/src/room/BackOffStrategy.test.ts +1 -1
- package/src/room/RTCEngine.test.ts +219 -0
- package/src/room/RTCEngine.ts +86 -46
- package/src/room/Room.test.ts +62 -1
- package/src/room/Room.ts +111 -86
- package/src/room/data-track/RemoteDataTrack.ts +8 -1
- package/src/room/data-track/depacketizer.test.ts +433 -1
- package/src/room/data-track/depacketizer.ts +79 -61
- package/src/room/data-track/frame.ts +2 -2
- package/src/room/data-track/incoming/IncomingDataTrackManager.test.ts +194 -0
- package/src/room/data-track/incoming/IncomingDataTrackManager.ts +21 -1
- package/src/room/data-track/incoming/pipeline.ts +13 -2
- package/src/room/data-track/outgoing/types.ts +3 -2
- package/src/room/data-track/packet/extensions.ts +2 -2
- package/src/room/data-track/packet/index.ts +6 -6
- package/src/room/data-track/packet/serializable.ts +1 -1
- package/src/room/data-track/types.ts +8 -0
- package/src/room/events.ts +2 -2
- package/src/room/participant/LocalParticipant.test.ts +81 -0
- package/src/room/participant/LocalParticipant.ts +64 -187
- package/src/room/participant/Participant.ts +1 -1
- package/src/room/participant/RemoteParticipant.ts +9 -0
- package/src/room/participant/publishUtils.ts +1 -1
- package/src/room/rpc/client/RpcClientManager.test.ts +430 -0
- package/src/room/rpc/client/RpcClientManager.ts +269 -0
- package/src/room/rpc/client/events.ts +9 -0
- package/src/room/rpc/index.ts +14 -0
- package/src/room/rpc/server/RpcServerManager.test.ts +471 -0
- package/src/room/rpc/server/RpcServerManager.ts +293 -0
- package/src/room/rpc/server/events.ts +9 -0
- package/src/room/{rpc.ts → rpc/utils.ts} +49 -8
- package/src/room/track/PacketTrailerExtractor.ts +43 -0
- package/src/room/track/RemoteVideoTrack.ts +23 -2
- package/src/room/track/Track.ts +1 -1
- package/src/room/track/create.ts +0 -4
- package/src/room/track/options.ts +11 -0
- package/src/room/track/record.ts +1 -1
- package/src/room/track/utils.ts +4 -1
- package/src/room/utils.test.ts +14 -1
- package/src/room/utils.ts +19 -4
- package/src/test/MockMediaStreamTrack.ts +0 -1
- package/src/type-polyfills/non-shared-typed-arrays.d.ts +6 -0
- package/src/utils/dataPacketBuffer.ts +1 -1
- package/src/version.ts +11 -1
- package/dist/src/room/rpc.d.ts.map +0 -1
- package/src/room/rpc.test.ts +0 -301
package/src/room/Room.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Mutex } from '@livekit/mutex';
|
|
2
2
|
import {
|
|
3
3
|
ChatMessage as ChatMessageModel,
|
|
4
|
+
ClientInfo_Capability,
|
|
4
5
|
ConnectionQualityUpdate,
|
|
5
6
|
type DataPacket,
|
|
6
7
|
DataPacket_Kind,
|
|
@@ -43,8 +44,11 @@ import type {
|
|
|
43
44
|
RoomConnectOptions,
|
|
44
45
|
RoomOptions,
|
|
45
46
|
} from '../options';
|
|
47
|
+
import { PacketTrailerManager } from '../packetTrailer/PacketTrailerManager';
|
|
48
|
+
import { isPacketTrailerSupported } from '../packetTrailer/utils';
|
|
46
49
|
import TypedPromise from '../utils/TypedPromise';
|
|
47
50
|
import { getBrowser } from '../utils/browserParser';
|
|
51
|
+
import { CLIENT_PROTOCOL_DEFAULT } from '../version';
|
|
48
52
|
import { BackOffStrategy } from './BackOffStrategy';
|
|
49
53
|
import DeviceManager from './DeviceManager';
|
|
50
54
|
import RTCEngine, { DataChannelKind, type RegionStrategy } from './RTCEngine';
|
|
@@ -78,7 +82,14 @@ import LocalParticipant from './participant/LocalParticipant';
|
|
|
78
82
|
import Participant from './participant/Participant';
|
|
79
83
|
import { type ConnectionQuality, ParticipantKind } from './participant/Participant';
|
|
80
84
|
import RemoteParticipant from './participant/RemoteParticipant';
|
|
81
|
-
import {
|
|
85
|
+
import {
|
|
86
|
+
RPC_REQUEST_DATA_STREAM_TOPIC,
|
|
87
|
+
RPC_RESPONSE_DATA_STREAM_TOPIC,
|
|
88
|
+
RpcClientManager,
|
|
89
|
+
RpcError,
|
|
90
|
+
type RpcInvocationData,
|
|
91
|
+
RpcServerManager,
|
|
92
|
+
} from './rpc';
|
|
82
93
|
import CriticalTimers from './timers';
|
|
83
94
|
import LocalAudioTrack from './track/LocalAudioTrack';
|
|
84
95
|
import type LocalTrack from './track/LocalTrack';
|
|
@@ -187,6 +198,8 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
187
198
|
|
|
188
199
|
private e2eeManager: BaseE2EEManager | undefined;
|
|
189
200
|
|
|
201
|
+
private packetTrailerManager: PacketTrailerManager | undefined;
|
|
202
|
+
|
|
190
203
|
private e2eeStateMutex: Mutex = new Mutex();
|
|
191
204
|
|
|
192
205
|
private connectionReconcileInterval?: ReturnType<typeof setInterval>;
|
|
@@ -216,7 +229,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
216
229
|
|
|
217
230
|
private outgoingDataTrackManager: OutgoingDataTrackManager;
|
|
218
231
|
|
|
219
|
-
private
|
|
232
|
+
private rpcClientManager: RpcClientManager;
|
|
233
|
+
|
|
234
|
+
private rpcServerManager: RpcServerManager;
|
|
220
235
|
|
|
221
236
|
get hasE2EESetup(): boolean {
|
|
222
237
|
return this.e2eeManager !== undefined;
|
|
@@ -296,17 +311,40 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
296
311
|
.finally(() => this.outgoingDataTrackManager.handlePacketSendComplete(handle));
|
|
297
312
|
});
|
|
298
313
|
|
|
314
|
+
this.registerRpcDataStreamHandler();
|
|
315
|
+
|
|
316
|
+
this.rpcClientManager = new RpcClientManager(
|
|
317
|
+
this.log,
|
|
318
|
+
this.outgoingDataStreamManager,
|
|
319
|
+
this.getRemoteParticipantClientProtocol,
|
|
320
|
+
() => this.engine.latestJoinResponse?.serverInfo?.version,
|
|
321
|
+
);
|
|
322
|
+
this.rpcClientManager.on('sendDataPacket', ({ packet }) => {
|
|
323
|
+
this.engine?.sendDataPacket(packet, DataChannelKind.RELIABLE);
|
|
324
|
+
});
|
|
325
|
+
this.rpcServerManager = new RpcServerManager(
|
|
326
|
+
this.log,
|
|
327
|
+
this.outgoingDataStreamManager,
|
|
328
|
+
this.getRemoteParticipantClientProtocol,
|
|
329
|
+
);
|
|
330
|
+
this.rpcServerManager.on('sendDataPacket', ({ packet }) => {
|
|
331
|
+
this.engine?.sendDataPacket(packet, DataChannelKind.RELIABLE);
|
|
332
|
+
});
|
|
333
|
+
|
|
299
334
|
this.disconnectLock = new Mutex();
|
|
300
335
|
this.localParticipant = new LocalParticipant(
|
|
301
336
|
'',
|
|
302
337
|
'',
|
|
303
338
|
this.engine,
|
|
304
339
|
this.options,
|
|
305
|
-
this.rpcHandlers,
|
|
306
340
|
this.outgoingDataStreamManager,
|
|
307
341
|
this.outgoingDataTrackManager,
|
|
342
|
+
this.rpcClientManager,
|
|
343
|
+
this.rpcServerManager,
|
|
308
344
|
);
|
|
309
345
|
|
|
346
|
+
this.setupPacketTrailer();
|
|
347
|
+
|
|
310
348
|
if (this.options.e2ee || this.options.encryption) {
|
|
311
349
|
this.setupE2EE();
|
|
312
350
|
}
|
|
@@ -393,12 +431,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
393
431
|
* Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as `1500` ("Application Error").
|
|
394
432
|
*/
|
|
395
433
|
registerRpcMethod(method: string, handler: (data: RpcInvocationData) => Promise<string>) {
|
|
396
|
-
|
|
397
|
-
throw Error(
|
|
398
|
-
`RPC handler already registered for method ${method}, unregisterRpcMethod before trying to register again`,
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
this.rpcHandlers.set(method, handler);
|
|
434
|
+
this.rpcServerManager.registerRpcMethod(method, handler);
|
|
402
435
|
}
|
|
403
436
|
|
|
404
437
|
/**
|
|
@@ -407,7 +440,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
407
440
|
* @param method - The name of the RPC method to unregister
|
|
408
441
|
*/
|
|
409
442
|
unregisterRpcMethod(method: string) {
|
|
410
|
-
this.
|
|
443
|
+
this.rpcServerManager.unregisterRpcMethod(method);
|
|
411
444
|
}
|
|
412
445
|
|
|
413
446
|
/**
|
|
@@ -465,6 +498,13 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
465
498
|
}
|
|
466
499
|
}
|
|
467
500
|
|
|
501
|
+
private setupPacketTrailer() {
|
|
502
|
+
// The manager is always created so tracks that advertise packet trailer
|
|
503
|
+
// features can be wired up when the app passes a packet trailer worker.
|
|
504
|
+
this.packetTrailerManager = new PacketTrailerManager(this.options.packetTrailer);
|
|
505
|
+
this.packetTrailerManager.setup(this);
|
|
506
|
+
}
|
|
507
|
+
|
|
468
508
|
private get logContext() {
|
|
469
509
|
return {
|
|
470
510
|
room: this.name,
|
|
@@ -914,6 +954,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
914
954
|
autoSubscribe: connectOptions.autoSubscribe,
|
|
915
955
|
adaptiveStream:
|
|
916
956
|
typeof roomOptions.adaptiveStream === 'object' ? true : roomOptions.adaptiveStream,
|
|
957
|
+
clientInfoCapabilities:
|
|
958
|
+
isPacketTrailerSupported(roomOptions.packetTrailer) || !!this.e2eeManager
|
|
959
|
+
? [ClientInfo_Capability.CAP_PACKET_TRAILER]
|
|
960
|
+
: undefined,
|
|
917
961
|
maxRetries: connectOptions.maxRetries,
|
|
918
962
|
e2eeEnabled: !!this.e2eeManager,
|
|
919
963
|
websocketTimeout: connectOptions.websocketTimeout,
|
|
@@ -946,7 +990,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
946
990
|
|
|
947
991
|
if (this.e2eeManager) {
|
|
948
992
|
try {
|
|
949
|
-
this.e2eeManager.setSifTrailer(joinResponse.sifTrailer);
|
|
993
|
+
this.e2eeManager.setSifTrailer(joinResponse.sifTrailer as NonSharedUint8Array);
|
|
950
994
|
} catch (e: any) {
|
|
951
995
|
this.log.error(e instanceof Error ? e.message : 'Could not set SifTrailer', {
|
|
952
996
|
error: e,
|
|
@@ -1825,7 +1869,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
1825
1869
|
this.handleParticipantDisconnected(info.identity, remoteParticipant);
|
|
1826
1870
|
} else {
|
|
1827
1871
|
// create participant if doesn't exist
|
|
1828
|
-
|
|
1872
|
+
this.getOrCreateParticipant(info.identity, info);
|
|
1829
1873
|
}
|
|
1830
1874
|
}
|
|
1831
1875
|
|
|
@@ -1855,7 +1899,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
1855
1899
|
});
|
|
1856
1900
|
this.emit(RoomEvent.ParticipantDisconnected, participant);
|
|
1857
1901
|
participant.setDisconnected();
|
|
1858
|
-
this.
|
|
1902
|
+
this.rpcClientManager.handleParticipantDisconnected(participant.identity);
|
|
1859
1903
|
}
|
|
1860
1904
|
|
|
1861
1905
|
// updates are sent only when there's a change to speaker ordering
|
|
@@ -1999,14 +2043,31 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
1999
2043
|
this.handleDataStream(packet, encryptionType);
|
|
2000
2044
|
} else if (packet.value.case === 'rpcRequest') {
|
|
2001
2045
|
const rpc = packet.value.value;
|
|
2002
|
-
this.handleIncomingRpcRequest(
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2046
|
+
this.rpcServerManager.handleIncomingRpcRequest(packet.participantIdentity, rpc);
|
|
2047
|
+
} else if (packet.value.case === 'rpcResponse') {
|
|
2048
|
+
const rpcResponse = packet.value.value;
|
|
2049
|
+
switch (rpcResponse.value.case) {
|
|
2050
|
+
case 'payload':
|
|
2051
|
+
this.rpcClientManager.handleIncomingRpcResponseSuccess(
|
|
2052
|
+
rpcResponse.requestId,
|
|
2053
|
+
rpcResponse.value.value,
|
|
2054
|
+
);
|
|
2055
|
+
break;
|
|
2056
|
+
case 'error':
|
|
2057
|
+
this.rpcClientManager.handleIncomingRpcResponseFailure(
|
|
2058
|
+
rpcResponse.requestId,
|
|
2059
|
+
RpcError.fromProto(rpcResponse.value.value),
|
|
2060
|
+
);
|
|
2061
|
+
break;
|
|
2062
|
+
default:
|
|
2063
|
+
this.log.warn(
|
|
2064
|
+
`Unknown rpcResponse.value.case: ${rpcResponse.value.case}`,
|
|
2065
|
+
this.logContext,
|
|
2066
|
+
);
|
|
2067
|
+
break;
|
|
2068
|
+
}
|
|
2069
|
+
} else if (packet.value.case === 'rpcAck') {
|
|
2070
|
+
this.rpcClientManager.handleIncomingRpcAck(packet.value.value.requestId);
|
|
2010
2071
|
}
|
|
2011
2072
|
};
|
|
2012
2073
|
|
|
@@ -2018,7 +2079,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
2018
2079
|
) => {
|
|
2019
2080
|
this.emit(
|
|
2020
2081
|
RoomEvent.DataReceived,
|
|
2021
|
-
userPacket.payload,
|
|
2082
|
+
userPacket.payload as NonSharedUint8Array,
|
|
2022
2083
|
participant,
|
|
2023
2084
|
kind,
|
|
2024
2085
|
userPacket.topic,
|
|
@@ -2026,7 +2087,12 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
2026
2087
|
);
|
|
2027
2088
|
|
|
2028
2089
|
// also emit on the participant
|
|
2029
|
-
participant?.emit(
|
|
2090
|
+
participant?.emit(
|
|
2091
|
+
ParticipantEvent.DataReceived,
|
|
2092
|
+
userPacket.payload as NonSharedUint8Array,
|
|
2093
|
+
kind,
|
|
2094
|
+
encryptionType,
|
|
2095
|
+
);
|
|
2030
2096
|
};
|
|
2031
2097
|
|
|
2032
2098
|
private handleSipDtmf = (participant: RemoteParticipant | undefined, dtmf: SipDTMF) => {
|
|
@@ -2070,68 +2136,6 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
2070
2136
|
this.incomingDataStreamManager.handleDataStreamPacket(packet, encryptionType);
|
|
2071
2137
|
};
|
|
2072
2138
|
|
|
2073
|
-
private async handleIncomingRpcRequest(
|
|
2074
|
-
callerIdentity: string,
|
|
2075
|
-
requestId: string,
|
|
2076
|
-
method: string,
|
|
2077
|
-
payload: string,
|
|
2078
|
-
responseTimeout: number,
|
|
2079
|
-
version: number,
|
|
2080
|
-
) {
|
|
2081
|
-
await this.engine.publishRpcAck(callerIdentity, requestId);
|
|
2082
|
-
|
|
2083
|
-
if (version !== 1) {
|
|
2084
|
-
await this.engine.publishRpcResponse(
|
|
2085
|
-
callerIdentity,
|
|
2086
|
-
requestId,
|
|
2087
|
-
null,
|
|
2088
|
-
RpcError.builtIn('UNSUPPORTED_VERSION'),
|
|
2089
|
-
);
|
|
2090
|
-
return;
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
const handler = this.rpcHandlers.get(method);
|
|
2094
|
-
|
|
2095
|
-
if (!handler) {
|
|
2096
|
-
await this.engine.publishRpcResponse(
|
|
2097
|
-
callerIdentity,
|
|
2098
|
-
requestId,
|
|
2099
|
-
null,
|
|
2100
|
-
RpcError.builtIn('UNSUPPORTED_METHOD'),
|
|
2101
|
-
);
|
|
2102
|
-
return;
|
|
2103
|
-
}
|
|
2104
|
-
|
|
2105
|
-
let responseError: RpcError | null = null;
|
|
2106
|
-
let responsePayload: string | null = null;
|
|
2107
|
-
|
|
2108
|
-
try {
|
|
2109
|
-
const response = await handler({
|
|
2110
|
-
requestId,
|
|
2111
|
-
callerIdentity,
|
|
2112
|
-
payload,
|
|
2113
|
-
responseTimeout,
|
|
2114
|
-
});
|
|
2115
|
-
if (byteLength(response) > MAX_PAYLOAD_BYTES) {
|
|
2116
|
-
responseError = RpcError.builtIn('RESPONSE_PAYLOAD_TOO_LARGE');
|
|
2117
|
-
this.log.warn(`RPC Response payload too large for ${method}`);
|
|
2118
|
-
} else {
|
|
2119
|
-
responsePayload = response;
|
|
2120
|
-
}
|
|
2121
|
-
} catch (error) {
|
|
2122
|
-
if (error instanceof RpcError) {
|
|
2123
|
-
responseError = error;
|
|
2124
|
-
} else {
|
|
2125
|
-
this.log.warn(
|
|
2126
|
-
`Uncaught error returned by RPC handler for ${method}. Returning APPLICATION_ERROR instead.`,
|
|
2127
|
-
error,
|
|
2128
|
-
);
|
|
2129
|
-
responseError = RpcError.builtIn('APPLICATION_ERROR');
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
await this.engine.publishRpcResponse(callerIdentity, requestId, responsePayload, responseError);
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
2139
|
bufferedSegments: Map<string, TranscriptionSegmentModel> = new Map();
|
|
2136
2140
|
|
|
2137
2141
|
private handleAudioPlaybackStarted = () => {
|
|
@@ -2477,6 +2481,27 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
|
2477
2481
|
}
|
|
2478
2482
|
}
|
|
2479
2483
|
|
|
2484
|
+
private getRemoteParticipantClientProtocol = (identity: Participant['identity']) => {
|
|
2485
|
+
return this.remoteParticipants.get(identity)?.clientProtocol ?? CLIENT_PROTOCOL_DEFAULT;
|
|
2486
|
+
};
|
|
2487
|
+
|
|
2488
|
+
private registerRpcDataStreamHandler() {
|
|
2489
|
+
this.incomingDataStreamManager.registerTextStreamHandler(
|
|
2490
|
+
RPC_REQUEST_DATA_STREAM_TOPIC,
|
|
2491
|
+
async (reader, { identity }) => {
|
|
2492
|
+
const attributes = reader.info.attributes ?? {};
|
|
2493
|
+
await this.rpcServerManager.handleIncomingDataStream(reader, identity, attributes);
|
|
2494
|
+
},
|
|
2495
|
+
);
|
|
2496
|
+
this.incomingDataStreamManager.registerTextStreamHandler(
|
|
2497
|
+
RPC_RESPONSE_DATA_STREAM_TOPIC,
|
|
2498
|
+
async (reader, { identity }) => {
|
|
2499
|
+
const attributes = reader.info.attributes ?? {};
|
|
2500
|
+
await this.rpcClientManager.handleIncomingDataStream(reader, identity, attributes);
|
|
2501
|
+
},
|
|
2502
|
+
);
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2480
2505
|
private registerConnectionReconcile() {
|
|
2481
2506
|
this.clearConnectionReconcile();
|
|
2482
2507
|
let consecutiveFailures = 0;
|
|
@@ -2874,7 +2899,7 @@ export type RoomEventCallbacks = {
|
|
|
2874
2899
|
activeSpeakersChanged: (speakers: Array<Participant>) => void;
|
|
2875
2900
|
roomMetadataChanged: (metadata: string) => void;
|
|
2876
2901
|
dataReceived: (
|
|
2877
|
-
payload:
|
|
2902
|
+
payload: NonSharedUint8Array,
|
|
2878
2903
|
participant?: RemoteParticipant,
|
|
2879
2904
|
kind?: DataPacket_Kind,
|
|
2880
2905
|
topic?: string,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type IRemoteTrack,
|
|
8
8
|
TrackSymbol,
|
|
9
9
|
} from './track-interfaces';
|
|
10
|
-
import { type DataTrackInfo } from './types';
|
|
10
|
+
import { type DataTrackInfo, type RemoteDataTrackPipelineOptions } from './types';
|
|
11
11
|
|
|
12
12
|
type RemoteDataTrackOptions = {
|
|
13
13
|
publisherIdentity: Participant['identity'];
|
|
@@ -80,4 +80,11 @@ export default class RemoteDataTrack implements IRemoteTrack, IDataTrack {
|
|
|
80
80
|
throw err;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
|
|
84
|
+
/** Configure how incoming frames for this track are processed before they are handed out to
|
|
85
|
+
* subscribers (the "pipeline"). These options apply to all current and future subscriptions
|
|
86
|
+
* of this track, and may be set at any time. */
|
|
87
|
+
setPipelineOptions(options: RemoteDataTrackPipelineOptions): void {
|
|
88
|
+
this.manager.setPipelineOptions(this.info.sid, options);
|
|
89
|
+
}
|
|
83
90
|
}
|