node-av-light 0.0.0-stage → 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 +710 -2
  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 +167 -4
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Native bindings loader
3
+ *
4
+ * This module loads the native C++ bindings compiled by node-gyp.
5
+ * All native classes are accessed through this single entry point.
6
+ */
7
+ import { existsSync } from 'node:fs';
8
+ import { createRequire } from 'node:module';
9
+ import { resolve } from 'node:path';
10
+ import { isMainThread } from 'node:worker_threads';
11
+ import { getDirname } from '../utils/electron.js';
12
+ import { isMusl } from '../utils/libc.js';
13
+ import { nativePackagePrefix } from '../utils/variant.js';
14
+ const __dirname = getDirname(import.meta.url);
15
+ /**
16
+ * Load the native binding
17
+ *
18
+ * @returns The loaded native binding interface
19
+ *
20
+ * @internal
21
+ */
22
+ function loadBinding() {
23
+ const require = createRequire(import.meta.url);
24
+ const errors = [];
25
+ // Detect platform
26
+ const platform = process.platform;
27
+ const arch = process.arch;
28
+ const platformArch = `${platform}-${arch}`;
29
+ const loadLocal = process.env.AV_FROM_SOURCE === '1';
30
+ // node-av, node-av-lgpl and node-av-light each depend on their own platform packages
31
+ const packagePrefix = nativePackagePrefix();
32
+ // Local build directory (--build-from-source)
33
+ try {
34
+ const releasePath = resolve(__dirname, '..', '..', 'build', 'Release', 'node-av.node');
35
+ const binaryPath = resolve(__dirname, '..', '..', 'binary', 'node-av.node');
36
+ const rootPath = resolve(__dirname, '..', '..', 'node-av.node');
37
+ const localPath = [releasePath, binaryPath, rootPath];
38
+ for (const path of localPath) {
39
+ if (existsSync(path)) {
40
+ return require(path);
41
+ }
42
+ }
43
+ }
44
+ catch (err) {
45
+ errors.push(new Error(`Local build loading failed: ${err}`));
46
+ }
47
+ if (!loadLocal) {
48
+ // For Windows, pick the binary matching the Node.js runtime's toolchain.
49
+ if (platform === 'win32') {
50
+ // MinGW builds are discontinued: a Node.js compiled under MSYS2/MinGW
51
+ // (os.type() 'MINGW64_NT-*') used to get its own package, now every
52
+ // Windows runtime loads the MSVC build.
53
+ // const useMingW = type() !== 'Windows_NT';
54
+ // if (useMingW) {
55
+ // try {
56
+ // const packageName = `@seydx/node-av-${platformArch}-mingw`;
57
+ // return require(`${packageName}/node-av.node`);
58
+ // } catch (err) {
59
+ // errors.push(new Error(`MinGW package not found or loading failed: ${err}`));
60
+ // }
61
+ // }
62
+ try {
63
+ const packageName = `${packagePrefix}-${platformArch}-msvc`;
64
+ return require(`${packageName}/node-av.node`);
65
+ }
66
+ catch (err) {
67
+ errors.push(new Error(`MSVC package not found or loading failed: ${err}`));
68
+ }
69
+ }
70
+ else {
71
+ // Non-Windows platforms. musl (Alpine) needs its own build, a glibc one doesn't load there.
72
+ try {
73
+ const packageName = `${packagePrefix}-${platformArch}${isMusl() ? '-musl' : ''}`;
74
+ return require(`${packageName}/node-av.node`);
75
+ }
76
+ catch (err) {
77
+ errors.push(new Error(`Platform package not found or loading failed: ${err}`));
78
+ }
79
+ }
80
+ }
81
+ // All attempts failed
82
+ const errorMessages = errors.map((e) => e.message).join('\n ');
83
+ // prettier-ignore
84
+ throw new Error(`Could not load the node-av native binding for ${platformArch}.\n` +
85
+ `Errors:\n ${errorMessages}\n\n`);
86
+ }
87
+ // Load the native binding with fallback logic
88
+ const bindings = loadBinding();
89
+ // Custom-IO callbacks called from the threadpool wait for this thread's event
90
+ // loop without a timeout (live sources stall legitimately). After 'exit' that
91
+ // loop never runs them, and process.exit() joins the threadpool, so the waiting
92
+ // threads must fail with AVERROR_EXIT instead of blocking the exit forever.
93
+ // Only the main thread's exit ends every environment. Node sets _exiting before
94
+ // every real 'exit'; a manual process.emit('exit') (from an embedder or a test
95
+ // harness) must not end IO, and the real exit can still follow, hence on().
96
+ process.on('exit', () => {
97
+ if (Reflect.get(process, '_exiting') === true) {
98
+ bindings.IOContext.markExiting?.(isMainThread);
99
+ }
100
+ });
101
+ export { bindings };
102
+ //# sourceMappingURL=binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/lib/binding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAkD1D,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAmT9C;;;;;;GAMG;AACH,SAAS,WAAW;IAClB,MAAM,OAAO,G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+EAA+E;AAC/E,4EAA4E;AAC5E,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;IACtB,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9C,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,381 @@
1
+ import { BitStreamFilter } from './bitstream-filter.js';
2
+ import { CodecParameters } from './codec-parameters.js';
3
+ import { OptionMember } from './option.js';
4
+ import { Rational } from './rational.js';
5
+ import type { NativeBitStreamFilterContext, NativeWrapper } from './native-types.js';
6
+ import type { Packet } from './packet.js';
7
+ /**
8
+ * Bitstream filter context for processing compressed video/audio streams.
9
+ *
10
+ * Applies bitstream filters to modify or analyze compressed packets without
11
+ * full decoding/encoding. Common uses include format conversion (e.g., H.264 MP4 to Annex B),
12
+ * metadata extraction, parameter set manipulation, and packet splitting/merging.
13
+ * Essential for stream compatibility between different containers and decoders.
14
+ *
15
+ * Direct mapping to FFmpeg's AVBSFContext.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { BitStreamFilterContext, BitStreamFilter, Packet, FFmpegError } from 'node-av';
20
+ *
21
+ * // Create and initialize H.264 stream format converter
22
+ * const ctx = new BitStreamFilterContext();
23
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
24
+ * if (!filter) {
25
+ * throw new Error('H.264 filter not available');
26
+ * }
27
+ *
28
+ * let ret = ctx.alloc(filter);
29
+ * FFmpegError.throwIfError(ret, 'alloc');
30
+ *
31
+ * ret = ctx.init();
32
+ * FFmpegError.throwIfError(ret, 'init');
33
+ *
34
+ * // Process packets
35
+ * const inputPacket = new Packet();
36
+ * const outputPacket = new Packet();
37
+ *
38
+ * ret = await ctx.sendPacket(inputPacket);
39
+ * FFmpegError.throwIfError(ret, 'sendPacket');
40
+ *
41
+ * ret = await ctx.receivePacket(outputPacket);
42
+ * if (ret >= 0) {
43
+ * // Process filtered packet
44
+ * }
45
+ *
46
+ * // Cleanup
47
+ * ctx.free();
48
+ * ```
49
+ *
50
+ * @see {@link BitStreamFilter} For available filter types
51
+ * @see {@link Packet} For packet manipulation
52
+ */
53
+ export declare class BitStreamFilterContext extends OptionMember<NativeBitStreamFilterContext> implements Disposable, NativeWrapper<NativeBitStreamFilterContext> {
54
+ private _filter?;
55
+ constructor();
56
+ /**
57
+ * Check if the context has been initialized.
58
+ *
59
+ * Returns true if init() has been successfully called.
60
+ * The context must be initialized before sending/receiving packets.
61
+ */
62
+ get isInitialized(): boolean;
63
+ /**
64
+ * Input codec parameters.
65
+ *
66
+ * Parameters describing the input stream format.
67
+ * These are automatically configured from the input packets in most cases.
68
+ * Reads defaults once the context is freed.
69
+ *
70
+ * Direct mapping to AVBSFContext->par_in.
71
+ */
72
+ get inputCodecParameters(): CodecParameters | null;
73
+ /**
74
+ * Output codec parameters.
75
+ *
76
+ * Parameters describing the output stream format after filtering.
77
+ * These reflect any changes made by the bitstream filter.
78
+ * Reads defaults once the context is freed.
79
+ *
80
+ * Direct mapping to AVBSFContext->par_out.
81
+ */
82
+ get outputCodecParameters(): CodecParameters | null;
83
+ /**
84
+ * Input time base.
85
+ *
86
+ * Time base of the input packets (timestamps per second).
87
+ * Must be set before init() for proper timestamp handling.
88
+ *
89
+ * Direct mapping to AVBSFContext->time_base_in.
90
+ */
91
+ get inputTimeBase(): Rational;
92
+ set inputTimeBase(value: Rational);
93
+ /**
94
+ * Output time base.
95
+ *
96
+ * Time base of the output packets after filtering.
97
+ * May differ from input if the filter modifies timing.
98
+ *
99
+ * Direct mapping to AVBSFContext->time_base_out.
100
+ */
101
+ get outputTimeBase(): Rational | null;
102
+ /**
103
+ * The bitstream filter being used.
104
+ *
105
+ * Reference to the filter descriptor allocated to this context.
106
+ *
107
+ * Direct mapping to AVBSFContext->filter.
108
+ */
109
+ get filter(): BitStreamFilter | null;
110
+ /**
111
+ * Allocate a bitstream filter context.
112
+ *
113
+ * Allocates and configures the context for the specified filter.
114
+ * Must be called before init().
115
+ *
116
+ * Direct mapping to av_bsf_alloc().
117
+ *
118
+ * @param filter - The bitstream filter to use
119
+ *
120
+ * @returns 0 on success, negative AVERROR on error:
121
+ * - AVERROR_ENOMEM: Memory allocation failure
122
+ * - AVERROR_EINVAL: Invalid filter
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * import { FFmpegError } from 'node-av';
127
+ *
128
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
129
+ * if (!filter) {
130
+ * throw new Error('Filter not found');
131
+ * }
132
+ *
133
+ * const ret = ctx.alloc(filter);
134
+ * FFmpegError.throwIfError(ret, 'alloc');
135
+ * ```
136
+ *
137
+ * @see {@link init} To initialize after allocation
138
+ * @see {@link BitStreamFilter.getByName} To get filter by name
139
+ */
140
+ alloc(filter: BitStreamFilter): number;
141
+ /**
142
+ * Initialize the bitstream filter context.
143
+ *
144
+ * Initializes the filter with the configured parameters.
145
+ * Must be called after alloc() and before processing packets.
146
+ *
147
+ * Direct mapping to av_bsf_init().
148
+ *
149
+ * @returns 0 on success, negative AVERROR on error:
150
+ * - AVERROR_EINVAL: Invalid parameters
151
+ * - AVERROR_ENOMEM: Memory allocation failure
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * import { FFmpegError } from 'node-av';
156
+ *
157
+ * // Allocate and initialize
158
+ * const ret1 = ctx.alloc(filter);
159
+ * FFmpegError.throwIfError(ret1, 'alloc');
160
+ *
161
+ * // Set parameters if needed
162
+ * ctx.inputTimeBase = new Rational(1, 25);
163
+ *
164
+ * const ret2 = ctx.init();
165
+ * FFmpegError.throwIfError(ret2, 'init');
166
+ * ```
167
+ *
168
+ * @see {@link alloc} Must be called first
169
+ * @see {@link isInitialized} To check initialization status
170
+ */
171
+ init(): number;
172
+ /**
173
+ * Free the bitstream filter context.
174
+ *
175
+ * Releases all resources associated with the context.
176
+ * The context becomes invalid after calling this.
177
+ *
178
+ * Direct mapping to av_bsf_free().
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * ctx.free();
183
+ * // Context is now invalid
184
+ * ```
185
+ *
186
+ * @see {@link Symbol.dispose} For automatic cleanup
187
+ * @see {@link alloc} To allocate
188
+ */
189
+ free(): void;
190
+ /**
191
+ * Flush the bitstream filter.
192
+ *
193
+ * Resets the internal state and discards any buffered data.
194
+ * Useful when seeking or switching streams.
195
+ *
196
+ * Direct mapping to av_bsf_flush().
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * // Flush when seeking
201
+ * ctx.flush();
202
+ * // Now ready to process packets from new position
203
+ * ```
204
+ */
205
+ flush(): void;
206
+ /**
207
+ * Send a packet to the bitstream filter.
208
+ *
209
+ * Submits a packet for filtering. The filter may buffer the packet
210
+ * internally and require multiple calls to receivePacket() to retrieve
211
+ * all output. Send null to signal end of stream.
212
+ *
213
+ * Direct mapping to av_bsf_send_packet().
214
+ *
215
+ * @param packet - Packet to filter, or null to signal EOF
216
+ *
217
+ * @returns 0 on success, negative AVERROR on error:
218
+ * - AVERROR_EAGAIN: Filter needs output to be consumed first
219
+ * - AVERROR_EOF: Filter has been flushed
220
+ * - AVERROR_EINVAL: Invalid parameters
221
+ * - AVERROR_ENOMEM: Memory allocation failure
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * import { FFmpegError } from 'node-av';
226
+ * import { AVERROR_EAGAIN } from 'node-av';
227
+ *
228
+ * const ret = await ctx.sendPacket(inputPacket);
229
+ * if (ret === AVERROR_EAGAIN) {
230
+ * // Need to receive packets first
231
+ * const ret2 = await ctx.receivePacket(outputPacket);
232
+ * FFmpegError.throwIfError(ret2, 'receivePacket');
233
+ * } else {
234
+ * FFmpegError.throwIfError(ret, 'sendPacket');
235
+ * }
236
+ *
237
+ * // Send EOF
238
+ * await ctx.sendPacket(null);
239
+ * ```
240
+ *
241
+ * @see {@link receivePacket} To retrieve filtered packets
242
+ */
243
+ sendPacket(packet: Packet | null): Promise<number>;
244
+ /**
245
+ * Send a packet to the bitstream filter synchronously.
246
+ * Synchronous version of sendPacket.
247
+ *
248
+ * Submits a packet for filtering. The filter may buffer packets
249
+ * internally and produce output with different timing.
250
+ *
251
+ * Direct mapping to av_bsf_send_packet().
252
+ *
253
+ * @param packet - Packet to filter (null to drain)
254
+ *
255
+ * @returns 0 on success, negative AVERROR on error:
256
+ * - AVERROR_EAGAIN: Need to receive packets first
257
+ * - AVERROR_EOF: Filter has been flushed
258
+ * - AVERROR_EINVAL: Invalid state
259
+ * - AVERROR(ENOMEM): Memory allocation failure
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * import { FFmpegError } from 'node-av';
264
+ * import { AVERROR_EAGAIN } from 'node-av/constants';
265
+ *
266
+ * // Send packet to filter
267
+ * const ret = ctx.sendPacketSync(inputPacket);
268
+ * if (ret === AVERROR_EAGAIN) {
269
+ * // Need to receive output first
270
+ * const outputPacket = new Packet();
271
+ * ctx.receivePacketSync(outputPacket);
272
+ * } else {
273
+ * FFmpegError.throwIfError(ret, 'sendPacketSync');
274
+ * }
275
+ *
276
+ * // Drain filter
277
+ * ctx.sendPacketSync(null);
278
+ * ```
279
+ *
280
+ * @see {@link sendPacket} For async version
281
+ */
282
+ sendPacketSync(packet: Packet | null): number;
283
+ /**
284
+ * Receive a filtered packet from the bitstream filter.
285
+ *
286
+ * Retrieves a packet that has been processed by the filter.
287
+ * May need to be called multiple times after each sendPacket().
288
+ *
289
+ * Direct mapping to av_bsf_receive_packet().
290
+ *
291
+ * @param packet - Packet to receive filtered data into
292
+ *
293
+ * @returns 0 on success, negative AVERROR on error:
294
+ * - AVERROR_EAGAIN: Need more input
295
+ * - AVERROR_EOF: No more packets available
296
+ * - AVERROR_EINVAL: Invalid parameters
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * import { FFmpegError } from 'node-av';
301
+ * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av';
302
+ *
303
+ * // Receive all available packets
304
+ * while (true) {
305
+ * const ret = await ctx.receivePacket(outputPacket);
306
+ * if (ret === AVERROR_EAGAIN || ret === AVERROR_EOF) {
307
+ * break;
308
+ * }
309
+ * FFmpegError.throwIfError(ret, 'receivePacket');
310
+ *
311
+ * // Process filtered packet
312
+ * console.log(`Filtered packet size: ${outputPacket.size}`);
313
+ * }
314
+ * ```
315
+ *
316
+ * @see {@link sendPacket} To submit packets for filtering
317
+ */
318
+ receivePacket(packet: Packet): Promise<number>;
319
+ /**
320
+ * Receive a filtered packet from the bitstream filter synchronously.
321
+ * Synchronous version of receivePacket.
322
+ *
323
+ * Retrieves a packet that has been processed by the filter.
324
+ * May need to be called multiple times after each sendPacketSync().
325
+ *
326
+ * Direct mapping to av_bsf_receive_packet().
327
+ *
328
+ * @param packet - Packet to receive filtered data into
329
+ *
330
+ * @returns 0 on success, negative AVERROR on error:
331
+ * - AVERROR_EAGAIN: Need more input
332
+ * - AVERROR_EOF: No more packets available
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * import { FFmpegError } from 'node-av';
337
+ * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';
338
+ *
339
+ * // Receive filtered packets
340
+ * const outputPacket = new Packet();
341
+ * let ret;
342
+ * while ((ret = ctx.receivePacketSync(outputPacket)) >= 0) {
343
+ * // Process filtered packet
344
+ * console.log(`Filtered packet size: ${outputPacket.size}`);
345
+ * outputPacket.unref();
346
+ * }
347
+ *
348
+ * if (ret !== AVERROR_EAGAIN && ret !== AVERROR_EOF) {
349
+ * FFmpegError.throwIfError(ret, 'receivePacketSync');
350
+ * }
351
+ * ```
352
+ *
353
+ * @see {@link receivePacket} For async version
354
+ */
355
+ receivePacketSync(packet: Packet): number;
356
+ /**
357
+ * Get the underlying native BitStreamFilterContext object.
358
+ *
359
+ * @returns The native BitStreamFilterContext binding object
360
+ *
361
+ * @internal
362
+ */
363
+ getNative(): NativeBitStreamFilterContext;
364
+ /**
365
+ * Dispose of the bitstream filter context.
366
+ *
367
+ * Implements the Disposable interface for automatic cleanup.
368
+ * Equivalent to calling free().
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * {
373
+ * using ctx = new BitStreamFilterContext();
374
+ * ctx.alloc(filter);
375
+ * ctx.init();
376
+ * // Use context...
377
+ * } // Automatically freed when leaving scope
378
+ * ```
379
+ */
380
+ [Symbol.dispose](): void;
381
+ }