@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.
- package/BUILD_LINUX.md +61 -0
- package/LICENSE.md +22 -0
- package/README.md +662 -0
- package/build_mac_local.sh +69 -0
- package/dist/api/audio-frame-buffer.d.ts +205 -0
- package/dist/api/audio-frame-buffer.js +287 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +820 -0
- package/dist/api/bitstream-filter.js +1242 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_h264.h264 +0 -0
- package/dist/api/data/test_hevc.h265 +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +1088 -0
- package/dist/api/decoder.js +1775 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1219 -0
- package/dist/api/demuxer.js +2081 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +586 -0
- package/dist/api/device.js +961 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder.d.ts +1132 -0
- package/dist/api/encoder.js +1988 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +821 -0
- package/dist/api/filter-complex.js +1604 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +1286 -0
- package/dist/api/filter-presets.js +2152 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1234 -0
- package/dist/api/filter.js +1976 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +426 -0
- package/dist/api/fmp4-stream.js +739 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +651 -0
- package/dist/api/hardware.js +1260 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +17 -0
- package/dist/api/index.js +32 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +307 -0
- package/dist/api/io-stream.js +282 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +957 -0
- package/dist/api/muxer.js +2002 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +607 -0
- package/dist/api/pipeline.js +1145 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +120 -0
- package/dist/api/utilities/async-queue.js +211 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +117 -0
- package/dist/api/utilities/audio-sample.js +112 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +76 -0
- package/dist/api/utilities/channel-layout.js +80 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
- package/dist/api/utilities/electron-shared-texture.js +503 -0
- package/dist/api/utilities/electron-shared-texture.js.map +1 -0
- package/dist/api/utilities/image.d.ts +207 -0
- package/dist/api/utilities/image.js +213 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +12 -0
- package/dist/api/utilities/index.js +25 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +49 -0
- package/dist/api/utilities/media-type.js +53 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +89 -0
- package/dist/api/utilities/pixel-format.js +97 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +129 -0
- package/dist/api/utilities/sample-format.js +141 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/scheduler.d.ts +138 -0
- package/dist/api/utilities/scheduler.js +98 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +186 -0
- package/dist/api/utilities/streaming.js +309 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +193 -0
- package/dist/api/utilities/timestamp.js +206 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utilities/whisper-model.d.ts +310 -0
- package/dist/api/utilities/whisper-model.js +528 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/utils.d.ts +19 -0
- package/dist/api/utils.js +39 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/api/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/channel-layouts.d.ts +53 -0
- package/dist/constants/channel-layouts.js +57 -0
- package/dist/constants/channel-layouts.js.map +1 -0
- package/dist/constants/constants.d.ts +2325 -0
- package/dist/constants/constants.js +1887 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +633 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +295 -0
- package/dist/constants/encoders.js +308 -0
- package/dist/constants/encoders.js.map +1 -0
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +99 -0
- package/dist/ffmpeg/index.js +115 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/utils.d.ts +31 -0
- package/dist/ffmpeg/utils.js +68 -0
- package/dist/ffmpeg/utils.js.map +1 -0
- package/dist/ffmpeg/version.d.ts +6 -0
- package/dist/ffmpeg/version.js +7 -0
- package/dist/ffmpeg/version.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +399 -0
- package/dist/lib/audio-fifo.js +431 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +228 -0
- package/dist/lib/binding.js +60 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +379 -0
- package/dist/lib/bitstream-filter-context.js +441 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +140 -0
- package/dist/lib/bitstream-filter.js +154 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/codec-context.d.ts +1071 -0
- package/dist/lib/codec-context.js +1354 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +616 -0
- package/dist/lib/codec-parameters.js +761 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +201 -0
- package/dist/lib/codec-parser.js +213 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +586 -0
- package/dist/lib/codec.js +713 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +291 -0
- package/dist/lib/device.js +324 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/dictionary.d.ts +333 -0
- package/dist/lib/dictionary.js +372 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +242 -0
- package/dist/lib/error.js +303 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/filter-context.d.ts +712 -0
- package/dist/lib/filter-context.js +789 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +160 -0
- package/dist/lib/filter-graph-segment.js +171 -0
- package/dist/lib/filter-graph-segment.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +641 -0
- package/dist/lib/filter-graph.js +704 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +198 -0
- package/dist/lib/filter-inout.js +257 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +243 -0
- package/dist/lib/filter.js +272 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +1254 -0
- package/dist/lib/format-context.js +1379 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame-utils.d.ts +116 -0
- package/dist/lib/frame-utils.js +98 -0
- package/dist/lib/frame-utils.js.map +1 -0
- package/dist/lib/frame.d.ts +1222 -0
- package/dist/lib/frame.js +1435 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +362 -0
- package/dist/lib/hardware-device-context.js +383 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +419 -0
- package/dist/lib/hardware-frames-context.js +477 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +35 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +249 -0
- package/dist/lib/input-format.js +306 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +696 -0
- package/dist/lib/io-context.js +769 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +174 -0
- package/dist/lib/log.js +184 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +946 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +927 -0
- package/dist/lib/option.js +1583 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +180 -0
- package/dist/lib/output-format.js +213 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +501 -0
- package/dist/lib/packet.js +590 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +251 -0
- package/dist/lib/rational.js +278 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +552 -0
- package/dist/lib/software-resample-context.js +592 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +344 -0
- package/dist/lib/software-scale-context.js +366 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +379 -0
- package/dist/lib/stream.js +526 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +34 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +1127 -0
- package/dist/lib/utilities.js +1225 -0
- package/dist/lib/utilities.js.map +1 -0
- package/dist/utils/electron.d.ts +49 -0
- package/dist/utils/electron.js +63 -0
- package/dist/utils/electron.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/install/check.js +121 -0
- package/install/ffmpeg.js +66 -0
- package/jellyfin-ffmpeg.patch +181 -0
- package/package.json +129 -0
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
import { AVIO_FLAG_READ } from '../constants/constants.js';
|
|
2
|
+
import { bindings } from './binding.js';
|
|
3
|
+
import { OptionMember } from './option.js';
|
|
4
|
+
/**
|
|
5
|
+
* I/O context for custom input/output operations.
|
|
6
|
+
*
|
|
7
|
+
* Provides an abstraction layer for all I/O operations in FFmpeg.
|
|
8
|
+
* Enables reading from and writing to various sources including files,
|
|
9
|
+
* network streams, memory buffers, and custom callbacks. Essential for
|
|
10
|
+
* implementing custom protocols or handling non-standard I/O scenarios.
|
|
11
|
+
*
|
|
12
|
+
* Direct mapping to FFmpeg's AVIOContext.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { IOContext, FFmpegError } from 'node-av';
|
|
17
|
+
* import { AVIO_FLAG_READ, AVIO_FLAG_WRITE, AVSEEK_SET } from 'node-av/constants';
|
|
18
|
+
*
|
|
19
|
+
* // Open file for reading
|
|
20
|
+
* const io = new IOContext();
|
|
21
|
+
* const ret = await io.open2('input.mp4', AVIO_FLAG_READ);
|
|
22
|
+
* FFmpegError.throwIfError(ret, 'open2');
|
|
23
|
+
*
|
|
24
|
+
* // Read data
|
|
25
|
+
* const data = await io.read(4096);
|
|
26
|
+
* if (data instanceof Buffer) {
|
|
27
|
+
* console.log(`Read ${data.length} bytes`);
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* // Seek to position
|
|
31
|
+
* const pos = await io.seek(1024n, AVSEEK_SET);
|
|
32
|
+
* console.log(`Seeked to position ${pos}`);
|
|
33
|
+
*
|
|
34
|
+
* // Get file size
|
|
35
|
+
* const fileSize = await io.size();
|
|
36
|
+
* console.log(`File size: ${fileSize}`);
|
|
37
|
+
*
|
|
38
|
+
* // Close when done
|
|
39
|
+
* await io.closep();
|
|
40
|
+
*
|
|
41
|
+
* // Custom I/O with callbacks
|
|
42
|
+
* const customIO = new IOContext();
|
|
43
|
+
* let position = 0n;
|
|
44
|
+
* const buffer = Buffer.from('Hello World');
|
|
45
|
+
*
|
|
46
|
+
* customIO.allocContextWithCallbacks(
|
|
47
|
+
* 4096, // Buffer size
|
|
48
|
+
* 0, // Read mode
|
|
49
|
+
* (size) => {
|
|
50
|
+
* // Read callback
|
|
51
|
+
* const end = Number(position) + size;
|
|
52
|
+
* const chunk = buffer.subarray(Number(position), end);
|
|
53
|
+
* position = BigInt(end);
|
|
54
|
+
* return chunk;
|
|
55
|
+
* },
|
|
56
|
+
* null, // No write callback for read mode
|
|
57
|
+
* (offset, whence) => {
|
|
58
|
+
* // Seek callback
|
|
59
|
+
* if (whence === AVSEEK_SET) position = offset;
|
|
60
|
+
* else if (whence === AVSEEK_CUR) position += offset;
|
|
61
|
+
* else if (whence === AVSEEK_END) position = BigInt(buffer.length) + offset;
|
|
62
|
+
* return position;
|
|
63
|
+
* }
|
|
64
|
+
* );
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @see [AVIOContext](https://ffmpeg.org/doxygen/trunk/structAVIOContext.html) - FFmpeg Doxygen
|
|
68
|
+
* @see {@link FormatContext} For using with demuxing/muxing
|
|
69
|
+
*/
|
|
70
|
+
export class IOContext extends OptionMember {
|
|
71
|
+
constructor() {
|
|
72
|
+
super(new bindings.IOContext());
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Find input format by short name.
|
|
76
|
+
*
|
|
77
|
+
* Creates an IOContext instance from a native binding object.
|
|
78
|
+
* Used internally for wrapping native I/O contexts.
|
|
79
|
+
*
|
|
80
|
+
* @param native - Native IOContext binding object
|
|
81
|
+
*
|
|
82
|
+
* @returns Wrapped IOContext instance
|
|
83
|
+
*
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
static fromNative(native) {
|
|
87
|
+
const io = Object.create(IOContext.prototype);
|
|
88
|
+
io.native = native;
|
|
89
|
+
return io;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* End of file indicator.
|
|
93
|
+
*
|
|
94
|
+
* True if end of file has been reached during reading.
|
|
95
|
+
*
|
|
96
|
+
* Direct mapping to AVIOContext->eof_reached.
|
|
97
|
+
*/
|
|
98
|
+
get eof() {
|
|
99
|
+
return this.native.eof;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Error code.
|
|
103
|
+
*
|
|
104
|
+
* Contains the last error that occurred, or 0 if no error.
|
|
105
|
+
*
|
|
106
|
+
* Direct mapping to AVIOContext->error.
|
|
107
|
+
*/
|
|
108
|
+
get error() {
|
|
109
|
+
return this.native.error;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Seekability indicator.
|
|
113
|
+
*
|
|
114
|
+
* Non-zero if the underlying resource supports seeking.
|
|
115
|
+
* Some protocols like pipes or network streams may not be seekable.
|
|
116
|
+
*
|
|
117
|
+
* Direct mapping to AVIOContext->seekable.
|
|
118
|
+
*/
|
|
119
|
+
get seekable() {
|
|
120
|
+
return this.native.seekable;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Maximum packet size.
|
|
124
|
+
*
|
|
125
|
+
* Used to limit packet sizes in network protocols.
|
|
126
|
+
* 0 means no limit.
|
|
127
|
+
*
|
|
128
|
+
* Direct mapping to AVIOContext->max_packet_size.
|
|
129
|
+
*/
|
|
130
|
+
get maxPacketSize() {
|
|
131
|
+
return this.native.maxPacketSize;
|
|
132
|
+
}
|
|
133
|
+
set maxPacketSize(value) {
|
|
134
|
+
this.native.maxPacketSize = value;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Direct mode flag.
|
|
138
|
+
*
|
|
139
|
+
* If set, the I/O context will attempt to avoid buffering.
|
|
140
|
+
*
|
|
141
|
+
* Direct mapping to AVIOContext->direct.
|
|
142
|
+
*/
|
|
143
|
+
get direct() {
|
|
144
|
+
return this.native.direct;
|
|
145
|
+
}
|
|
146
|
+
set direct(value) {
|
|
147
|
+
this.native.direct = value;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Current position.
|
|
151
|
+
*
|
|
152
|
+
* Current byte position in the stream.
|
|
153
|
+
*
|
|
154
|
+
* Direct mapping to AVIOContext->pos.
|
|
155
|
+
*/
|
|
156
|
+
get pos() {
|
|
157
|
+
return this.native.pos;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Internal buffer size.
|
|
161
|
+
*
|
|
162
|
+
* Size of the internal buffer used for I/O operations.
|
|
163
|
+
*
|
|
164
|
+
* Direct mapping to AVIOContext->buffer_size.
|
|
165
|
+
*/
|
|
166
|
+
get bufferSize() {
|
|
167
|
+
return this.native.bufferSize;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Write flag.
|
|
171
|
+
*
|
|
172
|
+
* True if opened for writing, false for reading.
|
|
173
|
+
*
|
|
174
|
+
* Direct mapping to AVIOContext->write_flag.
|
|
175
|
+
*/
|
|
176
|
+
get writeFlag() {
|
|
177
|
+
return this.native.writeFlag;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Allocate I/O context with buffer.
|
|
181
|
+
*
|
|
182
|
+
* Allocates a basic I/O context with an internal buffer.
|
|
183
|
+
* For custom I/O, use allocContextWithCallbacks instead.
|
|
184
|
+
*
|
|
185
|
+
* Direct mapping to avio_alloc_context() without callbacks.
|
|
186
|
+
*
|
|
187
|
+
* @param bufferSize - Size of internal buffer
|
|
188
|
+
*
|
|
189
|
+
* @param writeFlag - 1 for write, 0 for read
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const io = new IOContext();
|
|
194
|
+
* io.allocContext(4096, 0); // 4KB buffer for reading
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @see {@link allocContextWithCallbacks} For custom I/O
|
|
198
|
+
*/
|
|
199
|
+
allocContext(bufferSize, writeFlag) {
|
|
200
|
+
this.native.allocContext(bufferSize, writeFlag);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Allocate I/O context with custom callbacks.
|
|
204
|
+
*
|
|
205
|
+
* Creates an I/O context with custom read, write, and seek callbacks.
|
|
206
|
+
* Enables implementing custom protocols or data sources.
|
|
207
|
+
*
|
|
208
|
+
* NOTE: When using JavaScript callbacks, synchronous operations
|
|
209
|
+
* (e.g., readSync, seekSync) cannot be used on this context.
|
|
210
|
+
* This is because JavaScript callbacks require the event loop to be available,
|
|
211
|
+
* which is blocked during synchronous operations. Always use async methods
|
|
212
|
+
* (read, seek) when working with custom callbacks.
|
|
213
|
+
*
|
|
214
|
+
* Direct mapping to avio_alloc_context() with callbacks.
|
|
215
|
+
*
|
|
216
|
+
* @param bufferSize - Size of internal buffer
|
|
217
|
+
*
|
|
218
|
+
* @param writeFlag - 1 for write mode, 0 for read mode
|
|
219
|
+
*
|
|
220
|
+
* @param readCallback - Function to read data (null for write-only)
|
|
221
|
+
*
|
|
222
|
+
* @param writeCallback - Function to write data (null for read-only)
|
|
223
|
+
*
|
|
224
|
+
* @param seekCallback - Function to seek in stream (optional)
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* import { AVSEEK_SET, AVSEEK_CUR, AVSEEK_END, AVSEEK_SIZE } from 'node-av/constants';
|
|
229
|
+
*
|
|
230
|
+
* const data = Buffer.from('Custom data source');
|
|
231
|
+
* let position = 0;
|
|
232
|
+
*
|
|
233
|
+
* io.allocContextWithCallbacks(
|
|
234
|
+
* 4096,
|
|
235
|
+
* 0, // Read mode
|
|
236
|
+
* (size) => {
|
|
237
|
+
* // Read callback
|
|
238
|
+
* if (position >= data.length) return -541; // EOF
|
|
239
|
+
* const chunk = data.subarray(position, position + size);
|
|
240
|
+
* position += chunk.length;
|
|
241
|
+
* return chunk;
|
|
242
|
+
* },
|
|
243
|
+
* null,
|
|
244
|
+
* (offset, whence) => {
|
|
245
|
+
* // Seek callback
|
|
246
|
+
* if (whence === AVSEEK_SIZE) return BigInt(data.length);
|
|
247
|
+
* if (whence === AVSEEK_SET) position = Number(offset);
|
|
248
|
+
* else if (whence === AVSEEK_CUR) position += Number(offset);
|
|
249
|
+
* else if (whence === AVSEEK_END) position = data.length + Number(offset);
|
|
250
|
+
* return BigInt(position);
|
|
251
|
+
* }
|
|
252
|
+
* );
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* @see {@link allocContext} For simple allocation
|
|
256
|
+
*/
|
|
257
|
+
allocContextWithCallbacks(bufferSize, writeFlag, readCallback, writeCallback, seekCallback) {
|
|
258
|
+
this.native.allocContextWithCallbacks(bufferSize, writeFlag, readCallback, writeCallback, seekCallback);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Free I/O context.
|
|
262
|
+
*
|
|
263
|
+
* Releases the I/O context and its resources.
|
|
264
|
+
* The context becomes invalid after calling this.
|
|
265
|
+
*
|
|
266
|
+
* Direct mapping to avio_context_free().
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* io.freeContext();
|
|
271
|
+
* // Context is now invalid
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
freeContext() {
|
|
275
|
+
this.native.freeContext();
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Open resource for I/O.
|
|
279
|
+
*
|
|
280
|
+
* Opens a URL or file for reading or writing.
|
|
281
|
+
* Automatically selects the appropriate protocol handler.
|
|
282
|
+
*
|
|
283
|
+
* Direct mapping to avio_open2().
|
|
284
|
+
*
|
|
285
|
+
* @param url - URL or file path to open
|
|
286
|
+
*
|
|
287
|
+
* @param flags - Open flags (AVIO_FLAG_READ, AVIO_FLAG_WRITE, etc.)
|
|
288
|
+
*
|
|
289
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
290
|
+
* - AVERROR_ENOENT: File not found
|
|
291
|
+
* - AVERROR_EACCES: Permission denied
|
|
292
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* import { FFmpegError } from 'node-av';
|
|
297
|
+
* import { AVIO_FLAG_READ, AVIO_FLAG_WRITE } from 'node-av/constants';
|
|
298
|
+
*
|
|
299
|
+
* // Open for reading
|
|
300
|
+
* const ret = await io.open2('input.mp4', AVIO_FLAG_READ);
|
|
301
|
+
* FFmpegError.throwIfError(ret, 'open2');
|
|
302
|
+
*
|
|
303
|
+
* // Open for writing
|
|
304
|
+
* const ret2 = await io.open2('output.mp4', AVIO_FLAG_WRITE);
|
|
305
|
+
* FFmpegError.throwIfError(ret2, 'open2');
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* @see {@link closep} To close after use
|
|
309
|
+
*/
|
|
310
|
+
async open2(url, flags = AVIO_FLAG_READ) {
|
|
311
|
+
return await this.native.open2(url, flags);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Open resource for I/O synchronously.
|
|
315
|
+
* Synchronous version of open2.
|
|
316
|
+
*
|
|
317
|
+
* Opens a URL or file for reading or writing.
|
|
318
|
+
* Automatically selects the appropriate protocol handler.
|
|
319
|
+
*
|
|
320
|
+
* Direct mapping to avio_open2().
|
|
321
|
+
*
|
|
322
|
+
* @param url - URL or file path to open
|
|
323
|
+
*
|
|
324
|
+
* @param flags - Open flags (AVIO_FLAG_READ, AVIO_FLAG_WRITE, etc.)
|
|
325
|
+
*
|
|
326
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
327
|
+
* - AVERROR_ENOENT: File not found
|
|
328
|
+
* - AVERROR_EACCES: Permission denied
|
|
329
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* import { FFmpegError } from 'node-av';
|
|
334
|
+
* import { AVIO_FLAG_READ, AVIO_FLAG_WRITE } from 'node-av/constants';
|
|
335
|
+
*
|
|
336
|
+
* // Open for reading
|
|
337
|
+
* const ret = io.open2Sync('input.mp4', AVIO_FLAG_READ);
|
|
338
|
+
* FFmpegError.throwIfError(ret, 'open2');
|
|
339
|
+
*
|
|
340
|
+
* // Open for writing
|
|
341
|
+
* const ret2 = io.open2Sync('output.mp4', AVIO_FLAG_WRITE);
|
|
342
|
+
* FFmpegError.throwIfError(ret2, 'open2');
|
|
343
|
+
* ```
|
|
344
|
+
*
|
|
345
|
+
* @see {@link open2} For async version
|
|
346
|
+
*/
|
|
347
|
+
open2Sync(url, flags = AVIO_FLAG_READ) {
|
|
348
|
+
return this.native.open2Sync(url, flags);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Close I/O context.
|
|
352
|
+
*
|
|
353
|
+
* Closes the I/O context and releases associated resources.
|
|
354
|
+
* Flushes any buffered data before closing.
|
|
355
|
+
*
|
|
356
|
+
* Direct mapping to avio_closep().
|
|
357
|
+
*
|
|
358
|
+
* @returns 0 on success, negative AVERROR on error
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* const ret = await io.closep();
|
|
363
|
+
* if (ret < 0) {
|
|
364
|
+
* console.error('Error closing I/O context');
|
|
365
|
+
* }
|
|
366
|
+
* ```
|
|
367
|
+
*
|
|
368
|
+
* @see {@link open2} To open resources
|
|
369
|
+
*/
|
|
370
|
+
async closep() {
|
|
371
|
+
return await this.native.closep();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Close I/O context synchronously.
|
|
375
|
+
* Synchronous version of closep.
|
|
376
|
+
*
|
|
377
|
+
* Closes the I/O context and frees resources.
|
|
378
|
+
* Sets internal pointer to NULL.
|
|
379
|
+
*
|
|
380
|
+
* Direct mapping to avio_closep().
|
|
381
|
+
*
|
|
382
|
+
* @returns 0 on success, negative AVERROR on error
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```typescript
|
|
386
|
+
* const ret = io.closepSync();
|
|
387
|
+
* if (ret < 0) {
|
|
388
|
+
* console.error(`Failed to close: ${ret}`);
|
|
389
|
+
* }
|
|
390
|
+
* ```
|
|
391
|
+
*
|
|
392
|
+
* @see {@link closep} For async version
|
|
393
|
+
*/
|
|
394
|
+
closepSync() {
|
|
395
|
+
return this.native.closepSync();
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Read data from I/O context.
|
|
399
|
+
*
|
|
400
|
+
* Reads up to the specified number of bytes from the stream.
|
|
401
|
+
*
|
|
402
|
+
* Direct mapping to avio_read().
|
|
403
|
+
*
|
|
404
|
+
* @param size - Maximum number of bytes to read
|
|
405
|
+
*
|
|
406
|
+
* @returns Buffer with data, or error code if negative:
|
|
407
|
+
* - AVERROR_EOF: End of file reached
|
|
408
|
+
* - AVERROR_EIO: I/O error
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* const data = await io.read(4096);
|
|
413
|
+
* if (data instanceof Buffer) {
|
|
414
|
+
* console.log(`Read ${data.length} bytes`);
|
|
415
|
+
* } else {
|
|
416
|
+
* console.error(`Read error: ${data}`);
|
|
417
|
+
* }
|
|
418
|
+
* ```
|
|
419
|
+
*
|
|
420
|
+
* @see {@link write} For writing data
|
|
421
|
+
*/
|
|
422
|
+
async read(size) {
|
|
423
|
+
return await this.native.read(size);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Read data from I/O context synchronously.
|
|
427
|
+
* Synchronous version of read.
|
|
428
|
+
*
|
|
429
|
+
* Reads up to the specified number of bytes from the stream.
|
|
430
|
+
*
|
|
431
|
+
* Direct mapping to avio_read().
|
|
432
|
+
*
|
|
433
|
+
* @param size - Number of bytes to read
|
|
434
|
+
*
|
|
435
|
+
* @returns Buffer with data, or negative AVERROR on error
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```typescript
|
|
439
|
+
* const result = io.readSync(4096);
|
|
440
|
+
* if (Buffer.isBuffer(result)) {
|
|
441
|
+
* console.log(`Read ${result.length} bytes`);
|
|
442
|
+
* } else {
|
|
443
|
+
* console.log(`Read error: ${result}`);
|
|
444
|
+
* }
|
|
445
|
+
* ```
|
|
446
|
+
*
|
|
447
|
+
* @see {@link read} For async version
|
|
448
|
+
*/
|
|
449
|
+
readSync(size) {
|
|
450
|
+
return this.native.readSync(size);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Write data to I/O context.
|
|
454
|
+
*
|
|
455
|
+
* Writes buffer data to the stream.
|
|
456
|
+
*
|
|
457
|
+
* Direct mapping to avio_write().
|
|
458
|
+
*
|
|
459
|
+
* @param buffer - Data to write
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```typescript
|
|
463
|
+
* const data = Buffer.from('Hello World');
|
|
464
|
+
* await io.write(data);
|
|
465
|
+
* ```
|
|
466
|
+
*
|
|
467
|
+
* @see {@link read} For reading data
|
|
468
|
+
* @see {@link flush} To flush buffers
|
|
469
|
+
*/
|
|
470
|
+
async write(buffer) {
|
|
471
|
+
await this.native.write(buffer);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Write data to I/O context synchronously.
|
|
475
|
+
* Synchronous version of write.
|
|
476
|
+
*
|
|
477
|
+
* Writes buffer data to the stream.
|
|
478
|
+
*
|
|
479
|
+
* Direct mapping to avio_write().
|
|
480
|
+
*
|
|
481
|
+
* @param buffer - Data to write
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* ```typescript
|
|
485
|
+
* const data = Buffer.from('Hello, World!');
|
|
486
|
+
* io.writeSync(data);
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
489
|
+
* @see {@link write} For async version
|
|
490
|
+
*/
|
|
491
|
+
writeSync(buffer) {
|
|
492
|
+
this.native.writeSync(buffer);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Seek to position in stream.
|
|
496
|
+
*
|
|
497
|
+
* Changes the current position in the stream.
|
|
498
|
+
* Not all streams support seeking.
|
|
499
|
+
*
|
|
500
|
+
* Direct mapping to avio_seek().
|
|
501
|
+
*
|
|
502
|
+
* @param offset - Byte offset to seek to
|
|
503
|
+
*
|
|
504
|
+
* @param whence - Seek origin (AVSEEK_SET, AVSEEK_CUR, AVSEEK_END)
|
|
505
|
+
*
|
|
506
|
+
* @returns New position, or negative AVERROR on error:
|
|
507
|
+
* - AVERROR_EINVAL: Invalid arguments
|
|
508
|
+
* - AVERROR_ENOSYS: Seeking not supported
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```typescript
|
|
512
|
+
* import { AVSEEK_SET, AVSEEK_CUR, AVSEEK_END } from 'node-av/constants';
|
|
513
|
+
*
|
|
514
|
+
* // Seek to absolute position
|
|
515
|
+
* const pos1 = await io.seek(1024n, AVSEEK_SET);
|
|
516
|
+
*
|
|
517
|
+
* // Seek relative to current position
|
|
518
|
+
* const pos2 = await io.seek(512n, AVSEEK_CUR);
|
|
519
|
+
*
|
|
520
|
+
* // Seek relative to end
|
|
521
|
+
* const pos3 = await io.seek(-1024n, AVSEEK_END);
|
|
522
|
+
* ```
|
|
523
|
+
*
|
|
524
|
+
* @see {@link tell} To get current position
|
|
525
|
+
* @see {@link skip} For relative seeking
|
|
526
|
+
*/
|
|
527
|
+
async seek(offset, whence) {
|
|
528
|
+
return await this.native.seek(offset, whence);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Seek to position in stream synchronously.
|
|
532
|
+
* Synchronous version of seek.
|
|
533
|
+
*
|
|
534
|
+
* Changes the current position in the stream.
|
|
535
|
+
* Not all streams support seeking.
|
|
536
|
+
*
|
|
537
|
+
* Direct mapping to avio_seek().
|
|
538
|
+
*
|
|
539
|
+
* @param offset - Byte offset to seek to
|
|
540
|
+
*
|
|
541
|
+
* @param whence - Seek origin (AVSEEK_SET, AVSEEK_CUR, AVSEEK_END)
|
|
542
|
+
*
|
|
543
|
+
* @returns New position, or negative AVERROR on error:
|
|
544
|
+
* - AVERROR_EINVAL: Invalid arguments
|
|
545
|
+
* - AVERROR_ENOSYS: Seeking not supported
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* ```typescript
|
|
549
|
+
* import { AVSEEK_SET, AVSEEK_CUR, AVSEEK_END } from 'node-av/constants';
|
|
550
|
+
*
|
|
551
|
+
* // Seek to absolute position
|
|
552
|
+
* const pos1 = io.seekSync(1024n, AVSEEK_SET);
|
|
553
|
+
*
|
|
554
|
+
* // Seek relative to current position
|
|
555
|
+
* const pos2 = io.seekSync(512n, AVSEEK_CUR);
|
|
556
|
+
*
|
|
557
|
+
* // Seek relative to end
|
|
558
|
+
* const pos3 = io.seekSync(-1024n, AVSEEK_END);
|
|
559
|
+
* ```
|
|
560
|
+
*
|
|
561
|
+
* @see {@link seek} For async version
|
|
562
|
+
*/
|
|
563
|
+
seekSync(offset, whence) {
|
|
564
|
+
return this.native.seekSync(offset, whence);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Get stream size.
|
|
568
|
+
*
|
|
569
|
+
* Returns the total size of the stream in bytes.
|
|
570
|
+
* Not all streams have a known size.
|
|
571
|
+
*
|
|
572
|
+
* Direct mapping to avio_size().
|
|
573
|
+
*
|
|
574
|
+
* @returns Size in bytes, or negative AVERROR if unknown:
|
|
575
|
+
* - AVERROR_ENOSYS: Size not available
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* ```typescript
|
|
579
|
+
* const size = await io.size();
|
|
580
|
+
* if (size >= 0n) {
|
|
581
|
+
* console.log(`Stream size: ${size} bytes`);
|
|
582
|
+
* } else {
|
|
583
|
+
* console.log('Stream size unknown');
|
|
584
|
+
* }
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
async size() {
|
|
588
|
+
return await this.native.size();
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Get stream size synchronously.
|
|
592
|
+
* Synchronous version of size.
|
|
593
|
+
*
|
|
594
|
+
* Returns the total size of the stream in bytes.
|
|
595
|
+
* Not all streams have a known size.
|
|
596
|
+
*
|
|
597
|
+
* Direct mapping to avio_size().
|
|
598
|
+
*
|
|
599
|
+
* @returns Size in bytes, or negative AVERROR if unknown:
|
|
600
|
+
* - AVERROR_ENOSYS: Size not available
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* ```typescript
|
|
604
|
+
* const size = io.sizeSync();
|
|
605
|
+
* if (size >= 0n) {
|
|
606
|
+
* console.log(`Stream size: ${size} bytes`);
|
|
607
|
+
* } else {
|
|
608
|
+
* console.log('Stream size unknown');
|
|
609
|
+
* }
|
|
610
|
+
* ```
|
|
611
|
+
*
|
|
612
|
+
* @see {@link size} For async version
|
|
613
|
+
*/
|
|
614
|
+
sizeSync() {
|
|
615
|
+
return this.native.sizeSync();
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Flush buffered data.
|
|
619
|
+
*
|
|
620
|
+
* Forces any buffered data to be written to the underlying resource.
|
|
621
|
+
*
|
|
622
|
+
* Direct mapping to avio_flush().
|
|
623
|
+
*
|
|
624
|
+
* @example
|
|
625
|
+
* ```typescript
|
|
626
|
+
* await io.write(data);
|
|
627
|
+
* await io.flush(); // Ensure data is written
|
|
628
|
+
* ```
|
|
629
|
+
*
|
|
630
|
+
* @see {@link write} For writing data
|
|
631
|
+
*/
|
|
632
|
+
async flush() {
|
|
633
|
+
await this.native.flush();
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Flush buffered data synchronously.
|
|
637
|
+
* Synchronous version of flush.
|
|
638
|
+
*
|
|
639
|
+
* Forces any buffered data to be written to the underlying resource.
|
|
640
|
+
*
|
|
641
|
+
* Direct mapping to avio_flush().
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```typescript
|
|
645
|
+
* io.writeSync(data);
|
|
646
|
+
* io.flushSync(); // Ensure data is written
|
|
647
|
+
* ```
|
|
648
|
+
*
|
|
649
|
+
* @see {@link flush} For async version
|
|
650
|
+
*/
|
|
651
|
+
flushSync() {
|
|
652
|
+
this.native.flushSync();
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Skip bytes in stream.
|
|
656
|
+
*
|
|
657
|
+
* Advances the position by the specified offset.
|
|
658
|
+
* More efficient than reading and discarding data.
|
|
659
|
+
*
|
|
660
|
+
* Direct mapping to avio_skip().
|
|
661
|
+
*
|
|
662
|
+
* @param offset - Number of bytes to skip
|
|
663
|
+
*
|
|
664
|
+
* @returns New position after skipping
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* ```typescript
|
|
668
|
+
* // Skip 1024 bytes forward
|
|
669
|
+
* const newPos = await io.skip(1024n);
|
|
670
|
+
* console.log(`New position: ${newPos}`);
|
|
671
|
+
* ```
|
|
672
|
+
*
|
|
673
|
+
* @see {@link seek} For absolute positioning
|
|
674
|
+
*/
|
|
675
|
+
async skip(offset) {
|
|
676
|
+
return await this.native.skip(offset);
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Skip bytes in stream synchronously.
|
|
680
|
+
* Synchronous version of skip.
|
|
681
|
+
*
|
|
682
|
+
* Advances the position by the specified offset.
|
|
683
|
+
* More efficient than reading and discarding data.
|
|
684
|
+
*
|
|
685
|
+
* Direct mapping to avio_skip().
|
|
686
|
+
*
|
|
687
|
+
* @param offset - Number of bytes to skip
|
|
688
|
+
*
|
|
689
|
+
* @returns New position after skipping
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* ```typescript
|
|
693
|
+
* // Skip 1024 bytes forward
|
|
694
|
+
* const newPos = io.skipSync(1024n);
|
|
695
|
+
* console.log(`New position: ${newPos}`);
|
|
696
|
+
* ```
|
|
697
|
+
*
|
|
698
|
+
* @see {@link skip} For async version
|
|
699
|
+
*/
|
|
700
|
+
skipSync(offset) {
|
|
701
|
+
return this.native.skipSync(offset);
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Get current position.
|
|
705
|
+
*
|
|
706
|
+
* Returns the current byte position in the stream.
|
|
707
|
+
*
|
|
708
|
+
* Direct mapping to avio_tell().
|
|
709
|
+
*
|
|
710
|
+
* @returns Current position in bytes
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* ```typescript
|
|
714
|
+
* const position = io.tell();
|
|
715
|
+
* console.log(`Current position: ${position}`);
|
|
716
|
+
* ```
|
|
717
|
+
*
|
|
718
|
+
* @see {@link seek} To change position
|
|
719
|
+
*/
|
|
720
|
+
tell() {
|
|
721
|
+
return this.native.tell();
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Get the underlying native IOContext object.
|
|
725
|
+
*
|
|
726
|
+
* @returns The native IOContext binding object
|
|
727
|
+
*
|
|
728
|
+
* @internal
|
|
729
|
+
*/
|
|
730
|
+
getNative() {
|
|
731
|
+
return this.native;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Dispose of the I/O context synchronously.
|
|
735
|
+
*
|
|
736
|
+
* Implements the Disposable interface for automatic cleanup.
|
|
737
|
+
* Closes the context and releases resources.
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* ```typescript
|
|
741
|
+
* {
|
|
742
|
+
* using io = IOStream.create(buffer);
|
|
743
|
+
* // Use io...
|
|
744
|
+
* } // Automatically freed when leaving scope
|
|
745
|
+
* ```
|
|
746
|
+
*/
|
|
747
|
+
[Symbol.dispose]() {
|
|
748
|
+
this.native[Symbol.dispose]();
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Dispose of the I/O context asynchronously.
|
|
752
|
+
*
|
|
753
|
+
* Implements the AsyncDisposable interface for automatic cleanup.
|
|
754
|
+
* Closes the context and releases resources.
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
* ```typescript
|
|
758
|
+
* {
|
|
759
|
+
* await using io = new IOContext();
|
|
760
|
+
* await io.open2('input.mp4');
|
|
761
|
+
* // Use io...
|
|
762
|
+
* } // Automatically closed when leaving scope
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
async [Symbol.asyncDispose]() {
|
|
766
|
+
await this.native[Symbol.asyncDispose]();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
//# sourceMappingURL=io-context.js.map
|