@revizly/node-av 5.2.2-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 (254) hide show
  1. package/BUILD_LINUX.md +61 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +662 -0
  4. package/build_mac_local.sh +69 -0
  5. package/dist/api/audio-frame-buffer.d.ts +205 -0
  6. package/dist/api/audio-frame-buffer.js +287 -0
  7. package/dist/api/audio-frame-buffer.js.map +1 -0
  8. package/dist/api/bitstream-filter.d.ts +820 -0
  9. package/dist/api/bitstream-filter.js +1242 -0
  10. package/dist/api/bitstream-filter.js.map +1 -0
  11. package/dist/api/constants.d.ts +44 -0
  12. package/dist/api/constants.js +45 -0
  13. package/dist/api/constants.js.map +1 -0
  14. package/dist/api/data/test_av1.ivf +0 -0
  15. package/dist/api/data/test_h264.h264 +0 -0
  16. package/dist/api/data/test_hevc.h265 +0 -0
  17. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  18. package/dist/api/data/test_vp8.ivf +0 -0
  19. package/dist/api/data/test_vp9.ivf +0 -0
  20. package/dist/api/decoder.d.ts +1088 -0
  21. package/dist/api/decoder.js +1775 -0
  22. package/dist/api/decoder.js.map +1 -0
  23. package/dist/api/demuxer.d.ts +1219 -0
  24. package/dist/api/demuxer.js +2081 -0
  25. package/dist/api/demuxer.js.map +1 -0
  26. package/dist/api/device.d.ts +586 -0
  27. package/dist/api/device.js +961 -0
  28. package/dist/api/device.js.map +1 -0
  29. package/dist/api/encoder.d.ts +1132 -0
  30. package/dist/api/encoder.js +1988 -0
  31. package/dist/api/encoder.js.map +1 -0
  32. package/dist/api/filter-complex.d.ts +821 -0
  33. package/dist/api/filter-complex.js +1604 -0
  34. package/dist/api/filter-complex.js.map +1 -0
  35. package/dist/api/filter-presets.d.ts +1286 -0
  36. package/dist/api/filter-presets.js +2152 -0
  37. package/dist/api/filter-presets.js.map +1 -0
  38. package/dist/api/filter.d.ts +1234 -0
  39. package/dist/api/filter.js +1976 -0
  40. package/dist/api/filter.js.map +1 -0
  41. package/dist/api/fmp4-stream.d.ts +426 -0
  42. package/dist/api/fmp4-stream.js +739 -0
  43. package/dist/api/fmp4-stream.js.map +1 -0
  44. package/dist/api/hardware.d.ts +651 -0
  45. package/dist/api/hardware.js +1260 -0
  46. package/dist/api/hardware.js.map +1 -0
  47. package/dist/api/index.d.ts +17 -0
  48. package/dist/api/index.js +32 -0
  49. package/dist/api/index.js.map +1 -0
  50. package/dist/api/io-stream.d.ts +307 -0
  51. package/dist/api/io-stream.js +282 -0
  52. package/dist/api/io-stream.js.map +1 -0
  53. package/dist/api/muxer.d.ts +957 -0
  54. package/dist/api/muxer.js +2002 -0
  55. package/dist/api/muxer.js.map +1 -0
  56. package/dist/api/pipeline.d.ts +607 -0
  57. package/dist/api/pipeline.js +1145 -0
  58. package/dist/api/pipeline.js.map +1 -0
  59. package/dist/api/utilities/async-queue.d.ts +120 -0
  60. package/dist/api/utilities/async-queue.js +211 -0
  61. package/dist/api/utilities/async-queue.js.map +1 -0
  62. package/dist/api/utilities/audio-sample.d.ts +117 -0
  63. package/dist/api/utilities/audio-sample.js +112 -0
  64. package/dist/api/utilities/audio-sample.js.map +1 -0
  65. package/dist/api/utilities/channel-layout.d.ts +76 -0
  66. package/dist/api/utilities/channel-layout.js +80 -0
  67. package/dist/api/utilities/channel-layout.js.map +1 -0
  68. package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
  69. package/dist/api/utilities/electron-shared-texture.js +503 -0
  70. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  71. package/dist/api/utilities/image.d.ts +207 -0
  72. package/dist/api/utilities/image.js +213 -0
  73. package/dist/api/utilities/image.js.map +1 -0
  74. package/dist/api/utilities/index.d.ts +12 -0
  75. package/dist/api/utilities/index.js +25 -0
  76. package/dist/api/utilities/index.js.map +1 -0
  77. package/dist/api/utilities/media-type.d.ts +49 -0
  78. package/dist/api/utilities/media-type.js +53 -0
  79. package/dist/api/utilities/media-type.js.map +1 -0
  80. package/dist/api/utilities/pixel-format.d.ts +89 -0
  81. package/dist/api/utilities/pixel-format.js +97 -0
  82. package/dist/api/utilities/pixel-format.js.map +1 -0
  83. package/dist/api/utilities/sample-format.d.ts +129 -0
  84. package/dist/api/utilities/sample-format.js +141 -0
  85. package/dist/api/utilities/sample-format.js.map +1 -0
  86. package/dist/api/utilities/scheduler.d.ts +138 -0
  87. package/dist/api/utilities/scheduler.js +98 -0
  88. package/dist/api/utilities/scheduler.js.map +1 -0
  89. package/dist/api/utilities/streaming.d.ts +186 -0
  90. package/dist/api/utilities/streaming.js +309 -0
  91. package/dist/api/utilities/streaming.js.map +1 -0
  92. package/dist/api/utilities/timestamp.d.ts +193 -0
  93. package/dist/api/utilities/timestamp.js +206 -0
  94. package/dist/api/utilities/timestamp.js.map +1 -0
  95. package/dist/api/utilities/whisper-model.d.ts +310 -0
  96. package/dist/api/utilities/whisper-model.js +528 -0
  97. package/dist/api/utilities/whisper-model.js.map +1 -0
  98. package/dist/api/utils.d.ts +19 -0
  99. package/dist/api/utils.js +39 -0
  100. package/dist/api/utils.js.map +1 -0
  101. package/dist/api/whisper.d.ts +324 -0
  102. package/dist/api/whisper.js +362 -0
  103. package/dist/api/whisper.js.map +1 -0
  104. package/dist/constants/channel-layouts.d.ts +53 -0
  105. package/dist/constants/channel-layouts.js +57 -0
  106. package/dist/constants/channel-layouts.js.map +1 -0
  107. package/dist/constants/constants.d.ts +2325 -0
  108. package/dist/constants/constants.js +1887 -0
  109. package/dist/constants/constants.js.map +1 -0
  110. package/dist/constants/decoders.d.ts +633 -0
  111. package/dist/constants/decoders.js +641 -0
  112. package/dist/constants/decoders.js.map +1 -0
  113. package/dist/constants/encoders.d.ts +295 -0
  114. package/dist/constants/encoders.js +308 -0
  115. package/dist/constants/encoders.js.map +1 -0
  116. package/dist/constants/hardware.d.ts +26 -0
  117. package/dist/constants/hardware.js +27 -0
  118. package/dist/constants/hardware.js.map +1 -0
  119. package/dist/constants/index.d.ts +5 -0
  120. package/dist/constants/index.js +6 -0
  121. package/dist/constants/index.js.map +1 -0
  122. package/dist/ffmpeg/index.d.ts +99 -0
  123. package/dist/ffmpeg/index.js +115 -0
  124. package/dist/ffmpeg/index.js.map +1 -0
  125. package/dist/ffmpeg/utils.d.ts +31 -0
  126. package/dist/ffmpeg/utils.js +68 -0
  127. package/dist/ffmpeg/utils.js.map +1 -0
  128. package/dist/ffmpeg/version.d.ts +6 -0
  129. package/dist/ffmpeg/version.js +7 -0
  130. package/dist/ffmpeg/version.js.map +1 -0
  131. package/dist/index.d.ts +4 -0
  132. package/dist/index.js +9 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/lib/audio-fifo.d.ts +399 -0
  135. package/dist/lib/audio-fifo.js +431 -0
  136. package/dist/lib/audio-fifo.js.map +1 -0
  137. package/dist/lib/binding.d.ts +228 -0
  138. package/dist/lib/binding.js +60 -0
  139. package/dist/lib/binding.js.map +1 -0
  140. package/dist/lib/bitstream-filter-context.d.ts +379 -0
  141. package/dist/lib/bitstream-filter-context.js +441 -0
  142. package/dist/lib/bitstream-filter-context.js.map +1 -0
  143. package/dist/lib/bitstream-filter.d.ts +140 -0
  144. package/dist/lib/bitstream-filter.js +154 -0
  145. package/dist/lib/bitstream-filter.js.map +1 -0
  146. package/dist/lib/codec-context.d.ts +1071 -0
  147. package/dist/lib/codec-context.js +1354 -0
  148. package/dist/lib/codec-context.js.map +1 -0
  149. package/dist/lib/codec-parameters.d.ts +616 -0
  150. package/dist/lib/codec-parameters.js +761 -0
  151. package/dist/lib/codec-parameters.js.map +1 -0
  152. package/dist/lib/codec-parser.d.ts +201 -0
  153. package/dist/lib/codec-parser.js +213 -0
  154. package/dist/lib/codec-parser.js.map +1 -0
  155. package/dist/lib/codec.d.ts +586 -0
  156. package/dist/lib/codec.js +713 -0
  157. package/dist/lib/codec.js.map +1 -0
  158. package/dist/lib/device.d.ts +291 -0
  159. package/dist/lib/device.js +324 -0
  160. package/dist/lib/device.js.map +1 -0
  161. package/dist/lib/dictionary.d.ts +333 -0
  162. package/dist/lib/dictionary.js +372 -0
  163. package/dist/lib/dictionary.js.map +1 -0
  164. package/dist/lib/error.d.ts +242 -0
  165. package/dist/lib/error.js +303 -0
  166. package/dist/lib/error.js.map +1 -0
  167. package/dist/lib/fifo.d.ts +416 -0
  168. package/dist/lib/fifo.js +453 -0
  169. package/dist/lib/fifo.js.map +1 -0
  170. package/dist/lib/filter-context.d.ts +712 -0
  171. package/dist/lib/filter-context.js +789 -0
  172. package/dist/lib/filter-context.js.map +1 -0
  173. package/dist/lib/filter-graph-segment.d.ts +160 -0
  174. package/dist/lib/filter-graph-segment.js +171 -0
  175. package/dist/lib/filter-graph-segment.js.map +1 -0
  176. package/dist/lib/filter-graph.d.ts +641 -0
  177. package/dist/lib/filter-graph.js +704 -0
  178. package/dist/lib/filter-graph.js.map +1 -0
  179. package/dist/lib/filter-inout.d.ts +198 -0
  180. package/dist/lib/filter-inout.js +257 -0
  181. package/dist/lib/filter-inout.js.map +1 -0
  182. package/dist/lib/filter.d.ts +243 -0
  183. package/dist/lib/filter.js +272 -0
  184. package/dist/lib/filter.js.map +1 -0
  185. package/dist/lib/format-context.d.ts +1254 -0
  186. package/dist/lib/format-context.js +1379 -0
  187. package/dist/lib/format-context.js.map +1 -0
  188. package/dist/lib/frame-utils.d.ts +116 -0
  189. package/dist/lib/frame-utils.js +98 -0
  190. package/dist/lib/frame-utils.js.map +1 -0
  191. package/dist/lib/frame.d.ts +1222 -0
  192. package/dist/lib/frame.js +1435 -0
  193. package/dist/lib/frame.js.map +1 -0
  194. package/dist/lib/hardware-device-context.d.ts +362 -0
  195. package/dist/lib/hardware-device-context.js +383 -0
  196. package/dist/lib/hardware-device-context.js.map +1 -0
  197. package/dist/lib/hardware-frames-context.d.ts +419 -0
  198. package/dist/lib/hardware-frames-context.js +477 -0
  199. package/dist/lib/hardware-frames-context.js.map +1 -0
  200. package/dist/lib/index.d.ts +35 -0
  201. package/dist/lib/index.js +60 -0
  202. package/dist/lib/index.js.map +1 -0
  203. package/dist/lib/input-format.d.ts +249 -0
  204. package/dist/lib/input-format.js +306 -0
  205. package/dist/lib/input-format.js.map +1 -0
  206. package/dist/lib/io-context.d.ts +696 -0
  207. package/dist/lib/io-context.js +769 -0
  208. package/dist/lib/io-context.js.map +1 -0
  209. package/dist/lib/log.d.ts +174 -0
  210. package/dist/lib/log.js +184 -0
  211. package/dist/lib/log.js.map +1 -0
  212. package/dist/lib/native-types.d.ts +946 -0
  213. package/dist/lib/native-types.js +2 -0
  214. package/dist/lib/native-types.js.map +1 -0
  215. package/dist/lib/option.d.ts +927 -0
  216. package/dist/lib/option.js +1583 -0
  217. package/dist/lib/option.js.map +1 -0
  218. package/dist/lib/output-format.d.ts +180 -0
  219. package/dist/lib/output-format.js +213 -0
  220. package/dist/lib/output-format.js.map +1 -0
  221. package/dist/lib/packet.d.ts +501 -0
  222. package/dist/lib/packet.js +590 -0
  223. package/dist/lib/packet.js.map +1 -0
  224. package/dist/lib/rational.d.ts +251 -0
  225. package/dist/lib/rational.js +278 -0
  226. package/dist/lib/rational.js.map +1 -0
  227. package/dist/lib/software-resample-context.d.ts +552 -0
  228. package/dist/lib/software-resample-context.js +592 -0
  229. package/dist/lib/software-resample-context.js.map +1 -0
  230. package/dist/lib/software-scale-context.d.ts +344 -0
  231. package/dist/lib/software-scale-context.js +366 -0
  232. package/dist/lib/software-scale-context.js.map +1 -0
  233. package/dist/lib/stream.d.ts +379 -0
  234. package/dist/lib/stream.js +526 -0
  235. package/dist/lib/stream.js.map +1 -0
  236. package/dist/lib/sync-queue.d.ts +179 -0
  237. package/dist/lib/sync-queue.js +197 -0
  238. package/dist/lib/sync-queue.js.map +1 -0
  239. package/dist/lib/types.d.ts +34 -0
  240. package/dist/lib/types.js +2 -0
  241. package/dist/lib/types.js.map +1 -0
  242. package/dist/lib/utilities.d.ts +1127 -0
  243. package/dist/lib/utilities.js +1225 -0
  244. package/dist/lib/utilities.js.map +1 -0
  245. package/dist/utils/electron.d.ts +49 -0
  246. package/dist/utils/electron.js +63 -0
  247. package/dist/utils/electron.js.map +1 -0
  248. package/dist/utils/index.d.ts +4 -0
  249. package/dist/utils/index.js +5 -0
  250. package/dist/utils/index.js.map +1 -0
  251. package/install/check.js +121 -0
  252. package/install/ffmpeg.js +66 -0
  253. package/jellyfin-ffmpeg.patch +181 -0
  254. package/package.json +129 -0
