node-av 0.0.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 (175) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +377 -0
  4. package/binding.gyp +78 -0
  5. package/dist/api/bitstream-filter.d.ts +246 -0
  6. package/dist/api/bitstream-filter.js +369 -0
  7. package/dist/api/bitstream-filter.js.map +1 -0
  8. package/dist/api/decoder.d.ts +257 -0
  9. package/dist/api/decoder.js +424 -0
  10. package/dist/api/decoder.js.map +1 -0
  11. package/dist/api/encoder.d.ts +298 -0
  12. package/dist/api/encoder.js +574 -0
  13. package/dist/api/encoder.js.map +1 -0
  14. package/dist/api/filter.d.ts +457 -0
  15. package/dist/api/filter.js +876 -0
  16. package/dist/api/filter.js.map +1 -0
  17. package/dist/api/hardware.d.ts +318 -0
  18. package/dist/api/hardware.js +558 -0
  19. package/dist/api/hardware.js.map +1 -0
  20. package/dist/api/index.d.ts +12 -0
  21. package/dist/api/index.js +20 -0
  22. package/dist/api/index.js.map +1 -0
  23. package/dist/api/io-stream.d.ts +109 -0
  24. package/dist/api/io-stream.js +124 -0
  25. package/dist/api/io-stream.js.map +1 -0
  26. package/dist/api/media-input.d.ts +295 -0
  27. package/dist/api/media-input.js +456 -0
  28. package/dist/api/media-input.js.map +1 -0
  29. package/dist/api/media-output.d.ts +274 -0
  30. package/dist/api/media-output.js +486 -0
  31. package/dist/api/media-output.js.map +1 -0
  32. package/dist/api/pipeline.d.ts +117 -0
  33. package/dist/api/pipeline.js +836 -0
  34. package/dist/api/pipeline.js.map +1 -0
  35. package/dist/api/types.d.ts +440 -0
  36. package/dist/api/types.js +2 -0
  37. package/dist/api/types.js.map +1 -0
  38. package/dist/api/utilities/audio-sample.d.ts +115 -0
  39. package/dist/api/utilities/audio-sample.js +110 -0
  40. package/dist/api/utilities/audio-sample.js.map +1 -0
  41. package/dist/api/utilities/channel-layout.d.ts +83 -0
  42. package/dist/api/utilities/channel-layout.js +87 -0
  43. package/dist/api/utilities/channel-layout.js.map +1 -0
  44. package/dist/api/utilities/image.d.ts +177 -0
  45. package/dist/api/utilities/image.js +183 -0
  46. package/dist/api/utilities/image.js.map +1 -0
  47. package/dist/api/utilities/index.d.ts +8 -0
  48. package/dist/api/utilities/index.js +17 -0
  49. package/dist/api/utilities/index.js.map +1 -0
  50. package/dist/api/utilities/media-type.d.ts +56 -0
  51. package/dist/api/utilities/media-type.js +60 -0
  52. package/dist/api/utilities/media-type.js.map +1 -0
  53. package/dist/api/utilities/pixel-format.d.ts +94 -0
  54. package/dist/api/utilities/pixel-format.js +102 -0
  55. package/dist/api/utilities/pixel-format.js.map +1 -0
  56. package/dist/api/utilities/sample-format.d.ts +132 -0
  57. package/dist/api/utilities/sample-format.js +144 -0
  58. package/dist/api/utilities/sample-format.js.map +1 -0
  59. package/dist/api/utilities/streaming.d.ts +104 -0
  60. package/dist/api/utilities/streaming.js +137 -0
  61. package/dist/api/utilities/streaming.js.map +1 -0
  62. package/dist/api/utilities/timestamp.d.ts +187 -0
  63. package/dist/api/utilities/timestamp.js +200 -0
  64. package/dist/api/utilities/timestamp.js.map +1 -0
  65. package/dist/api/utils.d.ts +61 -0
  66. package/dist/api/utils.js +330 -0
  67. package/dist/api/utils.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +5 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/lib/audio-fifo.d.ts +339 -0
  72. package/dist/lib/audio-fifo.js +365 -0
  73. package/dist/lib/audio-fifo.js.map +1 -0
  74. package/dist/lib/binding.d.ts +192 -0
  75. package/dist/lib/binding.js +70 -0
  76. package/dist/lib/binding.js.map +1 -0
  77. package/dist/lib/bitstream-filter-context.d.ts +345 -0
  78. package/dist/lib/bitstream-filter-context.js +407 -0
  79. package/dist/lib/bitstream-filter-context.js.map +1 -0
  80. package/dist/lib/bitstream-filter.d.ts +124 -0
  81. package/dist/lib/bitstream-filter.js +138 -0
  82. package/dist/lib/bitstream-filter.js.map +1 -0
  83. package/dist/lib/channel-layouts.d.ts +51 -0
  84. package/dist/lib/channel-layouts.js +55 -0
  85. package/dist/lib/channel-layouts.js.map +1 -0
  86. package/dist/lib/codec-context.d.ts +763 -0
  87. package/dist/lib/codec-context.js +974 -0
  88. package/dist/lib/codec-context.js.map +1 -0
  89. package/dist/lib/codec-parameters.d.ts +362 -0
  90. package/dist/lib/codec-parameters.js +460 -0
  91. package/dist/lib/codec-parameters.js.map +1 -0
  92. package/dist/lib/codec-parser.d.ts +185 -0
  93. package/dist/lib/codec-parser.js +193 -0
  94. package/dist/lib/codec-parser.js.map +1 -0
  95. package/dist/lib/codec.d.ts +432 -0
  96. package/dist/lib/codec.js +492 -0
  97. package/dist/lib/codec.js.map +1 -0
  98. package/dist/lib/constants.d.ts +2037 -0
  99. package/dist/lib/constants.js +1659 -0
  100. package/dist/lib/constants.js.map +1 -0
  101. package/dist/lib/dictionary.d.ts +371 -0
  102. package/dist/lib/dictionary.js +406 -0
  103. package/dist/lib/dictionary.js.map +1 -0
  104. package/dist/lib/error.d.ts +216 -0
  105. package/dist/lib/error.js +254 -0
  106. package/dist/lib/error.js.map +1 -0
  107. package/dist/lib/filter-context.d.ts +445 -0
  108. package/dist/lib/filter-context.js +505 -0
  109. package/dist/lib/filter-context.js.map +1 -0
  110. package/dist/lib/filter-graph.d.ts +556 -0
  111. package/dist/lib/filter-graph.js +608 -0
  112. package/dist/lib/filter-graph.js.map +1 -0
  113. package/dist/lib/filter-inout.d.ts +205 -0
  114. package/dist/lib/filter-inout.js +264 -0
  115. package/dist/lib/filter-inout.js.map +1 -0
  116. package/dist/lib/filter.d.ts +231 -0
  117. package/dist/lib/filter.js +260 -0
  118. package/dist/lib/filter.js.map +1 -0
  119. package/dist/lib/format-context.d.ts +798 -0
  120. package/dist/lib/format-context.js +845 -0
  121. package/dist/lib/format-context.js.map +1 -0
  122. package/dist/lib/frame.d.ts +784 -0
  123. package/dist/lib/frame.js +933 -0
  124. package/dist/lib/frame.js.map +1 -0
  125. package/dist/lib/hardware-device-context.d.ts +407 -0
  126. package/dist/lib/hardware-device-context.js +429 -0
  127. package/dist/lib/hardware-device-context.js.map +1 -0
  128. package/dist/lib/hardware-frames-context.d.ts +374 -0
  129. package/dist/lib/hardware-frames-context.js +430 -0
  130. package/dist/lib/hardware-frames-context.js.map +1 -0
  131. package/dist/lib/index.d.ts +31 -0
  132. package/dist/lib/index.js +54 -0
  133. package/dist/lib/index.js.map +1 -0
  134. package/dist/lib/input-format.d.ts +216 -0
  135. package/dist/lib/input-format.js +246 -0
  136. package/dist/lib/input-format.js.map +1 -0
  137. package/dist/lib/io-context.d.ts +495 -0
  138. package/dist/lib/io-context.js +550 -0
  139. package/dist/lib/io-context.js.map +1 -0
  140. package/dist/lib/log.d.ts +201 -0
  141. package/dist/lib/log.js +219 -0
  142. package/dist/lib/log.js.map +1 -0
  143. package/dist/lib/native-types.d.ts +719 -0
  144. package/dist/lib/native-types.js +2 -0
  145. package/dist/lib/native-types.js.map +1 -0
  146. package/dist/lib/option.d.ts +589 -0
  147. package/dist/lib/option.js +853 -0
  148. package/dist/lib/option.js.map +1 -0
  149. package/dist/lib/output-format.d.ts +179 -0
  150. package/dist/lib/output-format.js +205 -0
  151. package/dist/lib/output-format.js.map +1 -0
  152. package/dist/lib/packet.d.ts +487 -0
  153. package/dist/lib/packet.js +558 -0
  154. package/dist/lib/packet.js.map +1 -0
  155. package/dist/lib/rational.d.ts +210 -0
  156. package/dist/lib/rational.js +233 -0
  157. package/dist/lib/rational.js.map +1 -0
  158. package/dist/lib/software-resample-context.d.ts +572 -0
  159. package/dist/lib/software-resample-context.js +610 -0
  160. package/dist/lib/software-resample-context.js.map +1 -0
  161. package/dist/lib/software-scale-context.d.ts +290 -0
  162. package/dist/lib/software-scale-context.js +308 -0
  163. package/dist/lib/software-scale-context.js.map +1 -0
  164. package/dist/lib/stream.d.ts +322 -0
  165. package/dist/lib/stream.js +408 -0
  166. package/dist/lib/stream.js.map +1 -0
  167. package/dist/lib/types.d.ts +59 -0
  168. package/dist/lib/types.js +8 -0
  169. package/dist/lib/types.js.map +1 -0
  170. package/dist/lib/utilities.d.ts +346 -0
  171. package/dist/lib/utilities.js +424 -0
  172. package/dist/lib/utilities.js.map +1 -0
  173. package/install/check.js +113 -0
  174. package/install/ffmpeg.js +163 -0
  175. package/package.json +107 -0
