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,407 @@
1
+ import { bindings } from './binding.js';
2
+ import { BitStreamFilter } from './bitstream-filter.js';
3
+ import { CodecParameters } from './codec-parameters.js';
4
+ import { OptionMember } from './option.js';
5
+ import { Rational } from './rational.js';
6
+ /**
7
+ * Bitstream filter context for processing packets.
8
+ *
9
+ * Manages the state for bitstream filtering operations.
10
+ * Processes packets through a bitstream filter without decoding.
11
+ * Supports packet-by-packet filtering with internal buffering.
12
+ *
13
+ * Direct mapping to FFmpeg's AVBSFContext.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { BitStreamFilter, BitStreamFilterContext, Packet, FFmpegError } from 'node-av';
18
+ * import { AVERROR_EOF, AVERROR } from 'node-av/constants';
19
+ *
20
+ * // Create and initialize filter context
21
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
22
+ * const ctx = new BitStreamFilterContext();
23
+ *
24
+ * // Allocate and configure
25
+ * let ret = ctx.alloc(filter);
26
+ * FFmpegError.throwIfError(ret, 'alloc');
27
+ *
28
+ * // Copy input parameters from stream to BSF context
29
+ * stream.codecpar.copy(ctx.inputCodecParameters);
30
+ * ctx.inputTimeBase = stream.timeBase;
31
+ *
32
+ * // Initialize filter
33
+ * ret = ctx.init();
34
+ * FFmpegError.throwIfError(ret, 'init');
35
+ *
36
+ * // Process packets
37
+ * while (hasMorePackets) {
38
+ * const inputPacket = getNextPacket();
39
+ *
40
+ * // Send packet to filter
41
+ * ret = await ctx.sendPacket(inputPacket);
42
+ * FFmpegError.throwIfError(ret, 'sendPacket');
43
+ *
44
+ * // Receive filtered packets
45
+ * while (true) {
46
+ * const outputPacket = new Packet();
47
+ * const result = await ctx.receivePacket(outputPacket);
48
+ *
49
+ * if (result.eagain || result.eof) break;
50
+ * FFmpegError.throwIfError(result.ret || result, 'receivePacket');
51
+ *
52
+ * // Process filtered packet
53
+ * processPacket(outputPacket);
54
+ * outputPacket.unref();
55
+ * }
56
+ * }
57
+ *
58
+ * // Send EOF
59
+ * await ctx.sendPacket(null);
60
+ *
61
+ * // Drain remaining packets
62
+ * while (true) {
63
+ * const outputPacket = new Packet();
64
+ * const result = await ctx.receivePacket(outputPacket);
65
+ * if (result.eof) break;
66
+ * // Process remaining packets
67
+ * }
68
+ *
69
+ * // Cleanup
70
+ * ctx.free();
71
+ * ```
72
+ */
73
+ export class BitStreamFilterContext extends OptionMember {
74
+ _filter; // Cache for filter wrapper
75
+ /**
76
+ * Create a new bitstream filter context.
77
+ *
78
+ * The context is uninitialized - you must call alloc() and init() before use.
79
+ * No FFmpeg resources are allocated until initialization.
80
+ *
81
+ * Direct wrapper around AVBSFContext.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const ctx = new BitStreamFilterContext();
86
+ * ctx.alloc(filter);
87
+ * ctx.init();
88
+ * // Context is now ready for filtering
89
+ * ```
90
+ */
91
+ constructor() {
92
+ super(new bindings.BitStreamFilterContext());
93
+ }
94
+ /**
95
+ * Check if the context is initialized.
96
+ *
97
+ * Returns true if init() has been called successfully.
98
+ *
99
+ * @returns True if initialized, false otherwise
100
+ */
101
+ get isInitialized() {
102
+ return this.native.isInitialized();
103
+ }
104
+ /**
105
+ * Input codec parameters (read-only reference, mutable contents).
106
+ *
107
+ * Returns a reference to the BSF context's internal codec parameters.
108
+ * While you cannot replace this object (no setter), you can modify its contents
109
+ * or use it as a destination for copy operations.
110
+ *
111
+ * You must configure these parameters before calling init().
112
+ *
113
+ * Maps to AVBSFContext->par_in.
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * // Copy parameters from input stream to BSF context
118
+ * if (ctx.inputCodecParameters) {
119
+ * stream.codecpar.copy(ctx.inputCodecParameters);
120
+ *
121
+ * // Or set individual properties
122
+ * ctx.inputCodecParameters.codecType = AVMEDIA_TYPE_VIDEO;
123
+ * ctx.inputCodecParameters.codecId = AV_CODEC_ID_H264;
124
+ * }
125
+ * ```
126
+ */
127
+ get inputCodecParameters() {
128
+ // The native binding returns a CodecParameters object created with the constructor
129
+ // It's the native object itself, not a TypeScript wrapper
130
+ const nativeParams = this.native.inputCodecParameters;
131
+ if (!nativeParams) {
132
+ return null;
133
+ }
134
+ // Wrap it in our TypeScript class
135
+ const wrapper = Object.create(CodecParameters.prototype);
136
+ wrapper.native = nativeParams;
137
+ return wrapper;
138
+ }
139
+ /**
140
+ * Output codec parameters (read-only reference, read-only contents).
141
+ *
142
+ * Returns a reference to the BSF context's output codec parameters.
143
+ * These are automatically configured by the filter during init().
144
+ * You should not modify these parameters.
145
+ *
146
+ * Maps to AVBSFContext->par_out.
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * // After initialization, read the output parameters
151
+ * console.log(`Output codec: ${ctx.outputCodecParameters?.codecId}`);
152
+ *
153
+ * // Use them to configure downstream components
154
+ * if (ctx.outputCodecParameters) {
155
+ * ctx.outputCodecParameters.copy(nextStream.codecpar);
156
+ * }
157
+ * ```
158
+ */
159
+ get outputCodecParameters() {
160
+ // The native binding returns a CodecParameters object created with the constructor
161
+ // It's the native object itself, not a TypeScript wrapper
162
+ const nativeParams = this.native.outputCodecParameters;
163
+ if (!nativeParams) {
164
+ return null;
165
+ }
166
+ // Wrap it in our TypeScript class
167
+ const wrapper = Object.create(CodecParameters.prototype);
168
+ wrapper.native = nativeParams;
169
+ return wrapper;
170
+ }
171
+ /**
172
+ * Input time base.
173
+ *
174
+ * Time base for input packet timestamps.
175
+ * Must be set before calling init().
176
+ *
177
+ * Maps to AVBSFContext->time_base_in.
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * ctx.inputTimeBase = new Rational(1, 1000); // 1ms time base
182
+ * ```
183
+ */
184
+ get inputTimeBase() {
185
+ const tb = this.native.inputTimeBase;
186
+ return new Rational(tb.num, tb.den);
187
+ }
188
+ set inputTimeBase(value) {
189
+ this.native.inputTimeBase = { num: value.num, den: value.den };
190
+ }
191
+ /**
192
+ * Output time base.
193
+ *
194
+ * Time base for output packet timestamps.
195
+ * Set by the filter during init().
196
+ *
197
+ * Maps to AVBSFContext->time_base_out.
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * // After initialization
202
+ * console.log(`Output time base: ${ctx.outputTimeBase.num}/${ctx.outputTimeBase.den}`);
203
+ * ```
204
+ */
205
+ get outputTimeBase() {
206
+ const tb = this.native.outputTimeBase;
207
+ if (!tb)
208
+ return null;
209
+ return new Rational(tb.num, tb.den);
210
+ }
211
+ /**
212
+ * The bitstream filter being used.
213
+ *
214
+ * Reference to the filter this context was allocated with.
215
+ *
216
+ * Maps to AVBSFContext->filter.
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * console.log(`Using filter: ${ctx.filter?.name}`);
221
+ * ```
222
+ */
223
+ get filter() {
224
+ if (!this._filter) {
225
+ const native = this.native.filter;
226
+ if (!native) {
227
+ return null;
228
+ }
229
+ this._filter = new BitStreamFilter(native);
230
+ }
231
+ return this._filter;
232
+ }
233
+ /**
234
+ * Allocate the bitstream filter context.
235
+ *
236
+ * Allocates the context for the specified filter.
237
+ * Must be called before any other operations.
238
+ * After allocation, configure input parameters before calling init().
239
+ *
240
+ * Calls av_bsf_alloc() internally.
241
+ *
242
+ * @param filter - The bitstream filter to use
243
+ * @returns 0 on success, negative error code on failure
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
248
+ * const ctx = new BitStreamFilterContext();
249
+ * const ret = ctx.alloc(filter);
250
+ * FFmpegError.throwIfError(ret, 'alloc');
251
+ * ```
252
+ */
253
+ alloc(filter) {
254
+ return this.native.alloc(filter.getNative());
255
+ }
256
+ /**
257
+ * Initialize the bitstream filter context.
258
+ *
259
+ * Prepares the filter for use after parameters have been set.
260
+ * Sets up output parameters based on input and filter configuration.
261
+ * Must be called after alloc() and parameter configuration.
262
+ *
263
+ * Calls av_bsf_init() internally.
264
+ *
265
+ * @returns 0 on success, negative error code on failure
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * // After allocation and parameter setup
270
+ * const ret = ctx.init();
271
+ * FFmpegError.throwIfError(ret, 'init');
272
+ * ```
273
+ */
274
+ init() {
275
+ return this.native.init();
276
+ }
277
+ /**
278
+ * Free the bitstream filter context.
279
+ *
280
+ * Releases all resources associated with the context.
281
+ * The context cannot be used after calling this method.
282
+ *
283
+ * Calls av_bsf_free() internally.
284
+ *
285
+ * @example
286
+ * ```typescript
287
+ * ctx.free();
288
+ * // Context is now freed and unusable
289
+ * ```
290
+ */
291
+ free() {
292
+ this.native.free();
293
+ this._filter = undefined;
294
+ }
295
+ /**
296
+ * Flush the bitstream filter.
297
+ *
298
+ * Resets the internal filter state.
299
+ * Should be called when seeking or switching streams.
300
+ *
301
+ * Calls av_bsf_flush() internally.
302
+ *
303
+ * @example
304
+ * ```typescript
305
+ * // When seeking
306
+ * ctx.flush();
307
+ * // Filter is reset and ready for new packets
308
+ * ```
309
+ */
310
+ flush() {
311
+ this.native.flush();
312
+ }
313
+ /**
314
+ * Send a packet to the filter.
315
+ *
316
+ * Submits a packet for filtering.
317
+ * The filter takes ownership of the packet.
318
+ * Pass null to signal end of stream.
319
+ *
320
+ * After sending a packet, call receivePacket() repeatedly
321
+ * until it returns EAGAIN or EOF.
322
+ *
323
+ * Calls av_bsf_send_packet() internally.
324
+ *
325
+ * @param packet - Packet to filter, or null for EOF
326
+ * @returns Promise resolving to 0 on success, error code on failure
327
+ *
328
+ * @example
329
+ * ```typescript
330
+ * // Send packet
331
+ * const ret = await ctx.sendPacket(inputPacket);
332
+ * if (ret < 0 && ret !== AVERROR_EAGAIN) {
333
+ * throw new Error('Failed to send packet');
334
+ * }
335
+ *
336
+ * // Send EOF
337
+ * await ctx.sendPacket(null);
338
+ * ```
339
+ */
340
+ async sendPacket(packet) {
341
+ return await this.native.sendPacket(packet ? packet.getNative() : null);
342
+ }
343
+ /**
344
+ * Receive a filtered packet.
345
+ *
346
+ * Gets a filtered packet from the filter.
347
+ * Must be called repeatedly after sendPacket() until EAGAIN or EOF.
348
+ * One input packet may produce multiple output packets.
349
+ *
350
+ * Calls av_bsf_receive_packet() internally.
351
+ *
352
+ * @param packet - Packet to receive filtered data into
353
+ * @returns Promise resolving to 0 on success, negative error code on failure
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';
358
+ *
359
+ * const packet = new Packet();
360
+ * const ret = await ctx.receivePacket(packet);
361
+ *
362
+ * if (ret === AVERROR_EAGAIN) {
363
+ * // Need to send more packets
364
+ * } else if (ret === AVERROR_EOF) {
365
+ * // No more packets
366
+ * } else if (ret < 0) {
367
+ * // Error occurred
368
+ * } else {
369
+ * // Got a packet successfully
370
+ * processPacket(packet);
371
+ * }
372
+ * ```
373
+ */
374
+ async receivePacket(packet) {
375
+ return await this.native.receivePacket(packet.getNative());
376
+ }
377
+ /**
378
+ * Get the underlying native object.
379
+ *
380
+ * For advanced use cases that need direct access to the native bindings.
381
+ *
382
+ * @returns Native BitStreamFilterContext object
383
+ * @internal
384
+ */
385
+ getNative() {
386
+ return this.native;
387
+ }
388
+ /**
389
+ * Dispose of the context resources.
390
+ *
391
+ * Automatically called when using the `using` statement.
392
+ * Frees all associated FFmpeg resources.
393
+ *
394
+ * @example
395
+ * ```typescript
396
+ * {
397
+ * using ctx = new BitStreamFilterContext();
398
+ * ctx.alloc(filter);
399
+ * // ... use context
400
+ * } // Automatically freed when leaving scope
401
+ * ```
402
+ */
403
+ [Symbol.dispose]() {
404
+ this.native[Symbol.dispose]();
405
+ }
406
+ }
407
+ //# sourceMappingURL=bitstream-filter-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitstream-filter-context.js","sourceRoot":"","s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QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK,CAAC,UAAU,CAAC,MAAqB;QACpC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,KAAK,CAAC,aAAa,CAAC,MAAc;QAChC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;OAOG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,124 @@
1
+ import type { AVCodecID } from './constants.js';
2
+ import type { NativeBitStreamFilter, NativeWrapper } from './native-types.js';
3
+ /**
4
+ * Bitstream filter definition.
5
+ *
6
+ * Represents a bitstream filter for manipulating encoded data without decoding.
7
+ * Allows modification of codec-specific headers, packet metadata, and bitstream syntax.
8
+ * This is an immutable descriptor - actual filtering happens via BitStreamFilterContext.
9
+ *
10
+ * Direct mapping to FFmpeg's AVBitStreamFilter.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { BitStreamFilter } from 'node-av';
15
+ *
16
+ * // Find a specific bitstream filter
17
+ * const h264Mp4ToAnnexB = BitStreamFilter.getByName('h264_mp4toannexb');
18
+ * if (!h264Mp4ToAnnexB) throw new Error('h264_mp4toannexb filter not found');
19
+ *
20
+ * console.log(`Filter: ${h264Mp4ToAnnexB.name}`);
21
+ * console.log(`Supported codecs: ${h264Mp4ToAnnexB.codecIds}`);
22
+ *
23
+ * // List all available bitstream filters
24
+ * const filters = BitStreamFilter.iterate();
25
+ * for (const filter of filters) {
26
+ * console.log(`Found filter: ${filter.name}`);
27
+ * }
28
+ * ```
29
+ */
30
+ export declare class BitStreamFilter implements NativeWrapper<NativeBitStreamFilter> {
31
+ private native;
32
+ /**
33
+ * Create a BitStreamFilter wrapper.
34
+ *
35
+ * Usually not called directly - use static methods instead.
36
+ * No FFmpeg resources are allocated.
37
+ *
38
+ * @param native - Native BitStreamFilter object from bindings
39
+ * @internal
40
+ */
41
+ constructor(native: NativeBitStreamFilter);
42
+ /**
43
+ * Find a bitstream filter by name.
44
+ *
45
+ * Searches for a registered bitstream filter with the given name.
46
+ * Returns null if no filter with that name exists.
47
+ *
48
+ * Calls av_bsf_get_by_name() internally.
49
+ *
50
+ * @param name - Name of the bitstream filter (e.g., 'h264_mp4toannexb')
51
+ * @returns BitStreamFilter if found, null otherwise
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
56
+ * if (filter) {
57
+ * console.log(`Found filter: ${filter.name}`);
58
+ * }
59
+ * ```
60
+ */
61
+ static getByName(name: string): BitStreamFilter | null;
62
+ /**
63
+ * Get all available bitstream filters.
64
+ *
65
+ * Returns an array of all registered bitstream filters.
66
+ * Useful for discovery and debugging.
67
+ *
68
+ * Calls av_bsf_iterate() internally.
69
+ *
70
+ * @returns Array of all available bitstream filters
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const filters = BitStreamFilter.iterate();
75
+ * for (const filter of filters) {
76
+ * console.log(`${filter.name}: ${filter.codecIds?.join(', ') || 'all codecs'}`);
77
+ * }
78
+ * ```
79
+ */
80
+ static iterate(): BitStreamFilter[];
81
+ /**
82
+ * Filter name.
83
+ *
84
+ * Short name used to identify the filter.
85
+ * This is the name used with getByName().
86
+ *
87
+ * Maps to AVBitStreamFilter->name.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
92
+ * console.log(filter.name); // 'h264_mp4toannexb'
93
+ * ```
94
+ */
95
+ get name(): string | null;
96
+ /**
97
+ * Supported codec IDs.
98
+ *
99
+ * List of codec IDs this filter can process.
100
+ * If null, the filter works with any codec.
101
+ *
102
+ * Maps to AVBitStreamFilter->codec_ids.
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
107
+ *
108
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
109
+ * if (filter.codecIds?.includes(AV_CODEC_ID_H264)) {
110
+ * console.log('Filter supports H.264');
111
+ * }
112
+ * ```
113
+ */
114
+ get codecIds(): AVCodecID[] | null;
115
+ /**
116
+ * Get the underlying native object.
117
+ *
118
+ * For advanced use cases that need direct access to the native bindings.
119
+ *
120
+ * @returns Native BitStreamFilter object
121
+ * @internal
122
+ */
123
+ getNative(): NativeBitStreamFilter;
124
+ }
@@ -0,0 +1,138 @@
1
+ import { bindings } from './binding.js';
2
+ /**
3
+ * Bitstream filter definition.
4
+ *
5
+ * Represents a bitstream filter for manipulating encoded data without decoding.
6
+ * Allows modification of codec-specific headers, packet metadata, and bitstream syntax.
7
+ * This is an immutable descriptor - actual filtering happens via BitStreamFilterContext.
8
+ *
9
+ * Direct mapping to FFmpeg's AVBitStreamFilter.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { BitStreamFilter } from 'node-av';
14
+ *
15
+ * // Find a specific bitstream filter
16
+ * const h264Mp4ToAnnexB = BitStreamFilter.getByName('h264_mp4toannexb');
17
+ * if (!h264Mp4ToAnnexB) throw new Error('h264_mp4toannexb filter not found');
18
+ *
19
+ * console.log(`Filter: ${h264Mp4ToAnnexB.name}`);
20
+ * console.log(`Supported codecs: ${h264Mp4ToAnnexB.codecIds}`);
21
+ *
22
+ * // List all available bitstream filters
23
+ * const filters = BitStreamFilter.iterate();
24
+ * for (const filter of filters) {
25
+ * console.log(`Found filter: ${filter.name}`);
26
+ * }
27
+ * ```
28
+ */
29
+ export class BitStreamFilter {
30
+ native;
31
+ /**
32
+ * Create a BitStreamFilter wrapper.
33
+ *
34
+ * Usually not called directly - use static methods instead.
35
+ * No FFmpeg resources are allocated.
36
+ *
37
+ * @param native - Native BitStreamFilter object from bindings
38
+ * @internal
39
+ */
40
+ constructor(native) {
41
+ this.native = native;
42
+ }
43
+ /**
44
+ * Find a bitstream filter by name.
45
+ *
46
+ * Searches for a registered bitstream filter with the given name.
47
+ * Returns null if no filter with that name exists.
48
+ *
49
+ * Calls av_bsf_get_by_name() internally.
50
+ *
51
+ * @param name - Name of the bitstream filter (e.g., 'h264_mp4toannexb')
52
+ * @returns BitStreamFilter if found, null otherwise
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
57
+ * if (filter) {
58
+ * console.log(`Found filter: ${filter.name}`);
59
+ * }
60
+ * ```
61
+ */
62
+ static getByName(name) {
63
+ const native = bindings.BitStreamFilter.getByName(name);
64
+ return native ? new BitStreamFilter(native) : null;
65
+ }
66
+ /**
67
+ * Get all available bitstream filters.
68
+ *
69
+ * Returns an array of all registered bitstream filters.
70
+ * Useful for discovery and debugging.
71
+ *
72
+ * Calls av_bsf_iterate() internally.
73
+ *
74
+ * @returns Array of all available bitstream filters
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const filters = BitStreamFilter.iterate();
79
+ * for (const filter of filters) {
80
+ * console.log(`${filter.name}: ${filter.codecIds?.join(', ') || 'all codecs'}`);
81
+ * }
82
+ * ```
83
+ */
84
+ static iterate() {
85
+ const natives = bindings.BitStreamFilter.iterate();
86
+ return natives.map((native) => new BitStreamFilter(native));
87
+ }
88
+ /**
89
+ * Filter name.
90
+ *
91
+ * Short name used to identify the filter.
92
+ * This is the name used with getByName().
93
+ *
94
+ * Maps to AVBitStreamFilter->name.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
99
+ * console.log(filter.name); // 'h264_mp4toannexb'
100
+ * ```
101
+ */
102
+ get name() {
103
+ return this.native.name;
104
+ }
105
+ /**
106
+ * Supported codec IDs.
107
+ *
108
+ * List of codec IDs this filter can process.
109
+ * If null, the filter works with any codec.
110
+ *
111
+ * Maps to AVBitStreamFilter->codec_ids.
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
116
+ *
117
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
118
+ * if (filter.codecIds?.includes(AV_CODEC_ID_H264)) {
119
+ * console.log('Filter supports H.264');
120
+ * }
121
+ * ```
122
+ */
123
+ get codecIds() {
124
+ return this.native.codecIds;
125
+ }
126
+ /**
127
+ * Get the underlying native object.
128
+ *
129
+ * For advanced use cases that need direct access to the native bindings.
130
+ *
131
+ * @returns Native BitStreamFilter object
132
+ * @internal
133
+ */
134
+ getNative() {
135
+ return this.native;
136
+ }
137
+ }
138
+ //# sourceMappingURL=bitstream-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitstream-filter.js","sourceRoot":"","sources":["../../src/lib/bitstream-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKxC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,eAAe;IAClB,MAAM,CAAwB;IAEtC;;;;;;;;OAQG;IACH,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,SAAS,CAAC,IAAY;QAC3B,MAAM,MAAM,GAAG,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QACnD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAA6B,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAA8B,CAAC;IACpD,CAAC;IAED;;;;;;;OAOG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}