@livekit/rtc-node 0.13.24 → 0.13.25

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 (281) 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 +1 -1
  13. package/dist/audio_mixer.cjs.map +1 -1
  14. package/dist/audio_mixer.d.cts +1 -6
  15. package/dist/audio_mixer.d.ts +1 -6
  16. package/dist/audio_mixer.js +1 -1
  17. package/dist/audio_mixer.js.map +1 -1
  18. package/dist/audio_resampler.cjs +20 -12
  19. package/dist/audio_resampler.cjs.map +1 -1
  20. package/dist/audio_resampler.d.cts +6 -6
  21. package/dist/audio_resampler.d.ts +6 -6
  22. package/dist/audio_resampler.d.ts.map +1 -1
  23. package/dist/audio_resampler.js +12 -4
  24. package/dist/audio_resampler.js.map +1 -1
  25. package/dist/audio_source.cjs +11 -7
  26. package/dist/audio_source.cjs.map +1 -1
  27. package/dist/audio_source.d.cts +1 -7
  28. package/dist/audio_source.d.ts +1 -7
  29. package/dist/audio_source.d.ts.map +1 -1
  30. package/dist/audio_source.js +8 -3
  31. package/dist/audio_source.js.map +1 -1
  32. package/dist/audio_stream.cjs +16 -6
  33. package/dist/audio_stream.cjs.map +1 -1
  34. package/dist/audio_stream.d.cts +1 -14
  35. package/dist/audio_stream.d.ts +1 -14
  36. package/dist/audio_stream.d.ts.map +1 -1
  37. package/dist/audio_stream.js +15 -5
  38. package/dist/audio_stream.js.map +1 -1
  39. package/dist/data_streams/index.d.cts +2 -10
  40. package/dist/data_streams/index.d.ts +2 -10
  41. package/dist/data_streams/stream_reader.cjs +8 -0
  42. package/dist/data_streams/stream_reader.cjs.map +1 -1
  43. package/dist/data_streams/stream_reader.d.cts +2 -10
  44. package/dist/data_streams/stream_reader.d.ts +2 -10
  45. package/dist/data_streams/stream_reader.d.ts.map +1 -1
  46. package/dist/data_streams/stream_reader.js +8 -0
  47. package/dist/data_streams/stream_reader.js.map +1 -1
  48. package/dist/data_streams/stream_writer.d.cts +2 -10
  49. package/dist/data_streams/stream_writer.d.ts +2 -10
  50. package/dist/data_streams/types.cjs.map +1 -1
  51. package/dist/data_streams/types.d.cts +2 -10
  52. package/dist/data_streams/types.d.ts +2 -10
  53. package/dist/data_streams/types.d.ts.map +1 -1
  54. package/dist/e2ee.cjs +21 -21
  55. package/dist/e2ee.cjs.map +1 -1
  56. package/dist/e2ee.d.cts +1 -2
  57. package/dist/e2ee.d.ts +1 -2
  58. package/dist/e2ee.d.ts.map +1 -1
  59. package/dist/e2ee.js +2 -2
  60. package/dist/e2ee.js.map +1 -1
  61. package/dist/ffi_client.cjs +11 -12
  62. package/dist/ffi_client.cjs.map +1 -1
  63. package/dist/ffi_client.d.cts +3 -16
  64. package/dist/ffi_client.d.ts +3 -16
  65. package/dist/ffi_client.d.ts.map +1 -1
  66. package/dist/ffi_client.js +5 -3
  67. package/dist/ffi_client.js.map +1 -1
  68. package/dist/frame_processor.cjs +13 -2
  69. package/dist/frame_processor.cjs.map +1 -1
  70. package/dist/frame_processor.d.cts +5 -8
  71. package/dist/frame_processor.d.ts +5 -8
  72. package/dist/frame_processor.d.ts.map +1 -1
  73. package/dist/frame_processor.js +10 -1
  74. package/dist/frame_processor.js.map +1 -1
  75. package/dist/index.cjs +25 -23
  76. package/dist/index.cjs.map +1 -1
  77. package/dist/index.d.cts +3 -16
  78. package/dist/index.d.ts +3 -16
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +9 -7
  81. package/dist/index.js.map +1 -1
  82. package/dist/participant.cjs +38 -38
  83. package/dist/participant.cjs.map +1 -1
  84. package/dist/participant.d.cts +2 -15
  85. package/dist/participant.d.ts +2 -15
  86. package/dist/participant.d.ts.map +1 -1
  87. package/dist/participant.js +12 -12
  88. package/dist/participant.js.map +1 -1
  89. package/dist/room.cjs +14 -14
  90. package/dist/room.cjs.map +1 -1
  91. package/dist/room.d.cts +2 -15
  92. package/dist/room.d.ts +2 -15
  93. package/dist/room.d.ts.map +1 -1
  94. package/dist/room.js +10 -10
  95. package/dist/room.js.map +1 -1
  96. package/dist/rpc.cjs.map +1 -1
  97. package/dist/rpc.d.cts +1 -2
  98. package/dist/rpc.d.ts +1 -2
  99. package/dist/rpc.d.ts.map +1 -1
  100. package/dist/rpc.js.map +1 -1
  101. package/dist/{stream_reader-Ch2zvjU3.d.cts → stream_reader-CuG4b8Y-.d.cts} +1 -1
  102. package/dist/{stream_reader-DRyR29vo.d.ts → stream_reader-CuG4b8Y-.d.ts} +1 -1
  103. package/dist/track.cjs +3 -3
  104. package/dist/track.cjs.map +1 -1
  105. package/dist/track.d.cts +1 -14
  106. package/dist/track.d.ts +1 -14
  107. package/dist/track.d.ts.map +1 -1
  108. package/dist/track.js +1 -1
  109. package/dist/track.js.map +1 -1
  110. package/dist/track_publication.cjs +4 -4
  111. package/dist/track_publication.cjs.map +1 -1
  112. package/dist/track_publication.d.cts +1 -14
  113. package/dist/track_publication.d.ts +1 -14
  114. package/dist/track_publication.d.ts.map +1 -1
  115. package/dist/track_publication.js +2 -2
  116. package/dist/track_publication.js.map +1 -1
  117. package/dist/version.cjs +1 -1
  118. package/dist/version.cjs.map +1 -1
  119. package/dist/version.d.cts +1 -1
  120. package/dist/version.d.ts +1 -1
  121. package/dist/version.js +1 -1
  122. package/dist/version.js.map +1 -1
  123. package/dist/video_frame.cjs +42 -42
  124. package/dist/video_frame.cjs.map +1 -1
  125. package/dist/video_frame.d.cts +1 -6
  126. package/dist/video_frame.d.ts +1 -6
  127. package/dist/video_frame.d.ts.map +1 -1
  128. package/dist/video_frame.js +2 -2
  129. package/dist/video_frame.js.map +1 -1
  130. package/dist/video_source.cjs +5 -5
  131. package/dist/video_source.cjs.map +1 -1
  132. package/dist/video_source.d.cts +1 -14
  133. package/dist/video_source.d.ts +1 -14
  134. package/dist/video_source.d.ts.map +1 -1
  135. package/dist/video_source.js +2 -2
  136. package/dist/video_source.js.map +1 -1
  137. package/dist/video_stream.cjs +12 -4
  138. package/dist/video_stream.cjs.map +1 -1
  139. package/dist/video_stream.d.cts +1 -14
  140. package/dist/video_stream.d.ts +1 -14
  141. package/dist/video_stream.d.ts.map +1 -1
  142. package/dist/video_stream.js +10 -2
  143. package/dist/video_stream.js.map +1 -1
  144. package/package.json +7 -37
  145. package/src/audio_filter.ts +2 -2
  146. package/src/audio_frame.ts +17 -5
  147. package/src/audio_mixer.ts +1 -1
  148. package/src/audio_resampler.ts +14 -4
  149. package/src/audio_source.ts +13 -5
  150. package/src/audio_stream.ts +21 -6
  151. package/src/data_streams/stream_reader.ts +19 -1
  152. package/src/data_streams/types.ts +1 -1
  153. package/src/e2ee.ts +3 -3
  154. package/src/ffi_client.ts +7 -5
  155. package/src/frame_processor.ts +21 -0
  156. package/src/index.ts +6 -5
  157. package/src/participant.ts +17 -17
  158. package/src/room.ts +22 -22
  159. package/src/rpc.ts +1 -1
  160. package/src/tests/e2e.test.ts +11 -8
  161. package/src/track.ts +4 -4
  162. package/src/track_publication.ts +6 -6
  163. package/src/version.ts +1 -1
  164. package/src/video_frame.ts +3 -3
  165. package/src/video_source.ts +3 -3
  166. package/src/video_stream.ts +15 -3
  167. package/Cargo.toml +0 -25
  168. package/build.rs +0 -9
  169. package/dist/napi/native.cjs +0 -301
  170. package/dist/napi/native.d.cjs +0 -17
  171. package/dist/napi/native.d.cjs.map +0 -1
  172. package/dist/napi/native.d.d.cts +0 -21
  173. package/dist/napi/native.d.d.ts +0 -21
  174. package/dist/napi/native.d.js +0 -1
  175. package/dist/napi/native.d.js.map +0 -1
  176. package/dist/napi/native.d.ts +0 -19
  177. package/dist/napi/native.js +0 -15
  178. package/dist/native.cjs +0 -301
  179. package/dist/native.d.ts +0 -19
  180. package/dist/native.js +0 -15
  181. package/dist/proto/audio_frame_pb.cjs +0 -1357
  182. package/dist/proto/audio_frame_pb.cjs.map +0 -1
  183. package/dist/proto/audio_frame_pb.d.cts +0 -1183
  184. package/dist/proto/audio_frame_pb.d.ts +0 -1183
  185. package/dist/proto/audio_frame_pb.d.ts.map +0 -1
  186. package/dist/proto/audio_frame_pb.js +0 -1283
  187. package/dist/proto/audio_frame_pb.js.map +0 -1
  188. package/dist/proto/data_stream_pb.cjs +0 -1638
  189. package/dist/proto/data_stream_pb.cjs.map +0 -1
  190. package/dist/proto/data_stream_pb.d.cts +0 -1449
  191. package/dist/proto/data_stream_pb.d.ts +0 -1449
  192. package/dist/proto/data_stream_pb.d.ts.map +0 -1
  193. package/dist/proto/data_stream_pb.js +0 -1559
  194. package/dist/proto/data_stream_pb.js.map +0 -1
  195. package/dist/proto/e2ee_pb.cjs +0 -746
  196. package/dist/proto/e2ee_pb.cjs.map +0 -1
  197. package/dist/proto/e2ee_pb.d.cts +0 -653
  198. package/dist/proto/e2ee_pb.d.ts +0 -653
  199. package/dist/proto/e2ee_pb.d.ts.map +0 -1
  200. package/dist/proto/e2ee_pb.js +0 -696
  201. package/dist/proto/e2ee_pb.js.map +0 -1
  202. package/dist/proto/ffi_pb.cjs +0 -477
  203. package/dist/proto/ffi_pb.cjs.map +0 -1
  204. package/dist/proto/ffi_pb.d.cts +0 -1321
  205. package/dist/proto/ffi_pb.d.ts +0 -1321
  206. package/dist/proto/ffi_pb.d.ts.map +0 -1
  207. package/dist/proto/ffi_pb.js +0 -444
  208. package/dist/proto/ffi_pb.js.map +0 -1
  209. package/dist/proto/handle_pb.cjs +0 -53
  210. package/dist/proto/handle_pb.cjs.map +0 -1
  211. package/dist/proto/handle_pb.d.cts +0 -31
  212. package/dist/proto/handle_pb.d.ts +0 -31
  213. package/dist/proto/handle_pb.d.ts.map +0 -1
  214. package/dist/proto/handle_pb.js +0 -29
  215. package/dist/proto/handle_pb.js.map +0 -1
  216. package/dist/proto/participant_pb.cjs +0 -173
  217. package/dist/proto/participant_pb.cjs.map +0 -1
  218. package/dist/proto/participant_pb.d.cts +0 -218
  219. package/dist/proto/participant_pb.d.ts +0 -218
  220. package/dist/proto/participant_pb.d.ts.map +0 -1
  221. package/dist/proto/participant_pb.js +0 -145
  222. package/dist/proto/participant_pb.js.map +0 -1
  223. package/dist/proto/room_pb.cjs +0 -3374
  224. package/dist/proto/room_pb.cjs.map +0 -1
  225. package/dist/proto/room_pb.d.cts +0 -3028
  226. package/dist/proto/room_pb.d.ts +0 -3028
  227. package/dist/proto/room_pb.d.ts.map +0 -1
  228. package/dist/proto/room_pb.js +0 -3232
  229. package/dist/proto/room_pb.js.map +0 -1
  230. package/dist/proto/rpc_pb.cjs +0 -328
  231. package/dist/proto/rpc_pb.cjs.map +0 -1
  232. package/dist/proto/rpc_pb.d.cts +0 -267
  233. package/dist/proto/rpc_pb.d.ts +0 -267
  234. package/dist/proto/rpc_pb.d.ts.map +0 -1
  235. package/dist/proto/rpc_pb.js +0 -294
  236. package/dist/proto/rpc_pb.js.map +0 -1
  237. package/dist/proto/stats_pb.cjs +0 -1370
  238. package/dist/proto/stats_pb.cjs.map +0 -1
  239. package/dist/proto/stats_pb.d.cts +0 -1764
  240. package/dist/proto/stats_pb.d.ts +0 -1764
  241. package/dist/proto/stats_pb.d.ts.map +0 -1
  242. package/dist/proto/stats_pb.js +0 -1300
  243. package/dist/proto/stats_pb.js.map +0 -1
  244. package/dist/proto/track_pb.cjs +0 -630
  245. package/dist/proto/track_pb.cjs.map +0 -1
  246. package/dist/proto/track_pb.d.cts +0 -542
  247. package/dist/proto/track_pb.d.ts +0 -542
  248. package/dist/proto/track_pb.d.ts.map +0 -1
  249. package/dist/proto/track_pb.js +0 -584
  250. package/dist/proto/track_pb.js.map +0 -1
  251. package/dist/proto/track_publication_pb.cjs +0 -194
  252. package/dist/proto/track_publication_pb.cjs.map +0 -1
  253. package/dist/proto/track_publication_pb.d.cts +0 -135
  254. package/dist/proto/track_publication_pb.d.ts +0 -135
  255. package/dist/proto/track_publication_pb.d.ts.map +0 -1
  256. package/dist/proto/track_publication_pb.js +0 -164
  257. package/dist/proto/track_publication_pb.js.map +0 -1
  258. package/dist/proto/video_frame_pb.cjs +0 -723
  259. package/dist/proto/video_frame_pb.cjs.map +0 -1
  260. package/dist/proto/video_frame_pb.d.cts +0 -667
  261. package/dist/proto/video_frame_pb.d.ts +0 -667
  262. package/dist/proto/video_frame_pb.d.ts.map +0 -1
  263. package/dist/proto/video_frame_pb.js +0 -673
  264. package/dist/proto/video_frame_pb.js.map +0 -1
  265. package/src/lib.rs +0 -9
  266. package/src/napi/native.cjs +0 -301
  267. package/src/napi/native.d.ts +0 -19
  268. package/src/napi/native.js +0 -15
  269. package/src/nodejs.rs +0 -134
  270. package/src/proto/audio_frame_pb.ts +0 -2270
  271. package/src/proto/data_stream_pb.ts +0 -2674
  272. package/src/proto/e2ee_pb.ts +0 -1231
  273. package/src/proto/ffi_pb.ts +0 -1700
  274. package/src/proto/handle_pb.ts +0 -69
  275. package/src/proto/participant_pb.ts +0 -351
  276. package/src/proto/room_pb.ts +0 -5661
  277. package/src/proto/rpc_pb.ts +0 -539
  278. package/src/proto/stats_pb.ts +0 -3050
  279. package/src/proto/track_pb.ts +0 -1040
  280. package/src/proto/track_publication_pb.ts +0 -284
  281. package/src/proto/video_frame_pb.ts +0 -1236
