@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.
Files changed (283) hide show
  1. package/dist/audio_filter.cjs +2 -2
  2. package/dist/audio_filter.cjs.map +1 -1
  3. package/dist/audio_filter.js +1 -1
  4. package/dist/audio_filter.js.map +1 -1
  5. package/dist/audio_frame.cjs +9 -5
  6. package/dist/audio_frame.cjs.map +1 -1
  7. package/dist/audio_frame.d.cts +2 -7
  8. package/dist/audio_frame.d.ts +2 -7
  9. package/dist/audio_frame.d.ts.map +1 -1
  10. package/dist/audio_frame.js +8 -4
  11. package/dist/audio_frame.js.map +1 -1
  12. package/dist/audio_mixer.cjs +10 -4
  13. package/dist/audio_mixer.cjs.map +1 -1
  14. package/dist/audio_mixer.d.cts +4 -7
  15. package/dist/audio_mixer.d.ts +4 -7
  16. package/dist/audio_mixer.d.ts.map +1 -1
  17. package/dist/audio_mixer.js +10 -4
  18. package/dist/audio_mixer.js.map +1 -1
  19. package/dist/audio_resampler.cjs +20 -12
  20. package/dist/audio_resampler.cjs.map +1 -1
  21. package/dist/audio_resampler.d.cts +6 -6
  22. package/dist/audio_resampler.d.ts +6 -6
  23. package/dist/audio_resampler.d.ts.map +1 -1
  24. package/dist/audio_resampler.js +12 -4
  25. package/dist/audio_resampler.js.map +1 -1
  26. package/dist/audio_source.cjs +11 -7
  27. package/dist/audio_source.cjs.map +1 -1
  28. package/dist/audio_source.d.cts +1 -7
  29. package/dist/audio_source.d.ts +1 -7
  30. package/dist/audio_source.d.ts.map +1 -1
  31. package/dist/audio_source.js +8 -3
  32. package/dist/audio_source.js.map +1 -1
  33. package/dist/audio_stream.cjs +16 -6
  34. package/dist/audio_stream.cjs.map +1 -1
  35. package/dist/audio_stream.d.cts +1 -14
  36. package/dist/audio_stream.d.ts +1 -14
  37. package/dist/audio_stream.d.ts.map +1 -1
  38. package/dist/audio_stream.js +15 -5
  39. package/dist/audio_stream.js.map +1 -1
  40. package/dist/data_streams/index.d.cts +2 -10
  41. package/dist/data_streams/index.d.ts +2 -10
  42. package/dist/data_streams/stream_reader.cjs +8 -0
  43. package/dist/data_streams/stream_reader.cjs.map +1 -1
  44. package/dist/data_streams/stream_reader.d.cts +2 -10
  45. package/dist/data_streams/stream_reader.d.ts +2 -10
  46. package/dist/data_streams/stream_reader.d.ts.map +1 -1
  47. package/dist/data_streams/stream_reader.js +8 -0
  48. package/dist/data_streams/stream_reader.js.map +1 -1
  49. package/dist/data_streams/stream_writer.d.cts +2 -10
  50. package/dist/data_streams/stream_writer.d.ts +2 -10
  51. package/dist/data_streams/types.cjs.map +1 -1
  52. package/dist/data_streams/types.d.cts +2 -10
  53. package/dist/data_streams/types.d.ts +2 -10
  54. package/dist/data_streams/types.d.ts.map +1 -1
  55. package/dist/e2ee.cjs +21 -21
  56. package/dist/e2ee.cjs.map +1 -1
  57. package/dist/e2ee.d.cts +1 -2
  58. package/dist/e2ee.d.ts +1 -2
  59. package/dist/e2ee.d.ts.map +1 -1
  60. package/dist/e2ee.js +2 -2
  61. package/dist/e2ee.js.map +1 -1
  62. package/dist/ffi_client.cjs +30 -15
  63. package/dist/ffi_client.cjs.map +1 -1
  64. package/dist/ffi_client.d.cts +6 -17
  65. package/dist/ffi_client.d.ts +6 -17
  66. package/dist/ffi_client.d.ts.map +1 -1
  67. package/dist/ffi_client.js +24 -6
  68. package/dist/ffi_client.js.map +1 -1
  69. package/dist/frame_processor.cjs +13 -2
  70. package/dist/frame_processor.cjs.map +1 -1
  71. package/dist/frame_processor.d.cts +5 -8
  72. package/dist/frame_processor.d.ts +5 -8
  73. package/dist/frame_processor.d.ts.map +1 -1
  74. package/dist/frame_processor.js +10 -1
  75. package/dist/frame_processor.js.map +1 -1
  76. package/dist/index.cjs +25 -23
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.cts +3 -16
  79. package/dist/index.d.ts +3 -16
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +9 -7
  82. package/dist/index.js.map +1 -1
  83. package/dist/participant.cjs +146 -101
  84. package/dist/participant.cjs.map +1 -1
  85. package/dist/participant.d.cts +4 -16
  86. package/dist/participant.d.ts +4 -16
  87. package/dist/participant.d.ts.map +1 -1
  88. package/dist/participant.js +120 -75
  89. package/dist/participant.js.map +1 -1
  90. package/dist/room.cjs +116 -58
  91. package/dist/room.cjs.map +1 -1
  92. package/dist/room.d.cts +6 -15
  93. package/dist/room.d.ts +6 -15
  94. package/dist/room.d.ts.map +1 -1
  95. package/dist/room.js +113 -55
  96. package/dist/room.js.map +1 -1
  97. package/dist/rpc.cjs.map +1 -1
  98. package/dist/rpc.d.cts +1 -2
  99. package/dist/rpc.d.ts +1 -2
  100. package/dist/rpc.d.ts.map +1 -1
  101. package/dist/rpc.js.map +1 -1
  102. package/dist/{stream_reader-Ch2zvjU3.d.cts → stream_reader-CuG4b8Y-.d.cts} +1 -1
  103. package/dist/{stream_reader-DRyR29vo.d.ts → stream_reader-CuG4b8Y-.d.ts} +1 -1
  104. package/dist/track.cjs +3 -3
  105. package/dist/track.cjs.map +1 -1
  106. package/dist/track.d.cts +1 -14
  107. package/dist/track.d.ts +1 -14
  108. package/dist/track.d.ts.map +1 -1
  109. package/dist/track.js +1 -1
  110. package/dist/track.js.map +1 -1
  111. package/dist/track_publication.cjs +4 -4
  112. package/dist/track_publication.cjs.map +1 -1
  113. package/dist/track_publication.d.cts +1 -14
  114. package/dist/track_publication.d.ts +1 -14
  115. package/dist/track_publication.d.ts.map +1 -1
  116. package/dist/track_publication.js +2 -2
  117. package/dist/track_publication.js.map +1 -1
  118. package/dist/version.cjs +1 -1
  119. package/dist/version.cjs.map +1 -1
  120. package/dist/version.d.cts +1 -1
  121. package/dist/version.d.ts +1 -1
  122. package/dist/version.js +1 -1
  123. package/dist/version.js.map +1 -1
  124. package/dist/video_frame.cjs +42 -42
  125. package/dist/video_frame.cjs.map +1 -1
  126. package/dist/video_frame.d.cts +1 -6
  127. package/dist/video_frame.d.ts +1 -6
  128. package/dist/video_frame.d.ts.map +1 -1
  129. package/dist/video_frame.js +2 -2
  130. package/dist/video_frame.js.map +1 -1
  131. package/dist/video_source.cjs +5 -5
  132. package/dist/video_source.cjs.map +1 -1
  133. package/dist/video_source.d.cts +1 -14
  134. package/dist/video_source.d.ts +1 -14
  135. package/dist/video_source.d.ts.map +1 -1
  136. package/dist/video_source.js +2 -2
  137. package/dist/video_source.js.map +1 -1
  138. package/dist/video_stream.cjs +12 -4
  139. package/dist/video_stream.cjs.map +1 -1
  140. package/dist/video_stream.d.cts +1 -14
  141. package/dist/video_stream.d.ts +1 -14
  142. package/dist/video_stream.d.ts.map +1 -1
  143. package/dist/video_stream.js +10 -2
  144. package/dist/video_stream.js.map +1 -1
  145. package/package.json +7 -37
  146. package/src/audio_filter.ts +2 -2
  147. package/src/audio_frame.ts +17 -5
  148. package/src/audio_mixer.test.ts +102 -0
  149. package/src/audio_mixer.ts +10 -4
  150. package/src/audio_resampler.ts +14 -4
  151. package/src/audio_source.ts +13 -5
  152. package/src/audio_stream.ts +21 -6
  153. package/src/data_streams/stream_reader.ts +19 -1
  154. package/src/data_streams/types.ts +1 -1
  155. package/src/e2ee.ts +3 -3
  156. package/src/ffi_client.ts +33 -8
  157. package/src/frame_processor.ts +21 -0
  158. package/src/index.ts +6 -5
  159. package/src/participant.ts +117 -66
  160. package/src/room.ts +161 -69
  161. package/src/rpc.ts +1 -1
  162. package/src/tests/e2e.test.ts +179 -8
  163. package/src/track.ts +4 -4
  164. package/src/track_publication.ts +6 -6
  165. package/src/version.ts +1 -1
  166. package/src/video_frame.ts +3 -3
  167. package/src/video_source.ts +3 -3
  168. package/src/video_stream.ts +15 -3
  169. package/Cargo.toml +0 -25
  170. package/build.rs +0 -9
  171. package/dist/napi/native.cjs +0 -301
  172. package/dist/napi/native.d.cjs +0 -17
  173. package/dist/napi/native.d.cjs.map +0 -1
  174. package/dist/napi/native.d.d.cts +0 -21
  175. package/dist/napi/native.d.d.ts +0 -21
  176. package/dist/napi/native.d.js +0 -1
  177. package/dist/napi/native.d.js.map +0 -1
  178. package/dist/napi/native.d.ts +0 -19
  179. package/dist/napi/native.js +0 -15
  180. package/dist/native.cjs +0 -301
  181. package/dist/native.d.ts +0 -19
  182. package/dist/native.js +0 -15
  183. package/dist/proto/audio_frame_pb.cjs +0 -1357
  184. package/dist/proto/audio_frame_pb.cjs.map +0 -1
  185. package/dist/proto/audio_frame_pb.d.cts +0 -1183
  186. package/dist/proto/audio_frame_pb.d.ts +0 -1183
  187. package/dist/proto/audio_frame_pb.d.ts.map +0 -1
  188. package/dist/proto/audio_frame_pb.js +0 -1283
  189. package/dist/proto/audio_frame_pb.js.map +0 -1
  190. package/dist/proto/data_stream_pb.cjs +0 -1638
  191. package/dist/proto/data_stream_pb.cjs.map +0 -1
  192. package/dist/proto/data_stream_pb.d.cts +0 -1449
  193. package/dist/proto/data_stream_pb.d.ts +0 -1449
  194. package/dist/proto/data_stream_pb.d.ts.map +0 -1
  195. package/dist/proto/data_stream_pb.js +0 -1559
  196. package/dist/proto/data_stream_pb.js.map +0 -1
  197. package/dist/proto/e2ee_pb.cjs +0 -746
  198. package/dist/proto/e2ee_pb.cjs.map +0 -1
  199. package/dist/proto/e2ee_pb.d.cts +0 -653
  200. package/dist/proto/e2ee_pb.d.ts +0 -653
  201. package/dist/proto/e2ee_pb.d.ts.map +0 -1
  202. package/dist/proto/e2ee_pb.js +0 -696
  203. package/dist/proto/e2ee_pb.js.map +0 -1
  204. package/dist/proto/ffi_pb.cjs +0 -477
  205. package/dist/proto/ffi_pb.cjs.map +0 -1
  206. package/dist/proto/ffi_pb.d.cts +0 -1321
  207. package/dist/proto/ffi_pb.d.ts +0 -1321
  208. package/dist/proto/ffi_pb.d.ts.map +0 -1
  209. package/dist/proto/ffi_pb.js +0 -444
  210. package/dist/proto/ffi_pb.js.map +0 -1
  211. package/dist/proto/handle_pb.cjs +0 -53
  212. package/dist/proto/handle_pb.cjs.map +0 -1
  213. package/dist/proto/handle_pb.d.cts +0 -31
  214. package/dist/proto/handle_pb.d.ts +0 -31
  215. package/dist/proto/handle_pb.d.ts.map +0 -1
  216. package/dist/proto/handle_pb.js +0 -29
  217. package/dist/proto/handle_pb.js.map +0 -1
  218. package/dist/proto/participant_pb.cjs +0 -173
  219. package/dist/proto/participant_pb.cjs.map +0 -1
  220. package/dist/proto/participant_pb.d.cts +0 -218
  221. package/dist/proto/participant_pb.d.ts +0 -218
  222. package/dist/proto/participant_pb.d.ts.map +0 -1
  223. package/dist/proto/participant_pb.js +0 -145
  224. package/dist/proto/participant_pb.js.map +0 -1
  225. package/dist/proto/room_pb.cjs +0 -3374
  226. package/dist/proto/room_pb.cjs.map +0 -1
  227. package/dist/proto/room_pb.d.cts +0 -3028
  228. package/dist/proto/room_pb.d.ts +0 -3028
  229. package/dist/proto/room_pb.d.ts.map +0 -1
  230. package/dist/proto/room_pb.js +0 -3232
  231. package/dist/proto/room_pb.js.map +0 -1
  232. package/dist/proto/rpc_pb.cjs +0 -328
  233. package/dist/proto/rpc_pb.cjs.map +0 -1
  234. package/dist/proto/rpc_pb.d.cts +0 -267
  235. package/dist/proto/rpc_pb.d.ts +0 -267
  236. package/dist/proto/rpc_pb.d.ts.map +0 -1
  237. package/dist/proto/rpc_pb.js +0 -294
  238. package/dist/proto/rpc_pb.js.map +0 -1
  239. package/dist/proto/stats_pb.cjs +0 -1370
  240. package/dist/proto/stats_pb.cjs.map +0 -1
  241. package/dist/proto/stats_pb.d.cts +0 -1764
  242. package/dist/proto/stats_pb.d.ts +0 -1764
  243. package/dist/proto/stats_pb.d.ts.map +0 -1
  244. package/dist/proto/stats_pb.js +0 -1300
  245. package/dist/proto/stats_pb.js.map +0 -1
  246. package/dist/proto/track_pb.cjs +0 -630
  247. package/dist/proto/track_pb.cjs.map +0 -1
  248. package/dist/proto/track_pb.d.cts +0 -542
  249. package/dist/proto/track_pb.d.ts +0 -542
  250. package/dist/proto/track_pb.d.ts.map +0 -1
  251. package/dist/proto/track_pb.js +0 -584
  252. package/dist/proto/track_pb.js.map +0 -1
  253. package/dist/proto/track_publication_pb.cjs +0 -194
  254. package/dist/proto/track_publication_pb.cjs.map +0 -1
  255. package/dist/proto/track_publication_pb.d.cts +0 -135
  256. package/dist/proto/track_publication_pb.d.ts +0 -135
  257. package/dist/proto/track_publication_pb.d.ts.map +0 -1
  258. package/dist/proto/track_publication_pb.js +0 -164
  259. package/dist/proto/track_publication_pb.js.map +0 -1
  260. package/dist/proto/video_frame_pb.cjs +0 -723
  261. package/dist/proto/video_frame_pb.cjs.map +0 -1
  262. package/dist/proto/video_frame_pb.d.cts +0 -667
  263. package/dist/proto/video_frame_pb.d.ts +0 -667
  264. package/dist/proto/video_frame_pb.d.ts.map +0 -1
  265. package/dist/proto/video_frame_pb.js +0 -673
  266. package/dist/proto/video_frame_pb.js.map +0 -1
  267. package/src/lib.rs +0 -9
  268. package/src/napi/native.cjs +0 -301
  269. package/src/napi/native.d.ts +0 -19
  270. package/src/napi/native.js +0 -15
  271. package/src/nodejs.rs +0 -134
  272. package/src/proto/audio_frame_pb.ts +0 -2270
  273. package/src/proto/data_stream_pb.ts +0 -2674
  274. package/src/proto/e2ee_pb.ts +0 -1231
  275. package/src/proto/ffi_pb.ts +0 -1700
  276. package/src/proto/handle_pb.ts +0 -69
  277. package/src/proto/participant_pb.ts +0 -351
  278. package/src/proto/room_pb.ts +0 -5661
  279. package/src/proto/rpc_pb.ts +0 -539
  280. package/src/proto/stats_pb.ts +0 -3050
  281. package/src/proto/track_pb.ts +0 -1040
  282. package/src/proto/track_publication_pb.ts +0 -284
  283. package/src/proto/video_frame_pb.ts +0 -1236
