@livekit/rtc-node 0.12.1 → 0.13.0

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 (223) hide show
  1. package/dist/audio_frame.cjs +2 -2
  2. package/dist/audio_frame.cjs.map +1 -1
  3. package/dist/audio_frame.d.cts +31 -0
  4. package/dist/audio_frame.d.ts +11 -5
  5. package/dist/audio_frame.d.ts.map +1 -1
  6. package/dist/audio_frame.js +3 -3
  7. package/dist/audio_frame.js.map +1 -1
  8. package/dist/audio_resampler.cjs +10 -7
  9. package/dist/audio_resampler.cjs.map +1 -1
  10. package/dist/audio_resampler.d.cts +59 -0
  11. package/dist/audio_resampler.d.ts +11 -3
  12. package/dist/audio_resampler.d.ts.map +1 -1
  13. package/dist/audio_resampler.js +13 -10
  14. package/dist/audio_resampler.js.map +1 -1
  15. package/dist/audio_source.cjs +6 -4
  16. package/dist/audio_source.cjs.map +1 -1
  17. package/dist/audio_source.d.cts +37 -0
  18. package/dist/audio_source.d.ts +13 -5
  19. package/dist/audio_source.d.ts.map +1 -1
  20. package/dist/audio_source.js +9 -7
  21. package/dist/audio_source.js.map +1 -1
  22. package/dist/audio_stream.cjs +1 -2
  23. package/dist/audio_stream.cjs.map +1 -1
  24. package/dist/audio_stream.d.cts +37 -0
  25. package/dist/audio_stream.d.ts +16 -5
  26. package/dist/audio_stream.d.ts.map +1 -1
  27. package/dist/audio_stream.js +2 -3
  28. package/dist/audio_stream.js.map +1 -1
  29. package/dist/e2ee.cjs +19 -20
  30. package/dist/e2ee.cjs.map +1 -1
  31. package/dist/e2ee.d.cts +47 -0
  32. package/dist/e2ee.d.ts +11 -8
  33. package/dist/e2ee.d.ts.map +1 -1
  34. package/dist/e2ee.js +29 -30
  35. package/dist/e2ee.js.map +1 -1
  36. package/dist/ffi_client.cjs +6 -5
  37. package/dist/ffi_client.cjs.map +1 -1
  38. package/dist/ffi_client.d.cts +35 -0
  39. package/dist/ffi_client.d.ts +23 -11
  40. package/dist/ffi_client.d.ts.map +1 -1
  41. package/dist/ffi_client.js +6 -10
  42. package/dist/ffi_client.js.map +1 -1
  43. package/dist/index.cjs +16 -49
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.cts +28 -0
  46. package/dist/index.d.ts +20 -41
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +7 -46
  49. package/dist/index.js.map +1 -1
  50. package/dist/napi/native.d.cjs.map +1 -1
  51. package/dist/napi/native.d.d.cts +21 -0
  52. package/dist/napi/native.d.d.ts +21 -0
  53. package/dist/napi/native.d.ts +5 -5
  54. package/dist/native.d.ts +5 -5
  55. package/dist/participant.cjs +57 -34
  56. package/dist/participant.cjs.map +1 -1
  57. package/dist/participant.d.cts +126 -0
  58. package/dist/participant.d.ts +34 -20
  59. package/dist/participant.d.ts.map +1 -1
  60. package/dist/participant.js +75 -50
  61. package/dist/participant.js.map +1 -1
  62. package/dist/proto/audio_frame_pb.cjs +977 -125
  63. package/dist/proto/audio_frame_pb.cjs.map +1 -1
  64. package/dist/proto/audio_frame_pb.d.cts +898 -0
  65. package/dist/proto/audio_frame_pb.d.ts +506 -417
  66. package/dist/proto/audio_frame_pb.d.ts.map +1 -1
  67. package/dist/proto/audio_frame_pb.js +943 -85
  68. package/dist/proto/audio_frame_pb.js.map +1 -1
  69. package/dist/proto/e2ee_pb.cjs +700 -85
  70. package/dist/proto/e2ee_pb.cjs.map +1 -1
  71. package/dist/proto/e2ee_pb.d.cts +653 -0
  72. package/dist/proto/e2ee_pb.d.ts +333 -263
  73. package/dist/proto/e2ee_pb.d.ts.map +1 -1
  74. package/dist/proto/e2ee_pb.js +675 -57
  75. package/dist/proto/e2ee_pb.js.map +1 -1
  76. package/dist/proto/ffi_pb.cjs +369 -36
  77. package/dist/proto/ffi_pb.cjs.map +1 -1
  78. package/dist/proto/ffi_pb.d.cts +898 -0
  79. package/dist/proto/ffi_pb.d.ts +164 -112
  80. package/dist/proto/ffi_pb.d.ts.map +1 -1
  81. package/dist/proto/ffi_pb.js +364 -29
  82. package/dist/proto/ffi_pb.js.map +1 -1
  83. package/dist/proto/handle_pb.cjs +27 -7
  84. package/dist/proto/handle_pb.cjs.map +1 -1
  85. package/dist/proto/handle_pb.d.cts +31 -0
  86. package/dist/proto/handle_pb.d.ts +15 -15
  87. package/dist/proto/handle_pb.d.ts.map +1 -1
  88. package/dist/proto/handle_pb.js +26 -5
  89. package/dist/proto/handle_pb.js.map +1 -1
  90. package/dist/proto/participant_pb.cjs +112 -15
  91. package/dist/proto/participant_pb.cjs.map +1 -1
  92. package/dist/proto/participant_pb.d.cts +181 -0
  93. package/dist/proto/participant_pb.d.ts +143 -53
  94. package/dist/proto/participant_pb.d.ts.map +1 -1
  95. package/dist/proto/participant_pb.js +109 -11
  96. package/dist/proto/participant_pb.js.map +1 -1
  97. package/dist/proto/room_pb.cjs +2693 -302
  98. package/dist/proto/room_pb.cjs.map +1 -1
  99. package/dist/proto/room_pb.d.cts +2475 -0
  100. package/dist/proto/room_pb.d.ts +1269 -864
  101. package/dist/proto/room_pb.d.ts.map +1 -1
  102. package/dist/proto/room_pb.js +2603 -210
  103. package/dist/proto/room_pb.js.map +1 -1
  104. package/dist/proto/rpc_pb.cjs +302 -37
  105. package/dist/proto/rpc_pb.cjs.map +1 -1
  106. package/dist/proto/rpc_pb.d.cts +267 -0
  107. package/dist/proto/rpc_pb.d.ts +140 -108
  108. package/dist/proto/rpc_pb.d.ts.map +1 -1
  109. package/dist/proto/rpc_pb.js +291 -25
  110. package/dist/proto/rpc_pb.js.map +1 -1
  111. package/dist/proto/stats_pb.cjs +1253 -139
  112. package/dist/proto/stats_pb.cjs.map +1 -1
  113. package/dist/proto/stats_pb.d.cts +1764 -0
  114. package/dist/proto/stats_pb.d.ts +806 -693
  115. package/dist/proto/stats_pb.d.ts.map +1 -1
  116. package/dist/proto/stats_pb.js +1216 -93
  117. package/dist/proto/stats_pb.js.map +1 -1
  118. package/dist/proto/track_pb.cjs +462 -64
  119. package/dist/proto/track_pb.cjs.map +1 -1
  120. package/dist/proto/track_pb.d.cts +434 -0
  121. package/dist/proto/track_pb.d.ts +254 -220
  122. package/dist/proto/track_pb.d.ts.map +1 -1
  123. package/dist/proto/track_pb.js +447 -45
  124. package/dist/proto/track_pb.js.map +1 -1
  125. package/dist/proto/track_publication_pb.cjs +130 -0
  126. package/dist/proto/track_publication_pb.cjs.map +1 -0
  127. package/dist/proto/track_publication_pb.d.cts +80 -0
  128. package/dist/proto/track_publication_pb.d.ts +80 -0
  129. package/dist/proto/track_publication_pb.d.ts.map +1 -0
  130. package/dist/proto/track_publication_pb.js +103 -0
  131. package/dist/proto/track_publication_pb.js.map +1 -0
  132. package/dist/proto/video_frame_pb.cjs +648 -88
  133. package/dist/proto/video_frame_pb.cjs.map +1 -1
  134. package/dist/proto/video_frame_pb.d.cts +660 -0
  135. package/dist/proto/video_frame_pb.d.ts +375 -328
  136. package/dist/proto/video_frame_pb.d.ts.map +1 -1
  137. package/dist/proto/video_frame_pb.js +626 -60
  138. package/dist/proto/video_frame_pb.js.map +1 -1
  139. package/dist/room.cjs +93 -125
  140. package/dist/room.cjs.map +1 -1
  141. package/dist/room.d.cts +123 -0
  142. package/dist/room.d.ts +37 -34
  143. package/dist/room.d.ts.map +1 -1
  144. package/dist/room.js +92 -122
  145. package/dist/room.js.map +1 -1
  146. package/dist/rpc.cjs.map +1 -1
  147. package/dist/rpc.d.cts +81 -0
  148. package/dist/rpc.d.ts +10 -7
  149. package/dist/rpc.js.map +1 -1
  150. package/dist/track.cjs +12 -8
  151. package/dist/track.cjs.map +1 -1
  152. package/dist/track.d.cts +45 -0
  153. package/dist/track.d.ts +30 -20
  154. package/dist/track.d.ts.map +1 -1
  155. package/dist/track.js +13 -9
  156. package/dist/track.js.map +1 -1
  157. package/dist/track_publication.cjs +21 -12
  158. package/dist/track_publication.cjs.map +1 -1
  159. package/dist/track_publication.d.cts +47 -0
  160. package/dist/track_publication.d.ts +30 -19
  161. package/dist/track_publication.d.ts.map +1 -1
  162. package/dist/track_publication.js +22 -13
  163. package/dist/track_publication.js.map +1 -1
  164. package/dist/transcription.d.cts +15 -0
  165. package/dist/transcription.d.ts +4 -3
  166. package/dist/types.d.cts +9 -0
  167. package/dist/types.d.ts +3 -2
  168. package/dist/version.cjs +1 -1
  169. package/dist/version.cjs.map +1 -1
  170. package/dist/version.d.cts +3 -0
  171. package/dist/version.d.ts +3 -2
  172. package/dist/version.js +1 -1
  173. package/dist/version.js.map +1 -1
  174. package/dist/video_frame.cjs +26 -45
  175. package/dist/video_frame.cjs.map +1 -1
  176. package/dist/video_frame.d.cts +24 -0
  177. package/dist/video_frame.d.ts +10 -4
  178. package/dist/video_frame.d.ts.map +1 -1
  179. package/dist/video_frame.js +29 -48
  180. package/dist/video_frame.js.map +1 -1
  181. package/dist/video_source.cjs +7 -4
  182. package/dist/video_source.cjs.map +1 -1
  183. package/dist/video_source.d.cts +22 -0
  184. package/dist/video_source.d.ts +14 -7
  185. package/dist/video_source.d.ts.map +1 -1
  186. package/dist/video_source.js +9 -6
  187. package/dist/video_source.js.map +1 -1
  188. package/dist/video_stream.cjs +16 -5
  189. package/dist/video_stream.cjs.map +1 -1
  190. package/dist/video_stream.d.cts +40 -0
  191. package/dist/video_stream.d.ts +18 -7
  192. package/dist/video_stream.d.ts.map +1 -1
  193. package/dist/video_stream.js +17 -6
  194. package/dist/video_stream.js.map +1 -1
  195. package/package.json +17 -12
  196. package/src/audio_frame.ts +10 -10
  197. package/src/audio_resampler.ts +15 -13
  198. package/src/audio_source.ts +11 -8
  199. package/src/audio_stream.ts +3 -4
  200. package/src/e2ee.ts +36 -37
  201. package/src/ffi_client.ts +8 -16
  202. package/src/index.ts +5 -68
  203. package/src/napi/native.d.ts +5 -5
  204. package/src/participant.ts +100 -72
  205. package/src/proto/audio_frame_pb.ts +1220 -496
  206. package/src/proto/e2ee_pb.ts +858 -337
  207. package/src/proto/ffi_pb.ts +442 -135
  208. package/src/proto/handle_pb.ts +33 -19
  209. package/src/proto/participant_pb.ts +225 -60
  210. package/src/proto/room_pb.ts +3149 -1013
  211. package/src/proto/rpc_pb.ts +358 -129
  212. package/src/proto/stats_pb.ts +1891 -877
  213. package/src/proto/track_pb.ts +587 -253
  214. package/src/proto/track_publication_pb.ts +180 -0
  215. package/src/proto/video_frame_pb.ts +861 -394
  216. package/src/room.ts +143 -188
  217. package/src/rpc.ts +1 -1
  218. package/src/track.ts +16 -17
  219. package/src/track_publication.ts +25 -26
  220. package/src/version.ts +1 -1
  221. package/src/video_frame.ts +48 -72
  222. package/src/video_source.ts +11 -8
  223. package/src/video_stream.ts +18 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/video_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { create } from '@bufbuild/protobuf';\nimport { Mutex } from '@livekit/mutex';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport type {\n NewVideoStreamResponse,\n VideoRotation,\n VideoStreamInfo,\n} from './proto/video_frame_pb.js';\nimport { NewVideoStreamRequestSchema, VideoStreamType } from './proto/video_frame_pb.js';\nimport type { Track } from './track.js';\nimport { VideoFrame } from './video_frame.js';\n\nexport type VideoFrameEvent = {\n frame: VideoFrame;\n timestampUs: bigint;\n rotation: VideoRotation;\n};\n\nexport class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {\n /** @internal */\n info: VideoStreamInfo;\n /** @internal */\n ffiHandle: FfiHandle;\n /** @internal */\n eventQueue: (VideoFrameEvent | null)[] = [];\n /** @internal */\n queueResolve: ((value: IteratorResult<VideoFrameEvent>) => void) | null = null;\n /** @internal */\n mutex = new Mutex();\n\n track: Track;\n\n constructor(track: Track) {\n this.track = track;\n\n const req = create(NewVideoStreamRequestSchema, {\n type: VideoStreamType.VIDEO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n });\n\n const res = FfiClient.instance.request<NewVideoStreamResponse>({\n message: {\n case: 'newVideoStream',\n value: req,\n },\n });\n\n this.info = res.stream!.info!;\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id);\n\n FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);\n }\n\n private onEvent = (ev: FfiEvent) => {\n if (\n ev.message.case != 'videoStreamEvent' ||\n ev.message.value.streamHandle != this.ffiHandle.handle\n ) {\n return;\n }\n\n const streamEvent = ev.message.value.message;\n switch (streamEvent.case) {\n case 'frameReceived':\n const rotation = streamEvent.value.rotation;\n const timestampUs = streamEvent.value.timestampUs;\n const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer!);\n const value = { rotation, timestampUs, frame };\n if (this.queueResolve) {\n this.queueResolve({ done: false, value });\n } else {\n this.eventQueue.push(value);\n }\n break;\n case 'eos':\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n break;\n }\n };\n\n async next(): Promise<IteratorResult<VideoFrameEvent>> {\n const unlock = await this.mutex.lock();\n if (this.eventQueue.length > 0) {\n unlock();\n const value = this.eventQueue.shift();\n if (value) {\n return { done: false, value };\n } else {\n return { done: true, value: undefined };\n }\n }\n const promise = new Promise<IteratorResult<VideoFrameEvent>>(\n (resolve) => (this.queueResolve = resolve),\n );\n unlock();\n return promise;\n }\n\n close() {\n this.eventQueue.push(null);\n this.ffiHandle.dispose();\n }\n\n [Symbol.asyncIterator](): VideoStream {\n return this;\n }\n}\n"],"mappings":"AAGA,SAAS,cAAc;AACvB,SAAS,aAAa;AAEtB,SAAS,WAAW,gBAAgB,iBAAiB;AAMrD,SAAS,6BAA6B,uBAAuB;AAE7D,SAAS,kBAAkB;AAQpB,MAAM,YAA8D;AAAA,EAczE,YAAY,OAAc;AAR1B;AAAA,sBAAyC,CAAC;AAE1C;AAAA,wBAA0E;AAE1E;AAAA,iBAAQ,IAAI,MAAM;AAyBlB,SAAQ,UAAU,CAAC,OAAiB;AAClC,UACE,GAAG,QAAQ,QAAQ,sBACnB,GAAG,QAAQ,MAAM,gBAAgB,KAAK,UAAU,QAChD;AACA;AAAA,MACF;AAEA,YAAM,cAAc,GAAG,QAAQ,MAAM;AACrC,cAAQ,YAAY,MAAM;AAAA,QACxB,KAAK;AACH,gBAAM,WAAW,YAAY,MAAM;AACnC,gBAAM,cAAc,YAAY,MAAM;AACtC,gBAAM,QAAQ,WAAW,cAAc,YAAY,MAAM,MAAO;AAChE,gBAAM,QAAQ,EAAE,UAAU,aAAa,MAAM;AAC7C,cAAI,KAAK,cAAc;AACrB,iBAAK,aAAa,EAAE,MAAM,OAAO,MAAM,CAAC;AAAA,UAC1C,OAAO;AACL,iBAAK,WAAW,KAAK,KAAK;AAAA,UAC5B;AACA;AAAA,QACF,KAAK;AACH,oBAAU,SAAS,IAAI,eAAe,UAAU,KAAK,OAAO;AAC5D;AAAA,MACJ;AAAA,IACF;AA7CE,SAAK,QAAQ;AAEb,UAAM,MAAM,OAAO,6BAA6B;AAAA,MAC9C,MAAM,gBAAgB;AAAA,MACtB,aAAa,MAAM,WAAW;AAAA,IAChC,CAAC;AAED,UAAM,MAAM,UAAU,SAAS,QAAgC;AAAA,MAC7D,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,SAAK,OAAO,IAAI,OAAQ;AACxB,SAAK,YAAY,IAAI,UAAU,IAAI,OAAQ,OAAQ,EAAE;AAErD,cAAU,SAAS,GAAG,eAAe,UAAU,KAAK,OAAO;AAAA,EAC7D;AAAA,EA6BA,MAAM,OAAiD;AACrD,UAAM,SAAS,MAAM,KAAK,MAAM,KAAK;AACrC,QAAI,KAAK,WAAW,SAAS,GAAG;AAC9B,aAAO;AACP,YAAM,QAAQ,KAAK,WAAW,MAAM;AACpC,UAAI,OAAO;AACT,eAAO,EAAE,MAAM,OAAO,MAAM;AAAA,MAC9B,OAAO;AACL,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAAA,IACF;AACA,UAAM,UAAU,IAAI;AAAA,MAClB,CAAC,YAAa,KAAK,eAAe;AAAA,IACpC;AACA,WAAO;AACP,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ;AACN,SAAK,WAAW,KAAK,IAAI;AACzB,SAAK,UAAU,QAAQ;AAAA,EACzB;AAAA,EAEA,CAAC,OAAO,aAAa,IAAiB;AACpC,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/video_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Mutex } from '@livekit/mutex';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport type {\n NewVideoStreamResponse,\n VideoRotation,\n VideoStreamInfo,\n} from './proto/video_frame_pb.js';\nimport { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';\nimport type { Track } from './track.js';\nimport { VideoFrame } from './video_frame.js';\n\nexport type VideoFrameEvent = {\n frame: VideoFrame;\n timestampUs: bigint;\n rotation: VideoRotation;\n};\n\nexport class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {\n /** @internal */\n info?: VideoStreamInfo;\n /** @internal */\n ffiHandle: FfiHandle;\n /** @internal */\n eventQueue: (VideoFrameEvent | null)[] = [];\n /** @internal */\n queueResolve: ((value: IteratorResult<VideoFrameEvent>) => void) | null = null;\n /** @internal */\n mutex = new Mutex();\n\n track: Track;\n\n constructor(track: Track) {\n this.track = track;\n\n const req = new NewVideoStreamRequest({\n type: VideoStreamType.VIDEO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n });\n\n const res = FfiClient.instance.request<NewVideoStreamResponse>({\n message: {\n case: 'newVideoStream',\n value: req,\n },\n });\n\n this.info = res.stream?.info;\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);\n\n FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);\n }\n\n private onEvent = (ev: FfiEvent) => {\n if (\n ev.message.case != 'videoStreamEvent' ||\n ev.message.value.streamHandle != this.ffiHandle.handle\n ) {\n return;\n }\n\n const streamEvent = ev.message.value.message;\n switch (streamEvent.case) {\n case 'frameReceived':\n const rotation = streamEvent.value.rotation;\n const timestampUs = streamEvent.value.timestampUs;\n const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer!);\n const value = { rotation, timestampUs, frame };\n if (this.queueResolve) {\n this.queueResolve({\n done: false,\n value: {\n frame: value.frame,\n timestampUs: value.timestampUs!,\n rotation: value.rotation!,\n },\n });\n } else {\n this.eventQueue.push({\n frame: value.frame,\n timestampUs: value.timestampUs!,\n rotation: value.rotation!,\n });\n }\n break;\n case 'eos':\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n break;\n }\n };\n\n async next(): Promise<IteratorResult<VideoFrameEvent>> {\n const unlock = await this.mutex.lock();\n if (this.eventQueue.length > 0) {\n unlock();\n const value = this.eventQueue.shift();\n if (value) {\n return { done: false, value };\n } else {\n return { done: true, value: undefined };\n }\n }\n const promise = new Promise<IteratorResult<VideoFrameEvent>>(\n (resolve) => (this.queueResolve = resolve),\n );\n unlock();\n return promise;\n }\n\n close() {\n this.eventQueue.push(null);\n this.ffiHandle.dispose();\n }\n\n [Symbol.asyncIterator](): VideoStream {\n return this;\n }\n}\n"],"mappings":"AAGA,SAAS,aAAa;AAEtB,SAAS,WAAW,gBAAgB,iBAAiB;AAMrD,SAAS,uBAAuB,uBAAuB;AAEvD,SAAS,kBAAkB;AAQpB,MAAM,YAA8D;AAAA,EAczE,YAAY,OAAc;AAR1B;AAAA,sBAAyC,CAAC;AAE1C;AAAA,wBAA0E;AAE1E;AAAA,iBAAQ,IAAI,MAAM;AAyBlB,SAAQ,UAAU,CAAC,OAAiB;AAClC,UACE,GAAG,QAAQ,QAAQ,sBACnB,GAAG,QAAQ,MAAM,gBAAgB,KAAK,UAAU,QAChD;AACA;AAAA,MACF;AAEA,YAAM,cAAc,GAAG,QAAQ,MAAM;AACrC,cAAQ,YAAY,MAAM;AAAA,QACxB,KAAK;AACH,gBAAM,WAAW,YAAY,MAAM;AACnC,gBAAM,cAAc,YAAY,MAAM;AACtC,gBAAM,QAAQ,WAAW,cAAc,YAAY,MAAM,MAAO;AAChE,gBAAM,QAAQ,EAAE,UAAU,aAAa,MAAM;AAC7C,cAAI,KAAK,cAAc;AACrB,iBAAK,aAAa;AAAA,cAChB,MAAM;AAAA,cACN,OAAO;AAAA,gBACL,OAAO,MAAM;AAAA,gBACb,aAAa,MAAM;AAAA,gBACnB,UAAU,MAAM;AAAA,cAClB;AAAA,YACF,CAAC;AAAA,UACH,OAAO;AACL,iBAAK,WAAW,KAAK;AAAA,cACnB,OAAO,MAAM;AAAA,cACb,aAAa,MAAM;AAAA,cACnB,UAAU,MAAM;AAAA,YAClB,CAAC;AAAA,UACH;AACA;AAAA,QACF,KAAK;AACH,oBAAU,SAAS,IAAI,eAAe,UAAU,KAAK,OAAO;AAC5D;AAAA,MACJ;AAAA,IACF;AA5FF;AAoCI,SAAK,QAAQ;AAEb,UAAM,MAAM,IAAI,sBAAsB;AAAA,MACpC,MAAM,gBAAgB;AAAA,MACtB,aAAa,MAAM,WAAW;AAAA,IAChC,CAAC;AAED,UAAM,MAAM,UAAU,SAAS,QAAgC;AAAA,MAC7D,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,SAAK,QAAO,SAAI,WAAJ,mBAAY;AACxB,SAAK,YAAY,IAAI,UAAU,IAAI,OAAQ,OAAQ,EAAG;AAEtD,cAAU,SAAS,GAAG,eAAe,UAAU,KAAK,OAAO;AAAA,EAC7D;AAAA,EAwCA,MAAM,OAAiD;AACrD,UAAM,SAAS,MAAM,KAAK,MAAM,KAAK;AACrC,QAAI,KAAK,WAAW,SAAS,GAAG;AAC9B,aAAO;AACP,YAAM,QAAQ,KAAK,WAAW,MAAM;AACpC,UAAI,OAAO;AACT,eAAO,EAAE,MAAM,OAAO,MAAM;AAAA,MAC9B,OAAO;AACL,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAAA,IACF;AACA,UAAM,UAAU,IAAI;AAAA,MAClB,CAAC,YAAa,KAAK,eAAe;AAAA,IACpC;AACA,WAAO;AACP,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ;AACN,SAAK,WAAW,KAAK,IAAI;AACzB,SAAK,UAAU,QAAQ;AAAA,EACzB;AAAA,EAEA,CAAC,OAAO,aAAa,IAAiB;AACpC,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json CHANGED
@@ -3,15 +3,20 @@
3
3
  "description": "LiveKit RTC Node",
4
4
  "license": "Apache-2.0",
5
5
  "author": "LiveKit",
6
- "version": "0.12.1",
6
+ "version": "0.13.0",
7
7
  "main": "dist/index.js",
8
8
  "require": "dist/index.cjs",
9
9
  "types": "dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js",
14
- "require": "./dist/index.cjs"
12
+ "import": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ }
15
20
  }