package/src/ffi_client.ts CHANGED
@@ -1,18 +1,20 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import type { PartialMessage } from '@bufbuild/protobuf';
5
- import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';
6
- import EventEmitter from 'events';
7
4
  import {
5
+ FfiEvent,
8
6
  FfiHandle,
7
+ FfiRequest,
8
+ FfiResponse,
9
+ type PartialMessage,
9
10
  livekitCopyBuffer,
10
11
  livekitDispose,
11
12
  livekitFfiRequest,
12
13
  livekitInitialize,
13
14
  livekitRetrievePtr,
14
- } from './napi/native.js';
15
- import { FfiEvent, FfiRequest, FfiResponse } from './proto/ffi_pb.js';
15
+ } from '@livekit/rtc-ffi-bindings';
16
+ import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';
17
+ import EventEmitter from 'events';
16
18
  import { SDK_VERSION } from './version.js';
17
19
 
18
20
  export { FfiHandle, type FfiEvent, type FfiResponse, FfiRequest, livekitDispose as dispose };
@@ -15,7 +15,28 @@ export type FrameProcessorCredentials = {
15
15
  url: string;
16
16
  };
17
17
 
18
+ export const FrameProcessorSymbol = Symbol.for('lk.frame-processor');
19
+
20
+ export function isFrameProcessor<
21
+ T extends FrameProcessor<AudioFrame> | FrameProcessor<VideoFrame> | unknown,
22
+ >(
23
+ maybeProcessor: unknown,
24
+ ): maybeProcessor is T extends FrameProcessor<AudioFrame>
25
+ ? FrameProcessor<AudioFrame>
26
+ : T extends FrameProcessor<VideoFrame>
27
+ ? FrameProcessor<VideoFrame>
28
+ : FrameProcessor<AudioFrame> | FrameProcessor<VideoFrame> {
29
+ return (
30
+ maybeProcessor !== null &&
31
+ typeof maybeProcessor === 'object' &&
32
+ 'symbol' in maybeProcessor &&
33
+ maybeProcessor.symbol === FrameProcessorSymbol
34
+ );
35
+ }
36
+
18
37
  export abstract class FrameProcessor<Frame extends VideoFrame | AudioFrame> {
38
+ readonly symbol = FrameProcessorSymbol;
39
+
19
40
  abstract isEnabled(): boolean;
20
41
  abstract setEnabled(enabled: boolean): void;
21
42
 
package/src/index.ts CHANGED
@@ -14,8 +14,8 @@ export { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';
14
14
  export type { E2EEOptions, KeyProviderOptions } from './e2ee.js';
15
15
  export { dispose } from './ffi_client.js';
16
16
  export { LocalParticipant, Participant, RemoteParticipant } from './participant.js';
17
- export { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';
18
- export { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';
17
+ export { EncryptionState, EncryptionType } from '@livekit/rtc-ffi-bindings';
18
+ export { DisconnectReason, ParticipantKind } from '@livekit/rtc-ffi-bindings';
19
19
  export {
20
20
  ConnectionQuality,
21
21
  ConnectionState,
@@ -24,9 +24,9 @@ export {
24
24
  IceServer,
25
25
  IceTransportType,
26
26
  TrackPublishOptions,
27
- } from './proto/room_pb.js';
28
- export { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';
29
- export { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';
27
+ } from '@livekit/rtc-ffi-bindings';
28
+ export { StreamState, TrackKind, TrackSource } from '@livekit/rtc-ffi-bindings';
29
+ export { VideoBufferType, VideoCodec, VideoRotation } from '@livekit/rtc-ffi-bindings';
30
30
  export { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';
31
31
  export { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';
32
32
  export {
@@ -54,4 +54,5 @@ export {
54
54
  FrameProcessor,
55
55
  type FrameProcessorStreamInfo,
56
56
  type FrameProcessorCredentials,
57
+ isFrameProcessor,
57
58
  } from './frame_processor.js';
@@ -2,23 +2,12 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import { Mutex } from '@livekit/mutex';
5
- import type { PathLike } from 'node:fs';
6
- import { open, stat } from 'node:fs/promises';
7
- import {
8
- type ByteStreamInfo,
9
- type ByteStreamOptions,
10
- ByteStreamWriter,
11
- type TextStreamInfo,
12
- TextStreamWriter,
13
- } from './data_streams/index.js';
14
- import { FfiClient, FfiHandle } from './ffi_client.js';
15
- import { log } from './log.js';
16
5
  import {
17
6
  DisconnectReason,
18
7
  type OwnedParticipant,
19
8
  type ParticipantInfo,
20
9
  ParticipantKind,
21
- } from './proto/participant_pb.js';
10
+ } from '@livekit/rtc-ffi-bindings';
22
11
  import {
23
12
  ChatMessage as ChatMessageModel,
24
13
  DataStream_ByteHeader,
@@ -66,20 +55,31 @@ import {
66
55
  type UnpublishTrackCallback,
67
56
  UnpublishTrackRequest,
68
57
  type UnpublishTrackResponse,
69
- } from './proto/room_pb.js';
58
+ } from '@livekit/rtc-ffi-bindings';
70
59
  import type {
71
60
  PerformRpcCallback,
72
61
  PerformRpcResponse,
73
62
  RegisterRpcMethodResponse,
74
63
  RpcMethodInvocationResponseResponse,
75
64
  UnregisterRpcMethodResponse,
76
- } from './proto/rpc_pb.js';
65
+ } from '@livekit/rtc-ffi-bindings';
77
66
  import {
78
67
  PerformRpcRequest,
79
68
  RegisterRpcMethodRequest,
80
69
  RpcMethodInvocationResponseRequest,
81
70
  UnregisterRpcMethodRequest,
82
- } from './proto/rpc_pb.js';
71
+ } from '@livekit/rtc-ffi-bindings';
72
+ import type { PathLike } from 'node:fs';
73
+ import { open, stat } from 'node:fs/promises';
74
+ import {
75
+ type ByteStreamInfo,
76
+ type ByteStreamOptions,
77
+ ByteStreamWriter,
78
+ type TextStreamInfo,
79
+ TextStreamWriter,
80
+ } from './data_streams/index.js';
81
+ import { FfiClient, FfiHandle } from './ffi_client.js';
82
+ import { log } from './log.js';
83
83
  import { type PerformRpcParams, RpcError, type RpcInvocationData } from './rpc.js';
84
84
  import type { LocalTrack } from './track.js';
85
85
  import type { RemoteTrackPublication, TrackPublication } from './track_publication.js';
@@ -336,7 +336,7 @@ export class LocalParticipant extends Participant {
336
336
  await sendTrailer(trailerReq);
337
337
  },
338
338
  abort(err) {
339
- log.error('Sink error:', err);
339
+ log.error(err, 'Sink Error');
340
340
  },
341
341
  });
342
342
 
@@ -451,7 +451,7 @@ export class LocalParticipant extends Participant {
451
451
  await sendTrailer(trailerReq);
452
452
  },
453
453
  abort(err) {
454
- log.error('Sink error:', err);
454
+ log.error(err, 'Sink error');
455
455
  },
456
456
  });
457
457
 
package/src/room.ts CHANGED
@@ -2,6 +2,27 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import { Mutex } from '@livekit/mutex';
5
+ import { EncryptionState, type EncryptionType } from '@livekit/rtc-ffi-bindings';
6
+ import type { FfiEvent } from '@livekit/rtc-ffi-bindings';
7
+ import type { DisconnectReason, OwnedParticipant } from '@livekit/rtc-ffi-bindings';
8
+ import type { DataStream_Trailer, DisconnectCallback } from '@livekit/rtc-ffi-bindings';
9
+ import {
10
+ type ConnectCallback,
11
+ ConnectRequest,
12
+ type ConnectResponse,
13
+ type ConnectionQuality,
14
+ ConnectionState,
15
+ ContinualGatheringPolicy,
16
+ type DataPacketKind,
17
+ type DataStream_Chunk,
18
+ type DataStream_Header,
19
+ type DisconnectResponse,
20
+ RoomOptions as FfiRoomOptions,
21
+ type IceServer,
22
+ IceTransportType,
23
+ type RoomInfo,
24
+ } from '@livekit/rtc-ffi-bindings';
25
+ import { TrackKind } from '@livekit/rtc-ffi-bindings';
5
26
  import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';
6
27
  import EventEmitter from 'events';
7
28
  import { ByteStreamReader, TextStreamReader } from './data_streams/stream_reader.js';
@@ -18,27 +39,6 @@ import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
18
39
  import { log } from './log.js';
19
40
  import type { Participant } from './participant.js';
20
41
  import { LocalParticipant, RemoteParticipant } from './participant.js';
21
- import { EncryptionState, type EncryptionType } from './proto/e2ee_pb.js';
22
- import type { FfiEvent } from './proto/ffi_pb.js';
23
- import type { DisconnectReason, OwnedParticipant } from './proto/participant_pb.js';
24
- import type { DataStream_Trailer, DisconnectCallback } from './proto/room_pb.js';
25
- import {
26
- type ConnectCallback,
27
- ConnectRequest,
28
- type ConnectResponse,
29
- type ConnectionQuality,
30
- ConnectionState,
31
- ContinualGatheringPolicy,
32
- type DataPacketKind,
33
- type DataStream_Chunk,
34
- type DataStream_Header,
35
- type DisconnectResponse,
36
- RoomOptions as FfiRoomOptions,
37
- type IceServer,
38
- IceTransportType,
39
- type RoomInfo,
40
- } from './proto/room_pb.js';
41
- import { TrackKind } from './proto/track_pb.js';
42
42
  import type { LocalTrack, RemoteTrack } from './track.js';
43
43
  import { RemoteAudioTrack, RemoteVideoTrack } from './track.js';
44
44
  import type { LocalTrackPublication, TrackPublication } from './track_publication.js';
@@ -792,7 +792,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
792
792
  const textBuffer = this.textStreamControllers.get(streamId);
793
793
  if (textBuffer) {
794
794
  textBuffer.controller.close();
795
- this.byteStreamControllers.delete(streamId);
795
+ this.textStreamControllers.delete(streamId);
796
796
  }
797
797
  }
798
798
  }