@@ -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 ?? import_participant_pb.ParticipantKind.STANDARD;
60
+ return this.info.kind ?? import_rtc_ffi_bindings.ParticipantKind.STANDARD;
61
61
  }
62
62
  get disconnectReason() {
63
- if (this.info.disconnectReason === import_participant_pb.DisconnectReason.UNKNOWN_REASON) {
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 import_room_pb.PublishDataRequest({
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((ev) => {
89
- return ev.message.case == "publishData" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.PublishSipDtmfRequest({
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((ev) => {
105
- return ev.message.case == "publishSipDtmf" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.PublishTranscriptionRequest({
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 import_room_pb.TranscriptionSegment({
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((ev) => {
131
- return ev.message.case == "publishTranscription" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.SetLocalMetadataRequest({
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((ev) => {
146
- return ev.message.case == "setLocalMetadata" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.SendStreamHeaderRequest({
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 import_room_pb.DataStream_Header({
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 import_room_pb.DataStream_TextHeader({
176
- operationType: import_room_pb.DataStream_OperationType.CREATE,
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 import_room_pb.SendStreamChunkRequest({
224
+ const chunkRequest = new import_rtc_ffi_bindings2.SendStreamChunkRequest({
194
225
  senderIdentity,
195
226
  localParticipantHandle: localHandle,
196
227
  destinationIdentities,
197
- chunk: new import_room_pb.DataStream_Chunk({
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 import_room_pb.SendStreamTrailerRequest({
239
+ const trailerReq = new import_rtc_ffi_bindings2.SendStreamTrailerRequest({
209
240
  senderIdentity,
210
241
  localParticipantHandle: localHandle,
211
242
  destinationIdentities,
212
- trailer: new import_room_pb.DataStream_Trailer({
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
- abort(err) {
220
- import_log.log.error("Sink error:", err);
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 import_room_pb.SendStreamHeaderRequest({
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 import_room_pb.DataStream_Header({
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 import_room_pb.DataStream_ByteHeader({
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 import_room_pb.SendStreamChunkRequest({
323
+ const chunkRequest = new import_rtc_ffi_bindings2.SendStreamChunkRequest({
278
324
  senderIdentity,
279
325
  localParticipantHandle: localHandle,
280
326
  destinationIdentities,
281
- chunk: new import_room_pb.DataStream_Chunk({
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 import_room_pb.SendStreamTrailerRequest({
342
+ const trailerReq = new import_rtc_ffi_bindings2.SendStreamTrailerRequest({
297
343
  senderIdentity,
298
344
  localParticipantHandle: localHandle,
299
345
  destinationIdentities,
300
- trailer: new import_room_pb.DataStream_Trailer({
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
- abort(err) {
308
- import_log.log.error("Sink error:", err);
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((ev) => {
345
- return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
346
- });
347
- if (cb.error) {
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 import_room_pb.SendChatMessageRequest({
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((ev) => {
394
- return ev.message.case == "chatMessage" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.EditChatMessageRequest({
453
+ const req = new import_rtc_ffi_bindings2.EditChatMessageRequest({
415
454
  localParticipantHandle: this.ffi_handle.handle,
416
455
  editText,
417
- originalMessage: new import_room_pb.ChatMessage({
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((ev) => {
429
- return ev.message.case == "chatMessage" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.SetLocalNameRequest({
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((ev) => {
454
- return ev.message.case == "setLocalName" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.SetLocalAttributesRequest({
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((ev) => {
466
- return ev.message.case == "setLocalAttributes" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.PublishTrackRequest({
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((ev) => {
481
- return ev.message.case == "publishTrack" && ev.message.value.asyncId == res.asyncId;
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 import_room_pb.UnpublishTrackRequest({
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((ev) => {
509
- return ev.message.case == "unpublishTrack" && ev.message.value.asyncId == res.asyncId;
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 import_rpc_pb.PerformRpcRequest({
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((ev) => {
546
- return ev.message.case === "performRpc" && ev.message.value.asyncId === res.asyncId;
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 import_rpc_pb.RegisterRpcMethodRequest({
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 import_rpc_pb.UnregisterRpcMethodRequest({
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 import_rpc_pb.RpcMethodInvocationResponseRequest({
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,