16
21
  },
17
22
  "type": "module",
@@ -41,24 +46,24 @@
41
46
  }
42
47
  },
43
48
  "dependencies": {
44
- "@bufbuild/protobuf": "^2.2.0",
49
+ "@bufbuild/protobuf": "^1.10.0",
45
50
  "@livekit/mutex": "^1.0.0",
46
51
  "@livekit/typed-emitter": "^3.0.0"
47
52
  },
48
53
  "devDependencies": {
49
- "@bufbuild/protoc-gen-es": "^2.2.0",
50
54
  "@napi-rs/cli": "^2.18.0",
51
55
  "@types/node": "^20.9.2",
52
56
  "prettier": "^3.0.3",
53
57
  "tsup": "^8.3.5",
54
- "typescript": "^5.2.2"
58
+ "typescript": "^5.2.2",
59
+ "@bufbuild/protoc-gen-es": "^1.10.0"
55
60
  },
56
61
  "optionalDependencies": {
57
- "@livekit/rtc-node-darwin-arm64": "0.12.1",
58
- "@livekit/rtc-node-darwin-x64": "0.12.1",
59
- "@livekit/rtc-node-linux-arm64-gnu": "0.12.1",
60
- "@livekit/rtc-node-linux-x64-gnu": "0.12.1",
61
- "@livekit/rtc-node-win32-x64-msvc": "0.12.1"
62
+ "@livekit/rtc-node-darwin-arm64": "0.13.0",
63
+ "@livekit/rtc-node-darwin-x64": "0.13.0",
64
+ "@livekit/rtc-node-linux-arm64-gnu": "0.13.0",
65
+ "@livekit/rtc-node-linux-x64-gnu": "0.13.0",
66
+ "@livekit/rtc-node-win32-x64-msvc": "0.13.0"
62
67
  },
