node-av-lgpl 0.0.0 → 7.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +711 -0
  3. package/dist/api/audio-frame-buffer.d.ts +636 -0
  4. package/dist/api/audio-frame-buffer.js +1027 -0
  5. package/dist/api/audio-frame-buffer.js.map +1 -0
  6. package/dist/api/bitstream-filter.d.ts +938 -0
  7. package/dist/api/bitstream-filter.js +1427 -0
  8. package/dist/api/bitstream-filter.js.map +1 -0
  9. package/dist/api/constants.d.ts +44 -0
  10. package/dist/api/constants.js +45 -0
  11. package/dist/api/constants.js.map +1 -0
  12. package/dist/api/data/test_av1.ivf +0 -0
  13. package/dist/api/data/test_h264.h264 +0 -0
  14. package/dist/api/data/test_hevc.h265 +0 -0
  15. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  16. package/dist/api/data/test_vp8.ivf +0 -0
  17. package/dist/api/data/test_vp9.ivf +0 -0
  18. package/dist/api/decoder.d.ts +1413 -0
  19. package/dist/api/decoder.js +2367 -0
  20. package/dist/api/decoder.js.map +1 -0
  21. package/dist/api/demuxer.d.ts +1295 -0
  22. package/dist/api/demuxer.js +2344 -0
  23. package/dist/api/demuxer.js.map +1 -0
  24. package/dist/api/device.d.ts +589 -0
  25. package/dist/api/device.js +964 -0
  26. package/dist/api/device.js.map +1 -0
  27. package/dist/api/encoder-pool.d.ts +262 -0
  28. package/dist/api/encoder-pool.js +397 -0
  29. package/dist/api/encoder-pool.js.map +1 -0
  30. package/dist/api/encoder.d.ts +1509 -0
  31. package/dist/api/encoder.js +2619 -0
  32. package/dist/api/encoder.js.map +1 -0
  33. package/dist/api/filter-complex.d.ts +828 -0
  34. package/dist/api/filter-complex.js +1661 -0
  35. package/dist/api/filter-complex.js.map +1 -0
  36. package/dist/api/filter-presets.d.ts +800 -0
  37. package/dist/api/filter-presets.js +1554 -0
  38. package/dist/api/filter-presets.js.map +1 -0
  39. package/dist/api/filter.d.ts +1339 -0
  40. package/dist/api/filter.js +2075 -0
  41. package/dist/api/filter.js.map +1 -0
  42. package/dist/api/fmp4-stream.d.ts +797 -0
  43. package/dist/api/fmp4-stream.js +1428 -0
  44. package/dist/api/fmp4-stream.js.map +1 -0
  45. package/dist/api/hardware.d.ts +677 -0
  46. package/dist/api/hardware.js +1300 -0
  47. package/dist/api/hardware.js.map +1 -0
  48. package/dist/api/index.d.ts +21 -0
  49. package/dist/api/index.js +38 -0
  50. package/dist/api/index.js.map +1 -0
  51. package/dist/api/io-stream.d.ts +308 -0
  52. package/dist/api/io-stream.js +358 -0
  53. package/dist/api/io-stream.js.map +1 -0
  54. package/dist/api/muxer.d.ts +1311 -0
  55. package/dist/api/muxer.js +2672 -0
  56. package/dist/api/muxer.js.map +1 -0
  57. package/dist/api/pipeline.d.ts +801 -0
  58. package/dist/api/pipeline.js +1344 -0
  59. package/dist/api/pipeline.js.map +1 -0
  60. package/dist/api/probe.d.ts +128 -0
  61. package/dist/api/probe.js +227 -0
  62. package/dist/api/probe.js.map +1 -0
  63. package/dist/api/rtp-stream.d.ts +497 -0
  64. package/dist/api/rtp-stream.js +1131 -0
  65. package/dist/api/rtp-stream.js.map +1 -0
  66. package/dist/api/scaler.d.ts +561 -0
  67. package/dist/api/scaler.js +918 -0
  68. package/dist/api/scaler.js.map +1 -0
  69. package/dist/api/types.d.ts +17 -0
  70. package/dist/api/types.js +2 -0
  71. package/dist/api/types.js.map +1 -0
  72. package/dist/api/utilities/async-queue.d.ts +149 -0
  73. package/dist/api/utilities/async-queue.js +254 -0
  74. package/dist/api/utilities/async-queue.js.map +1 -0
  75. package/dist/api/utilities/audio-sample.d.ts +117 -0
  76. package/dist/api/utilities/audio-sample.js +112 -0
  77. package/dist/api/utilities/audio-sample.js.map +1 -0
  78. package/dist/api/utilities/audio-transcode.d.ts +20 -0
  79. package/dist/api/utilities/audio-transcode.js +27 -0
  80. package/dist/api/utilities/audio-transcode.js.map +1 -0
  81. package/dist/api/utilities/channel-layout.d.ts +76 -0
  82. package/dist/api/utilities/channel-layout.js +80 -0
  83. package/dist/api/utilities/channel-layout.js.map +1 -0
  84. package/dist/api/utilities/codec-format.d.ts +87 -0
  85. package/dist/api/utilities/codec-format.js +117 -0
  86. package/dist/api/utilities/codec-format.js.map +1 -0
  87. package/dist/api/utilities/context-options.d.ts +25 -0
  88. package/dist/api/utilities/context-options.js +23 -0
  89. package/dist/api/utilities/context-options.js.map +1 -0
  90. package/dist/api/utilities/electron-shared-texture.d.ts +368 -0
  91. package/dist/api/utilities/electron-shared-texture.js +540 -0
  92. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  93. package/dist/api/utilities/image.d.ts +207 -0
  94. package/dist/api/utilities/image.js +213 -0
  95. package/dist/api/utilities/image.js.map +1 -0
  96. package/dist/api/utilities/index.d.ts +14 -0
  97. package/dist/api/utilities/index.js +27 -0
  98. package/dist/api/utilities/index.js.map +1 -0
  99. package/dist/api/utilities/live-decoding.d.ts +15 -0
  100. package/dist/api/utilities/live-decoding.js +32 -0
  101. package/dist/api/utilities/live-decoding.js.map +1 -0
  102. package/dist/api/utilities/media-type.d.ts +49 -0
  103. package/dist/api/utilities/media-type.js +53 -0
  104. package/dist/api/utilities/media-type.js.map +1 -0
  105. package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
  106. package/dist/api/utilities/packet-age-watchdog.js +594 -0
  107. package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
  108. package/dist/api/utilities/pixel-format.d.ts +89 -0
  109. package/dist/api/utilities/pixel-format.js +97 -0
  110. package/dist/api/utilities/pixel-format.js.map +1 -0
  111. package/dist/api/utilities/sample-format.d.ts +129 -0
  112. package/dist/api/utilities/sample-format.js +141 -0
  113. package/dist/api/utilities/sample-format.js.map +1 -0
  114. package/dist/api/utilities/scale-size.d.ts +51 -0
  115. package/dist/api/utilities/scale-size.js +55 -0
  116. package/dist/api/utilities/scale-size.js.map +1 -0
  117. package/dist/api/utilities/scheduler.d.ts +138 -0
  118. package/dist/api/utilities/scheduler.js +98 -0
  119. package/dist/api/utilities/scheduler.js.map +1 -0
  120. package/dist/api/utilities/streaming.d.ts +186 -0
  121. package/dist/api/utilities/streaming.js +309 -0
  122. package/dist/api/utilities/streaming.js.map +1 -0
  123. package/dist/api/utilities/timestamp.d.ts +193 -0
  124. package/dist/api/utilities/timestamp.js +206 -0
  125. package/dist/api/utilities/timestamp.js.map +1 -0
  126. package/dist/api/utilities/video-transcode.d.ts +218 -0
  127. package/dist/api/utilities/video-transcode.js +624 -0
  128. package/dist/api/utilities/video-transcode.js.map +1 -0
  129. package/dist/api/utilities/whisper-model.d.ts +330 -0
  130. package/dist/api/utilities/whisper-model.js +587 -0
  131. package/dist/api/utilities/whisper-model.js.map +1 -0
  132. package/dist/api/utils.d.ts +19 -0
  133. package/dist/api/utils.js +39 -0
  134. package/dist/api/utils.js.map +1 -0
  135. package/dist/api/webrtc-stream.d.ts +294 -0
  136. package/dist/api/webrtc-stream.js +546 -0
  137. package/dist/api/webrtc-stream.js.map +1 -0
  138. package/dist/api/whisper.d.ts +326 -0
  139. package/dist/api/whisper.js +402 -0
  140. package/dist/api/whisper.js.map +1 -0
  141. package/dist/constants/bsf-options.d.ts +364 -0
  142. package/dist/constants/bsf-options.js +7 -0
  143. package/dist/constants/bsf-options.js.map +1 -0
  144. package/dist/constants/channel-layouts.d.ts +53 -0
  145. package/dist/constants/channel-layouts.js +57 -0
  146. package/dist/constants/channel-layouts.js.map +1 -0
  147. package/dist/constants/constants.d.ts +2435 -0
  148. package/dist/constants/constants.js +1989 -0
  149. package/dist/constants/constants.js.map +1 -0
  150. package/dist/constants/decoders.d.ts +651 -0
  151. package/dist/constants/decoders.js +641 -0
  152. package/dist/constants/decoders.js.map +1 -0
  153. package/dist/constants/encoders.d.ts +314 -0
  154. package/dist/constants/encoders.js +309 -0
  155. package/dist/constants/encoders.js.map +1 -0
  156. package/dist/constants/filter-options.d.ts +12099 -0
  157. package/dist/constants/filter-options.js +7 -0
  158. package/dist/constants/filter-options.js.map +1 -0
  159. package/dist/constants/format-options.d.ts +4319 -0
  160. package/dist/constants/format-options.js +7 -0
  161. package/dist/constants/format-options.js.map +1 -0
  162. package/dist/constants/formats.d.ts +18 -0
  163. package/dist/constants/formats.js +7 -0
  164. package/dist/constants/formats.js.map +1 -0
  165. package/dist/constants/hardware.d.ts +26 -0
  166. package/dist/constants/hardware.js +27 -0
  167. package/dist/constants/hardware.js.map +1 -0
  168. package/dist/constants/index.d.ts +10 -0
  169. package/dist/constants/index.js +6 -0
  170. package/dist/constants/index.js.map +1 -0
  171. package/dist/constants/options.d.ts +6217 -0
  172. package/dist/constants/options.js +7 -0
  173. package/dist/constants/options.js.map +1 -0
  174. package/dist/ffmpeg/index.d.ts +101 -0
  175. package/dist/ffmpeg/index.js +161 -0
  176. package/dist/ffmpeg/index.js.map +1 -0
  177. package/dist/ffmpeg/version.d.ts +6 -0
  178. package/dist/ffmpeg/version.js +7 -0
  179. package/dist/ffmpeg/version.js.map +1 -0
  180. package/dist/index.d.ts +4 -0
  181. package/dist/index.js +9 -0
  182. package/dist/index.js.map +1 -0
  183. package/dist/lib/audio-fifo.d.ts +399 -0
  184. package/dist/lib/audio-fifo.js +431 -0
  185. package/dist/lib/audio-fifo.js.map +1 -0
  186. package/dist/lib/binding.d.ts +242 -0
  187. package/dist/lib/binding.js +102 -0
  188. package/dist/lib/binding.js.map +1 -0
  189. package/dist/lib/bitstream-filter-context.d.ts +381 -0
  190. package/dist/lib/bitstream-filter-context.js +443 -0
  191. package/dist/lib/bitstream-filter-context.js.map +1 -0
  192. package/dist/lib/bitstream-filter.d.ts +140 -0
  193. package/dist/lib/bitstream-filter.js +154 -0
  194. package/dist/lib/bitstream-filter.js.map +1 -0
  195. package/dist/lib/codec-context.d.ts +1069 -0
  196. package/dist/lib/codec-context.js +1336 -0
  197. package/dist/lib/codec-context.js.map +1 -0
  198. package/dist/lib/codec-parameters.d.ts +664 -0
  199. package/dist/lib/codec-parameters.js +813 -0
  200. package/dist/lib/codec-parameters.js.map +1 -0
  201. package/dist/lib/codec-parser.d.ts +201 -0
  202. package/dist/lib/codec-parser.js +213 -0
  203. package/dist/lib/codec-parser.js.map +1 -0
  204. package/dist/lib/codec.d.ts +617 -0
  205. package/dist/lib/codec.js +746 -0
  206. package/dist/lib/codec.js.map +1 -0
  207. package/dist/lib/device.d.ts +294 -0
  208. package/dist/lib/device.js +326 -0
  209. package/dist/lib/device.js.map +1 -0
  210. package/dist/lib/dictionary.d.ts +333 -0
  211. package/dist/lib/dictionary.js +372 -0
  212. package/dist/lib/dictionary.js.map +1 -0
  213. package/dist/lib/error.d.ts +311 -0
  214. package/dist/lib/error.js +395 -0
  215. package/dist/lib/error.js.map +1 -0
  216. package/dist/lib/fifo.d.ts +416 -0
  217. package/dist/lib/fifo.js +453 -0
  218. package/dist/lib/fifo.js.map +1 -0
  219. package/dist/lib/filter-context.d.ts +714 -0
  220. package/dist/lib/filter-context.js +783 -0
  221. package/dist/lib/filter-context.js.map +1 -0
  222. package/dist/lib/filter-graph-segment.d.ts +161 -0
  223. package/dist/lib/filter-graph-segment.js +172 -0
  224. package/dist/lib/filter-graph-segment.js.map +1 -0
  225. package/dist/lib/filter-graph.d.ts +641 -0
  226. package/dist/lib/filter-graph.js +704 -0
  227. package/dist/lib/filter-graph.js.map +1 -0
  228. package/dist/lib/filter-inout.d.ts +202 -0
  229. package/dist/lib/filter-inout.js +261 -0
  230. package/dist/lib/filter-inout.js.map +1 -0
  231. package/dist/lib/filter.d.ts +243 -0
  232. package/dist/lib/filter.js +272 -0
  233. package/dist/lib/filter.js.map +1 -0
  234. package/dist/lib/format-context.d.ts +1335 -0
  235. package/dist/lib/format-context.js +1455 -0
  236. package/dist/lib/format-context.js.map +1 -0
  237. package/dist/lib/frame-utils.d.ts +116 -0
  238. package/dist/lib/frame-utils.js +98 -0
  239. package/dist/lib/frame-utils.js.map +1 -0
  240. package/dist/lib/frame.d.ts +1315 -0
  241. package/dist/lib/frame.js +1535 -0
  242. package/dist/lib/frame.js.map +1 -0
  243. package/dist/lib/hardware-device-context.d.ts +362 -0
  244. package/dist/lib/hardware-device-context.js +383 -0
  245. package/dist/lib/hardware-device-context.js.map +1 -0
  246. package/dist/lib/hardware-frames-context.d.ts +418 -0
  247. package/dist/lib/hardware-frames-context.js +471 -0
  248. package/dist/lib/hardware-frames-context.js.map +1 -0
  249. package/dist/lib/index.d.ts +35 -0
  250. package/dist/lib/index.js +60 -0
  251. package/dist/lib/index.js.map +1 -0
  252. package/dist/lib/input-format.d.ts +249 -0
  253. package/dist/lib/input-format.js +306 -0
  254. package/dist/lib/input-format.js.map +1 -0
  255. package/dist/lib/io-context.d.ts +698 -0
  256. package/dist/lib/io-context.js +771 -0
  257. package/dist/lib/io-context.js.map +1 -0
  258. package/dist/lib/log.d.ts +174 -0
  259. package/dist/lib/log.js +184 -0
  260. package/dist/lib/log.js.map +1 -0
  261. package/dist/lib/native-types.d.ts +1024 -0
  262. package/dist/lib/native-types.js +2 -0
  263. package/dist/lib/native-types.js.map +1 -0
  264. package/dist/lib/option.d.ts +953 -0
  265. package/dist/lib/option.js +1607 -0
  266. package/dist/lib/option.js.map +1 -0
  267. package/dist/lib/output-format.d.ts +222 -0
  268. package/dist/lib/output-format.js +259 -0
  269. package/dist/lib/output-format.js.map +1 -0
  270. package/dist/lib/packet.d.ts +521 -0
  271. package/dist/lib/packet.js +613 -0
  272. package/dist/lib/packet.js.map +1 -0
  273. package/dist/lib/rational.d.ts +251 -0
  274. package/dist/lib/rational.js +278 -0
  275. package/dist/lib/rational.js.map +1 -0
  276. package/dist/lib/software-resample-context.d.ts +552 -0
  277. package/dist/lib/software-resample-context.js +592 -0
  278. package/dist/lib/software-resample-context.js.map +1 -0
  279. package/dist/lib/software-scale-context.d.ts +344 -0
  280. package/dist/lib/software-scale-context.js +366 -0
  281. package/dist/lib/software-scale-context.js.map +1 -0
  282. package/dist/lib/stream.d.ts +383 -0
  283. package/dist/lib/stream.js +524 -0
  284. package/dist/lib/stream.js.map +1 -0
  285. package/dist/lib/sync-queue.d.ts +179 -0
  286. package/dist/lib/sync-queue.js +197 -0
  287. package/dist/lib/sync-queue.js.map +1 -0
  288. package/dist/lib/types.d.ts +34 -0
  289. package/dist/lib/types.js +2 -0
  290. package/dist/lib/types.js.map +1 -0
  291. package/dist/lib/utilities.d.ts +1198 -0
  292. package/dist/lib/utilities.js +1302 -0
  293. package/dist/lib/utilities.js.map +1 -0
  294. package/dist/utils/electron.d.ts +49 -0
  295. package/dist/utils/electron.js +63 -0
  296. package/dist/utils/electron.js.map +1 -0
  297. package/dist/utils/index.d.ts +6 -0
  298. package/dist/utils/index.js +7 -0
  299. package/dist/utils/index.js.map +1 -0
  300. package/dist/utils/libc.d.ts +11 -0
  301. package/dist/utils/libc.js +35 -0
  302. package/dist/utils/libc.js.map +1 -0
  303. package/dist/utils/variant.d.ts +26 -0
  304. package/dist/utils/variant.js +31 -0
  305. package/dist/utils/variant.js.map +1 -0
  306. package/dist/webrtc/index.d.ts +4 -0
  307. package/dist/webrtc/index.js +7 -0
  308. package/dist/webrtc/index.js.map +1 -0
  309. package/install/check.js +124 -0
  310. package/install/ffmpeg.js +66 -0
  311. package/package.json +165 -3