@@ -0,0 +1,399 @@
1
+ import type { AVSampleFormat } from '../constants/constants.js';
2
+ import type { NativeAudioFifo, NativeWrapper } from './native-types.js';
3
+ /**
4
+ * Audio FIFO (First-In-First-Out) buffer for managing audio samples.
5
+ *
6
+ * Provides a thread-safe buffer for audio sample data, supporting both planar and interleaved formats.
7
+ * Automatically handles buffer reallocation when needed. Essential for audio resampling,
8
+ * format conversion, and buffering operations.
9
+ *
10
+ * Direct mapping to FFmpeg's AVAudioFifo.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { AudioFifo, FFmpegError } from 'node-av';
15
+ * import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
16
+ *
17
+ * // Create FIFO for stereo float planar audio
18
+ * const fifo = new AudioFifo();
19
+ * fifo.alloc(AV_SAMPLE_FMT_FLTP, 2, 4096);
20
+ *
21
+ * // Write samples
22
+ * const leftChannel = Buffer.alloc(1024 * 4); // 1024 float samples
23
+ * const rightChannel = Buffer.alloc(1024 * 4);
24
+ * const written = await fifo.write([leftChannel, rightChannel], 1024);
25
+ * FFmpegError.throwIfError(written, 'write');
26
+ *
27
+ * // Read samples when enough available
28
+ * if (fifo.size >= 512) {
29
+ * const outLeft = Buffer.alloc(512 * 4);
30
+ * const outRight = Buffer.alloc(512 * 4);
31
+ * const read = await fifo.read([outLeft, outRight], 512);
32
+ * FFmpegError.throwIfError(read, 'read');
33
+ * }
34
+ *
35
+ * // Cleanup
36
+ * fifo.free();
37
+ * ```
38
+ *
39
+ * @see [AudioFifo](https://ffmpeg.org/doxygen/trunk/structAVAudioFifo.html) - FFmpeg Doxygen
40
+ */
41
+ export declare class AudioFifo implements Disposable, NativeWrapper<NativeAudioFifo> {
42
+ private native;
43
+ constructor();
44
+ /**
45
+ * Number of samples currently in the FIFO.
46
+ *
47
+ * Direct mapping to av_audio_fifo_size().
48
+ */
49
+ get size(): number;
50
+ /**
51
+ * Number of samples that can be written without reallocation.
52
+ *
53
+ * Direct mapping to av_audio_fifo_space().
54
+ */
55
+ get space(): number;
56
+ /**
57
+ * Allocate an AVAudioFifo buffer.
58
+ *
59
+ * Creates a FIFO buffer for the specified audio format and size.
60
+ * The FIFO will automatically grow if more data is written than allocated.
61
+ *
62
+ * Direct mapping to av_audio_fifo_alloc().
63
+ *
64
+ * @param sampleFmt - Sample format (e.g., AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP)
65
+ *
66
+ * @param channels - Number of audio channels
67
+ *
68
+ * @param nbSamples - Initial buffer size in samples
69
+ *
70
+ * @throws {Error} If allocation fails (ENOMEM)
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * import { AudioFifo } from 'node-av';
75
+ * import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
76
+ *
77
+ * // For interleaved 16-bit stereo
78
+ * const fifo1 = new AudioFifo();
79
+ * fifo1.alloc(AV_SAMPLE_FMT_S16, 2, 4096);
80
+ *
81
+ * // For planar float 5.1 audio
82
+ * const fifo2 = new AudioFifo();
83
+ * fifo2.alloc(AV_SAMPLE_FMT_FLTP, 6, 8192);
84
+ * ```
85
+ *
86
+ * @see {@link realloc} To resize the FIFO
87
+ * @see {@link free} To release the FIFO
88
+ */
89
+ alloc(sampleFmt: AVSampleFormat, channels: number, nbSamples: number): void;
90
+ /**
91
+ * Free the FIFO buffer and all associated resources.
92
+ *
93
+ * After calling this, the FIFO is invalid and must be reallocated before use.
94
+ *
95
+ * Direct mapping to av_audio_fifo_free().
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * fifo.free();
100
+ * // FIFO is now invalid, must call alloc() before using again
101
+ * ```
102
+ *
103
+ * @see {@link Symbol.dispose} For automatic cleanup
104
+ * @see {@link alloc} To allocate
105
+ */
106
+ free(): void;
107
+ /**
108
+ * Write audio samples to the FIFO.
109
+ *
110
+ * Writes samples to the FIFO buffer. Automatically reallocates if more space is needed.
111
+ * For planar formats, provide an array of buffers (one per channel).
112
+ * For interleaved formats, provide a single buffer.
113
+ *
114
+ * Direct mapping to av_audio_fifo_write().
115
+ *
116
+ * @param data - Audio data buffer(s). Array for planar, single Buffer for interleaved
117
+ *
118
+ * @param nbSamples - Number of samples to write
119
+ *
120
+ * @returns Number of samples written, or negative AVERROR:
121
+ * - AVERROR_EINVAL: Invalid parameters
122
+ * - AVERROR_ENOMEM: Memory allocation failure
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * import { FFmpegError } from 'node-av';
127
+ *
128
+ * // Planar format (e.g., FLTP) - separate buffers per channel
129
+ * const leftData = Buffer.alloc(1024 * 4); // 1024 float samples
130
+ * const rightData = Buffer.alloc(1024 * 4);
131
+ * const written = await fifo.write([leftData, rightData], 1024);
132
+ * FFmpegError.throwIfError(written, 'write');
133
+ * console.log(`Wrote ${written} samples`);
134
+ *
135
+ * // Interleaved format (e.g., S16) - single buffer
136
+ * const interleavedData = Buffer.alloc(1024 * 2 * 2); // 1024 stereo S16 samples
137
+ * const written2 = await fifo.write(interleavedData, 1024);
138
+ * FFmpegError.throwIfError(written2, 'write');
139
+ * ```
140
+ *
141
+ * @see {@link read} To retrieve samples from FIFO
142
+ * @see {@link space} To check available space
143
+ */
144
+ write(data: Buffer | Buffer[], nbSamples: number): Promise<number>;
145
+ /**
146
+ * Write samples to the FIFO synchronously.
147
+ * Synchronous version of write.
148
+ *
149
+ * Adds audio samples to the FIFO buffer.
150
+ * The FIFO automatically handles format and layout conversions.
151
+ * Can write fewer samples than requested if space is limited.
152
+ *
153
+ * Direct mapping to av_audio_fifo_write().
154
+ *
155
+ * @param data - Audio data buffer(s). Array for planar, single Buffer for interleaved
156
+ *
157
+ * @param nbSamples - Number of samples to write per channel
158
+ *
159
+ * @returns Number of samples written, or negative AVERROR:
160
+ * - AVERROR_EINVAL: Invalid parameters
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * import { FFmpegError } from 'node-av';
165
+ *
166
+ * // Interleaved stereo data (2 channels * 1024 samples * 4 bytes)
167
+ * const buffer = Buffer.alloc(2 * 1024 * 4);
168
+ * // Fill with audio data...
169
+ *
170
+ * const written = fifo.writeSync(buffer, 1024);
171
+ * FFmpegError.throwIfError(written, 'writeSync');
172
+ * console.log(`Wrote ${written} samples`);
173
+ * ```
174
+ *
175
+ * @see {@link write} For async version
176
+ */
177
+ writeSync(data: Buffer | Buffer[], nbSamples: number): number;
178
+ /**
179
+ * Read and remove samples from the FIFO.
180
+ *
181
+ * Reads up to the specified number of samples from the FIFO.
182
+ * The samples are removed from the FIFO after reading.
183
+ * Buffers must be pre-allocated with sufficient size.
184
+ *
185
+ * Direct mapping to av_audio_fifo_read().
186
+ *
187
+ * @param data - Pre-allocated buffer(s) to read into. Array for planar, single Buffer for interleaved
188
+ *
189
+ * @param nbSamples - Maximum number of samples to read
190
+ *
191
+ * @returns Number of samples read, or negative AVERROR:
192
+ * - AVERROR_EINVAL: Invalid parameters
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * import { FFmpegError } from 'node-av';
197
+ *
198
+ * // Check available samples
199
+ * const available = fifo.size;
200
+ * if (available >= 1024) {
201
+ * // Planar format
202
+ * const leftOut = Buffer.alloc(1024 * 4);
203
+ * const rightOut = Buffer.alloc(1024 * 4);
204
+ * const read = await fifo.read([leftOut, rightOut], 1024);
205
+ * FFmpegError.throwIfError(read, 'read');
206
+ * console.log(`Read ${read} samples`);
207
+ * }
208
+ * ```
209
+ *
210
+ * @see {@link peek} To read without removing
211
+ * @see {@link size} To check available samples
212
+ */
213
+ read(data: Buffer | Buffer[], nbSamples: number): Promise<number>;
214
+ /**
215
+ * Read and remove samples from the FIFO synchronously.
216
+ * Synchronous version of read.
217
+ *
218
+ * Reads up to the specified number of samples from the FIFO.
219
+ * The samples are removed from the FIFO after reading.
220
+ * Buffers must be pre-allocated with sufficient size.
221
+ *
222
+ * Direct mapping to av_audio_fifo_read().
223
+ *
224
+ * @param data - Pre-allocated buffer(s) to read into. Array for planar, single Buffer for interleaved
225
+ *
226
+ * @param nbSamples - Maximum number of samples to read
227
+ *
228
+ * @returns Number of samples read, or negative AVERROR:
229
+ * - AVERROR_EINVAL: Invalid parameters
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * import { FFmpegError } from 'node-av';
234
+ *
235
+ * // Read up to 1024 samples
236
+ * const readBuffer = Buffer.alloc(2 * 1024 * 4); // stereo float32
237
+ * const read = fifo.readSync(readBuffer, 1024);
238
+ * FFmpegError.throwIfError(read, 'readSync');
239
+ *
240
+ * console.log(`Read ${read} samples from FIFO`);
241
+ * console.log(`FIFO now has ${fifo.size} samples remaining`);
242
+ * ```
243
+ *
244
+ * @see {@link read} For async version
245
+ */
246
+ readSync(data: Buffer | Buffer[], nbSamples: number): number;
247
+ /**
248
+ * Read samples from the FIFO without removing them.
249
+ *
250
+ * Similar to read() but leaves the samples in the FIFO.
251
+ * Useful for inspecting upcoming data without consuming it.
252
+ *
253
+ * Direct mapping to av_audio_fifo_peek().
254
+ *
255
+ * @param data - Pre-allocated buffer(s) to peek into. Array for planar, single Buffer for interleaved
256
+ *
257
+ * @param nbSamples - Maximum number of samples to peek
258
+ *
259
+ * @returns Number of samples peeked, or negative AVERROR:
260
+ * - AVERROR_EINVAL: Invalid parameters
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * import { FFmpegError } from 'node-av';
265
+ *
266
+ * // Peek at next samples without removing them
267
+ * const peekBuffer = Buffer.alloc(256 * 4);
268
+ * const peeked = await fifo.peek(peekBuffer, 256);
269
+ * FFmpegError.throwIfError(peeked, 'peek');
270
+ *
271
+ * // Samples are still in FIFO
272
+ * console.log(`FIFO still has ${fifo.size} samples`);
273
+ * ```
274
+ *
275
+ * @see {@link read} To read and remove samples
276
+ */
277
+ peek(data: Buffer | Buffer[], nbSamples: number): Promise<number>;
278
+ /**
279
+ * Read samples from the FIFO without removing them synchronously.
280
+ * Synchronous version of peek.
281
+ *
282
+ * Similar to readSync() but leaves the samples in the FIFO.
283
+ * Useful for inspecting upcoming data without consuming it.
284
+ *
285
+ * Direct mapping to av_audio_fifo_peek().
286
+ *
287
+ * @param data - Pre-allocated buffer(s) to peek into. Array for planar, single Buffer for interleaved
288
+ *
289
+ * @param nbSamples - Maximum number of samples to peek
290
+ *
291
+ * @returns Number of samples peeked, or negative AVERROR:
292
+ * - AVERROR_EINVAL: Invalid parameters
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * import { FFmpegError } from 'node-av';
297
+ *
298
+ * // Peek at next samples without removing them
299
+ * const peekBuffer = Buffer.alloc(256 * 4);
300
+ * const peeked = fifo.peekSync(peekBuffer, 256);
301
+ * FFmpegError.throwIfError(peeked, 'peekSync');
302
+ *
303
+ * // Samples are still in FIFO
304
+ * console.log(`FIFO still has ${fifo.size} samples`);
305
+ * ```
306
+ *
307
+ * @see {@link peek} For async version
308
+ */
309
+ peekSync(data: Buffer | Buffer[], nbSamples: number): number;
310
+ /**
311
+ * Remove samples from the FIFO without reading them.
312
+ *
313
+ * Discards the specified number of samples from the FIFO.
314
+ * Useful for skipping unwanted audio data.
315
+ *
316
+ * Direct mapping to av_audio_fifo_drain().
317
+ *
318
+ * @param nbSamples - Number of samples to discard
319
+ *
320
+ * @example
321
+ * ```typescript
322
+ * // Skip 100 samples
323
+ * fifo.drain(100);
324
+ * console.log(`FIFO now has ${fifo.size} samples`);
325
+ * ```
326
+ *
327
+ * @see {@link reset} To remove all samples
328
+ */
329
+ drain(nbSamples: number): void;
330
+ /**
331
+ * Remove all samples from the FIFO.
332
+ *
333
+ * Empties the FIFO buffer without deallocating it.
334
+ * The FIFO remains allocated and ready for new data.
335
+ *
336
+ * Direct mapping to av_audio_fifo_reset().
337
+ *
338
+ * @example
339
+ * ```typescript
340
+ * fifo.reset();
341
+ * console.log(fifo.size); // 0
342
+ * console.log(fifo.space); // Original allocation size
343
+ * ```
344
+ *
345
+ * @see {@link drain} To remove specific number of samples
346
+ */
347
+ reset(): void;
348
+ /**
349
+ * Resize the FIFO buffer.
350
+ *
351
+ * Changes the allocated size of the FIFO. Can grow or shrink the buffer.
352
+ * Existing samples are preserved up to the new size.
353
+ *
354
+ * Direct mapping to av_audio_fifo_realloc().
355
+ *
356
+ * @param nbSamples - New allocation size in samples
357
+ *
358
+ * @returns 0 on success, negative AVERROR on error:
359
+ * - AVERROR_EINVAL: Invalid size
360
+ * - AVERROR_ENOMEM: Memory allocation failure
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * import { FFmpegError } from 'node-av';
365
+ *
366
+ * // Grow FIFO to handle larger buffers
367
+ * const ret = fifo.realloc(16384);
368
+ * FFmpegError.throwIfError(ret, 'realloc');
369
+ * console.log(`New space: ${fifo.space} samples`);
370
+ * ```
371
+ *
372
+ * @see {@link alloc} For initial allocation
373
+ */
374
+ realloc(nbSamples: number): number;
375
+ /**
376
+ * Get the underlying native AudioFifo object.
377
+ *
378
+ * @returns The native AudioFifo binding object
379
+ *
380
+ * @internal
381
+ */
382
+ getNative(): NativeAudioFifo;
383
+ /**
384
+ * Dispose of the audio FIFO buffer.
385
+ *
386
+ * Implements the Disposable interface for automatic cleanup.
387
+ * Equivalent to calling free().
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * {
392
+ * using fifo = new AudioFifo();
393
+ * fifo.alloc(AV_SAMPLE_FMT_FLTP, 2, 4096);
394
+ * // Use fifo...
395
+ * } // Automatically freed when leaving scope
396
+ * ```
397
+ */
398
+ [Symbol.dispose](): void;
399
+ }