@@ -0,0 +1,430 @@
1
+ import { bindings } from './binding.js';
2
+ import { HardwareDeviceContext } from './hardware-device-context.js';
3
+ /**
4
+ * Hardware frames context for GPU memory management.
5
+ *
6
+ * Manages pools of hardware frames for efficient GPU memory allocation.
7
+ * Handles format conversions and data transfers between CPU and GPU memory.
8
+ * Required for hardware-accelerated video processing pipelines.
9
+ *
10
+ * Direct mapping to FFmpeg's AVHWFramesContext.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { HardwareDeviceContext, HardwareFramesContext, Frame, FFmpegError } from 'node-av';
15
+ * import { AV_HWDEVICE_TYPE_CUDA, AV_PIX_FMT_CUDA, AV_PIX_FMT_NV12 } from 'node-av/constants';
16
+ *
17
+ * // Create hardware frames context
18
+ * const device = new HardwareDeviceContext();
19
+ * const deviceRet = device.create(AV_HWDEVICE_TYPE_CUDA, null, null);
20
+ * FFmpegError.throwIfError(deviceRet, 'create device');
21
+ *
22
+ * const frames = new HardwareFramesContext();
23
+ * frames.alloc(device);
24
+ *
25
+ * // Configure frame parameters
26
+ * frames.format = AV_PIX_FMT_CUDA; // Hardware format
27
+ * frames.swFormat = AV_PIX_FMT_NV12; // Software format
28
+ * frames.width = 1920;
29
+ * frames.height = 1080;
30
+ * frames.initialPoolSize = 10;
31
+ *
32
+ * // Initialize the context
33
+ * const ret = frames.init();
34
+ * FFmpegError.throwIfError(ret, 'init frames');
35
+ *
36
+ * // Allocate hardware frame
37
+ * const hwFrame = new Frame();
38
+ * hwFrame.alloc();
39
+ * const ret2 = frames.getBuffer(hwFrame, 0);
40
+ * FFmpegError.throwIfError(ret2, 'getBuffer');
41
+ *
42
+ * // Transfer between hardware and software
43
+ * const swFrame = new Frame();
44
+ * swFrame.alloc();
45
+ * swFrame.width = 1920;
46
+ * swFrame.height = 1080;
47
+ * swFrame.format = AV_PIX_FMT_NV12;
48
+ * const swRet = swFrame.getBuffer();
49
+ * FFmpegError.throwIfError(swRet, 'getBuffer sw');
50
+ *
51
+ * // Download from hardware
52
+ * const dlRet = await frames.transferData(swFrame, hwFrame, 0);
53
+ * FFmpegError.throwIfError(dlRet, 'download');
54
+ *
55
+ * // Upload to hardware
56
+ * const ulRet = await frames.transferData(hwFrame, swFrame, 0);
57
+ * FFmpegError.throwIfError(ulRet, 'upload');
58
+ *
59
+ * // Cleanup
60
+ * hwFrame.free();
61
+ * swFrame.free();
62
+ * frames.free();
63
+ * device.free();
64
+ * ```
65
+ *
66
+ * @see {@link HardwareDeviceContext} For device management
67
+ * @see {@link Frame} For frame allocation
68
+ */
69
+ export class HardwareFramesContext {
70
+ native;
71
+ _deviceRef; // Cache for device context wrapper
72
+ /**
73
+ * Create a new hardware frames context.
74
+ *
75
+ * The context is uninitialized - you must call alloc() before use.
76
+ * No FFmpeg resources are allocated until initialization.
77
+ *
78
+ * Direct wrapper around AVHWFramesContext.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * import { HardwareFramesContext, FFmpegError } from 'node-av';
83
+ *
84
+ * const frames = new HardwareFramesContext();
85
+ * frames.alloc(device);
86
+ * // Configure parameters
87
+ * const ret = frames.init();
88
+ * FFmpegError.throwIfError(ret, 'init');
89
+ * ```
90
+ */
91
+ constructor() {
92
+ this.native = new bindings.HardwareFramesContext();
93
+ }
94
+ /**
95
+ * Hardware pixel format.
96
+ *
97
+ * The pixel format identifying the underlying HW surface type.
98
+ *
99
+ * Direct mapping to AVHWFramesContext->format
100
+ */
101
+ get format() {
102
+ return this.native.format;
103
+ }
104
+ set format(value) {
105
+ this.native.format = value;
106
+ }
107
+ /**
108
+ * Software pixel format.
109
+ *
110
+ * The pixel format identifying the actual data layout of the hardware frames.
111
+ *
112
+ * Direct mapping to AVHWFramesContext->sw_format
113
+ */
114
+ get swFormat() {
115
+ return this.native.swFormat;
116
+ }
117
+ set swFormat(value) {
118
+ this.native.swFormat = value;
119
+ }
120
+ /**
121
+ * Frame width.
122
+ *
123
+ * The allocated dimensions of the frames in this pool.
124
+ *
125
+ * Direct mapping to AVHWFramesContext->width
126
+ */
127
+ get width() {
128
+ return this.native.width;
129
+ }
130
+ set width(value) {
131
+ this.native.width = value;
132
+ }
133
+ /**
134
+ * Frame height.
135
+ *
136
+ * The allocated dimensions of the frames in this pool.
137
+ *
138
+ * Direct mapping to AVHWFramesContext->height
139
+ */
140
+ get height() {
141
+ return this.native.height;
142
+ }
143
+ set height(value) {
144
+ this.native.height = value;
145
+ }
146
+ /**
147
+ * Initial pool size.
148
+ *
149
+ * Initial size of the frame pool. If a device type does not support
150
+ * dynamically resizing the pool, then this is also the maximum pool size.
151
+ */
152
+ get initialPoolSize() {
153
+ return this.native.initialPoolSize;
154
+ }
155
+ set initialPoolSize(value) {
156
+ this.native.initialPoolSize = value;
157
+ }
158
+ /**
159
+ * Associated device context.
160
+ *
161
+ * Direct mapping to AVHWFramesContext->device_ref
162
+ *
163
+ * @readonly
164
+ */
165
+ get deviceRef() {
166
+ // Return cached wrapper if we already have one
167
+ if (this._deviceRef !== undefined) {
168
+ return this._deviceRef;
169
+ }
170
+ const native = this.native.deviceRef;
171
+ if (!native) {
172
+ this._deviceRef = null;
173
+ return null;
174
+ }
175
+ // Create and cache the wrapper
176
+ const device = Object.create(HardwareDeviceContext.prototype);
177
+ device.native = native;
178
+ this._deviceRef = device;
179
+ return device;
180
+ }
181
+ /**
182
+ * Allocate an AVHWFramesContext tied to a given device context.
183
+ *
184
+ * Direct mapping to av_hwframe_ctx_alloc()
185
+ *
186
+ * @param device - Hardware device context
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const frames = new HardwareFramesContext();
191
+ * frames.alloc(device);
192
+ * // Set parameters before init()
193
+ * frames.format = AV_PIX_FMT_CUDA;
194
+ * frames.swFormat = AV_PIX_FMT_NV12;
195
+ * frames.width = 1920;
196
+ * frames.height = 1080;
197
+ * ```
198
+ *
199
+ * @throws {Error} If allocation fails
200
+ */
201
+ alloc(device) {
202
+ this.native.alloc(device.getNative());
203
+ }
204
+ /**
205
+ * Finalize the context before use.
206
+ *
207
+ * Direct mapping to av_hwframe_ctx_init()
208
+ *
209
+ * @returns 0 on success, negative AVERROR on error:
210
+ * - 0: Success
211
+ * - AVERROR(EINVAL): Invalid parameters
212
+ * - AVERROR(ENOMEM): Memory allocation failure
213
+ * - <0: Device-specific errors
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const ret = frames.init();
218
+ * if (ret < 0) {
219
+ * throw new FFmpegError(ret);
220
+ * }
221
+ * ```
222
+ */
223
+ init() {
224
+ return this.native.init();
225
+ }
226
+ /**
227
+ * Free the frames context.
228
+ *
229
+ * Unreferences the AVBufferRef.
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * frames.free();
234
+ * // frames is now invalid and should not be used
235
+ * ```
236
+ */
237
+ free() {
238
+ this.native.free();
239
+ }
240
+ /**
241
+ * Allocate a new frame attached to the given AVHWFramesContext.
242
+ *
243
+ * Direct mapping to av_hwframe_get_buffer()
244
+ *
245
+ * @param frame - Frame to allocate (must be allocated but empty)
246
+ * @param flags - Currently unused, should be set to 0
247
+ *
248
+ * @returns 0 on success, negative AVERROR on error:
249
+ * - 0: Success
250
+ * - AVERROR(EINVAL): Invalid parameters
251
+ * - AVERROR(ENOMEM): Memory allocation failure
252
+ * - <0: Device-specific errors
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * const frame = new Frame();
257
+ * frame.alloc();
258
+ * const ret = frames.getBuffer(frame, 0);
259
+ * if (ret < 0) {
260
+ * throw new FFmpegError(ret);
261
+ * }
262
+ * // frame now contains a hardware frame
263
+ * ```
264
+ */
265
+ getBuffer(frame, flags) {
266
+ return this.native.getBuffer(frame.getNative(), flags ?? 0);
267
+ }
268
+ /**
269
+ * Copy data to or from a hardware surface.
270
+ *
271
+ * Direct mapping to av_hwframe_transfer_data()
272
+ *
273
+ * @param dst - Destination frame
274
+ * @param src - Source frame
275
+ * @param flags - Currently unused, should be set to 0
276
+ *
277
+ * @returns Promise resolving to 0 on success, negative AVERROR on error:
278
+ * - 0: Success
279
+ * - AVERROR(ENOSYS): Transfer not supported
280
+ * - AVERROR(EINVAL): Invalid parameters
281
+ * - <0: Other errors
282
+ *
283
+ * @example
284
+ * ```typescript
285
+ * // Download from hardware to software
286
+ * const ret = await frames.transferData(swFrame, hwFrame, 0);
287
+ * if (ret < 0) {
288
+ * throw new FFmpegError(ret);
289
+ * }
290
+ *
291
+ * // Upload from software to hardware
292
+ * const ret2 = await frames.transferData(hwFrame, swFrame, 0);
293
+ * if (ret2 < 0) {
294
+ * throw new FFmpegError(ret2);
295
+ * }
296
+ * ```
297
+ */
298
+ async transferData(dst, src, flags) {
299
+ return this.native.transferData(dst.getNative(), src.getNative(), flags ?? 0);
300
+ }
301
+ /**
302
+ * Get a list of possible source/target formats.
303
+ *
304
+ * Direct mapping to av_hwframe_transfer_get_formats()
305
+ *
306
+ * @param direction - Transfer direction (AV_HWFRAME_TRANSFER_DIRECTION_*)
307
+ *
308
+ * @returns Array of pixel formats or error code:
309
+ * - Array: List of supported formats
310
+ * - <0: AVERROR on failure
311
+ *
312
+ * @example
313
+ * ```typescript
314
+ * // Get formats for downloading from hardware
315
+ * const formats = frames.transferGetFormats(AV_HWFRAME_TRANSFER_DIRECTION_FROM);
316
+ * if (Array.isArray(formats)) {
317
+ * console.log('Supported download formats:', formats);
318
+ * }
319
+ *
320
+ * // Get formats for uploading to hardware
321
+ * const formats2 = frames.transferGetFormats(AV_HWFRAME_TRANSFER_DIRECTION_TO);
322
+ * if (Array.isArray(formats2)) {
323
+ * console.log('Supported upload formats:', formats2);
324
+ * }
325
+ * ```
326
+ */
327
+ transferGetFormats(direction) {
328
+ return this.native.transferGetFormats(direction);
329
+ }
330
+ /**
331
+ * Map a hardware frame.
332
+ *
333
+ * Direct mapping to av_hwframe_map()
334
+ *
335
+ * This has a number of different possible effects, depending on the format
336
+ * and origin of the src and dst frames. On input, src should be a usable
337
+ * frame with valid hardware/software format and allocated data.
338
+ *
339
+ * @param dst - Destination frame
340
+ * @param src - Source frame to map
341
+ * @param flags - Combination of AV_HWFRAME_MAP_* flags
342
+ *
343
+ * @returns 0 on success, negative AVERROR on error:
344
+ * - 0: Success
345
+ * - AVERROR(ENOSYS): Mapping not supported
346
+ * - AVERROR(EINVAL): Invalid parameters
347
+ * - <0: Other errors
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * const mappedFrame = new Frame();
352
+ * mappedFrame.alloc();
353
+ * const ret = frames.map(mappedFrame, hwFrame, AV_HWFRAME_MAP_READ);
354
+ * if (ret < 0) {
355
+ * throw new FFmpegError(ret);
356
+ * }
357
+ * // mappedFrame now provides CPU access to hwFrame
358
+ * ```
359
+ */
360
+ map(dst, src, flags) {
361
+ return this.native.map(dst.getNative(), src.getNative(), flags ?? 0);
362
+ }
363
+ /**
364
+ * Create a new frame context derived from an existing one.
365
+ *
366
+ * Direct mapping to av_hwframe_ctx_create_derived()
367
+ *
368
+ * @param format - Pixel format for the derived context
369
+ * @param derivedDevice - Device context for the derived frames
370
+ * @param source - Source frames context
371
+ * @param flags - Currently unused, should be 0
372
+ *
373
+ * @returns 0 on success, negative AVERROR on error:
374
+ * - 0: Success
375
+ * - AVERROR(ENOSYS): Derivation not supported
376
+ * - AVERROR(EINVAL): Invalid parameters
377
+ * - <0: Other errors
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * const derived = new HardwareFramesContext();
382
+ * const ret = derived.createDerived(
383
+ * AV_PIX_FMT_NV12,
384
+ * derivedDevice,
385
+ * sourceFrames,
386
+ * 0
387
+ * );
388
+ * if (ret < 0) {
389
+ * throw new FFmpegError(ret);
390
+ * }
391
+ * ```
392
+ */
393
+ createDerived(format, derivedDevice, source, flags) {
394
+ return this.native.createDerived(format, derivedDevice.getNative(), source.native, flags ?? 0);
395
+ }
396
+ /**
397
+ * Get the native FFmpeg AVHWFramesContext pointer.
398
+ *
399
+ * @internal For use by other wrapper classes
400
+ * @returns The underlying native hardware frames context object
401
+ */
402
+ getNative() {
403
+ return this.native;
404
+ }
405
+ /**
406
+ * Dispose of the hardware frames context.
407
+ *
408
+ * Implements the Disposable interface for automatic cleanup.
409
+ * Equivalent to calling free().
410
+ *
411
+ * @example
412
+ * ```typescript
413
+ * import { HardwareFramesContext, FFmpegError } from 'node-av';
414
+ *
415
+ * {
416
+ * using frames = new HardwareFramesContext();
417
+ * frames.alloc(device);
418
+ * const ret = frames.init();
419
+ * FFmpegError.throwIfError(ret, 'init');
420
+ * // ... use frames
421
+ * } // Automatically freed when leaving scope
422
+ * ```
423
+ *
424
+ * @see {@link free} For manual cleanup
425
+ */
426
+ [Symbol.dispose]() {
427
+ this.native[Symbol.dispose]();
428
+ }
429
+ }
430
+ //# sourceMappingURL=hardware-frames-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hardware-frames-context.js","sourceRoot":"","sources":["../../src/lib/hardware-frames-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAMrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAA8B;IACpC,UAAU,CAAgC,CAAC,mCAAmC;IAEtF;;;;;;;;;;;;;;;;;;OAkBG;IACH;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAC,qBAAqB,EAAE,CAAC;IACrD,CAAC;IAED;;;;;;OAMG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,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AAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,GAAG,CAAC,SAAS,EAAE,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,aAAa,CAAC,MAAqB,EAAE,aAAoC,EAAE,MAA6B,EAAE,KAAc;QACtH,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IACjG,CAAC;IAED;;;;;OAKG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ export * from './channel-layouts.js';
2
+ export * from './constants.js';
3
+ export type * from './types.js';
4
+ export { FormatContext } from './format-context.js';
5
+ export { CodecContext } from './codec-context.js';
6
+ export { CodecParameters } from './codec-parameters.js';
7
+ export { Codec } from './codec.js';
8
+ export { CodecParser } from './codec-parser.js';
9
+ export { Packet } from './packet.js';
10
+ export { Frame } from './frame.js';
11
+ export { Stream } from './stream.js';
12
+ export { InputFormat } from './input-format.js';
13
+ export { OutputFormat } from './output-format.js';
14
+ export { HardwareDeviceContext } from './hardware-device-context.js';
15
+ export { HardwareFramesContext } from './hardware-frames-context.js';
16
+ export { SoftwareScaleContext } from './software-scale-context.js';
17
+ export { SoftwareResampleContext } from './software-resample-context.js';
18
+ export { AudioFifo } from './audio-fifo.js';
19
+ export { IOContext } from './io-context.js';
20
+ export { Dictionary } from './dictionary.js';
21
+ export { FilterContext } from './filter-context.js';
22
+ export { FilterGraph } from './filter-graph.js';
23
+ export { FilterInOut } from './filter-inout.js';
24
+ export { Filter } from './filter.js';
25
+ export { BitStreamFilterContext } from './bitstream-filter-context.js';
26
+ export { BitStreamFilter } from './bitstream-filter.js';
27
+ export { Rational } from './rational.js';
28
+ export { Log } from './log.js';
29
+ export { FFmpegError } from './error.js';
30
+ export * from './utilities.js';
31
+ export { Option, OptionInfo } from './option.js';
@@ -0,0 +1,54 @@
1
+ // Export all generated constants and types
2
+ export * from './channel-layouts.js';
3
+ export * from './constants.js';
4
+ // Format Context
5
+ export { FormatContext } from './format-context.js';
6
+ // Codec Context
7
+ export { CodecContext } from './codec-context.js';
8
+ // Codec Parameters
9
+ export { CodecParameters } from './codec-parameters.js';
10
+ // Codec
11
+ export { Codec } from './codec.js';
12
+ // Codec Parser
13
+ export { CodecParser } from './codec-parser.js';
14
+ // Packet
15
+ export { Packet } from './packet.js';
16
+ // Frame
17
+ export { Frame } from './frame.js';
18
+ // Stream
19
+ export { Stream } from './stream.js';
20
+ // Input/Output Format
21
+ export { InputFormat } from './input-format.js';
22
+ export { OutputFormat } from './output-format.js';
23
+ // Hardware related classes
24
+ export { HardwareDeviceContext } from './hardware-device-context.js';
25
+ export { HardwareFramesContext } from './hardware-frames-context.js';
26
+ // Software Scale
27
+ export { SoftwareScaleContext } from './software-scale-context.js';
28
+ // Software Resample
29
+ export { SoftwareResampleContext } from './software-resample-context.js';
30
+ // Audio FIFO
31
+ export { AudioFifo } from './audio-fifo.js';
32
+ // I/O Context
33
+ export { IOContext } from './io-context.js';
34
+ // Dictionary
35
+ export { Dictionary } from './dictionary.js';
36
+ // Filter related classes
37
+ export { FilterContext } from './filter-context.js';
38
+ export { FilterGraph } from './filter-graph.js';
39
+ export { FilterInOut } from './filter-inout.js';
40
+ export { Filter } from './filter.js';
41
+ // Bitstream Filter related classes
42
+ export { BitStreamFilterContext } from './bitstream-filter-context.js';
43
+ export { BitStreamFilter } from './bitstream-filter.js';
44
+ // Utils
45
+ export { Rational } from './rational.js';
46
+ // Logging
47
+ export { Log } from './log.js';
48
+ // FFmpegError
49
+ export { FFmpegError } from './error.js';
50
+ // Utilities
51
+ export * from './utilities.js';
52
+ // Option
53
+ export { Option, OptionInfo } from './option.js';
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAG/B,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,QAAQ;AACR,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,QAAQ;AACR,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,sBAAsB;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,2BAA2B;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,iBAAiB;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,oBAAoB;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,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