@@ -0,0 +1,358 @@
1
+ import { Readable } from 'node:stream';
2
+ import { AVSEEK_CUR, AVSEEK_END, AVSEEK_SET, AVSEEK_SIZE } from '../constants/constants.js';
3
+ import { AVERROR_EIO } from '../lib/error.js';
4
+ import { IOContext } from '../lib/index.js';
5
+ import { IO_BUFFER_SIZE, MAX_PACKET_SIZE } from './constants.js';
6
+ /**
7
+ * Factory for creating custom I/O contexts.
8
+ *
9
+ * Provides simplified creation of I/O contexts from buffers or custom callbacks.
10
+ * Handles buffer management and seek operations for in-memory media.
11
+ * Bridges the gap between high-level media operations and custom I/O sources.
12
+ * Essential for processing media from non-file sources like network streams or memory.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { IOStream, Demuxer } from 'node-av/api';
17
+ *
18
+ * // From buffer
19
+ * const buffer = await fs.readFile('video.mp4');
20
+ * const ioContext = IOStream.create(buffer);
21
+ * const input = await Demuxer.open(buffer);
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Custom I/O callbacks
27
+ * const callbacks = {
28
+ * read: async (size: number) => {
29
+ * // Read from custom source
30
+ * return Buffer.alloc(size);
31
+ * },
32
+ * seek: async (offset: bigint, whence: AVSeekWhence) => {
33
+ * // Seek in custom source
34
+ * return offset;
35
+ * }
36
+ * };
37
+ *
38
+ * const ioContext = IOStream.create(callbacks, {
39
+ * bufferSize: 4096
40
+ * });
41
+ * ```
42
+ *
43
+ * @see {@link IOContext} For low-level I/O operations
44
+ * @see {@link Demuxer} For using I/O contexts
45
+ * @see {@link IOInputCallbacks} For callback interface
46
+ */
47
+ export class IOStream {
48
+ static create(input, options = {}) {
49
+ const { bufferSize = IO_BUFFER_SIZE } = options;
50
+ // Handle Buffer
51
+ if (Buffer.isBuffer(input)) {
52
+ return this.createFromBuffer(input, bufferSize);
53
+ }
54
+ // Handle Readable stream (must be before callbacks check since Readable has 'read')
55
+ if (input instanceof Readable) {
56
+ return this.createFromReadable(input, bufferSize);
57
+ }
58
+ // Handle custom callbacks
59
+ if (typeof input === 'object' && 'read' in input) {
60
+ return this.createFromInputCallbacks(input, bufferSize);
61
+ }
62
+ throw new TypeError('Invalid input type. Expected Buffer, Readable, or IOInputCallbacks');
63
+ }
64
+ static createOutput(output, options) {
65
+ const { bufferSize = IO_BUFFER_SIZE, maxPacketSize = MAX_PACKET_SIZE } = options ?? {};
66
+ // Handle Writable stream (must be before callbacks check since Writable has 'write')
67
+ if (typeof output === 'object' && 'writable' in output) {
68
+ return this.createForWritable(output, bufferSize, maxPacketSize);
69
+ }
70
+ // Handle custom callbacks
71
+ if (typeof output === 'object' && 'write' in output) {
72
+ return this.createFromOutputCallbacks(output, bufferSize, maxPacketSize);
73
+ }
74
+ throw new TypeError('Invalid output type. Expected Writable or IOOutputCallbacks');
75
+ }
76
+ /**
77
+ * Create I/O context from buffer.
78
+ *
79
+ * Sets up read and seek callbacks for in-memory buffer.
80
+ * Manages position tracking and EOF handling.
81
+ *
82
+ * @param buffer - Source buffer
83
+ *
84
+ * @param bufferSize - Internal buffer size
85
+ *
86
+ * @returns Configured I/O context
87
+ *
88
+ * @internal
89
+ */
90
+ static createFromBuffer(buffer, bufferSize) {
91
+ let position = 0;
92
+ const ioContext = new IOContext();
93
+ ioContext.allocContextWithCallbacks(bufferSize, 0, (size) => {
94
+ if (position >= buffer.length) {
95
+ return null; // EOF
96
+ }
97
+ const chunk = buffer.subarray(position, Math.min(position + size, buffer.length));
98
+ position += chunk.length;
99
+ return chunk;
100
+ }, undefined, (offset, whence) => {
101
+ switch (whence) {
102
+ case AVSEEK_SIZE:
103
+ return BigInt(buffer.length);
104
+ case AVSEEK_SET:
105
+ position = Number(offset);
106
+ break;
107
+ case AVSEEK_CUR:
108
+ position += Number(offset);
109
+ break;
110
+ case AVSEEK_END:
111
+ position = buffer.length + Number(offset);
112
+ break;
113
+ }
114
+ // Clamp position
115
+ position = Math.max(0, Math.min(position, buffer.length));
116
+ return BigInt(position);
117
+ });
118
+ return ioContext;
119
+ }
120
+ /**
121
+ * Create I/O context from a Node.js Readable stream.
122
+ *
123
+ * Sets up async read callbacks that buffer data from the stream.
124
+ * Seeking is not supported for streams.
125
+ *
126
+ * @param stream - Node.js Readable stream
127
+ *
128
+ * @param bufferSize - Internal buffer size
129
+ *
130
+ * @returns Configured I/O context
131
+ *
132
+ * @internal
133
+ */
134
+ static createFromReadable(stream, bufferSize) {
135
+ let chunks = [];
136
+ let totalBuffered = 0;
137
+ let streamEnded = false;
138
+ let streamError = null;
139
+ let ioFreed = false;
140
+ let pendingResolve = null;
141
+ const wakeUp = () => {
142
+ if (pendingResolve) {
143
+ const resolve = pendingResolve;
144
+ pendingResolve = null;
145
+ resolve();
146
+ }
147
+ };
148
+ const removeListeners = () => {
149
+ stream.off('readable', onReadable);
150
+ stream.off('end', onEnd);
151
+ stream.off('error', onError);
152
+ stream.off('close', wakeUp);
153
+ };
154
+ const onReadable = () => wakeUp();
155
+ const onEnd = () => {
156
+ streamEnded = true;
157
+ wakeUp();
158
+ };
159
+ const onError = (err) => {
160
+ streamError = err;
161
+ wakeUp();
162
+ };
163
+ // Track state changes and wake up pending reads
164
+ stream.on('readable', onReadable);
165
+ stream.on('end', onEnd);
166
+ stream.on('error', onError);
167
+ stream.on('close', wakeUp);
168
+ const ioContext = new IOContext();
169
+ ioContext.allocContextWithCallbacks(bufferSize, 0, // read mode
170
+ async (size) => {
171
+ // Pull-based: read from stream on demand. Return as soon as *any* data is
172
+ // available rather than waiting for the full `size` — FFmpeg's AVIO handles
173
+ // short reads and calls back for more. Blocking until the whole AVIO buffer
174
+ // (often 64 KiB) is filled would stall probing on realtime sources that
175
+ // deliver data slowly, where only the first few KiB are needed up front.
176
+ while (totalBuffered === 0 && !ioFreed && !streamEnded && !streamError && !stream.destroyed) {
177
+ // Try to read available data first
178
+ let chunk;
179
+ while ((chunk = stream.read()) !== null) {
180
+ chunks.push(chunk);
181
+ totalBuffered += chunk.length;
182
+ }
183
+ // Got something — return it without waiting for more.
184
+ if (totalBuffered > 0)
185
+ break;
186
+ // If stream is done, stop waiting
187
+ if (streamEnded || streamError || stream.destroyed)
188
+ break;
189
+ // Nothing buffered yet — wait for more data
190
+ await new Promise((resolve) => {
191
+ pendingResolve = resolve;
192
+ });
193
+ }
194
+ // I/O context was freed while this read was in flight — treat as EOF,
195
+ // the result has no consumer anymore.
196
+ if (ioFreed) {
197
+ return null;
198
+ }
199
+ // No data available — stream is done, remove listeners
200
+ if (totalBuffered === 0) {
201
+ removeListeners();
202
+ // A stream error must surface as a read error, not clean EOF —
203
+ // the demuxer treats null as regular end-of-file, which would make
204
+ // a broken source indistinguishable from a finished one.
205
+ if (streamError) {
206
+ return AVERROR_EIO;
207
+ }
208
+ return null;
209
+ }
210
+ const concat = Buffer.concat(chunks);
211
+ const result = concat.subarray(0, Math.min(size, concat.length));
212
+ const remainder = concat.subarray(result.length);
213
+ chunks = remainder.length > 0 ? [remainder] : [];
214
+ totalBuffered = remainder.length;
215
+ // If stream is done and all data consumed, remove listeners
216
+ if (totalBuffered === 0 && (streamEnded || streamError || stream.destroyed)) {
217
+ removeListeners();
218
+ }
219
+ return result;
220
+ }, undefined, // no write
221
+ undefined);
222
+ // The demuxer frees the I/O context on close (or disposes it when the
223
+ // caller passed it in) - the only signal we get that consumption stopped,
224
+ // possibly before EOF. Hook both so listeners and buffered chunks don't
225
+ // stay attached to the caller's stream forever. The native side has
226
+ // already stopped waiting for a read parked here once the input closed.
227
+ const release = () => {
228
+ ioFreed = true;
229
+ removeListeners();
230
+ chunks = [];
231
+ totalBuffered = 0;
232
+ wakeUp(); // settle a read parked on an empty buffer
233
+ };
234
+ // The hooks reach the I/O context through `this` rather than capturing it:
235
+ // the read callback above shares this scope and the native side holds it
236
+ // strongly, so a captured reference would keep an I/O context that is never
237
+ // freed (demuxer dropped without close()) alive together with the stream.
238
+ ioContext.freeContext = function () {
239
+ release();
240
+ IOContext.prototype.freeContext.call(this);
241
+ };
242
+ ioContext[Symbol.dispose] = function () {
243
+ release();
244
+ IOContext.prototype[Symbol.dispose].call(this);
245
+ };
246
+ ioContext[Symbol.asyncDispose] = async function () {
247
+ release();
248
+ await IOContext.prototype[Symbol.asyncDispose].call(this);
249
+ };
250
+ return ioContext;
251
+ }
252
+ /**
253
+ * Create I/O context for writing to a Node.js Writable stream.
254
+ *
255
+ * Sets up async write callbacks with backpressure support.
256
+ * The buffer is copied before writing since FFmpeg reuses its internal buffer.
257
+ *
258
+ * @param stream - Node.js Writable stream
259
+ *
260
+ * @param bufferSize - Internal buffer size
261
+ *
262
+ * @param maxPacketSize - Maximum packet size
263
+ *
264
+ * @returns Configured I/O context
265
+ *
266
+ * @internal
267
+ */
268
+ static createForWritable(stream, bufferSize, maxPacketSize) {
269
+ const ioContext = new IOContext();
270
+ ioContext.allocContextWithCallbacks(bufferSize, 1, // write mode
271
+ undefined, // no read
272
+ async (buffer) => {
273
+ // Fail fast on a dead stream - a thrown error is surfaced to FFmpeg
274
+ // as a write error (AVERROR(EIO)) by the native layer, so the muxer
275
+ // write rejects instead of silently feeding a destroyed stream.
276
+ if (stream.destroyed || stream.writableEnded) {
277
+ throw stream.errored ?? new Error('Writable stream was destroyed or ended during muxing');
278
+ }
279
+ // Copy buffer — FFmpeg reuses the internal buffer after callback returns
280
+ const copy = Buffer.from(buffer);
281
+ if (!stream.write(copy)) {
282
+ // Backpressure: wait for drain, but never park unconditionally -
283
+ // 'drain' never fires on a stream that errors or is destroyed while
284
+ // we wait, which would hang the muxer forever. Race it against
285
+ // 'error'/'close' and clean up all listeners on whichever settles.
286
+ await new Promise((resolve, reject) => {
287
+ const settle = (err) => {
288
+ stream.off('drain', onDrain);
289
+ stream.off('error', onError);
290
+ stream.off('close', onClose);
291
+ if (err) {
292
+ reject(err);
293
+ }
294
+ else {
295
+ resolve();
296
+ }
297
+ };
298
+ const onDrain = () => settle();
299
+ const onError = (err) => settle(err);
300
+ const onClose = () => settle(new Error('Writable stream closed before draining'));
301
+ stream.on('drain', onDrain);
302
+ stream.on('error', onError);
303
+ stream.on('close', onClose);
304
+ // Destroyed between write() and listener registration - 'close'
305
+ // may already have fired, so it would never wake us up.
306
+ if (stream.destroyed) {
307
+ settle(stream.errored ?? new Error('Writable stream destroyed before draining'));
308
+ }
309
+ });
310
+ }
311
+ return copy.length;
312
+ }, undefined);
313
+ ioContext.maxPacketSize = maxPacketSize;
314
+ return ioContext;
315
+ }
316
+ /**
317
+ * Create I/O context from custom input callbacks.
318
+ *
319
+ * Sets up custom I/O with user-provided read and optional seek callbacks.
320
+ *
321
+ * @param callbacks - User I/O callbacks
322
+ *
323
+ * @param bufferSize - Internal buffer size
324
+ *
325
+ * @returns Configured I/O context
326
+ *
327
+ * @internal
328
+ */
329
+ static createFromInputCallbacks(callbacks, bufferSize) {
330
+ const ioContext = new IOContext();
331
+ ioContext.allocContextWithCallbacks(bufferSize, 0, // read mode
332
+ callbacks.read, undefined, callbacks.seek);
333
+ return ioContext;
334
+ }
335
+ /**
336
+ * Create I/O context from custom output callbacks.
337
+ *
338
+ * Sets up custom I/O with user-provided write, optional seek, and optional read callbacks.
339
+ *
340
+ * @param callbacks - User I/O callbacks
341
+ *
342
+ * @param bufferSize - Internal buffer size
343
+ *
344
+ * @param maxPacketSize - Maximum packet size
345
+ *
346
+ * @returns Configured I/O context
347
+ *
348
+ * @internal
349
+ */
350
+ static createFromOutputCallbacks(callbacks, bufferSize, maxPacketSize) {
351
+ const ioContext = new IOContext();
352
+ ioContext.allocContextWithCallbacks(bufferSize, 1, // write mode
353
+ callbacks.read, callbacks.write, callbacks.seek);
354
+ ioContext.maxPacketSize = maxPacketSize;
355
+ return ioContext;
356
+ }
357
+ }
358
+ //# sourceMappingURL=io-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io-stream.js","sourceRoot":"","sources":["../../src/api/io-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAiFjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,OAAO,QAAQ;IAoEnB,MAAM,CAAC,MAAM,CAAC,KAA2C,EAAE,UAA0B,EAAE;QACrF,MAAM,EAAE,UAAU,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;QAEhD,gBAAgB;QAChB,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC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