63
68
  "engines": {
64
69
  "node": ">= 18"
@@ -1,10 +1,9 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import { FfiClient, FfiHandle } from './ffi_client.js';
6
5
  import type { OwnedAudioFrameBuffer } from './proto/audio_frame_pb.js';
7
- import { type AudioFrameBufferInfo, AudioFrameBufferInfoSchema } from './proto/audio_frame_pb.js';
6
+ import { AudioFrameBufferInfo } from './proto/audio_frame_pb.js';
8
7
 
9
8
  export class AudioFrame {
10
9
  data: Int16Array;
@@ -32,20 +31,20 @@ export class AudioFrame {
32
31
  /** @internal */
33
32
  static fromOwnedInfo(owned: OwnedAudioFrameBuffer): AudioFrame {
34
33
  const info = owned.info!;
35
- const len = info.numChannels * info.samplesPerChannel * 2; // c_int16
36
- const data = FfiClient.instance.copyBuffer(info.dataPtr, len);
37
- new FfiHandle(owned.handle!.id).dispose();
34
+ const len = info.numChannels! * info.samplesPerChannel! * 2; // c_int16
35
+ const data = FfiClient.instance.copyBuffer(info.dataPtr!, len);
36
+ new FfiHandle(owned.handle!.id!).dispose();
38
37
  return new AudioFrame(
39
38
  new Int16Array(data.buffer),
40
- info.sampleRate,
41
- info.numChannels,
42
- info.samplesPerChannel,
39
+ info.sampleRate!,
40
+ info.numChannels!,
41
+ info.samplesPerChannel!,
43
42
  );
44
43
  }
45
44
 
46
45
  /** @internal */
47
46
  protoInfo(): AudioFrameBufferInfo {
48
- return create(AudioFrameBufferInfoSchema, {
47
+ return new AudioFrameBufferInfo({
49
48
  dataPtr: FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer)),
50
49
  sampleRate: this.sampleRate,
51
50
  numChannels: this.channels,
@@ -65,8 +64,9 @@ export class AudioFrame {
65
64
  */
66
65
  export const combineAudioFrames = (buffer: AudioFrame | AudioFrame[]): AudioFrame => {
67
66
  if (!Array.isArray(buffer)) {
68
- return buffer as AudioFrame;
67
+ return buffer;
69
68
  }
69
+ buffer = buffer as AudioFrame[];
70
70
 
71
71
  if (buffer.length === 0) {
72
72
  throw new Error('buffer is empty');
@@ -1,7 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import { AudioFrame } from './audio_frame.js';
6
5
  import { FfiClient, FfiHandle } from './ffi_client.js';
7
6
  import type {
@@ -10,9 +9,9 @@ import type {
10
9
  PushSoxResamplerResponse,
11
10
  } from './proto/audio_frame_pb.js';
12
11
  import {
13
- FlushSoxResamplerRequestSchema,
14
- NewSoxResamplerRequestSchema,
15
- PushSoxResamplerRequestSchema,
12
+ FlushSoxResamplerRequest,
13
+ NewSoxResamplerRequest,
14
+ PushSoxResamplerRequest,
16
15
  SoxQualityRecipe,
17
16
  SoxResamplerDataType,
18
17
  } from './proto/audio_frame_pb.js';
@@ -59,7 +58,7 @@ export class AudioResampler {
59
58
  this.#outputRate = outputRate;
60
59
  this.#channels = channels;
61
60
 
62
- const req = create(NewSoxResamplerRequestSchema, {
61
+ const req = new NewSoxResamplerRequest({
63
62
  inputRate,
64
63
  outputRate,
65
64
  numChannels: channels,
@@ -76,11 +75,14 @@ export class AudioResampler {
76
75
  },
77
76
  });
78
77
 
79
- if (res.message.case !== 'resampler') {
80
- throw new Error(res.message.value ?? 'Unknown Error');
78
+ switch (res.message.case) {
79
+ case 'resampler':
80
+ this.#ffiHandle = new FfiHandle(res.message.value.handle!.id!);
81
+ break;
82
+ case 'error':
83
+ default:
84
+ throw new Error(res.message.value);
81
85
  }
82
-
83
- this.#ffiHandle = new FfiHandle(res.message.value.handle!.id);
84
86
  }
85
87
 
86
88
  /**
@@ -95,7 +97,7 @@ export class AudioResampler {
95
97
  * be empty if no output data is available yet.
96
98
  */
97
99
  push(data: AudioFrame): AudioFrame[] {
98
- const req = create(PushSoxResamplerRequestSchema, {
100
+ const req = new PushSoxResamplerRequest({
99
101
  resamplerHandle: this.#ffiHandle.handle,
100
102
  dataPtr: data.protoInfo().dataPtr,
101
103
  size: data.data.byteLength,
@@ -116,7 +118,7 @@ export class AudioResampler {
116
118
  return [];
117
119
  }
118
120
 
119
- const outputData = FfiClient.instance.copyBuffer(res.outputPtr, res.size);
121
+ const outputData = FfiClient.instance.copyBuffer(res.outputPtr, res.size!);
120
122
  return [
121
123
  new AudioFrame(
122
124
  new Int16Array(outputData.buffer),
@@ -135,7 +137,7 @@ export class AudioResampler {
135
137
  * internal buffers are processed and all resampled data is output.
136
138
  */
137
139
  flush(): AudioFrame[] {
138
- const req = create(FlushSoxResamplerRequestSchema, {
140
+ const req = new FlushSoxResamplerRequest({
139
141
  resamplerHandle: this.#ffiHandle.handle,
140
142
  });
141
143
 
@@ -154,7 +156,7 @@ export class AudioResampler {
154
156
  return [];
155
157
  }
156
158
 
157
- const outputData = FfiClient.instance.copyBuffer(res.outputPtr, res.size);
159
+ const outputData = FfiClient.instance.copyBuffer(res.outputPtr, res.size!);
158
160
  return [
159
161
  new AudioFrame(
160
162
  new Int16Array(outputData.buffer),
@@ -1,7 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import type { AudioFrame } from './audio_frame.js';
6
5
  import { FfiClient } from './ffi_client.js';
7
6
  import { FfiHandle } from './napi/native.js';
@@ -14,9 +13,9 @@ import type {
14
13
  } from './proto/audio_frame_pb.js';
15
14
  import {
16
15
  AudioSourceType,
17
- CaptureAudioFrameRequestSchema,
18
- ClearAudioBufferRequestSchema,
19
- NewAudioSourceRequestSchema,
16
+ CaptureAudioFrameRequest,
17
+ ClearAudioBufferRequest,
18
+ NewAudioSourceRequest,
20
19
  } from './proto/audio_frame_pb.js';
21
20
 
22
21
  export class AudioSource {
@@ -46,7 +45,7 @@ export class AudioSource {
46
45
  this.lastCapture = 0;
47
46
  this.currentQueueSize = 0;
48
47
 
49
- const req = create(NewAudioSourceRequestSchema, {
48
+ const req = new NewAudioSourceRequest({
50
49
  type: AudioSourceType.AUDIO_SOURCE_NATIVE,
51
50
  sampleRate: sampleRate,
52
51
  numChannels: numChannels,
@@ -61,7 +60,7 @@ export class AudioSource {
61
60
  });
62
61
 
63
62
  this.info = res.source!.info!;
64
- this.ffiHandle = new FfiHandle(res.source!.handle!.id);
63
+ this.ffiHandle = new FfiHandle(res.source!.handle!.id!);
65
64
  }
66
65
 
67
66
  get queuedDuration(): number {
@@ -72,7 +71,7 @@ export class AudioSource {
72
71
  }
73
72
 
74
73
  clearQueue() {
75
- const req = create(ClearAudioBufferRequestSchema, {
74
+ const req = new ClearAudioBufferRequest({
76
75
  sourceHandle: this.ffiHandle.handle,
77
76
  });
78
77
 
@@ -117,7 +116,7 @@ export class AudioSource {
117
116
  // (e.g. using wait_for_playout for very small chunks)
118
117
  this.timeout = setTimeout(this.release, this.currentQueueSize - 50);
119
118
 
120
- const req = create(CaptureAudioFrameRequestSchema, {
119
+ const req = new CaptureAudioFrameRequest({
121
120
  sourceHandle: this.ffiHandle.handle,
122
121
  buffer: frame.protoInfo(),
123
122
  });
@@ -134,4 +133,8 @@ export class AudioSource {
134
133
  throw new Error(cb.error);
135
134
  }
136
135
  }
136
+
137
+ async close() {
138
+ this.ffiHandle.dispose();
139
+ }
137
140
  }
@@ -1,13 +1,12 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import { Mutex } from '@livekit/mutex';
6
5
  import { AudioFrame } from './audio_frame.js';
7
6
  import type { FfiEvent } from './ffi_client.js';
8
7
  import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
9
8
  import type { AudioStreamInfo, NewAudioStreamResponse } from './proto/audio_frame_pb.js';
10
- import { AudioStreamType, NewAudioStreamRequestSchema } from './proto/audio_frame_pb.js';
9
+ import { AudioStreamType, NewAudioStreamRequest } from './proto/audio_frame_pb.js';
11
10
  import type { Track } from './track.js';
12
11
 
13
12
  export class AudioStream implements AsyncIterableIterator<AudioFrame> {
@@ -31,7 +30,7 @@ export class AudioStream implements AsyncIterableIterator<AudioFrame> {
31
30
  this.sampleRate = sampleRate;
32
31
  this.numChannels = numChannels;
33
32
 
34
- const req = create(NewAudioStreamRequestSchema, {
33
+ const req = new NewAudioStreamRequest({
35
34
  type: AudioStreamType.AUDIO_STREAM_NATIVE,
36
35
  trackHandle: track.ffi_handle.handle,
37
36
  sampleRate: sampleRate,
@@ -46,7 +45,7 @@ export class AudioStream implements AsyncIterableIterator<AudioFrame> {
46
45
  });
47
46
 
48
47
  this.info = res.stream!.info!;
49
- this.ffiHandle = new FfiHandle(res.stream!.handle!.id);
48
+ this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);
50
49
 
51
50
  FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);
52
51
  }
package/src/e2ee.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import { FfiClient } from './ffi_client.js';
6
5
  import type {
7
6
  E2eeManagerGetFrameCryptorsResponse,
@@ -12,17 +11,17 @@ import type {
12
11
  RatchetSharedKeyResponse,
13
12
  } from './proto/e2ee_pb.js';
14
13
  import {
15
- E2eeManagerSetEnabledRequestSchema,
16
- E2eeRequestSchema,
14
+ E2eeManagerSetEnabledRequest,
15
+ E2eeRequest,
17
16
  EncryptionType,
18
- FrameCryptorSetEnabledRequestSchema,
19
- FrameCryptorSetKeyIndexRequestSchema,
20
- GetKeyRequestSchema,
21
- GetSharedKeyRequestSchema,
22
- RatchetKeyRequestSchema,
23
- RatchetSharedKeyRequestSchema,
24
- SetKeyRequestSchema,
25
- SetSharedKeyRequestSchema,
17
+ FrameCryptorSetEnabledRequest,
18
+ FrameCryptorSetKeyIndexRequest,
19
+ GetKeyRequest,
20
+ GetSharedKeyRequest,
21
+ RatchetKeyRequest,
22
+ RatchetSharedKeyRequest,
23
+ SetKeyRequest,
24
+ SetSharedKeyRequest,
26
25
  } from './proto/e2ee_pb.js';
27
26
 
28
27
  const DEFAULT_RATCHET_SALT = new TextEncoder().encode('LKFrameEncryptionKey');
@@ -63,11 +62,11 @@ export class KeyProvider {
63
62
  }
64
63
 
65
64
  setSharedKey(sharedKey: Uint8Array, keyIndex: number) {
66
- const req = create(E2eeRequestSchema, {
65
+ const req = new E2eeRequest({
67
66
  roomHandle: this.roomHandle,
68
67
  message: {
69
68
  case: 'setSharedKey',
70
- value: create(SetSharedKeyRequestSchema, {
69
+ value: new SetSharedKeyRequest({
71
70
  keyIndex: keyIndex,
72
71
  sharedKey: sharedKey,
73
72
  }),
@@ -83,11 +82,11 @@ export class KeyProvider {
83
82
  }
84
83
 
85
84
  exportSharedKey(keyIndex: number): Uint8Array {
86
- const req = create(E2eeRequestSchema, {
85
+ const req = new E2eeRequest({
87
86
  roomHandle: this.roomHandle,
88
87
  message: {
89
88
  case: 'getSharedKey',
90
- value: create(GetSharedKeyRequestSchema, {
89
+ value: new GetSharedKeyRequest({
91
90
  keyIndex: keyIndex,
92
91
  }),
93
92
  },
@@ -100,15 +99,15 @@ export class KeyProvider {
100
99
  },
101
100
  });
102
101
 
103
- return (res.message.value as GetSharedKeyResponse).key;
102
+ return (res.message.value as GetSharedKeyResponse).key!;
104
103
  }
105
104
 
106
105
  ratchetSharedKey(keyIndex: number): Uint8Array {
107
- const req = create(E2eeRequestSchema, {
106
+ const req = new E2eeRequest({
108
107
  roomHandle: this.roomHandle,
109
108
  message: {
110
109
  case: 'ratchetSharedKey',
111
- value: create(RatchetSharedKeyRequestSchema, {
110
+ value: new RatchetSharedKeyRequest({
112
111
  keyIndex: keyIndex,
113
112
  }),
114
113
  },
@@ -121,15 +120,15 @@ export class KeyProvider {
121
120
  },
122
121
  });
123
122
 
124
- return (res.message.value as RatchetSharedKeyResponse).newKey;
123
+ return (res.message.value as RatchetSharedKeyResponse).newKey!;
125
124
  }
126
125
 
127
126
  setKey(participantIdentity: string, keyIndex: number) {
128
- const req = create(E2eeRequestSchema, {
127
+ const req = new E2eeRequest({
129
128
  roomHandle: this.roomHandle,
130
129
  message: {
131
130
  case: 'setKey',
132
- value: create(SetKeyRequestSchema, {
131
+ value: new SetKeyRequest({
133
132
  keyIndex: keyIndex,
134
133
  participantIdentity: participantIdentity,
135
134
  }),
@@ -145,11 +144,11 @@ export class KeyProvider {
145
144
  }
146
145
 
147
146
  exportKey(participantIdentity: string, keyIndex: number): Uint8Array {
148
- const req = create(E2eeRequestSchema, {
147
+ const req = new E2eeRequest({
149
148
  roomHandle: this.roomHandle,
150
149
  message: {
151
150
  case: 'getKey',
152
- value: create(GetKeyRequestSchema, {
151
+ value: new GetKeyRequest({
153
152
  keyIndex: keyIndex,
154
153
  participantIdentity: participantIdentity,
155
154
  }),
@@ -163,15 +162,15 @@ export class KeyProvider {
163
162
  },
164
163
  });
165
164
 
166
- return (res.message.value as GetKeyResponse).key;
165
+ return (res.message.value as GetKeyResponse).key!;
167
166
  }
168
167
 
169
168
  ratchetKey(participantIdentity: string, keyIndex: number): Uint8Array {
170
- const req = create(E2eeRequestSchema, {
169
+ const req = new E2eeRequest({
171
170
  roomHandle: this.roomHandle,
172
171
  message: {
173
172
  case: 'ratchetKey',
174
- value: create(RatchetKeyRequestSchema, {
173
+ value: new RatchetKeyRequest({
175
174
  keyIndex: keyIndex,
176
175
  participantIdentity: participantIdentity,
177
176
  }),
@@ -185,7 +184,7 @@ export class KeyProvider {
185
184
  },
186
185
  });
187
186
 
188
- return (res.message.value as RatchetKeyResponse).newKey;
187
+ return (res.message.value as RatchetKeyResponse).newKey!;
189
188
  }
190
189
  }
191
190
 
@@ -204,11 +203,11 @@ export class FrameCryptor {
204
203
 
205
204
  setEnabled(enabled: boolean) {
206
205
  this.enabled = enabled;
207
- const req = create(E2eeRequestSchema, {
206
+ const req = new E2eeRequest({
208
207
  roomHandle: this.roomHandle,
209
208
  message: {
210
209
  case: 'cryptorSetEnabled',
211
- value: create(FrameCryptorSetEnabledRequestSchema, {
210
+ value: new FrameCryptorSetEnabledRequest({
212
211
  participantIdentity: this.participantIdentity,
213
212
  enabled: this.enabled,
214
213
  }),
@@ -225,11 +224,11 @@ export class FrameCryptor {
225
224
 
226
225
  setKeyIndex(keyIndex: number) {
227
226
  this.keyIndex = keyIndex;
228
- const req = create(E2eeRequestSchema, {
227
+ const req = new E2eeRequest({
229
228
  roomHandle: this.roomHandle,
230
229
  message: {
231
230
  case: 'cryptorSetKeyIndex',
232
- value: create(FrameCryptorSetKeyIndexRequestSchema, {
231
+ value: new FrameCryptorSetKeyIndexRequest({
233
232
  participantIdentity: this.participantIdentity,
234
233
  keyIndex: this.keyIndex,
235
234
  }),
@@ -265,11 +264,11 @@ export class E2EEManager {
265
264
 
266
265
  setEnabled(enabled: boolean) {
267
266
  this.enabled = enabled;
268
- const req = create(E2eeRequestSchema, {
267
+ const req = new E2eeRequest({
269
268
  roomHandle: this.roomHandle,
270
269
  message: {
271
270
  case: 'managerSetEnabled',
272
- value: create(E2eeManagerSetEnabledRequestSchema, {
271
+ value: new E2eeManagerSetEnabledRequest({
273
272
  enabled: this.enabled,
274
273
  }),
275
274
  },
@@ -284,7 +283,7 @@ export class E2EEManager {
284
283
  }
285
284
 
286
285
  frameCryptors(): FrameCryptor[] {
287
- const req = create(E2eeRequestSchema, {
286
+ const req = new E2eeRequest({
288
287
  roomHandle: this.roomHandle,
289
288
  message: {
290
289
  case: 'managerGetFrameCryptors',
@@ -305,9 +304,9 @@ export class E2EEManager {
305
304
  (cryptor) =>
306
305
  new FrameCryptor(
307
306
  this.roomHandle,
308
- cryptor.participantIdentity,
309
- cryptor.keyIndex,
310
- cryptor.enabled,
307
+ cryptor.participantIdentity!,
308
+ cryptor.keyIndex!,
309
+ cryptor.enabled!,
311
310
  ),
312
311
  );
313
312
 
package/src/ffi_client.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import type { MessageInitShape } from '@bufbuild/protobuf';
5
- import { create, fromBinary, toBinary } from '@bufbuild/protobuf';
4
+ import type { PartialMessage } from '@bufbuild/protobuf';
6
5
  import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';
7
6
  import EventEmitter from 'events';
8
7
  import {
@@ -13,17 +12,10 @@ import {
13
12
  livekitInitialize,
14
13
  livekitRetrievePtr,
15
14
  } from './napi/native.js';
16
- import {
17
- type FfiEvent,
18
- FfiEventSchema,
19
- type FfiRequest,
20
- FfiRequestSchema,
21
- type FfiResponse,
22
- FfiResponseSchema,
23
- } from './proto/ffi_pb.js';
15
+ import { FfiEvent, FfiRequest, FfiResponse } from './proto/ffi_pb.js';
24
16
  import { SDK_VERSION } from './version.js';
25
17
 
26
- export { FfiHandle, type FfiEvent, type FfiResponse, type FfiRequest, livekitDispose as dispose };
18
+ export { FfiHandle, type FfiEvent, type FfiResponse, FfiRequest, livekitDispose as dispose };
27
19
 
28
20
  export type FfiClientCallbacks = {
29
21
  ffi_event: (event: FfiEvent) => void;
@@ -49,7 +41,7 @@ export class FfiClient extends (EventEmitter as new () => TypedEmitter<FfiClient
49
41
 
50
42
  livekitInitialize(
51
43
  (event_data: Uint8Array) => {
52
- const event = fromBinary(FfiEventSchema, event_data);
44
+ const event = FfiEvent.fromBinary(event_data);
53
45
  this.emit(FfiClientEvent.FfiEvent, event);
54
46
  },
55
47
  true,
@@ -57,11 +49,11 @@ export class FfiClient extends (EventEmitter as new () => TypedEmitter<FfiClient
57
49
  );
58
50
  }
59
51
 
60
- request<T>(req: MessageInitShape<typeof FfiRequestSchema>): T {
61
- const request = create(FfiRequestSchema, req);
62
- const req_data = toBinary(FfiRequestSchema, request);
52
+ request<T>(req: PartialMessage<FfiRequest>): T {
53
+ const request = new FfiRequest(req);
54
+ const req_data = request.toBinary();
63
55
  const res_data = livekitFfiRequest(req_data);
64
- return fromBinary(FfiResponseSchema, res_data).message.value as T;
56
+ return FfiResponse.fromBinary(res_data).message.value as T;
65
57
  }
66
58
 
67
59
  copyBuffer(ptr: bigint, len: number): Uint8Array {
package/src/index.ts CHANGED
@@ -1,18 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import type { MessageInitShape } from '@bufbuild/protobuf';
5
- import { create } from '@bufbuild/protobuf';
6
- import type { AudioEncoding, TrackPublishOptionsSchema, VideoEncoding } from './proto/room_pb.js';
7
- import {
8
- AudioEncodingSchema,
9
- IceServerSchema,
10
- type IceServer as IceServerType,
11
- type TrackPublishOptions as TrackPublishOptionsType,
12
- VideoEncodingSchema,
13
- } from './proto/room_pb.js';
14
- import { TrackSource } from './proto/track_pb.js';
15
- import { VideoCodec } from './proto/video_frame_pb.js';
16
4
 
17
5
  export { Room, RoomEvent, ConnectError, type RoomOptions, type RtcConfiguration } from './room.js';
18
6
  export { Participant, RemoteParticipant, LocalParticipant } from './participant.js';
@@ -39,20 +27,16 @@ export {
39
27
  RemoteTrackPublication,
40
28
  LocalTrackPublication,
41
29
  } from './track_publication.js';
42
- export { type Transcription, type TranscriptionSegment } from './transcription.js';
43
- export {
44
- E2EEManager,
45
- type E2EEOptions,
46
- type KeyProviderOptions,
47
- KeyProvider,
48
- FrameCryptor,
49
- } from './e2ee.js';
50
-
30
+ export type { Transcription, TranscriptionSegment } from './transcription.js';
31
+ export { E2EEManager, KeyProvider, FrameCryptor } from './e2ee.js';
32
+ export type { E2EEOptions, KeyProviderOptions } from './e2ee.js';
51
33
  export {
52
34
  ConnectionQuality,
35
+ IceServer,
53
36
  IceTransportType,
54
37
  DataPacketKind,
55
38
  ContinualGatheringPolicy,
39
+ TrackPublishOptions,
56
40
  ConnectionState,
57
41
  } from './proto/room_pb.js';
58
42
  export { RpcError, type RpcInvocationData, type PerformRpcParams } from './rpc.js';
@@ -62,50 +46,3 @@ export { VideoBufferType, VideoRotation, VideoCodec } from './proto/video_frame_
62
46
  export { ParticipantKind } from './proto/participant_pb.js';
63
47
  export { dispose } from './ffi_client.js';
64
48
  export type { ChatMessage } from './types.js';
65
-
66
- // exposing helpers for API compatibility with 1.x version of protobuf-es where these were class instances
67
-
68
- type IceServerInit = MessageInitShape<typeof IceServerSchema> & {
69
- urls: string[];
70
- };
71
- export class IceServer implements IceServerType {
72
- $typeName = 'livekit.proto.IceServer' as const;
73
- urls: string[];
74
- username: string;
75
- password: string;
76
- constructor(init: IceServerInit) {
77
- const { urls, username, password } = init;
78
- this.urls = urls;
79
- this.username = username ?? '';
80
- this.password = password ?? '';
81
- create(IceServerSchema, init);
82
- }
83
- }
84
-
85
- export class TrackPublishOptions implements TrackPublishOptionsType {
86
- $typeName = 'livekit.proto.TrackPublishOptions' as const;
87
- videoCodec: VideoCodec;
88
- videoEncoding?: VideoEncoding | undefined;
89
- audioEncoding?: AudioEncoding | undefined;
90
- dtx: boolean;
91
- simulcast: boolean;
92
- source: TrackSource;
93
- stream: string;
94
- red: boolean;
95
-
96
- constructor(init: MessageInitShape<typeof TrackPublishOptionsSchema> = {}) {
97
- const { videoCodec, videoEncoding, audioEncoding, dtx, simulcast, source, stream, red } = init;
98
- this.videoCodec = videoCodec ?? VideoCodec.VP8;
99
- if (videoEncoding) {
100
- this.videoEncoding = create(VideoEncodingSchema, videoEncoding);
101
- }
102
- if (audioEncoding) {
103
- this.audioEncoding = create(AudioEncodingSchema, audioEncoding);
104
- }
105
- this.dtx = dtx ?? false;
106
- this.simulcast = simulcast ?? false;
107
- this.source = source ?? TrackSource.SOURCE_UNKNOWN;
108
- this.stream = stream ?? '';
109
- this.red = red ?? false;
110
- }
111
- }