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,429 @@
1
+ import { bindings } from './binding.js';
2
+ /**
3
+ * Hardware device context for hardware acceleration.
4
+ *
5
+ * Manages hardware acceleration devices like CUDA, VAAPI, DXVA2, etc.
6
+ * Provides device creation, configuration, and constraint querying.
7
+ * Required for hardware-accelerated encoding, decoding, and filtering.
8
+ *
9
+ * Direct mapping to FFmpeg's AVHWDeviceContext.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { HardwareDeviceContext, HardwareFramesContext, FFmpegError } from 'node-av';
14
+ * import { AV_HWDEVICE_TYPE_CUDA, AV_PIX_FMT_CUDA, AV_PIX_FMT_NV12 } from 'node-av/constants';
15
+ *
16
+ * // Create CUDA device context
17
+ * const device = new HardwareDeviceContext();
18
+ * const ret = device.create(AV_HWDEVICE_TYPE_CUDA, null, null);
19
+ * FFmpegError.throwIfError(ret, 'create device');
20
+ *
21
+ * // Get device constraints
22
+ * const constraints = device.getHwframeConstraints();
23
+ * console.log(`Max size: ${constraints.maxWidth}x${constraints.maxHeight}`);
24
+ *
25
+ * // Create frames context for this device
26
+ * const frames = new HardwareFramesContext();
27
+ * frames.alloc(device);
28
+ * frames.format = AV_PIX_FMT_CUDA;
29
+ * frames.swFormat = AV_PIX_FMT_NV12;
30
+ * frames.width = 1920;
31
+ * frames.height = 1080;
32
+ * const initRet = frames.init();
33
+ * FFmpegError.throwIfError(initRet, 'init frames');
34
+ *
35
+ * // Cleanup
36
+ * frames.free();
37
+ * device.free();
38
+ * ```
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * import { HardwareDeviceContext } from 'node-av';
43
+ * import { AV_HWDEVICE_TYPE_NONE } from 'node-av/constants';
44
+ *
45
+ * // List available hardware device types
46
+ * const types = HardwareDeviceContext.iterateTypes();
47
+ * for (const type of types) {
48
+ * const name = HardwareDeviceContext.getTypeName(type);
49
+ * console.log(`Available: ${name}`);
50
+ * }
51
+ *
52
+ * // Find specific device type
53
+ * const vaapi = HardwareDeviceContext.findTypeByName('vaapi');
54
+ * if (vaapi !== AV_HWDEVICE_TYPE_NONE) {
55
+ * const device = new HardwareDeviceContext();
56
+ * const ret = device.create(vaapi, '/dev/dri/renderD128', null);
57
+ * FFmpegError.throwIfError(ret, 'create VAAPI device');
58
+ * }
59
+ * ```
60
+ *
61
+ * @see {@link HardwareFramesContext} For managing hardware frame pools
62
+ * @see {@link CodecContext} For hardware-accelerated encoding/decoding
63
+ */
64
+ export class HardwareDeviceContext {
65
+ native;
66
+ /**
67
+ * Create a new hardware device context.
68
+ *
69
+ * The context is uninitialized - you must call alloc() or create() before use.
70
+ * No FFmpeg resources are allocated until initialization.
71
+ *
72
+ * Direct wrapper around AVHWDeviceContext.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * import { HardwareDeviceContext, FFmpegError } from 'node-av';
77
+ * import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
78
+ *
79
+ * const device = new HardwareDeviceContext();
80
+ * const ret = device.create(AV_HWDEVICE_TYPE_CUDA, null, null);
81
+ * FFmpegError.throwIfError(ret, 'create device');
82
+ * // Device is now ready for use
83
+ * ```
84
+ */
85
+ constructor() {
86
+ this.native = new bindings.HardwareDeviceContext();
87
+ }
88
+ /**
89
+ * Get the string name of an AVHWDeviceType.
90
+ *
91
+ * Returns the human-readable name for a hardware device type.
92
+ *
93
+ * Direct mapping to av_hwdevice_get_type_name()
94
+ *
95
+ * @param type - Hardware device type (AVHWDeviceType)
96
+ *
97
+ * @returns Device type name or null if unknown
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * import { HardwareDeviceContext } from 'node-av';
102
+ * import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
103
+ *
104
+ * const name = HardwareDeviceContext.getTypeName(AV_HWDEVICE_TYPE_CUDA);
105
+ * console.log(name); // "cuda"
106
+ * ```
107
+ */
108
+ static getTypeName(type) {
109
+ return bindings.HardwareDeviceContext.getTypeName(type);
110
+ }
111
+ /**
112
+ * Iterate over supported device types.
113
+ *
114
+ * Returns all hardware device types supported by this FFmpeg build.
115
+ *
116
+ * Direct mapping to av_hwdevice_iterate_types()
117
+ *
118
+ * @returns Array of supported AVHWDeviceType values
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * import { HardwareDeviceContext } from 'node-av';
123
+ *
124
+ * const types = HardwareDeviceContext.iterateTypes();
125
+ * for (const type of types) {
126
+ * const name = HardwareDeviceContext.getTypeName(type);
127
+ * console.log(`Supported: ${name}`);
128
+ * }
129
+ * ```
130
+ */
131
+ static iterateTypes() {
132
+ return bindings.HardwareDeviceContext.iterateTypes();
133
+ }
134
+ /**
135
+ * Get the AVHWDeviceType corresponding to the name.
136
+ *
137
+ * Looks up a hardware device type by its string name.
138
+ *
139
+ * Direct mapping to av_hwdevice_find_type_by_name()
140
+ *
141
+ * @param name - Device type name (e.g., "cuda", "vaapi", "dxva2")
142
+ *
143
+ * @returns AVHWDeviceType or AV_HWDEVICE_TYPE_NONE if not found
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * import { HardwareDeviceContext } from 'node-av';
148
+ * import { AV_HWDEVICE_TYPE_NONE } from 'node-av/constants';
149
+ *
150
+ * const type = HardwareDeviceContext.findTypeByName('cuda');
151
+ * if (type !== AV_HWDEVICE_TYPE_NONE) {
152
+ * // CUDA is available
153
+ * }
154
+ * ```
155
+ */
156
+ static findTypeByName(name) {
157
+ return bindings.HardwareDeviceContext.findTypeByName(name);
158
+ }
159
+ /**
160
+ * Hardware device type.
161
+ *
162
+ * Direct mapping to AVHWDeviceContext->type
163
+ *
164
+ * @readonly
165
+ */
166
+ get type() {
167
+ return this.native.type;
168
+ }
169
+ /**
170
+ * Hardware-specific data.
171
+ *
172
+ * Direct mapping to AVHWDeviceContext->hwctx
173
+ *
174
+ * Returns opaque pointer as BigInt for advanced users.
175
+ * @readonly
176
+ */
177
+ get hwctx() {
178
+ return this.native.hwctx;
179
+ }
180
+ /**
181
+ * Allocate an AVHWDeviceContext for a given hardware type.
182
+ *
183
+ * Allocates the device context structure but doesn't open the device.
184
+ * Must call init() after configuration to finalize.
185
+ *
186
+ * Direct mapping to av_hwdevice_ctx_alloc()
187
+ *
188
+ * @param type - Hardware device type
189
+ *
190
+ * @throws {Error} Memory allocation failure (ENOMEM)
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * import { HardwareDeviceContext, FFmpegError } from 'node-av';
195
+ * import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
196
+ *
197
+ * const device = new HardwareDeviceContext();
198
+ * device.alloc(AV_HWDEVICE_TYPE_CUDA);
199
+ * // Configure device properties if needed
200
+ * const ret = device.init();
201
+ * FFmpegError.throwIfError(ret, 'init device');
202
+ * ```
203
+ *
204
+ * @see {@link init} To finalize the device
205
+ * @see {@link create} For one-step device creation
206
+ */
207
+ alloc(type) {
208
+ this.native.alloc(type);
209
+ }
210
+ /**
211
+ * Finalize the device context before use.
212
+ *
213
+ * Completes device initialization after alloc() and configuration.
214
+ * Must be called before using the device context.
215
+ *
216
+ * Direct mapping to av_hwdevice_ctx_init()
217
+ *
218
+ * @returns 0 on success, negative AVERROR on error:
219
+ * - 0: Success (device ready)
220
+ * - AVERROR(EINVAL): Invalid parameters
221
+ * - AVERROR(ENOMEM): Memory allocation failure
222
+ * - <0: Device-specific errors
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * import { HardwareDeviceContext, FFmpegError } from 'node-av';
227
+ *
228
+ * const ret = device.init();
229
+ * FFmpegError.throwIfError(ret, 'init device');
230
+ * // Device is now ready for use
231
+ * ```
232
+ *
233
+ * @see {@link alloc} Must be called first
234
+ */
235
+ init() {
236
+ return this.native.init();
237
+ }
238
+ /**
239
+ * Open a device of the specified type and create an AVHWDeviceContext.
240
+ *
241
+ * One-step device creation that allocates, opens, and initializes the device.
242
+ * This is the preferred method for creating hardware devices.
243
+ *
244
+ * Direct mapping to av_hwdevice_ctx_create()
245
+ *
246
+ * @param type - Hardware device type
247
+ * @param device - Device to open (e.g., "/dev/dri/renderD128" for VAAPI), or null for default
248
+ * @param options - Device creation options, or null
249
+ *
250
+ * @returns 0 on success, negative AVERROR on error:
251
+ * - 0: Success (device created and ready)
252
+ * - AVERROR(EINVAL): Invalid parameters
253
+ * - AVERROR(ENOMEM): Memory allocation failure
254
+ * - AVERROR(ENOSYS): Device type not supported
255
+ * - <0: Device-specific errors
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * import { HardwareDeviceContext, FFmpegError } from 'node-av';
260
+ * import { AV_HWDEVICE_TYPE_CUDA, AV_HWDEVICE_TYPE_VAAPI } from 'node-av/constants';
261
+ *
262
+ * // Create CUDA device
263
+ * const ret = device.create(AV_HWDEVICE_TYPE_CUDA, null, null);
264
+ * FFmpegError.throwIfError(ret, 'create CUDA device');
265
+ *
266
+ * // Create VAAPI device with specific device
267
+ * const ret2 = device.create(
268
+ * AV_HWDEVICE_TYPE_VAAPI,
269
+ * '/dev/dri/renderD128',
270
+ * null
271
+ * );
272
+ * FFmpegError.throwIfError(ret2, 'create VAAPI device');
273
+ * ```
274
+ *
275
+ * @see {@link alloc} For manual device allocation
276
+ * @see {@link createDerived} To derive from another device
277
+ */
278
+ create(type, device = null, options = null) {
279
+ return this.native.create(type, device, options?.getNative() ?? null);
280
+ }
281
+ /**
282
+ * Create a new device of the specified type from an existing device.
283
+ *
284
+ * Creates a device that shares resources with the source device.
285
+ * Useful for interop between different hardware APIs.
286
+ *
287
+ * Direct mapping to av_hwdevice_ctx_create_derived()
288
+ *
289
+ * @param source - Source device context to derive from
290
+ * @param type - Target hardware device type
291
+ *
292
+ * @returns 0 on success, negative AVERROR on error:
293
+ * - 0: Success (derived device created)
294
+ * - AVERROR(ENOSYS): Derivation not supported
295
+ * - AVERROR(EINVAL): Invalid parameters
296
+ * - <0: Other errors
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * import { HardwareDeviceContext, FFmpegError } from 'node-av';
301
+ * import { AV_HWDEVICE_TYPE_VAAPI, AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
302
+ *
303
+ * // Create CUDA device from VAAPI device
304
+ * const vaapi = new HardwareDeviceContext();
305
+ * const vaapiRet = vaapi.create(AV_HWDEVICE_TYPE_VAAPI, null, null);
306
+ * FFmpegError.throwIfError(vaapiRet, 'create VAAPI');
307
+ *
308
+ * const cuda = new HardwareDeviceContext();
309
+ * const ret = cuda.createDerived(vaapi, AV_HWDEVICE_TYPE_CUDA);
310
+ * FFmpegError.throwIfError(ret, 'derive CUDA from VAAPI');
311
+ * ```
312
+ *
313
+ * @see {@link create} For standalone device creation
314
+ */
315
+ createDerived(source, type) {
316
+ return this.native.createDerived(source.native, type);
317
+ }
318
+ /**
319
+ * Free the device context.
320
+ *
321
+ * Unreferences the AVBufferRef and releases all device resources.
322
+ *
323
+ * Direct mapping to av_buffer_unref()
324
+ *
325
+ * @example
326
+ * ```typescript
327
+ * import { HardwareDeviceContext } from 'node-av';
328
+ *
329
+ * device.free();
330
+ * // device is now invalid and should not be used
331
+ * ```
332
+ */
333
+ free() {
334
+ this.native.free();
335
+ }
336
+ /**
337
+ * Allocate a HW-specific configuration structure.
338
+ *
339
+ * Allocates a configuration structure for querying device constraints.
340
+ *
341
+ * Direct mapping to av_hwdevice_hwconfig_alloc()
342
+ *
343
+ * @returns Opaque pointer as BigInt or null
344
+ *
345
+ * @example
346
+ * ```typescript
347
+ * import { HardwareDeviceContext } from 'node-av';
348
+ *
349
+ * const hwconfig = device.hwconfigAlloc();
350
+ * if (hwconfig) {
351
+ * // Use with getHwframeConstraints
352
+ * const constraints = device.getHwframeConstraints(hwconfig);
353
+ * }
354
+ * ```
355
+ *
356
+ * @see {@link getHwframeConstraints} To use the configuration
357
+ */
358
+ hwconfigAlloc() {
359
+ return this.native.hwconfigAlloc();
360
+ }
361
+ /**
362
+ * Get the constraints on HW frames given a device and parameters.
363
+ *
364
+ * Queries the device for supported formats, sizes, and other constraints.
365
+ * Essential for configuring hardware frames contexts.
366
+ *
367
+ * Direct mapping to av_hwdevice_get_hwframe_constraints()
368
+ *
369
+ * @param hwconfig - Hardware configuration from hwconfigAlloc(), or undefined
370
+ *
371
+ * @returns Constraints object or null:
372
+ * - Object: Device constraints
373
+ * - null: No constraints available
374
+ *
375
+ * @example
376
+ * ```typescript
377
+ * import { HardwareDeviceContext } from 'node-av';
378
+ *
379
+ * const constraints = device.getHwframeConstraints();
380
+ * if (constraints) {
381
+ * console.log(`Size range: ${constraints.minWidth}x${constraints.minHeight} to ${constraints.maxWidth}x${constraints.maxHeight}`);
382
+ *
383
+ * if (constraints.validSwFormats) {
384
+ * console.log('Valid software formats:', constraints.validSwFormats);
385
+ * }
386
+ * }
387
+ * ```
388
+ *
389
+ * @see {@link hwconfigAlloc} To create configuration
390
+ * @see {@link HardwareFramesContext} To use with frame pools
391
+ */
392
+ getHwframeConstraints(hwconfig) {
393
+ return this.native.getHwframeConstraints(hwconfig);
394
+ }
395
+ /**
396
+ * Get the native FFmpeg AVHWDeviceContext pointer.
397
+ *
398
+ * @internal For use by other wrapper classes
399
+ * @returns The underlying native hardware device context object
400
+ */
401
+ getNative() {
402
+ return this.native;
403
+ }
404
+ /**
405
+ * Dispose of the hardware device context.
406
+ *
407
+ * Implements the Disposable interface for automatic cleanup.
408
+ * Equivalent to calling free().
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * import { HardwareDeviceContext, FFmpegError } from 'node-av';
413
+ * import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
414
+ *
415
+ * {
416
+ * using device = new HardwareDeviceContext();
417
+ * const ret = device.create(AV_HWDEVICE_TYPE_CUDA, null, null);
418
+ * FFmpegError.throwIfError(ret, 'create device');
419
+ * // ... use device
420
+ * } // Automatically freed when leaving scope
421
+ * ```
422
+ *
423
+ * @see {@link free} For manual cleanup
424
+ */
425
+ [Symbol.dispose]() {
426
+ this.native[Symbol.dispose]();
427
+ }
428
+ }
429
+ //# sourceMappingURL=hardware-device-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hardware-device-context.js","sourceRoot":"","sources":["../../src/lib/hardware-device-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAMxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAA8B;IAE5C;;;;;;;;;;;;;;;;;;OAkBG;IACH;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAC,qBAAqB,EAAE,CAAC;IACrD,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,WAAW,CAAC,IAAoB;QACrC,OAAO,QAAQ,CAAC,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,YAAY;QACjB,OAAO,QAAQ,CAAC,qBAAqB,CAAC,YAAY,EAAE,CAAC;IACvD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,cAAc,CAAC,IAAY;QAChC,OAAO,QAAQ,CAAC,qBAAqB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;OAMG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK,CAAC,IAAoB;QACxB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,MAAM,CAAC,IAAoB,EAAE,SAAwB,IAAI,EAAE,UAA6B,IAAI;QAC1F,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC;IACxE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,aAAa,CAAC,MAA6B,EAAE,IAAoB;QAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,IAAI;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,qBAAqB,CAAC,QAAiB;QAQrC,OAAO,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACrD,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"}