@livekit/rtc-node 0.13.24 → 0.13.26
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 +9 -5
- package/dist/audio_frame.cjs.map +1 -1
- package/dist/audio_frame.d.cts +2 -7
- package/dist/audio_frame.d.ts +2 -7
- package/dist/audio_frame.d.ts.map +1 -1
- package/dist/audio_frame.js +8 -4
- package/dist/audio_frame.js.map +1 -1
- package/dist/audio_mixer.cjs +10 -4
- package/dist/audio_mixer.cjs.map +1 -1
- package/dist/audio_mixer.d.cts +4 -7
- package/dist/audio_mixer.d.ts +4 -7
- package/dist/audio_mixer.d.ts.map +1 -1
- package/dist/audio_mixer.js +10 -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 +16 -6
- 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 +15 -5
- 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 +30 -15
- package/dist/ffi_client.cjs.map +1 -1
- package/dist/ffi_client.d.cts +6 -17
- package/dist/ffi_client.d.ts +6 -17
- package/dist/ffi_client.d.ts.map +1 -1
- package/dist/ffi_client.js +24 -6
- 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/participant.cjs +146 -101
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +4 -16
- package/dist/participant.d.ts +4 -16
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +120 -75
- package/dist/participant.js.map +1 -1
- package/dist/room.cjs +116 -58
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +6 -15
- package/dist/room.d.ts +6 -15
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +113 -55
- 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 +7 -37
- package/src/audio_filter.ts +2 -2
- package/src/audio_frame.ts +17 -5
- package/src/audio_mixer.test.ts +102 -0
- package/src/audio_mixer.ts +10 -4
- package/src/audio_resampler.ts +14 -4
- package/src/audio_source.ts +13 -5
- package/src/audio_stream.ts +21 -6
- 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 +33 -8
- package/src/frame_processor.ts +21 -0
- package/src/index.ts +6 -5
- package/src/participant.ts +117 -66
- package/src/room.ts +161 -69
- package/src/rpc.ts +1 -1
- package/src/tests/e2e.test.ts +179 -8
- 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/dist/participant.cjs
CHANGED
|
@@ -24,13 +24,13 @@ __export(participant_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(participant_exports);
|
|
26
26
|
var import_mutex = require("@livekit/mutex");
|
|
27
|
+
var import_rtc_ffi_bindings = require("@livekit/rtc-ffi-bindings");
|
|
28
|
+
var import_rtc_ffi_bindings2 = require("@livekit/rtc-ffi-bindings");
|
|
29
|
+
var import_rtc_ffi_bindings3 = require("@livekit/rtc-ffi-bindings");
|
|
27
30
|
var import_promises = require("node:fs/promises");
|
|
28
31
|
var import_data_streams = require("./data_streams/index.cjs");
|
|
29
32
|
var import_ffi_client = require("./ffi_client.cjs");
|
|
30
33
|
var import_log = require("./log.cjs");
|
|
31
|
-
var import_participant_pb = require("./proto/participant_pb.cjs");
|
|
32
|
-
var import_room_pb = require("./proto/room_pb.cjs");
|
|
33
|
-
var import_rpc_pb = require("./proto/rpc_pb.cjs");
|
|
34
34
|
var import_rpc = require("./rpc.cjs");
|
|
35
35
|
var import_track_publication = require("./track_publication.cjs");
|
|
36
36
|
var import_utils = require("./utils.cjs");
|
|
@@ -57,24 +57,51 @@ class Participant {
|
|
|
57
57
|
return this.info.attributes ?? {};
|
|
58
58
|
}
|
|
59
59
|
get kind() {
|
|
60
|
-
return this.info.kind ??
|
|
60
|
+
return this.info.kind ?? import_rtc_ffi_bindings.ParticipantKind.STANDARD;
|
|
61
61
|
}
|
|
62
62
|
get disconnectReason() {
|
|
63
|
-
if (this.info.disconnectReason ===
|
|
63
|
+
if (this.info.disconnectReason === import_rtc_ffi_bindings.DisconnectReason.UNKNOWN_REASON) {
|
|
64
64
|
return void 0;
|
|
65
65
|
}
|
|
66
66
|
return this.info.disconnectReason;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
class LocalParticipant extends Participant {
|
|
70
|
-
constructor(info, ffiEventLock) {
|
|
70
|
+
constructor(info, ffiEventLock, disconnectSignal) {
|
|
71
71
|
super(info);
|
|
72
72
|
this.rpcHandlers = /* @__PURE__ */ new Map();
|
|
73
73
|
this.trackPublications = /* @__PURE__ */ new Map();
|
|
74
|
+
this.sendStreamChunk = async (req) => {
|
|
75
|
+
const type = "sendStreamChunk";
|
|
76
|
+
const res = import_ffi_client.FfiClient.instance.request({
|
|
77
|
+
message: { case: type, value: req }
|
|
78
|
+
});
|
|
79
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
80
|
+
(ev) => ev.message.case == type && ev.message.value.asyncId == res.asyncId,
|
|
81
|
+
{ signal: this.disconnectSignal }
|
|
82
|
+
);
|
|
83
|
+
if (cb.error) {
|
|
84
|
+
throw new Error(cb.error);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
this.sendStreamTrailer = async (req) => {
|
|
88
|
+
const type = "sendStreamTrailer";
|
|
89
|
+
const res = import_ffi_client.FfiClient.instance.request({
|
|
90
|
+
message: { case: type, value: req }
|
|
91
|
+
});
|
|
92
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
93
|
+
(ev) => ev.message.case == type && ev.message.value.asyncId == res.asyncId,
|
|
94
|
+
{ signal: this.disconnectSignal }
|
|
95
|
+
);
|
|
96
|
+
if (cb.error) {
|
|
97
|
+
throw new Error(cb.error);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
74
100
|
this.ffiEventLock = ffiEventLock;
|
|
101
|
+
this.disconnectSignal = disconnectSignal;
|
|
75
102
|
}
|
|
76
103
|
async publishData(data, options) {
|
|
77
|
-
const req = new
|
|
104
|
+
const req = new import_rtc_ffi_bindings2.PublishDataRequest({
|
|
78
105
|
localParticipantHandle: this.ffi_handle.handle,
|
|
79
106
|
dataPtr: import_ffi_client.FfiClient.instance.retrievePtr(data),
|
|
80
107
|
dataLen: BigInt(data.byteLength),
|
|
@@ -85,15 +112,16 @@ class LocalParticipant extends Participant {
|
|
|
85
112
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
86
113
|
message: { case: "publishData", value: req }
|
|
87
114
|
});
|
|
88
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
89
|
-
|
|
90
|
-
|
|
115
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
116
|
+
(ev) => ev.message.case == "publishData" && ev.message.value.asyncId == res.asyncId,
|
|
117
|
+
{ signal: this.disconnectSignal }
|
|
118
|
+
);
|
|
91
119
|
if (cb.error) {
|
|
92
120
|
throw new Error(cb.error);
|
|
93
121
|
}
|
|
94
122
|
}
|
|
95
123
|
async publishDtmf(code, digit) {
|
|
96
|
-
const req = new
|
|
124
|
+
const req = new import_rtc_ffi_bindings2.PublishSipDtmfRequest({
|
|
97
125
|
localParticipantHandle: this.ffi_handle.handle,
|
|
98
126
|
code,
|
|
99
127
|
digit
|
|
@@ -101,19 +129,20 @@ class LocalParticipant extends Participant {
|
|
|
101
129
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
102
130
|
message: { case: "publishSipDtmf", value: req }
|
|
103
131
|
});
|
|
104
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
105
|
-
|
|
106
|
-
|
|
132
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
133
|
+
(ev) => ev.message.case == "publishSipDtmf" && ev.message.value.asyncId == res.asyncId,
|
|
134
|
+
{ signal: this.disconnectSignal }
|
|
135
|
+
);
|
|
107
136
|
if (cb.error) {
|
|
108
137
|
throw new Error(cb.error);
|
|
109
138
|
}
|
|
110
139
|
}
|
|
111
140
|
async publishTranscription(transcription) {
|
|
112
|
-
const req = new
|
|
141
|
+
const req = new import_rtc_ffi_bindings2.PublishTranscriptionRequest({
|
|
113
142
|
localParticipantHandle: this.ffi_handle.handle,
|
|
114
143
|
participantIdentity: transcription.participantIdentity,
|
|
115
144
|
segments: transcription.segments.map(
|
|
116
|
-
(s) => new
|
|
145
|
+
(s) => new import_rtc_ffi_bindings2.TranscriptionSegment({
|
|
117
146
|
id: s.id,
|
|
118
147
|
text: s.text,
|
|
119
148
|
startTime: s.startTime,
|
|
@@ -127,24 +156,26 @@ class LocalParticipant extends Participant {
|
|
|
127
156
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
128
157
|
message: { case: "publishTranscription", value: req }
|
|
129
158
|
});
|
|
130
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
131
|
-
|
|
132
|
-
|
|
159
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
160
|
+
(ev) => ev.message.case == "publishTranscription" && ev.message.value.asyncId == res.asyncId,
|
|
161
|
+
{ signal: this.disconnectSignal }
|
|
162
|
+
);
|
|
133
163
|
if (cb.error) {
|
|
134
164
|
throw new Error(cb.error);
|
|
135
165
|
}
|
|
136
166
|
}
|
|
137
167
|
async updateMetadata(metadata) {
|
|
138
|
-
const req = new
|
|
168
|
+
const req = new import_rtc_ffi_bindings2.SetLocalMetadataRequest({
|
|
139
169
|
localParticipantHandle: this.ffi_handle.handle,
|
|
140
170
|
metadata
|
|
141
171
|
});
|
|
142
172
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
143
173
|
message: { case: "setLocalMetadata", value: req }
|
|
144
174
|
});
|
|
145
|
-
await import_ffi_client.FfiClient.instance.waitFor(
|
|
146
|
-
|
|
147
|
-
|
|
175
|
+
await import_ffi_client.FfiClient.instance.waitFor(
|
|
176
|
+
(ev) => ev.message.case == "setLocalMetadata" && ev.message.value.asyncId == res.asyncId,
|
|
177
|
+
{ signal: this.disconnectSignal }
|
|
178
|
+
);
|
|
148
179
|
}
|
|
149
180
|
/**
|
|
150
181
|
* Returns a `StreamWriter` instance that allows to write individual chunks of text to a stream.
|
|
@@ -160,11 +191,11 @@ class LocalParticipant extends Participant {
|
|
|
160
191
|
topic: (options == null ? void 0 : options.topic) ?? "",
|
|
161
192
|
timestamp: Date.now()
|
|
162
193
|
};
|
|
163
|
-
const headerReq = new
|
|
194
|
+
const headerReq = new import_rtc_ffi_bindings2.SendStreamHeaderRequest({
|
|
164
195
|
senderIdentity,
|
|
165
196
|
destinationIdentities,
|
|
166
197
|
localParticipantHandle: this.ffi_handle.handle,
|
|
167
|
-
header: new
|
|
198
|
+
header: new import_rtc_ffi_bindings2.DataStream_Header({
|
|
168
199
|
streamId,
|
|
169
200
|
mimeType: info.mimeType,
|
|
170
201
|
topic: info.topic,
|
|
@@ -172,8 +203,8 @@ class LocalParticipant extends Participant {
|
|
|
172
203
|
attributes: options == null ? void 0 : options.attributes,
|
|
173
204
|
contentHeader: {
|
|
174
205
|
case: "textHeader",
|
|
175
|
-
value: new
|
|
176
|
-
operationType:
|
|
206
|
+
value: new import_rtc_ffi_bindings2.DataStream_TextHeader({
|
|
207
|
+
operationType: import_rtc_ffi_bindings2.DataStream_OperationType.CREATE,
|
|
177
208
|
version: 0,
|
|
178
209
|
replyToStreamId: "",
|
|
179
210
|
generated: false
|
|
@@ -190,11 +221,11 @@ class LocalParticipant extends Participant {
|
|
|
190
221
|
// Implement the sink
|
|
191
222
|
async write(text) {
|
|
192
223
|
for (const textByteChunk of (0, import_utils.splitUtf8)(text, STREAM_CHUNK_SIZE)) {
|
|
193
|
-
const chunkRequest = new
|
|
224
|
+
const chunkRequest = new import_rtc_ffi_bindings2.SendStreamChunkRequest({
|
|
194
225
|
senderIdentity,
|
|
195
226
|
localParticipantHandle: localHandle,
|
|
196
227
|
destinationIdentities,
|
|
197
|
-
chunk: new
|
|
228
|
+
chunk: new import_rtc_ffi_bindings2.DataStream_Chunk({
|
|
198
229
|
content: textByteChunk,
|
|
199
230
|
streamId,
|
|
200
231
|
chunkIndex: (0, import_utils.numberToBigInt)(nextChunkId)
|
|
@@ -205,19 +236,34 @@ class LocalParticipant extends Participant {
|
|
|
205
236
|
}
|
|
206
237
|
},
|
|
207
238
|
async close() {
|
|
208
|
-
const trailerReq = new
|
|
239
|
+
const trailerReq = new import_rtc_ffi_bindings2.SendStreamTrailerRequest({
|
|
209
240
|
senderIdentity,
|
|
210
241
|
localParticipantHandle: localHandle,
|
|
211
242
|
destinationIdentities,
|
|
212
|
-
trailer: new
|
|
243
|
+
trailer: new import_rtc_ffi_bindings2.DataStream_Trailer({
|
|
213
244
|
streamId,
|
|
214
245
|
reason: ""
|
|
215
246
|
})
|
|
216
247
|
});
|
|
217
248
|
await sendTrailer(trailerReq);
|
|
218
249
|
},
|
|
219
|
-
|
|
220
|
-
|
|
250
|
+
// Send a trailer with the error reason so the remote side's stream
|
|
251
|
+
// controller is closed instead of waiting for data that won't arrive.
|
|
252
|
+
async abort(err) {
|
|
253
|
+
import_log.log.error(err, "Sink Error");
|
|
254
|
+
try {
|
|
255
|
+
const trailerReq = new import_rtc_ffi_bindings2.SendStreamTrailerRequest({
|
|
256
|
+
senderIdentity,
|
|
257
|
+
localParticipantHandle: localHandle,
|
|
258
|
+
destinationIdentities,
|
|
259
|
+
trailer: new import_rtc_ffi_bindings2.DataStream_Trailer({
|
|
260
|
+
streamId,
|
|
261
|
+
reason: err instanceof Error ? err.message : String(err ?? "")
|
|
262
|
+
})
|
|
263
|
+
});
|
|
264
|
+
await sendTrailer(trailerReq);
|
|
265
|
+
} catch {
|
|
266
|
+
}
|
|
221
267
|
}
|
|
222
268
|
});
|
|
223
269
|
const writer = new import_data_streams.TextStreamWriter(writableStream, info);
|
|
@@ -242,11 +288,11 @@ class LocalParticipant extends Participant {
|
|
|
242
288
|
totalSize: options == null ? void 0 : options.totalSize,
|
|
243
289
|
name: (options == null ? void 0 : options.name) ?? "unknown"
|
|
244
290
|
};
|
|
245
|
-
const headerReq = new
|
|
291
|
+
const headerReq = new import_rtc_ffi_bindings2.SendStreamHeaderRequest({
|
|
246
292
|
senderIdentity,
|
|
247
293
|
destinationIdentities,
|
|
248
294
|
localParticipantHandle: this.ffi_handle.handle,
|
|
249
|
-
header: new
|
|
295
|
+
header: new import_rtc_ffi_bindings2.DataStream_Header({
|
|
250
296
|
streamId,
|
|
251
297
|
mimeType: info.mimeType,
|
|
252
298
|
topic: info.topic,
|
|
@@ -255,7 +301,7 @@ class LocalParticipant extends Participant {
|
|
|
255
301
|
totalLength: (0, import_utils.numberToBigInt)(info.totalSize),
|
|
256
302
|
contentHeader: {
|
|
257
303
|
case: "byteHeader",
|
|
258
|
-
value: new
|
|
304
|
+
value: new import_rtc_ffi_bindings2.DataStream_ByteHeader({
|
|
259
305
|
name: info.name
|
|
260
306
|
})
|
|
261
307
|
}
|
|
@@ -274,11 +320,11 @@ class LocalParticipant extends Participant {
|
|
|
274
320
|
try {
|
|
275
321
|
while (byteOffset < chunk.byteLength) {
|
|
276
322
|
const subChunk = chunk.slice(byteOffset, byteOffset + STREAM_CHUNK_SIZE);
|
|
277
|
-
const chunkRequest = new
|
|
323
|
+
const chunkRequest = new import_rtc_ffi_bindings2.SendStreamChunkRequest({
|
|
278
324
|
senderIdentity,
|
|
279
325
|
localParticipantHandle: localHandle,
|
|
280
326
|
destinationIdentities,
|
|
281
|
-
chunk: new
|
|
327
|
+
chunk: new import_rtc_ffi_bindings2.DataStream_Chunk({
|
|
282
328
|
content: subChunk,
|
|
283
329
|
streamId,
|
|
284
330
|
chunkIndex: (0, import_utils.numberToBigInt)(chunkId)
|
|
@@ -293,19 +339,34 @@ class LocalParticipant extends Participant {
|
|
|
293
339
|
}
|
|
294
340
|
},
|
|
295
341
|
async close() {
|
|
296
|
-
const trailerReq = new
|
|
342
|
+
const trailerReq = new import_rtc_ffi_bindings2.SendStreamTrailerRequest({
|
|
297
343
|
senderIdentity,
|
|
298
344
|
localParticipantHandle: localHandle,
|
|
299
345
|
destinationIdentities,
|
|
300
|
-
trailer: new
|
|
346
|
+
trailer: new import_rtc_ffi_bindings2.DataStream_Trailer({
|
|
301
347
|
streamId,
|
|
302
348
|
reason: ""
|
|
303
349
|
})
|
|
304
350
|
});
|
|
305
351
|
await sendTrailer(trailerReq);
|
|
306
352
|
},
|
|
307
|
-
|
|
308
|
-
|
|
353
|
+
// Send a trailer with the error reason so the remote side's stream
|
|
354
|
+
// controller is closed instead of waiting for data that won't arrive.
|
|
355
|
+
async abort(err) {
|
|
356
|
+
import_log.log.error(err, "Sink error");
|
|
357
|
+
try {
|
|
358
|
+
const trailerReq = new import_rtc_ffi_bindings2.SendStreamTrailerRequest({
|
|
359
|
+
senderIdentity,
|
|
360
|
+
localParticipantHandle: localHandle,
|
|
361
|
+
destinationIdentities,
|
|
362
|
+
trailer: new import_rtc_ffi_bindings2.DataStream_Trailer({
|
|
363
|
+
streamId,
|
|
364
|
+
reason: err instanceof Error ? err.message : String(err ?? "")
|
|
365
|
+
})
|
|
366
|
+
});
|
|
367
|
+
await sendTrailer(trailerReq);
|
|
368
|
+
} catch {
|
|
369
|
+
}
|
|
309
370
|
}
|
|
310
371
|
});
|
|
311
372
|
const byteWriter = new import_data_streams.ByteStreamWriter(writableStream, info);
|
|
@@ -341,33 +402,10 @@ class LocalParticipant extends Participant {
|
|
|
341
402
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
342
403
|
message: { case: type, value: req }
|
|
343
404
|
});
|
|
344
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
throw new Error(cb.error);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
async sendStreamChunk(req) {
|
|
352
|
-
const type = "sendStreamChunk";
|
|
353
|
-
const res = import_ffi_client.FfiClient.instance.request({
|
|
354
|
-
message: { case: type, value: req }
|
|
355
|
-
});
|
|
356
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor((ev) => {
|
|
357
|
-
return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
|
|
358
|
-
});
|
|
359
|
-
if (cb.error) {
|
|
360
|
-
throw new Error(cb.error);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
async sendStreamTrailer(req) {
|
|
364
|
-
const type = "sendStreamTrailer";
|
|
365
|
-
const res = import_ffi_client.FfiClient.instance.request({
|
|
366
|
-
message: { case: type, value: req }
|
|
367
|
-
});
|
|
368
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor((ev) => {
|
|
369
|
-
return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
|
|
370
|
-
});
|
|
405
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
406
|
+
(ev) => ev.message.case == type && ev.message.value.asyncId == res.asyncId,
|
|
407
|
+
{ signal: this.disconnectSignal }
|
|
408
|
+
);
|
|
371
409
|
if (cb.error) {
|
|
372
410
|
throw new Error(cb.error);
|
|
373
411
|
}
|
|
@@ -381,7 +419,7 @@ class LocalParticipant extends Participant {
|
|
|
381
419
|
*
|
|
382
420
|
*/
|
|
383
421
|
async sendChatMessage(text, destinationIdentities, senderIdentity) {
|
|
384
|
-
const req = new
|
|
422
|
+
const req = new import_rtc_ffi_bindings2.SendChatMessageRequest({
|
|
385
423
|
localParticipantHandle: this.ffi_handle.handle,
|
|
386
424
|
message: text,
|
|
387
425
|
destinationIdentities,
|
|
@@ -390,9 +428,10 @@ class LocalParticipant extends Participant {
|
|
|
390
428
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
391
429
|
message: { case: "sendChatMessage", value: req }
|
|
392
430
|
});
|
|
393
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
394
|
-
|
|
395
|
-
|
|
431
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
432
|
+
(ev) => ev.message.case == "chatMessage" && ev.message.value.asyncId == res.asyncId,
|
|
433
|
+
{ signal: this.disconnectSignal }
|
|
434
|
+
);
|
|
396
435
|
switch (cb.message.case) {
|
|
397
436
|
case "chatMessage":
|
|
398
437
|
const { id, timestamp, editTimestamp, message } = cb.message.value;
|
|
@@ -411,10 +450,10 @@ class LocalParticipant extends Participant {
|
|
|
411
450
|
* @experimental
|
|
412
451
|
*/
|
|
413
452
|
async editChatMessage(editText, originalMessage, destinationIdentities, senderIdentity) {
|
|
414
|
-
const req = new
|
|
453
|
+
const req = new import_rtc_ffi_bindings2.EditChatMessageRequest({
|
|
415
454
|
localParticipantHandle: this.ffi_handle.handle,
|
|
416
455
|
editText,
|
|
417
|
-
originalMessage: new
|
|
456
|
+
originalMessage: new import_rtc_ffi_bindings2.ChatMessage({
|
|
418
457
|
...originalMessage,
|
|
419
458
|
timestamp: BigInt(originalMessage.timestamp),
|
|
420
459
|
editTimestamp: originalMessage.editTimestamp ? BigInt(originalMessage.editTimestamp) : void 0
|
|
@@ -425,9 +464,10 @@ class LocalParticipant extends Participant {
|
|
|
425
464
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
426
465
|
message: { case: "editChatMessage", value: req }
|
|
427
466
|
});
|
|
428
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
429
|
-
|
|
430
|
-
|
|
467
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
468
|
+
(ev) => ev.message.case == "chatMessage" && ev.message.value.asyncId == res.asyncId,
|
|
469
|
+
{ signal: this.disconnectSignal }
|
|
470
|
+
);
|
|
431
471
|
switch (cb.message.case) {
|
|
432
472
|
case "chatMessage":
|
|
433
473
|
const { id, timestamp, editTimestamp, message } = cb.message.value;
|
|
@@ -443,31 +483,33 @@ class LocalParticipant extends Participant {
|
|
|
443
483
|
}
|
|
444
484
|
}
|
|
445
485
|
async updateName(name) {
|
|
446
|
-
const req = new
|
|
486
|
+
const req = new import_rtc_ffi_bindings2.SetLocalNameRequest({
|
|
447
487
|
localParticipantHandle: this.ffi_handle.handle,
|
|
448
488
|
name
|
|
449
489
|
});
|
|
450
490
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
451
491
|
message: { case: "setLocalName", value: req }
|
|
452
492
|
});
|
|
453
|
-
await import_ffi_client.FfiClient.instance.waitFor(
|
|
454
|
-
|
|
455
|
-
|
|
493
|
+
await import_ffi_client.FfiClient.instance.waitFor(
|
|
494
|
+
(ev) => ev.message.case == "setLocalName" && ev.message.value.asyncId == res.asyncId,
|
|
495
|
+
{ signal: this.disconnectSignal }
|
|
496
|
+
);
|
|
456
497
|
}
|
|
457
498
|
async setAttributes(attributes) {
|
|
458
|
-
const req = new
|
|
499
|
+
const req = new import_rtc_ffi_bindings2.SetLocalAttributesRequest({
|
|
459
500
|
localParticipantHandle: this.ffi_handle.handle,
|
|
460
501
|
attributes: Object.entries(attributes).map(([key, value]) => ({ key, value }))
|
|
461
502
|
});
|
|
462
503
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
463
504
|
message: { case: "setLocalAttributes", value: req }
|
|
464
505
|
});
|
|
465
|
-
await import_ffi_client.FfiClient.instance.waitFor(
|
|
466
|
-
|
|
467
|
-
|
|
506
|
+
await import_ffi_client.FfiClient.instance.waitFor(
|
|
507
|
+
(ev) => ev.message.case == "setLocalAttributes" && ev.message.value.asyncId == res.asyncId,
|
|
508
|
+
{ signal: this.disconnectSignal }
|
|
509
|
+
);
|
|
468
510
|
}
|
|
469
511
|
async publishTrack(track, options) {
|
|
470
|
-
const req = new
|
|
512
|
+
const req = new import_rtc_ffi_bindings2.PublishTrackRequest({
|
|
471
513
|
localParticipantHandle: this.ffi_handle.handle,
|
|
472
514
|
trackHandle: track.ffi_handle.handle,
|
|
473
515
|
options
|
|
@@ -477,9 +519,10 @@ class LocalParticipant extends Participant {
|
|
|
477
519
|
message: { case: "publishTrack", value: req }
|
|
478
520
|
});
|
|
479
521
|
try {
|
|
480
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
481
|
-
|
|
482
|
-
|
|
522
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
523
|
+
(ev) => ev.message.case == "publishTrack" && ev.message.value.asyncId == res.asyncId,
|
|
524
|
+
{ signal: this.disconnectSignal }
|
|
525
|
+
);
|
|
483
526
|
switch (cb.message.case) {
|
|
484
527
|
case "publication":
|
|
485
528
|
const track_publication = new import_track_publication.LocalTrackPublication(cb.message.value);
|
|
@@ -497,7 +540,7 @@ class LocalParticipant extends Participant {
|
|
|
497
540
|
async unpublishTrack(trackSid, stopOnUnpublish) {
|
|
498
541
|
const unlock = await this.ffiEventLock.lock();
|
|
499
542
|
try {
|
|
500
|
-
const req = new
|
|
543
|
+
const req = new import_rtc_ffi_bindings2.UnpublishTrackRequest({
|
|
501
544
|
localParticipantHandle: this.ffi_handle.handle,
|
|
502
545
|
trackSid,
|
|
503
546
|
stopOnUnpublish: stopOnUnpublish ?? true
|
|
@@ -505,9 +548,10 @@ class LocalParticipant extends Participant {
|
|
|
505
548
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
506
549
|
message: { case: "unpublishTrack", value: req }
|
|
507
550
|
});
|
|
508
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
509
|
-
|
|
510
|
-
|
|
551
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
552
|
+
(ev) => ev.message.case == "unpublishTrack" && ev.message.value.asyncId == res.asyncId,
|
|
553
|
+
{ signal: this.disconnectSignal }
|
|
554
|
+
);
|
|
511
555
|
if (cb.error) {
|
|
512
556
|
throw new Error(cb.error);
|
|
513
557
|
}
|
|
@@ -532,7 +576,7 @@ class LocalParticipant extends Participant {
|
|
|
532
576
|
payload,
|
|
533
577
|
responseTimeout
|
|
534
578
|
}) {
|
|
535
|
-
const req = new
|
|
579
|
+
const req = new import_rtc_ffi_bindings3.PerformRpcRequest({
|
|
536
580
|
localParticipantHandle: this.ffi_handle.handle,
|
|
537
581
|
destinationIdentity,
|
|
538
582
|
method,
|
|
@@ -542,9 +586,10 @@ class LocalParticipant extends Participant {
|
|
|
542
586
|
const res = import_ffi_client.FfiClient.instance.request({
|
|
543
587
|
message: { case: "performRpc", value: req }
|
|
544
588
|
});
|
|
545
|
-
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
546
|
-
|
|
547
|
-
|
|
589
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor(
|
|
590
|
+
(ev) => ev.message.case === "performRpc" && ev.message.value.asyncId === res.asyncId,
|
|
591
|
+
{ signal: this.disconnectSignal }
|
|
592
|
+
);
|
|
548
593
|
if (cb.error) {
|
|
549
594
|
throw import_rpc.RpcError.fromProto(cb.error);
|
|
550
595
|
}
|
|
@@ -580,7 +625,7 @@ class LocalParticipant extends Participant {
|
|
|
580
625
|
*/
|
|
581
626
|
registerRpcMethod(method, handler) {
|
|
582
627
|
this.rpcHandlers.set(method, handler);
|
|
583
|
-
const req = new
|
|
628
|
+
const req = new import_rtc_ffi_bindings3.RegisterRpcMethodRequest({
|
|
584
629
|
localParticipantHandle: this.ffi_handle.handle,
|
|
585
630
|
method
|
|
586
631
|
});
|
|
@@ -595,7 +640,7 @@ class LocalParticipant extends Participant {
|
|
|
595
640
|
*/
|
|
596
641
|
unregisterRpcMethod(method) {
|
|
597
642
|
this.rpcHandlers.delete(method);
|
|
598
|
-
const req = new
|
|
643
|
+
const req = new import_rtc_ffi_bindings3.UnregisterRpcMethodRequest({
|
|
599
644
|
localParticipantHandle: this.ffi_handle.handle,
|
|
600
645
|
method
|
|
601
646
|
});
|
|
@@ -625,7 +670,7 @@ class LocalParticipant extends Participant {
|
|
|
625
670
|
}
|
|
626
671
|
}
|
|
627
672
|
}
|
|
628
|
-
const req = new
|
|
673
|
+
const req = new import_rtc_ffi_bindings3.RpcMethodInvocationResponseRequest({
|
|
629
674
|
localParticipantHandle: this.ffi_handle.handle,
|
|
630
675
|
invocationId,
|
|
631
676
|
error: responseError ? responseError.toProto() : void 0,
|