@livekit/rtc-node 0.13.20 → 0.13.22
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/Cargo.toml +6 -3
- package/dist/async_queue.cjs +80 -0
- package/dist/async_queue.cjs.map +1 -0
- package/dist/async_queue.d.cts +30 -0
- package/dist/async_queue.d.ts +30 -0
- package/dist/async_queue.d.ts.map +1 -0
- package/dist/async_queue.js +56 -0
- package/dist/async_queue.js.map +1 -0
- package/dist/audio_mixer.cjs +281 -0
- package/dist/audio_mixer.cjs.map +1 -0
- package/dist/audio_mixer.d.cts +121 -0
- package/dist/audio_mixer.d.ts +121 -0
- package/dist/audio_mixer.d.ts.map +1 -0
- package/dist/audio_mixer.js +256 -0
- package/dist/audio_mixer.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/participant.cjs +43 -32
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +3 -0
- package/dist/participant.d.ts +3 -0
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +43 -32
- package/dist/participant.js.map +1 -1
- package/dist/proto/data_stream_pb.cjs +91 -2
- package/dist/proto/data_stream_pb.cjs.map +1 -1
- package/dist/proto/data_stream_pb.d.cts +92 -1
- package/dist/proto/data_stream_pb.d.ts +92 -1
- package/dist/proto/data_stream_pb.d.ts.map +1 -1
- package/dist/proto/data_stream_pb.js +88 -2
- package/dist/proto/data_stream_pb.js.map +1 -1
- package/dist/proto/ffi_pb.cjs +6 -3
- package/dist/proto/ffi_pb.cjs.map +1 -1
- package/dist/proto/ffi_pb.d.cts +19 -1
- package/dist/proto/ffi_pb.d.ts +19 -1
- package/dist/proto/ffi_pb.d.ts.map +1 -1
- package/dist/proto/ffi_pb.js +7 -4
- package/dist/proto/ffi_pb.js.map +1 -1
- package/dist/proto/room_pb.cjs +32 -2
- package/dist/proto/room_pb.cjs.map +1 -1
- package/dist/proto/room_pb.d.cts +38 -2
- package/dist/proto/room_pb.d.ts +38 -2
- package/dist/proto/room_pb.d.ts.map +1 -1
- package/dist/proto/room_pb.js +31 -2
- package/dist/proto/room_pb.js.map +1 -1
- package/dist/room.cjs +173 -80
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +16 -3
- package/dist/room.d.ts +16 -3
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +174 -81
- package/dist/room.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/package.json +9 -8
- package/src/async_queue.test.ts +250 -0
- package/src/async_queue.ts +80 -0
- package/src/audio_mixer.test.ts +167 -0
- package/src/audio_mixer.ts +407 -0
- package/src/index.ts +1 -0
- package/src/participant.ts +48 -30
- package/src/proto/data_stream_pb.ts +159 -0
- package/src/proto/ffi_pb.ts +22 -1
- package/src/proto/room_pb.ts +64 -1
- package/src/room.ts +193 -91
- package/src/version.ts +1 -1
package/dist/room.d.cts
CHANGED
|
@@ -2,16 +2,17 @@ import { TypedEventEmitter } from '@livekit/typed-emitter';
|
|
|
2
2
|
import { g as TextStreamHandler, f as ByteStreamHandler } from './stream_reader-Ch2zvjU3.cjs';
|
|
3
3
|
import { E2EEManager, E2EEOptions } from './e2ee.cjs';
|
|
4
4
|
import { RemoteParticipant, LocalParticipant, Participant } from './participant.cjs';
|
|
5
|
+
import { EncryptionType } from './proto/e2ee_pb.cjs';
|
|
5
6
|
import { DisconnectReason } from './proto/participant_pb.cjs';
|
|
6
7
|
import { RoomInfo, ConnectionQuality, DataPacketKind, ConnectionState, IceTransportType, ContinualGatheringPolicy, IceServer, RoomOptions as RoomOptions$1 } from './proto/room_pb.cjs';
|
|
7
8
|
import { LocalTrack, RemoteTrack } from './track.cjs';
|
|
8
9
|
import { LocalTrackPublication, RemoteTrackPublication, TrackPublication } from './track_publication.cjs';
|
|
9
10
|
import { ChatMessage } from './types.cjs';
|
|
10
|
-
import '
|
|
11
|
-
import '@bufbuild/protobuf';
|
|
11
|
+
import '@livekit/mutex';
|
|
12
12
|
import 'node:fs';
|
|
13
13
|
import './data_streams/stream_writer.cjs';
|
|
14
14
|
import './ffi_client.cjs';
|
|
15
|
+
import '@bufbuild/protobuf';
|
|
15
16
|
import './napi/native.d.cjs';
|
|
16
17
|
import './proto/ffi_pb.cjs';
|
|
17
18
|
import './proto/track_pb.cjs';
|
|
@@ -38,7 +39,11 @@ declare const defaultRtcConfiguration: RtcConfiguration;
|
|
|
38
39
|
interface RoomOptions {
|
|
39
40
|
autoSubscribe: boolean;
|
|
40
41
|
dynacast: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use `encryption` instead. See x for details
|
|
44
|
+
*/
|
|
41
45
|
e2ee?: E2EEOptions;
|
|
46
|
+
encryption?: E2EEOptions;
|
|
42
47
|
rtcConfig?: RtcConfiguration;
|
|
43
48
|
}
|
|
44
49
|
declare const defaultRoomOptions: RoomOptions$1;
|
|
@@ -46,6 +51,12 @@ declare const Room_base: new () => TypedEventEmitter<RoomCallbacks>;
|
|
|
46
51
|
declare class Room extends Room_base {
|
|
47
52
|
private info?;
|
|
48
53
|
private ffiHandle?;
|
|
54
|
+
/**
|
|
55
|
+
* used to ensure events are processed sequentially and allow for
|
|
56
|
+
* the local participant to acquire the lock while doing state updates related to FFI events
|
|
57
|
+
* before processing the next events
|
|
58
|
+
*/
|
|
59
|
+
private ffiEventLock;
|
|
49
60
|
private byteStreamControllers;
|
|
50
61
|
private textStreamControllers;
|
|
51
62
|
private byteStreamHandlers;
|
|
@@ -144,8 +155,9 @@ type RoomCallbacks = {
|
|
|
144
155
|
participantMetadataChanged: (metadata: string | undefined, participant: Participant) => void;
|
|
145
156
|
participantNameChanged: (name: string, participant: Participant) => void;
|
|
146
157
|
participantAttributesChanged: (changedAttributes: Record<string, string>, participant: Participant) => void;
|
|
158
|
+
participantEncryptionStatusChanged: (isEncrypted: boolean, participant: Participant) => void;
|
|
147
159
|
connectionQualityChanged: (quality: ConnectionQuality, participant: Participant) => void;
|
|
148
|
-
dataReceived: (payload: Uint8Array, participant?: RemoteParticipant, kind?: DataPacketKind, topic?: string) => void;
|
|
160
|
+
dataReceived: (payload: Uint8Array, participant?: RemoteParticipant, kind?: DataPacketKind, topic?: string, encryptionType?: EncryptionType) => void;
|
|
149
161
|
chatMessage: (message: ChatMessage, participant?: Participant) => void;
|
|
150
162
|
dtmfReceived: (code: number, digit: string, participant: RemoteParticipant) => void;
|
|
151
163
|
encryptionError: (error: Error) => void;
|
|
@@ -177,6 +189,7 @@ declare enum RoomEvent {
|
|
|
177
189
|
ParticipantMetadataChanged = "participantMetadataChanged",
|
|
178
190
|
ParticipantNameChanged = "participantNameChanged",
|
|
179
191
|
ParticipantAttributesChanged = "participantAttributesChanged",
|
|
192
|
+
ParticipantEncryptionStatusChanged = "participantEncryptionStatusChanged",
|
|
180
193
|
ConnectionQualityChanged = "connectionQualityChanged",
|
|
181
194
|
DataReceived = "dataReceived",
|
|
182
195
|
ChatMessage = "chatMessage",
|
package/dist/room.d.ts
CHANGED
|
@@ -2,16 +2,17 @@ import { TypedEventEmitter } from '@livekit/typed-emitter';
|
|
|
2
2
|
import { g as TextStreamHandler, f as ByteStreamHandler } from './stream_reader-DRyR29vo.js';
|
|
3
3
|
import { E2EEManager, E2EEOptions } from './e2ee.js';
|
|
4
4
|
import { RemoteParticipant, LocalParticipant, Participant } from './participant.js';
|
|
5
|
+
import { EncryptionType } from './proto/e2ee_pb.js';
|
|
5
6
|
import { DisconnectReason } from './proto/participant_pb.js';
|
|
6
7
|
import { RoomInfo, ConnectionQuality, DataPacketKind, ConnectionState, IceTransportType, ContinualGatheringPolicy, IceServer, RoomOptions as RoomOptions$1 } from './proto/room_pb.js';
|
|
7
8
|
import { LocalTrack, RemoteTrack } from './track.js';
|
|
8
9
|
import { LocalTrackPublication, RemoteTrackPublication, TrackPublication } from './track_publication.js';
|
|
9
10
|
import { ChatMessage } from './types.js';
|
|
10
|
-
import '
|
|
11
|
-
import '@bufbuild/protobuf';
|
|
11
|
+
import '@livekit/mutex';
|
|
12
12
|
import 'node:fs';
|
|
13
13
|
import './data_streams/stream_writer.js';
|
|
14
14
|
import './ffi_client.js';
|
|
15
|
+
import '@bufbuild/protobuf';
|
|
15
16
|
import './napi/native.d.js';
|
|
16
17
|
import './proto/ffi_pb.js';
|
|
17
18
|
import './proto/track_pb.js';
|
|
@@ -38,7 +39,11 @@ declare const defaultRtcConfiguration: RtcConfiguration;
|
|
|
38
39
|
interface RoomOptions {
|
|
39
40
|
autoSubscribe: boolean;
|
|
40
41
|
dynacast: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use `encryption` instead. See x for details
|
|
44
|
+
*/
|
|
41
45
|
e2ee?: E2EEOptions;
|
|
46
|
+
encryption?: E2EEOptions;
|
|
42
47
|
rtcConfig?: RtcConfiguration;
|
|
43
48
|
}
|
|
44
49
|
declare const defaultRoomOptions: RoomOptions$1;
|
|
@@ -46,6 +51,12 @@ declare const Room_base: new () => TypedEventEmitter<RoomCallbacks>;
|
|
|
46
51
|
declare class Room extends Room_base {
|
|
47
52
|
private info?;
|
|
48
53
|
private ffiHandle?;
|
|
54
|
+
/**
|
|
55
|
+
* used to ensure events are processed sequentially and allow for
|
|
56
|
+
* the local participant to acquire the lock while doing state updates related to FFI events
|
|
57
|
+
* before processing the next events
|
|
58
|
+
*/
|
|
59
|
+
private ffiEventLock;
|
|
49
60
|
private byteStreamControllers;
|
|
50
61
|
private textStreamControllers;
|
|
51
62
|
private byteStreamHandlers;
|
|
@@ -144,8 +155,9 @@ type RoomCallbacks = {
|
|
|
144
155
|
participantMetadataChanged: (metadata: string | undefined, participant: Participant) => void;
|
|
145
156
|
participantNameChanged: (name: string, participant: Participant) => void;
|
|
146
157
|
participantAttributesChanged: (changedAttributes: Record<string, string>, participant: Participant) => void;
|
|
158
|
+
participantEncryptionStatusChanged: (isEncrypted: boolean, participant: Participant) => void;
|
|
147
159
|
connectionQualityChanged: (quality: ConnectionQuality, participant: Participant) => void;
|
|
148
|
-
dataReceived: (payload: Uint8Array, participant?: RemoteParticipant, kind?: DataPacketKind, topic?: string) => void;
|
|
160
|
+
dataReceived: (payload: Uint8Array, participant?: RemoteParticipant, kind?: DataPacketKind, topic?: string, encryptionType?: EncryptionType) => void;
|
|
149
161
|
chatMessage: (message: ChatMessage, participant?: Participant) => void;
|
|
150
162
|
dtmfReceived: (code: number, digit: string, participant: RemoteParticipant) => void;
|
|
151
163
|
encryptionError: (error: Error) => void;
|
|
@@ -177,6 +189,7 @@ declare enum RoomEvent {
|
|
|
177
189
|
ParticipantMetadataChanged = "participantMetadataChanged",
|
|
178
190
|
ParticipantNameChanged = "participantNameChanged",
|
|
179
191
|
ParticipantAttributesChanged = "participantAttributesChanged",
|
|
192
|
+
ParticipantEncryptionStatusChanged = "participantEncryptionStatusChanged",
|
|
180
193
|
ConnectionQualityChanged = "connectionQualityChanged",
|
|
181
194
|
DataReceived = "dataReceived",
|
|
182
195
|
ChatMessage = "chatMessage",
|
package/dist/room.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room.d.ts","sourceRoot":"","sources":["../src/room.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"room.d.ts","sourceRoot":"","sources":["../src/room.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGhF,OAAO,KAAK,EACV,iBAAiB,EAGjB,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAsB,MAAM,WAAW,CAAC;AAG5D,OAAO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ChB"}
|
package/dist/room.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Mutex } from "@livekit/mutex";
|
|
1
2
|
import EventEmitter from "events";
|
|
2
3
|
import { ByteStreamReader, TextStreamReader } from "./data_streams/stream_reader.js";
|
|
3
4
|
import { E2EEManager, defaultE2EEOptions } from "./e2ee.js";
|
|
4
5
|
import { FfiClient, FfiClientEvent, FfiHandle } from "./ffi_client.js";
|
|
5
6
|
import { log } from "./log.js";
|
|
6
7
|
import { LocalParticipant, RemoteParticipant } from "./participant.js";
|
|
7
|
-
import { EncryptionState } from "./proto/e2ee_pb.js";
|
|
8
|
+
import { EncryptionState, EncryptionType } from "./proto/e2ee_pb.js";
|
|
8
9
|
import {
|
|
9
10
|
ConnectRequest,
|
|
10
11
|
ConnectionState,
|
|
@@ -25,6 +26,7 @@ const defaultRoomOptions = new FfiRoomOptions({
|
|
|
25
26
|
autoSubscribe: true,
|
|
26
27
|
dynacast: false,
|
|
27
28
|
e2ee: void 0,
|
|
29
|
+
encryption: void 0,
|
|
28
30
|
rtcConfig: void 0,
|
|
29
31
|
adaptiveStream: false,
|
|
30
32
|
joinRetries: 1
|
|
@@ -32,6 +34,12 @@ const defaultRoomOptions = new FfiRoomOptions({
|
|
|
32
34
|
class Room extends EventEmitter {
|
|
33
35
|
constructor() {
|
|
34
36
|
super();
|
|
37
|
+
/**
|
|
38
|
+
* used to ensure events are processed sequentially and allow for
|
|
39
|
+
* the local participant to acquire the lock while doing state updates related to FFI events
|
|
40
|
+
* before processing the next events
|
|
41
|
+
*/
|
|
42
|
+
this.ffiEventLock = new Mutex();
|
|
35
43
|
this.byteStreamControllers = /* @__PURE__ */ new Map();
|
|
36
44
|
this.textStreamControllers = /* @__PURE__ */ new Map();
|
|
37
45
|
this.byteStreamHandlers = /* @__PURE__ */ new Map();
|
|
@@ -39,18 +47,23 @@ class Room extends EventEmitter {
|
|
|
39
47
|
this.preConnectEvents = [];
|
|
40
48
|
this.connectionState = ConnectionState.CONN_DISCONNECTED;
|
|
41
49
|
this.remoteParticipants = /* @__PURE__ */ new Map();
|
|
42
|
-
this.onFfiEvent = (ffiEvent) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
this.onFfiEvent = async (ffiEvent) => {
|
|
51
|
+
const unlock = await this.ffiEventLock.lock();
|
|
52
|
+
try {
|
|
53
|
+
if (!this.localParticipant || !this.ffiHandle || !this.info) {
|
|
54
|
+
this.preConnectEvents.push(ffiEvent);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
for (const ev of this.preConnectEvents) {
|
|
58
|
+
await this.processFfiEvent(ev);
|
|
59
|
+
}
|
|
60
|
+
this.preConnectEvents = [];
|
|
61
|
+
await this.processFfiEvent(ffiEvent);
|
|
62
|
+
} finally {
|
|
63
|
+
unlock();
|
|
49
64
|
}
|
|
50
|
-
this.preConnectEvents = [];
|
|
51
|
-
this.processFfiEvent(ffiEvent);
|
|
52
65
|
};
|
|
53
|
-
this.processFfiEvent = (ffiEvent) => {
|
|
66
|
+
this.processFfiEvent = async (ffiEvent) => {
|
|
54
67
|
if (!this.localParticipant || !this.ffiHandle || !this.info) {
|
|
55
68
|
throw new Error("processFfiEvent called before connect");
|
|
56
69
|
}
|
|
@@ -79,9 +92,13 @@ class Room extends EventEmitter {
|
|
|
79
92
|
this.emit("participantConnected" /* ParticipantConnected */, participant);
|
|
80
93
|
} else if (ev.case == "participantDisconnected") {
|
|
81
94
|
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
95
|
+
if (participant) {
|
|
96
|
+
this.remoteParticipants.delete(participant.identity);
|
|
97
|
+
participant.info.disconnectReason = ev.value.disconnectReason;
|
|
98
|
+
this.emit("participantDisconnected" /* ParticipantDisconnected */, participant);
|
|
99
|
+
} else {
|
|
100
|
+
console.log(`RoomEvent.ParticipantDisconnected: Could not find participant`);
|
|
101
|
+
}
|
|
85
102
|
} else if (ev.case == "localTrackPublished") {
|
|
86
103
|
const publication = this.localParticipant.trackPublications.get(ev.value.trackSid);
|
|
87
104
|
this.emit("localTrackPublished" /* LocalTrackPublished */, publication, this.localParticipant);
|
|
@@ -91,12 +108,22 @@ class Room extends EventEmitter {
|
|
|
91
108
|
this.emit("localTrackUnpublished" /* LocalTrackUnpublished */, publication, this.localParticipant);
|
|
92
109
|
} else if (ev.case == "localTrackSubscribed") {
|
|
93
110
|
const publication = this.localParticipant.trackPublications.get(ev.value.trackSid);
|
|
94
|
-
publication
|
|
95
|
-
|
|
111
|
+
if (publication) {
|
|
112
|
+
publication.resolveFirstSubscription();
|
|
113
|
+
this.emit("localTrackSubscribed" /* LocalTrackSubscribed */, publication.track);
|
|
114
|
+
} else {
|
|
115
|
+
console.warn(`RoomEvent.LocalTrackSubscribed: Publication not found: ${ev.value.trackSid}`);
|
|
116
|
+
}
|
|
96
117
|
} else if (ev.case == "trackPublished") {
|
|
97
118
|
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
98
119
|
const publication = new RemoteTrackPublication(ev.value.publication);
|
|
99
|
-
participant
|
|
120
|
+
if (participant) {
|
|
121
|
+
participant.trackPublications.set(publication.sid, publication);
|
|
122
|
+
} else {
|
|
123
|
+
console.warn(
|
|
124
|
+
`RoomEvent.TrackPublished: Could not find participant: ${ev.value.participantIdentity}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
100
127
|
this.emit("trackPublished" /* TrackPublished */, publication, participant);
|
|
101
128
|
} else if (ev.case == "trackUnpublished") {
|
|
102
129
|
const participant = this.requireRemoteParticipant(ev.value.participantIdentity);
|
|
@@ -104,91 +131,138 @@ class Room extends EventEmitter {
|
|
|
104
131
|
participant.trackPublications.delete(ev.value.publicationSid);
|
|
105
132
|
if (publication) {
|
|
106
133
|
this.emit("trackUnpublished" /* TrackUnpublished */, publication, participant);
|
|
134
|
+
} else {
|
|
135
|
+
console.warn(`RoomEvent.TrackUnpublished: Could not find publication`);
|
|
107
136
|
}
|
|
108
137
|
} else if (ev.case == "trackSubscribed") {
|
|
109
138
|
const ownedTrack = ev.value.track;
|
|
110
139
|
const trackInfo = ownedTrack.info;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
140
|
+
try {
|
|
141
|
+
const { participant, publication } = this.requirePublicationOfRemoteParticipant(
|
|
142
|
+
ev.value.participantIdentity,
|
|
143
|
+
trackInfo.sid
|
|
144
|
+
);
|
|
145
|
+
publication.subscribed = true;
|
|
146
|
+
if (trackInfo.kind == TrackKind.KIND_VIDEO) {
|
|
147
|
+
publication.track = new RemoteVideoTrack(ownedTrack);
|
|
148
|
+
} else if (trackInfo.kind == TrackKind.KIND_AUDIO) {
|
|
149
|
+
publication.track = new RemoteAudioTrack(ownedTrack);
|
|
150
|
+
}
|
|
151
|
+
this.emit("trackSubscribed" /* TrackSubscribed */, publication.track, publication, participant);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.warn(`RoomEvent.TrackSubscribed: ${e.message}`);
|
|
120
154
|
}
|
|
121
|
-
this.emit("trackSubscribed" /* TrackSubscribed */, publication.track, publication, participant);
|
|
122
155
|
} else if (ev.case == "trackUnsubscribed") {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
156
|
+
try {
|
|
157
|
+
const { participant, publication } = this.requirePublicationOfRemoteParticipant(
|
|
158
|
+
ev.value.participantIdentity,
|
|
159
|
+
ev.value.trackSid
|
|
160
|
+
);
|
|
161
|
+
const track = publication.track;
|
|
162
|
+
publication.track = void 0;
|
|
163
|
+
publication.subscribed = false;
|
|
164
|
+
this.emit("trackUnsubscribed" /* TrackUnsubscribed */, track, publication, participant);
|
|
165
|
+
} catch (e) {
|
|
166
|
+
console.warn(`RoomEvent.TrackUnsubscribed: ${e.message}`);
|
|
167
|
+
}
|
|
131
168
|
} else if (ev.case == "trackSubscriptionFailed") {
|
|
132
|
-
|
|
133
|
-
|
|
169
|
+
try {
|
|
170
|
+
const participant = this.requireRemoteParticipant(ev.value.participantIdentity);
|
|
171
|
+
this.emit(
|
|
172
|
+
"trackSubscriptionFailed" /* TrackSubscriptionFailed */,
|
|
173
|
+
ev.value.trackSid,
|
|
174
|
+
participant,
|
|
175
|
+
ev.value.error
|
|
176
|
+
);
|
|
177
|
+
} catch (e) {
|
|
178
|
+
console.warn(`RoomEvent.TrackSubscriptionFailed: ${e.message}`);
|
|
179
|
+
}
|
|
134
180
|
} else if (ev.case == "trackMuted") {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
publication.track
|
|
181
|
+
try {
|
|
182
|
+
const { participant, publication } = this.requirePublicationOfParticipant(
|
|
183
|
+
ev.value.participantIdentity,
|
|
184
|
+
ev.value.trackSid
|
|
185
|
+
);
|
|
186
|
+
publication.info.muted = true;
|
|
187
|
+
if (publication.track) {
|
|
188
|
+
publication.track.info.muted = true;
|
|
189
|
+
}
|
|
190
|
+
this.emit("trackMuted" /* TrackMuted */, publication, participant);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
console.warn(`RoomEvent.TrackMuted: ${e.message}`);
|
|
142
193
|
}
|
|
143
|
-
this.emit("trackMuted" /* TrackMuted */, publication, participant);
|
|
144
194
|
} else if (ev.case == "trackUnmuted") {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
publication.track
|
|
195
|
+
try {
|
|
196
|
+
const { participant, publication } = this.requirePublicationOfParticipant(
|
|
197
|
+
ev.value.participantIdentity,
|
|
198
|
+
ev.value.trackSid
|
|
199
|
+
);
|
|
200
|
+
publication.info.muted = false;
|
|
201
|
+
if (publication.track) {
|
|
202
|
+
publication.track.info.muted = false;
|
|
203
|
+
}
|
|
204
|
+
this.emit("trackUnmuted" /* TrackUnmuted */, publication, participant);
|
|
205
|
+
} catch (e) {
|
|
206
|
+
console.warn(`RoomEvent.TrackUnmuted: ${e.message}`);
|
|
152
207
|
}
|
|
153
|
-
this.emit("trackUnmuted" /* TrackUnmuted */, publication, participant);
|
|
154
208
|
} else if (ev.case == "activeSpeakersChanged") {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
209
|
+
try {
|
|
210
|
+
const activeSpeakers = ev.value.participantIdentities.map(
|
|
211
|
+
(identity) => this.requireParticipantByIdentity(identity)
|
|
212
|
+
);
|
|
213
|
+
this.emit("activeSpeakersChanged" /* ActiveSpeakersChanged */, activeSpeakers);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
console.warn(`RoomEvent.ActiveSpeakersChanged: ${e.message}`);
|
|
216
|
+
}
|
|
159
217
|
} else if (ev.case == "roomMetadataChanged") {
|
|
160
|
-
this.info.metadata = ev.value.metadata;
|
|
218
|
+
this.info.metadata = ev.value.metadata ?? "";
|
|
161
219
|
this.emit("roomMetadataChanged" /* RoomMetadataChanged */, this.info.metadata);
|
|
162
220
|
} else if (ev.case == "participantMetadataChanged") {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
221
|
+
try {
|
|
222
|
+
const participant = this.requireParticipantByIdentity(ev.value.participantIdentity);
|
|
223
|
+
participant.info.metadata = ev.value.metadata;
|
|
224
|
+
this.emit("participantMetadataChanged" /* ParticipantMetadataChanged */, participant.metadata, participant);
|
|
225
|
+
} catch (e) {
|
|
226
|
+
console.warn(`RoomEvent.ParticipantMetadataChanged: ${e.message}`);
|
|
227
|
+
}
|
|
166
228
|
} else if (ev.case == "participantNameChanged") {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
229
|
+
try {
|
|
230
|
+
const participant = this.requireParticipantByIdentity(ev.value.participantIdentity);
|
|
231
|
+
participant.info.name = ev.value.name;
|
|
232
|
+
this.emit("participantNameChanged" /* ParticipantNameChanged */, participant.name, participant);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
console.warn(`RoomEvent.ParticipantNameChanged: ${e.message}`);
|
|
235
|
+
}
|
|
170
236
|
} else if (ev.case == "participantAttributesChanged") {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
acc[value.key] = value.value;
|
|
175
|
-
return acc;
|
|
176
|
-
},
|
|
177
|
-
{}
|
|
178
|
-
);
|
|
179
|
-
if (Object.keys(ev.value.changedAttributes).length > 0) {
|
|
180
|
-
const changedAttributes = ev.value.changedAttributes.reduce(
|
|
237
|
+
try {
|
|
238
|
+
const participant = this.requireParticipantByIdentity(ev.value.participantIdentity);
|
|
239
|
+
participant.info.attributes = ev.value.attributes.reduce(
|
|
181
240
|
(acc, value) => {
|
|
182
241
|
acc[value.key] = value.value;
|
|
183
242
|
return acc;
|
|
184
243
|
},
|
|
185
244
|
{}
|
|
186
245
|
);
|
|
187
|
-
|
|
246
|
+
if (Object.keys(ev.value.changedAttributes).length > 0) {
|
|
247
|
+
const changedAttributes = ev.value.changedAttributes.reduce(
|
|
248
|
+
(acc, value) => {
|
|
249
|
+
acc[value.key] = value.value;
|
|
250
|
+
return acc;
|
|
251
|
+
},
|
|
252
|
+
{}
|
|
253
|
+
);
|
|
254
|
+
this.emit("participantAttributesChanged" /* ParticipantAttributesChanged */, changedAttributes, participant);
|
|
255
|
+
}
|
|
256
|
+
} catch (e) {
|
|
257
|
+
console.warn(`RoomEvent.ParticipantAttributesChanged: ${e.message}`);
|
|
188
258
|
}
|
|
189
259
|
} else if (ev.case == "connectionQualityChanged") {
|
|
190
|
-
|
|
191
|
-
|
|
260
|
+
try {
|
|
261
|
+
const participant = this.requireParticipantByIdentity(ev.value.participantIdentity);
|
|
262
|
+
this.emit("connectionQualityChanged" /* ConnectionQualityChanged */, ev.value.quality, participant);
|
|
263
|
+
} catch (e) {
|
|
264
|
+
console.warn(`RoomEvent.ConnectionQualityChanged: ${e.message}`);
|
|
265
|
+
}
|
|
192
266
|
} else if (ev.case == "chatMessage") {
|
|
193
267
|
const participant = this.retrieveParticipantByIdentity(ev.value.participantIdentity);
|
|
194
268
|
const { id, message: messageText, timestamp, editTimestamp, generated } = ev.value.message;
|
|
@@ -259,6 +333,17 @@ class Room extends EventEmitter {
|
|
|
259
333
|
participant.info = info;
|
|
260
334
|
}
|
|
261
335
|
}
|
|
336
|
+
} else if (ev.case === "participantEncryptionStatusChanged") {
|
|
337
|
+
try {
|
|
338
|
+
const participant = this.requireParticipantByIdentity(ev.value.participantIdentity);
|
|
339
|
+
this.emit(
|
|
340
|
+
"participantEncryptionStatusChanged" /* ParticipantEncryptionStatusChanged */,
|
|
341
|
+
!!ev.value.isEncrypted,
|
|
342
|
+
participant
|
|
343
|
+
);
|
|
344
|
+
} catch (e) {
|
|
345
|
+
console.warn(`RoomEvent.ParticipantEncryptionStatusChanged: ${e.message}`);
|
|
346
|
+
}
|
|
262
347
|
}
|
|
263
348
|
};
|
|
264
349
|
}
|
|
@@ -341,7 +426,8 @@ class Room extends EventEmitter {
|
|
|
341
426
|
*/
|
|
342
427
|
async connect(url, token, opts) {
|
|
343
428
|
const options = { ...defaultRoomOptions, ...opts };
|
|
344
|
-
const
|
|
429
|
+
const e2eeEnabled = options.encryption || options.e2ee;
|
|
430
|
+
const e2eeOptions = options.encryption ? { ...defaultE2EEOptions, ...options.encryption } : { ...defaultE2EEOptions, ...options.e2ee };
|
|
345
431
|
const req = new ConnectRequest({
|
|
346
432
|
url,
|
|
347
433
|
token,
|
|
@@ -361,10 +447,13 @@ class Room extends EventEmitter {
|
|
|
361
447
|
switch (cb.message.case) {
|
|
362
448
|
case "result":
|
|
363
449
|
this.ffiHandle = new FfiHandle(cb.message.value.room.handle.id);
|
|
364
|
-
this.e2eeManager =
|
|
450
|
+
this.e2eeManager = e2eeEnabled && new E2EEManager(this.ffiHandle.handle, e2eeOptions);
|
|
365
451
|
this.info = cb.message.value.room.info;
|
|
366
452
|
this.connectionState = ConnectionState.CONN_CONNECTED;
|
|
367
|
-
this.localParticipant = new LocalParticipant(
|
|
453
|
+
this.localParticipant = new LocalParticipant(
|
|
454
|
+
cb.message.value.localParticipant,
|
|
455
|
+
this.ffiEventLock
|
|
456
|
+
);
|
|
368
457
|
for (const pt of cb.message.value.participants) {
|
|
369
458
|
const rp = this.createRemoteParticipant(pt.participant);
|
|
370
459
|
for (const pub of pt.publications) {
|
|
@@ -387,7 +476,7 @@ class Room extends EventEmitter {
|
|
|
387
476
|
if (!this.isConnected) {
|
|
388
477
|
return;
|
|
389
478
|
}
|
|
390
|
-
FfiClient.instance.request({
|
|
479
|
+
const res = FfiClient.instance.request({
|
|
391
480
|
message: {
|
|
392
481
|
case: "disconnect",
|
|
393
482
|
value: {
|
|
@@ -395,6 +484,9 @@ class Room extends EventEmitter {
|
|
|
395
484
|
}
|
|
396
485
|
}
|
|
397
486
|
});
|
|
487
|
+
await FfiClient.instance.waitFor((ev) => {
|
|
488
|
+
return ev.message.case == "disconnect" && ev.message.value.asyncId == res.asyncId;
|
|
489
|
+
});
|
|
398
490
|
FfiClient.instance.removeListener(FfiClientEvent.FfiEvent, this.onFfiEvent);
|
|
399
491
|
this.removeAllListeners();
|
|
400
492
|
}
|
|
@@ -599,6 +691,7 @@ var RoomEvent = /* @__PURE__ */ ((RoomEvent2) => {
|
|
|
599
691
|
RoomEvent2["ParticipantMetadataChanged"] = "participantMetadataChanged";
|
|
600
692
|
RoomEvent2["ParticipantNameChanged"] = "participantNameChanged";
|
|
601
693
|
RoomEvent2["ParticipantAttributesChanged"] = "participantAttributesChanged";
|
|
694
|
+
RoomEvent2["ParticipantEncryptionStatusChanged"] = "participantEncryptionStatusChanged";
|
|
602
695
|
RoomEvent2["ConnectionQualityChanged"] = "connectionQualityChanged";
|
|
603
696
|
RoomEvent2["DataReceived"] = "dataReceived";
|
|
604
697
|
RoomEvent2["ChatMessage"] = "chatMessage";
|