package/src/rpc.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import type { RpcError as RpcError_Proto } from './proto/rpc_pb.js';
4
+ import type { RpcError as RpcError_Proto } from '@livekit/rtc-ffi-bindings';
5
5
 
6
6
  /** Parameters for initiating an RPC call */
7
7
  export interface PerformRpcParams {
@@ -4,7 +4,7 @@
4
4
  import { AccessToken } from 'livekit-server-sdk';
5
5
  import { randomUUID } from 'node:crypto';
6
6
  import { setTimeout as delay } from 'node:timers/promises';
7
- import { afterAll, describe, expect, it } from 'vitest';
7
+ import { afterAll, describe, expect, it as itRaw } from 'vitest';
8
8
  import {
9
9
  AudioFrame,
10
10
  AudioSource,
@@ -20,6 +20,9 @@ import {
20
20
  dispose,
21
21
  } from '../index.js';
22
22
 
23
+ // use concurrent testing if available on the runner (currently not supported by bun's api)
24
+ const it = typeof itRaw.concurrent === 'function' ? itRaw.concurrent : itRaw;
25
+
23
26
  const hasE2EEnv =
24
27
  !!process.env.LIVEKIT_URL && !!process.env.LIVEKIT_API_KEY && !!process.env.LIVEKIT_API_SECRET;
25
28
  const describeE2E = hasE2EEnv ? describe : describe.skip;
@@ -202,7 +205,7 @@ describeE2E('livekit-rtc e2e', () => {
202
205
  await dispose();
203
206
  });
204
207
 
205
- it.concurrent(
208
+ it(
206
209
  'connects to a room',
207
210
  async () => {
208
211
  const { roomName, rooms } = await connectTestRooms(1);
@@ -225,7 +228,7 @@ describeE2E('livekit-rtc e2e', () => {
225
228
  testTimeoutMs,
226
229
  );
227
230
 
228
- it.concurrent(
231
+ it(
229
232
  'connects multiple participants to the same room',
230
233
  async () => {
231
234
  const { roomName, rooms } = await connectTestRooms(2);
@@ -241,7 +244,7 @@ describeE2E('livekit-rtc e2e', () => {
241
244
  testTimeoutMs,
242
245
  );
243
246
 
244
- it.concurrent(
247
+ it(
245
248
  'emits participantDisconnected when a participant leaves',
246
249
  async () => {
247
250
  const { rooms } = await connectTestRooms(2);
@@ -267,7 +270,7 @@ describeE2E('livekit-rtc e2e', () => {
267
270
  testTimeoutMs,
268
271
  );
269
272
 
270
- it.concurrent(
273
+ it(
271
274
  'transfers audio between two participants (sine detection)',
272
275
  async () => {
273
276
  const cases = [
@@ -367,7 +370,7 @@ describeE2E('livekit-rtc e2e', () => {
367
370
  testTimeoutMs * 2,
368
371
  );
369
372
 
370
- it.concurrent(
373
+ it(
371
374
  'publishes and receives reliable data packets',
372
375
  async () => {
373
376
  const { rooms } = await connectTestRooms(2);
@@ -407,7 +410,7 @@ describeE2E('livekit-rtc e2e', () => {
407
410
  testTimeoutMs,
408
411
  );
409
412
 
410
- it.concurrent(
413
+ it(
411
414
  'sends and receives text and byte streams',
412
415
  async () => {
413
416
  const { rooms } = await connectTestRooms(2);
@@ -469,7 +472,7 @@ describeE2E('livekit-rtc e2e', () => {
469
472
  testTimeoutMs,
470
473
  );
471
474
 
472
- it.concurrent(
475
+ it(
473
476
  'invokes RPC methods and returns structured errors',
474
477
  async () => {
475
478
  const { rooms } = await connectTestRooms(2);
package/src/track.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import type { AudioSource } from './audio_source.js';
5
- import { FfiClient, FfiHandle } from './ffi_client.js';
6
4
  import type {
7
5
  CreateAudioTrackResponse,
8
6
  CreateVideoTrackResponse,
@@ -10,8 +8,10 @@ import type {
10
8
  StreamState,
11
9
  TrackInfo,
12
10
  TrackKind,
13
- } from './proto/track_pb.js';
14
- import { CreateAudioTrackRequest, CreateVideoTrackRequest } from './proto/track_pb.js';
11
+ } from '@livekit/rtc-ffi-bindings';
12
+ import { CreateAudioTrackRequest, CreateVideoTrackRequest } from '@livekit/rtc-ffi-bindings';
13
+ import type { AudioSource } from './audio_source.js';
14
+ import { FfiClient, FfiHandle } from './ffi_client.js';
15
15
  import type { VideoSource } from './video_source.js';
16
16
 
17
17
  export abstract class Track {
@@ -1,17 +1,17 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { FfiClient } from './ffi_client.js';
5
- import { FfiHandle } from './napi/native.js';
6
- import type { EncryptionType } from './proto/e2ee_pb.js';
7
- import type { SetSubscribedResponse } from './proto/room_pb.js';
8
- import { SetSubscribedRequest } from './proto/room_pb.js';
4
+ import type { EncryptionType } from '@livekit/rtc-ffi-bindings';
5
+ import type { SetSubscribedResponse } from '@livekit/rtc-ffi-bindings';
6
+ import { SetSubscribedRequest } from '@livekit/rtc-ffi-bindings';
9
7
  import type {
10
8
  OwnedTrackPublication,
11
9
  TrackKind,
12
10
  TrackPublicationInfo,
13
11
  TrackSource,
14
- } from './proto/track_pb.js';
12
+ } from '@livekit/rtc-ffi-bindings';
13
+ import { FfiHandle } from '@livekit/rtc-ffi-bindings';
14
+ import { FfiClient } from './ffi_client.js';
15
15
  import type { Track } from './track.js';
16
16
 
17
17
  export abstract class TrackPublication {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.13.24";
1
+ export const SDK_VERSION = "0.13.25";
@@ -1,13 +1,13 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { FfiClient, FfiHandle, FfiRequest } from './ffi_client.js';
5
- import type { OwnedVideoBuffer, VideoConvertResponse } from './proto/video_frame_pb.js';
4
+ import type { OwnedVideoBuffer, VideoConvertResponse } from '@livekit/rtc-ffi-bindings';
6
5
  import {
7
6
  VideoBufferInfo,
8
7
  VideoBufferInfo_ComponentInfo,
9
8
  VideoBufferType,
10
- } from './proto/video_frame_pb.js';
9
+ } from '@livekit/rtc-ffi-bindings';
10
+ import { FfiClient, FfiHandle, FfiRequest } from './ffi_client.js';
11
11
 
12
12
  export class VideoFrame {
13
13
  data: Uint8Array;
@@ -1,18 +1,18 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { FfiClient, FfiHandle } from './ffi_client.js';
5
4
  import type {
6
5
  CaptureVideoFrameResponse,
7
6
  NewVideoSourceResponse,
8
7
  VideoSourceInfo,
9
- } from './proto/video_frame_pb.js';
8
+ } from '@livekit/rtc-ffi-bindings';
10
9
  import {
11
10
  CaptureVideoFrameRequest,
12
11
  NewVideoSourceRequest,
13
12
  VideoRotation,
14
13
  VideoSourceType,
15
- } from './proto/video_frame_pb.js';
14
+ } from '@livekit/rtc-ffi-bindings';
15
+ import { FfiClient, FfiHandle } from './ffi_client.js';
16
16
  import type { VideoFrame } from './video_frame.js';
17
17
 
18
18
  export class VideoSource {
@@ -1,11 +1,11 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
+ import type { NewVideoStreamResponse, VideoRotation } from '@livekit/rtc-ffi-bindings';
5
+ import { NewVideoStreamRequest, VideoStreamType } from '@livekit/rtc-ffi-bindings';
4
6
  import type { UnderlyingSource } from 'node:stream/web';
5
7
  import type { FfiEvent } from './ffi_client.js';
6
8
  import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
7
- import type { NewVideoStreamResponse, VideoRotation } from './proto/video_frame_pb.js';
8
- import { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';
9
9
  import type { Track } from './track.js';
10
10
  import { VideoFrame } from './video_frame.js';
11
11
 
@@ -18,6 +18,7 @@ export type VideoFrameEvent = {
18
18
  class VideoStreamSource implements UnderlyingSource<VideoFrameEvent> {
19
19
  private controller?: ReadableStreamDefaultController<VideoFrameEvent>;
20
20
  private ffiHandle: FfiHandle;
21
+ private disposed = false;
21
22
 
22
23
  constructor(track: Track) {
23
24
  const req = new NewVideoStreamRequest({
@@ -65,6 +66,14 @@ class VideoStreamSource implements UnderlyingSource<VideoFrameEvent> {
65
66
  case 'eos':
66
67
  FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);
67
68
  this.controller.close();
69
+ // Dispose the native handle so the FD is released on stream end,
70
+ // not just when cancel() is called explicitly by the consumer.
71
+ // Guard against double-dispose if cancel() is called after EOS
72
+ // while buffered frames are still in the ReadableStream queue.
73
+ if (!this.disposed) {
74
+ this.disposed = true;
75
+ this.ffiHandle.dispose();
76
+ }
68
77
  break;
69
78
  }
70
79
  };
@@ -75,7 +84,10 @@ class VideoStreamSource implements UnderlyingSource<VideoFrameEvent> {
75
84
 
76
85
  cancel() {
77
86
  FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);
78
- this.ffiHandle.dispose();
87
+ if (!this.disposed) {
88
+ this.disposed = true;
89
+ this.ffiHandle.dispose();
90
+ }
79
91
  }
80
92
  }
81
93
 
package/Cargo.toml DELETED
@@ -1,25 +0,0 @@
1
- [package]
2
- edition = "2021"
3
- name = "rtc-node"
4
- version = "0.0.1"
5
-
6
- [lib]
7
- crate-type = ["cdylib"]
8
-
9
- [dependencies]
10
- napi = { version = "2.12.2", default-features = false, features = [
11
- "async",
12
- "napi6",
13
- ] }
14
- napi-derive = "2.12.2"
15
- livekit-ffi = { path = "./rust-sdks/livekit-ffi" }
16
- prost = "0.14"
17
- prost-types = "0.14"
18
- log = "0.4.20"
19
- tokio = { version = "1.37.0", features = ["full"] }
20
-
21
- [build-dependencies]
22
- napi-build = "2.0.1"
23
-
24
- [profile.release]
25
- lto = true
package/build.rs DELETED
@@ -1,9 +0,0 @@
1
- // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
- //
3
- // SPDX-License-Identifier: Apache-2.0
4
-
5
- extern crate napi_build;
6
-
7
- fn main() {
8
- napi_build::setup();
9
- }