@livekit/rtc-node 0.5.1 → 0.6.1
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/README.md +5 -2
- package/dist/audio_frame.d.ts.map +1 -1
- package/dist/audio_frame.js +5 -0
- package/dist/audio_frame.js.map +1 -1
- package/dist/audio_source.d.ts +1 -1
- package/dist/audio_source.d.ts.map +1 -1
- package/dist/audio_source.js +2 -1
- package/dist/audio_source.js.map +1 -1
- package/dist/audio_stream.d.ts.map +1 -1
- package/dist/ffi_client.d.ts.map +1 -1
- package/dist/napi/native.d.ts +1 -1
- package/dist/participant.d.ts +5 -2
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +40 -16
- package/dist/participant.js.map +1 -1
- package/dist/proto/audio_frame_pb.d.ts +4 -0
- package/dist/proto/audio_frame_pb.d.ts.map +1 -1
- package/dist/proto/audio_frame_pb.js +1 -0
- package/dist/proto/audio_frame_pb.js.map +1 -1
- package/dist/proto/ffi_pb.d.ts +105 -51
- package/dist/proto/ffi_pb.d.ts.map +1 -1
- package/dist/proto/ffi_pb.js +48 -39
- package/dist/proto/ffi_pb.js.map +1 -1
- package/dist/proto/participant_pb.d.ts +6 -0
- package/dist/proto/participant_pb.d.ts.map +1 -1
- package/dist/proto/participant_pb.js +5 -0
- package/dist/proto/participant_pb.js.map +1 -1
- package/dist/proto/room_pb.d.ts +501 -110
- package/dist/proto/room_pb.d.ts.map +1 -1
- package/dist/proto/room_pb.js +672 -128
- package/dist/proto/room_pb.js.map +1 -1
- package/dist/room.d.ts +5 -2
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +40 -24
- package/dist/room.js.map +1 -1
- package/dist/video_stream.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/audio_frame.ts +5 -0
- package/src/audio_source.ts +2 -1
- package/src/napi/native.d.ts +1 -1
- package/src/participant.ts +65 -28
- package/src/proto/audio_frame_pb.ts +7 -1
- package/src/proto/e2ee_pb.ts +1 -1
- package/src/proto/ffi_pb.ts +153 -90
- package/src/proto/handle_pb.ts +1 -1
- package/src/proto/participant_pb.ts +7 -1
- package/src/proto/room_pb.ts +900 -168
- package/src/proto/stats_pb.ts +1 -1
- package/src/proto/track_pb.ts +1 -1
- package/src/proto/video_frame_pb.ts +1 -1
- package/src/room.ts +55 -26
package/src/proto/stats_pb.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
|
-
// @generated by protoc-gen-es v1.
|
|
15
|
+
// @generated by protoc-gen-es v1.10.0 with parameter "target=ts"
|
|
16
16
|
// @generated from file stats.proto (package livekit.proto, syntax proto3)
|
|
17
17
|
/* eslint-disable */
|
|
18
18
|
// @ts-nocheck
|
package/src/proto/track_pb.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
|
-
// @generated by protoc-gen-es v1.
|
|
15
|
+
// @generated by protoc-gen-es v1.10.0 with parameter "target=ts"
|
|
16
16
|
// @generated from file track.proto (package livekit.proto, syntax proto3)
|
|
17
17
|
/* eslint-disable */
|
|
18
18
|
// @ts-nocheck
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
|
-
// @generated by protoc-gen-es v1.
|
|
15
|
+
// @generated by protoc-gen-es v1.10.0 with parameter "target=ts"
|
|
16
16
|
// @generated from file video_frame.proto (package livekit.proto, syntax proto3)
|
|
17
17
|
/* eslint-disable */
|
|
18
18
|
// @ts-nocheck
|
package/src/room.ts
CHANGED
|
@@ -175,7 +175,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
175
175
|
this.remoteParticipants.set(participant.identity, participant);
|
|
176
176
|
this.emit(RoomEvent.ParticipantConnected, participant);
|
|
177
177
|
} else if (ev.case == 'participantDisconnected') {
|
|
178
|
-
const participant = this.
|
|
178
|
+
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
179
179
|
this.remoteParticipants.delete(participant.identity);
|
|
180
180
|
this.emit(RoomEvent.ParticipantDisconnected, participant);
|
|
181
181
|
} else if (ev.case == 'localTrackPublished') {
|
|
@@ -186,18 +186,18 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
186
186
|
this.localParticipant.trackPublications.delete(ev.value.publicationSid);
|
|
187
187
|
this.emit(RoomEvent.LocalTrackUnpublished, publication, this.localParticipant);
|
|
188
188
|
} else if (ev.case == 'trackPublished') {
|
|
189
|
-
const participant = this.
|
|
189
|
+
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
190
190
|
const publication = new RemoteTrackPublication(ev.value.publication);
|
|
191
191
|
participant.trackPublications.set(publication.sid, publication);
|
|
192
192
|
this.emit(RoomEvent.TrackPublished, publication, participant);
|
|
193
193
|
} else if (ev.case == 'trackUnpublished') {
|
|
194
|
-
const participant = this.
|
|
194
|
+
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
195
195
|
const publication = participant.trackPublications.get(ev.value.publicationSid);
|
|
196
196
|
participant.trackPublications.delete(ev.value.publicationSid);
|
|
197
197
|
this.emit(RoomEvent.TrackUnpublished, publication, participant);
|
|
198
198
|
} else if (ev.case == 'trackSubscribed') {
|
|
199
199
|
const ownedTrack = ev.value.track;
|
|
200
|
-
const participant = this.
|
|
200
|
+
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
201
201
|
const publication = participant.trackPublications.get(ownedTrack.info.sid);
|
|
202
202
|
publication.subscribed = true;
|
|
203
203
|
if (ownedTrack.info.kind == TrackKind.KIND_VIDEO) {
|
|
@@ -208,16 +208,16 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
208
208
|
|
|
209
209
|
this.emit(RoomEvent.TrackSubscribed, publication.track, publication, participant);
|
|
210
210
|
} else if (ev.case == 'trackUnsubscribed') {
|
|
211
|
-
const participant = this.
|
|
211
|
+
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
212
212
|
const publication = participant.trackPublications.get(ev.value.trackSid);
|
|
213
213
|
publication.track = undefined;
|
|
214
214
|
publication.subscribed = false;
|
|
215
215
|
this.emit(RoomEvent.TrackUnsubscribed, publication.track, publication, participant);
|
|
216
216
|
} else if (ev.case == 'trackSubscriptionFailed') {
|
|
217
|
-
const participant = this.
|
|
217
|
+
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
218
218
|
this.emit(RoomEvent.TrackSubscriptionFailed, ev.value.trackSid, participant, ev.value.error);
|
|
219
219
|
} else if (ev.case == 'trackMuted') {
|
|
220
|
-
const participant = this.
|
|
220
|
+
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
221
221
|
const publication = participant.trackPublications.get(ev.value.trackSid);
|
|
222
222
|
publication.info.muted = true;
|
|
223
223
|
if (publication.track) {
|
|
@@ -225,7 +225,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
225
225
|
}
|
|
226
226
|
this.emit(RoomEvent.TrackMuted, publication, participant);
|
|
227
227
|
} else if (ev.case == 'trackUnmuted') {
|
|
228
|
-
const participant = this.
|
|
228
|
+
const participant = this.retrieveParticipantByIdentity(ev.value.participantIdentity);
|
|
229
229
|
const publication = participant.trackPublications.get(ev.value.trackSid);
|
|
230
230
|
publication.info.muted = false;
|
|
231
231
|
if (publication.track) {
|
|
@@ -233,31 +233,57 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
233
233
|
}
|
|
234
234
|
this.emit(RoomEvent.TrackUnmuted, publication, participant);
|
|
235
235
|
} else if (ev.case == 'activeSpeakersChanged') {
|
|
236
|
-
const activeSpeakers = ev.value.
|
|
237
|
-
this.
|
|
236
|
+
const activeSpeakers = ev.value.participantIdentities.map((identity) =>
|
|
237
|
+
this.retrieveParticipantByIdentity(identity),
|
|
238
238
|
);
|
|
239
239
|
this.emit(RoomEvent.ActiveSpeakersChanged, activeSpeakers);
|
|
240
240
|
} else if (ev.case == 'roomMetadataChanged') {
|
|
241
241
|
this.info.metadata = ev.value.metadata;
|
|
242
242
|
this.emit(RoomEvent.RoomMetadataChanged, this.info.metadata);
|
|
243
243
|
} else if (ev.case == 'participantMetadataChanged') {
|
|
244
|
-
const participant = this.
|
|
244
|
+
const participant = this.retrieveParticipantByIdentity(ev.value.participantIdentity);
|
|
245
245
|
participant.info.metadata = ev.value.metadata;
|
|
246
246
|
this.emit(RoomEvent.ParticipantMetadataChanged, participant.metadata, participant);
|
|
247
247
|
} else if (ev.case == 'participantNameChanged') {
|
|
248
|
-
const participant = this.
|
|
248
|
+
const participant = this.retrieveParticipantByIdentity(ev.value.participantIdentity);
|
|
249
249
|
participant.info.name = ev.value.name;
|
|
250
250
|
this.emit(RoomEvent.ParticipantNameChanged, participant.name, participant);
|
|
251
|
+
} else if (ev.case == 'participantAttributesChanged') {
|
|
252
|
+
const participant = this.retrieveParticipantByIdentity(ev.value.participantIdentity);
|
|
253
|
+
participant.info.attributes = ev.value.attributes;
|
|
254
|
+
if (Object.keys(ev.value.changedAttributes).length > 0) {
|
|
255
|
+
this.emit(RoomEvent.ParticipantAttributesChanged, ev.value.changedAttributes, participant);
|
|
256
|
+
}
|
|
251
257
|
} else if (ev.case == 'connectionQualityChanged') {
|
|
252
|
-
const participant = this.
|
|
258
|
+
const participant = this.retrieveParticipantByIdentity(ev.value.participantIdentity);
|
|
253
259
|
this.emit(RoomEvent.ConnectionQualityChanged, ev.value.quality, participant);
|
|
254
|
-
} else if (ev.case == '
|
|
260
|
+
} else if (ev.case == 'dataPacketReceived') {
|
|
255
261
|
// Can be undefined if the data is sent from a Server SDK
|
|
256
|
-
const participant = this.
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
262
|
+
const participant = this.remoteParticipants.get(ev.value.participantIdentity);
|
|
263
|
+
const dataPacket = ev.value.value;
|
|
264
|
+
switch (dataPacket.case) {
|
|
265
|
+
case 'user':
|
|
266
|
+
const buffer = FfiClient.instance.copyBuffer(
|
|
267
|
+
dataPacket.value.data.data.dataPtr,
|
|
268
|
+
Number(dataPacket.value.data.data.dataLen),
|
|
269
|
+
);
|
|
270
|
+
new FfiHandle(dataPacket.value.data.handle.id).dispose();
|
|
271
|
+
this.emit(
|
|
272
|
+
RoomEvent.DataReceived,
|
|
273
|
+
buffer,
|
|
274
|
+
participant,
|
|
275
|
+
ev.value.kind,
|
|
276
|
+
dataPacket.value.topic,
|
|
277
|
+
);
|
|
278
|
+
break;
|
|
279
|
+
case 'sipDtmf':
|
|
280
|
+
const { code, digit } = dataPacket.value;
|
|
281
|
+
this.emit(RoomEvent.DtmfReceived, code, digit, participant);
|
|
282
|
+
break;
|
|
283
|
+
|
|
284
|
+
default:
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
261
287
|
} else if (ev.case == 'e2eeStateChanged') {
|
|
262
288
|
if (ev.value.state == EncryptionState.INTERNAL_ERROR) {
|
|
263
289
|
// throw generic error until Rust SDK is updated to supply the error alongside INTERNAL_ERROR
|
|
@@ -277,15 +303,11 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
|
|
|
277
303
|
}
|
|
278
304
|
};
|
|
279
305
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
private retrieveParticipant(sid: string): Participant {
|
|
285
|
-
if (this.localParticipant.sid === sid) {
|
|
306
|
+
private retrieveParticipantByIdentity(identity: string): Participant {
|
|
307
|
+
if (this.localParticipant.identity === identity) {
|
|
286
308
|
return this.localParticipant;
|
|
287
309
|
} else {
|
|
288
|
-
return this.
|
|
310
|
+
return this.remoteParticipants.get(identity);
|
|
289
311
|
}
|
|
290
312
|
}
|
|
291
313
|
|
|
@@ -337,6 +359,10 @@ export type RoomCallbacks = {
|
|
|
337
359
|
roomMetadataChanged: (metadata: string) => void;
|
|
338
360
|
participantMetadataChanged: (metadata: string | undefined, participant: Participant) => void;
|
|
339
361
|
participantNameChanged: (name: string, participant: Participant) => void;
|
|
362
|
+
participantAttributesChanged: (
|
|
363
|
+
changedAttributes: Record<string, string>,
|
|
364
|
+
participant: Participant,
|
|
365
|
+
) => void;
|
|
340
366
|
connectionQualityChanged: (quality: ConnectionQuality, participant: Participant) => void;
|
|
341
367
|
dataReceived: (
|
|
342
368
|
payload: Uint8Array,
|
|
@@ -344,6 +370,7 @@ export type RoomCallbacks = {
|
|
|
344
370
|
kind?: DataPacketKind,
|
|
345
371
|
topic?: string,
|
|
346
372
|
) => void;
|
|
373
|
+
dtmfReceived: (code: number, digit: string, participant: RemoteParticipant) => void;
|
|
347
374
|
encryptionError: (error: Error) => void;
|
|
348
375
|
connectionStateChanged: (state: ConnectionState) => void;
|
|
349
376
|
connected: () => void;
|
|
@@ -368,8 +395,10 @@ export enum RoomEvent {
|
|
|
368
395
|
RoomMetadataChanged = 'roomMetadataChanged',
|
|
369
396
|
ParticipantMetadataChanged = 'participantMetadataChanged',
|
|
370
397
|
ParticipantNameChanged = 'participantNameChanged',
|
|
398
|
+
ParticipantAttributesChanged = 'participantAttributesChanged',
|
|
371
399
|
ConnectionQualityChanged = 'connectionQualityChanged',
|
|
372
400
|
DataReceived = 'dataReceived',
|
|
401
|
+
DtmfReceived = 'dtmfReceived',
|
|
373
402
|
EncryptionError = 'encryptionError',
|
|
374
403
|
ConnectionStateChanged = 'connectionStateChanged',
|
|
375
404
|
Connected = 'connected',
|