node-av-lgpl 0.0.0 → 7.1.0-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/LICENSE.md +22 -0
- package/README.md +711 -0
- package/dist/api/audio-frame-buffer.d.ts +636 -0
- package/dist/api/audio-frame-buffer.js +1027 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +938 -0
- package/dist/api/bitstream-filter.js +1427 -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 +1413 -0
- package/dist/api/decoder.js +2367 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1295 -0
- package/dist/api/demuxer.js +2344 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +589 -0
- package/dist/api/device.js +964 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder-pool.d.ts +262 -0
- package/dist/api/encoder-pool.js +397 -0
- package/dist/api/encoder-pool.js.map +1 -0
- package/dist/api/encoder.d.ts +1509 -0
- package/dist/api/encoder.js +2619 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +828 -0
- package/dist/api/filter-complex.js +1661 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +800 -0
- package/dist/api/filter-presets.js +1554 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1339 -0
- package/dist/api/filter.js +2075 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +797 -0
- package/dist/api/fmp4-stream.js +1428 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +677 -0
- package/dist/api/hardware.js +1300 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +21 -0
- package/dist/api/index.js +38 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +308 -0
- package/dist/api/io-stream.js +358 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +1311 -0
- package/dist/api/muxer.js +2672 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +801 -0
- package/dist/api/pipeline.js +1344 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/probe.d.ts +128 -0
- package/dist/api/probe.js +227 -0
- package/dist/api/probe.js.map +1 -0
- package/dist/api/rtp-stream.d.ts +497 -0
- package/dist/api/rtp-stream.js +1131 -0
- package/dist/api/rtp-stream.js.map +1 -0
- package/dist/api/scaler.d.ts +561 -0
- package/dist/api/scaler.js +918 -0
- package/dist/api/scaler.js.map +1 -0
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +149 -0
- package/dist/api/utilities/async-queue.js +254 -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/audio-transcode.d.ts +20 -0
- package/dist/api/utilities/audio-transcode.js +27 -0
- package/dist/api/utilities/audio-transcode.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/codec-format.d.ts +87 -0
- package/dist/api/utilities/codec-format.js +117 -0
- package/dist/api/utilities/codec-format.js.map +1 -0
- package/dist/api/utilities/context-options.d.ts +25 -0
- package/dist/api/utilities/context-options.js +23 -0
- package/dist/api/utilities/context-options.js.map +1 -0
- package/dist/api/utilities/electron-shared-texture.d.ts +368 -0
- package/dist/api/utilities/electron-shared-texture.js +540 -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 +14 -0
- package/dist/api/utilities/index.js +27 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/live-decoding.d.ts +15 -0
- package/dist/api/utilities/live-decoding.js +32 -0
- package/dist/api/utilities/live-decoding.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/packet-age-watchdog.d.ts +198 -0
- package/dist/api/utilities/packet-age-watchdog.js +594 -0
- package/dist/api/utilities/packet-age-watchdog.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/scale-size.d.ts +51 -0
- package/dist/api/utilities/scale-size.js +55 -0
- package/dist/api/utilities/scale-size.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/video-transcode.d.ts +218 -0
- package/dist/api/utilities/video-transcode.js +624 -0
- package/dist/api/utilities/video-transcode.js.map +1 -0
- package/dist/api/utilities/whisper-model.d.ts +330 -0
- package/dist/api/utilities/whisper-model.js +587 -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/webrtc-stream.d.ts +294 -0
- package/dist/api/webrtc-stream.js +546 -0
- package/dist/api/webrtc-stream.js.map +1 -0
- package/dist/api/whisper.d.ts +326 -0
- package/dist/api/whisper.js +402 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/bsf-options.d.ts +364 -0
- package/dist/constants/bsf-options.js +7 -0
- package/dist/constants/bsf-options.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 +2435 -0
- package/dist/constants/constants.js +1989 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +651 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +314 -0
- package/dist/constants/encoders.js +309 -0
- package/dist/constants/encoders.js.map +1 -0
- package/dist/constants/filter-options.d.ts +12099 -0
- package/dist/constants/filter-options.js +7 -0
- package/dist/constants/filter-options.js.map +1 -0
- package/dist/constants/format-options.d.ts +4319 -0
- package/dist/constants/format-options.js +7 -0
- package/dist/constants/format-options.js.map +1 -0
- package/dist/constants/formats.d.ts +18 -0
- package/dist/constants/formats.js +7 -0
- package/dist/constants/formats.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 +10 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/options.d.ts +6217 -0
- package/dist/constants/options.js +7 -0
- package/dist/constants/options.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +101 -0
- package/dist/ffmpeg/index.js +161 -0
- package/dist/ffmpeg/index.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 +242 -0
- package/dist/lib/binding.js +102 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +381 -0
- package/dist/lib/bitstream-filter-context.js +443 -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 +1069 -0
- package/dist/lib/codec-context.js +1336 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +664 -0
- package/dist/lib/codec-parameters.js +813 -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 +617 -0
- package/dist/lib/codec.js +746 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +294 -0
- package/dist/lib/device.js +326 -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 +311 -0
- package/dist/lib/error.js +395 -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 +714 -0
- package/dist/lib/filter-context.js +783 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +161 -0
- package/dist/lib/filter-graph-segment.js +172 -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 +202 -0
- package/dist/lib/filter-inout.js +261 -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 +1335 -0
- package/dist/lib/format-context.js +1455 -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 +1315 -0
- package/dist/lib/frame.js +1535 -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 +418 -0
- package/dist/lib/hardware-frames-context.js +471 -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 +698 -0
- package/dist/lib/io-context.js +771 -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 +1024 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +953 -0
- package/dist/lib/option.js +1607 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +222 -0
- package/dist/lib/output-format.js +259 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +521 -0
- package/dist/lib/packet.js +613 -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 +383 -0
- package/dist/lib/stream.js +524 -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 +1198 -0
- package/dist/lib/utilities.js +1302 -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 +6 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/libc.d.ts +11 -0
- package/dist/utils/libc.js +35 -0
- package/dist/utils/libc.js.map +1 -0
- package/dist/utils/variant.d.ts +26 -0
- package/dist/utils/variant.js +31 -0
- package/dist/utils/variant.js.map +1 -0
- package/dist/webrtc/index.d.ts +4 -0
- package/dist/webrtc/index.js +7 -0
- package/dist/webrtc/index.js.map +1 -0
- package/install/check.js +124 -0
- package/install/ffmpeg.js +66 -0
- package/package.json +165 -3
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Muxer } from '../muxer.js';
|
|
2
|
+
import type { Frame, Packet } from '../../lib/index.js';
|
|
3
|
+
import type { BitStreamFilterAPI } from '../bitstream-filter.js';
|
|
4
|
+
import type { Encoder } from '../encoder.js';
|
|
5
|
+
import type { FilterAPI } from '../filter.js';
|
|
6
|
+
export interface SchedulableComponent<TItem = Packet | Frame> {
|
|
7
|
+
sendToQueue(item: TItem | null): Promise<void>;
|
|
8
|
+
pipeTo(target: FilterAPI | Encoder | BitStreamFilterAPI | Muxer, streamIndex?: number): any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Pipeline scheduler for chaining components.
|
|
12
|
+
*
|
|
13
|
+
* Allows piping between components (Decoder → Filter → Encoder → Output).
|
|
14
|
+
*/
|
|
15
|
+
export declare class Scheduler<TSend = Packet | Frame> {
|
|
16
|
+
private firstComponent;
|
|
17
|
+
/** @internal */
|
|
18
|
+
lastComponent: SchedulableComponent<any>;
|
|
19
|
+
/**
|
|
20
|
+
* @param firstComponent - First component in the pipeline
|
|
21
|
+
*
|
|
22
|
+
* @param lastComponent - Last component in the pipeline (defaults to firstComponent)
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
constructor(firstComponent: SchedulableComponent<TSend>, lastComponent?: SchedulableComponent<any>);
|
|
27
|
+
/**
|
|
28
|
+
* Pipe output to a filter component.
|
|
29
|
+
*
|
|
30
|
+
* @param target - Filter to receive frames
|
|
31
|
+
*
|
|
32
|
+
* @returns Scheduler for continued chaining
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* decoder.pipeTo(filter1).pipeTo(filter2)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
pipeTo(target: FilterAPI): Scheduler<TSend>;
|
|
40
|
+
/**
|
|
41
|
+
* Pipe output to an encoder component.
|
|
42
|
+
*
|
|
43
|
+
* @param target - Encoder to receive frames
|
|
44
|
+
*
|
|
45
|
+
* @returns Scheduler for continued chaining
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* decoder.pipeTo(filter).pipeTo(encoder)
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
pipeTo(target: Encoder): Scheduler<TSend>;
|
|
53
|
+
/**
|
|
54
|
+
* Pipe output to a bitstream filter component.
|
|
55
|
+
*
|
|
56
|
+
* @param target - BitStreamFilter to receive packets
|
|
57
|
+
*
|
|
58
|
+
* @returns Scheduler for continued chaining
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* decoder.pipeTo(encoder).pipeTo(bsf).pipeTo(output, 0)
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
pipeTo(target: BitStreamFilterAPI): Scheduler<TSend>;
|
|
66
|
+
/**
|
|
67
|
+
* Pipe output to a muxer (final stage).
|
|
68
|
+
*
|
|
69
|
+
* @param output - Muxer to write to
|
|
70
|
+
*
|
|
71
|
+
* @param streamIndex - Stream index in output
|
|
72
|
+
*
|
|
73
|
+
* @returns Control interface without pipeTo
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const control = decoder
|
|
78
|
+
* .pipeTo(encoder)
|
|
79
|
+
* .pipeTo(output, 0);
|
|
80
|
+
*
|
|
81
|
+
* await control.send(packet);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
pipeTo(output: Muxer, streamIndex: number): SchedulerControl<TSend>;
|
|
85
|
+
/**
|
|
86
|
+
* Send an item into the pipeline or flush.
|
|
87
|
+
*
|
|
88
|
+
* When item is provided, queues it for processing through the pipeline.
|
|
89
|
+
* When null is provided, triggers flush sequence through all components.
|
|
90
|
+
*
|
|
91
|
+
* @param item - Packet or Frame to process, or null to flush
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Send packet for processing
|
|
96
|
+
* await scheduler.send(packet);
|
|
97
|
+
*
|
|
98
|
+
* // Flush pipeline
|
|
99
|
+
* await scheduler.send(null);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
send(item: TSend | null): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Control interface for completed pipelines.
|
|
106
|
+
*
|
|
107
|
+
* Provides control methods without pipeTo() - this is the final
|
|
108
|
+
* stage after piping to Muxer.
|
|
109
|
+
*
|
|
110
|
+
* @template TSend - The input type flowing through the pipeline
|
|
111
|
+
*/
|
|
112
|
+
export declare class SchedulerControl<TSend = Packet | Frame> {
|
|
113
|
+
private firstComponent;
|
|
114
|
+
/**
|
|
115
|
+
* @param firstComponent - First component in the pipeline
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
constructor(firstComponent: SchedulableComponent<TSend>);
|
|
120
|
+
/**
|
|
121
|
+
* Send an item into the pipeline or flush.
|
|
122
|
+
*
|
|
123
|
+
* When item is provided, queues it for processing through the pipeline.
|
|
124
|
+
* When null is provided, triggers flush sequence through all components.
|
|
125
|
+
*
|
|
126
|
+
* @param item - Packet or Frame to process, or null to flush
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* // Send packet for processing
|
|
131
|
+
* await control.send(packet);
|
|
132
|
+
*
|
|
133
|
+
* // Flush pipeline
|
|
134
|
+
* await control.send(null);
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
send(item: TSend | null): Promise<void>;
|
|
138
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Muxer } from '../muxer.js';
|
|
2
|
+
/**
|
|
3
|
+
* Pipeline scheduler for chaining components.
|
|
4
|
+
*
|
|
5
|
+
* Allows piping between components (Decoder → Filter → Encoder → Output).
|
|
6
|
+
*/
|
|
7
|
+
export class Scheduler {
|
|
8
|
+
firstComponent;
|
|
9
|
+
/** @internal */
|
|
10
|
+
lastComponent;
|
|
11
|
+
/**
|
|
12
|
+
* @param firstComponent - First component in the pipeline
|
|
13
|
+
*
|
|
14
|
+
* @param lastComponent - Last component in the pipeline (defaults to firstComponent)
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
constructor(firstComponent, lastComponent) {
|
|
19
|
+
this.firstComponent = firstComponent;
|
|
20
|
+
this.lastComponent = lastComponent ?? firstComponent;
|
|
21
|
+
}
|
|
22
|
+
pipeTo(target, streamIndex) {
|
|
23
|
+
if (typeof this.lastComponent.pipeTo === 'function') {
|
|
24
|
+
if (target instanceof Muxer) {
|
|
25
|
+
// Start the pipe task (encoder -> output)
|
|
26
|
+
this.lastComponent.pipeTo(target, streamIndex);
|
|
27
|
+
// Return control with correct firstComponent (not lastComponent!)
|
|
28
|
+
return new SchedulerControl(this.firstComponent);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const resultScheduler = this.lastComponent.pipeTo(target);
|
|
32
|
+
// Keep the original firstComponent, update to new lastComponent
|
|
33
|
+
return new Scheduler(this.firstComponent, resultScheduler.lastComponent);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
throw new Error('Last component does not support pipeTo');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Send an item into the pipeline or flush.
|
|
40
|
+
*
|
|
41
|
+
* When item is provided, queues it for processing through the pipeline.
|
|
42
|
+
* When null is provided, triggers flush sequence through all components.
|
|
43
|
+
*
|
|
44
|
+
* @param item - Packet or Frame to process, or null to flush
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Send packet for processing
|
|
49
|
+
* await scheduler.send(packet);
|
|
50
|
+
*
|
|
51
|
+
* // Flush pipeline
|
|
52
|
+
* await scheduler.send(null);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
async send(item) {
|
|
56
|
+
await this.firstComponent.sendToQueue(item);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Control interface for completed pipelines.
|
|
61
|
+
*
|
|
62
|
+
* Provides control methods without pipeTo() - this is the final
|
|
63
|
+
* stage after piping to Muxer.
|
|
64
|
+
*
|
|
65
|
+
* @template TSend - The input type flowing through the pipeline
|
|
66
|
+
*/
|
|
67
|
+
export class SchedulerControl {
|
|
68
|
+
firstComponent;
|
|
69
|
+
/**
|
|
70
|
+
* @param firstComponent - First component in the pipeline
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
constructor(firstComponent) {
|
|
75
|
+
this.firstComponent = firstComponent;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Send an item into the pipeline or flush.
|
|
79
|
+
*
|
|
80
|
+
* When item is provided, queues it for processing through the pipeline.
|
|
81
|
+
* When null is provided, triggers flush sequence through all components.
|
|
82
|
+
*
|
|
83
|
+
* @param item - Packet or Frame to process, or null to flush
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // Send packet for processing
|
|
88
|
+
* await control.send(packet);
|
|
89
|
+
*
|
|
90
|
+
* // Flush pipeline
|
|
91
|
+
* await control.send(null);
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
async send(item) {
|
|
95
|
+
await this.firstComponent.sendToQueue(item);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../../src/api/utilities/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAYpC;;;;GAIG;AACH,MAAM,OAAO,SAAS;IACZ,cAAc,CAA8B;IAEpD,gBAAgB;IAChB,aAAa,CAA4B;IAEzC;;;;;;OAMG;IACH,YAAY,cAA2C,EAAE,aAAyC;QAChG,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,cAAc,CAAC;IACvD,CAAC;IAgED,MAAM,CAAC,MAAwD,EAAE,WAAoB;QACnF,IAAI,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACpD,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;gBAC5B,0CAA0C;gBAC1C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;gBAC/C,kEAAkE;gBAClE,OAAO,IAAI,gBAAgB,CAAQ,IAAI,CAAC,cAAc,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACN,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC1D,gEAAgE;gBAChE,OAAO,IAAI,SAAS,CAAQ,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;YAClF,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,IAAI,CAAC,IAAkB;QAC3B,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IACnB,cAAc,CAA8B;IAEpD;;;;OAIG;IACH,YAAY,cAA2C;QACrD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,IAAI,CAAC,IAAkB;QAC3B,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { FormatContext } from '../../lib/format-context.js';
|
|
2
|
+
import type { AVCodecID } from '../../constants/index.js';
|
|
3
|
+
import type { Muxer } from '../muxer.js';
|
|
4
|
+
/**
|
|
5
|
+
* Streaming protocol utilities.
|
|
6
|
+
*
|
|
7
|
+
* Provides static methods for SDP generation, RTP URL building, and
|
|
8
|
+
* network streaming helpers for RTP/RTSP protocols.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { StreamingUtils, Muxer } from 'node-av/api';
|
|
13
|
+
*
|
|
14
|
+
* // Create RTP outputs
|
|
15
|
+
* const videoOutput = await Muxer.open('rtp://127.0.0.1:5004');
|
|
16
|
+
* const audioOutput = await Muxer.open('rtp://127.0.0.1:5006');
|
|
17
|
+
*
|
|
18
|
+
* // Generate SDP for streaming
|
|
19
|
+
* const sdp = StreamingUtils.createSdp([videoOutput, audioOutput]);
|
|
20
|
+
* if (sdp) {
|
|
21
|
+
* console.log('SDP for streaming:', sdp);
|
|
22
|
+
* // Save to .sdp file or serve via RTSP server
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class StreamingUtils {
|
|
27
|
+
/**
|
|
28
|
+
* Create an SDP (Session Description Protocol) string from demuxer/muxer
|
|
29
|
+
*
|
|
30
|
+
* Generates an SDP description for RTP/RTSP streaming from one or more
|
|
31
|
+
* configured demuxer/muxer. The inputs/outputs should be configured with RTP
|
|
32
|
+
* format and have their streams set up before calling this method.
|
|
33
|
+
*
|
|
34
|
+
* @param contexts - Alternatively, array of FormatContext objects
|
|
35
|
+
*
|
|
36
|
+
* @returns SDP string if successful, null if failed
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Set up RTP outputs with streams
|
|
41
|
+
* const output1 = await Muxer.open('rtp://239.0.0.1:5004');
|
|
42
|
+
* await output1.addStream(encoder1);
|
|
43
|
+
*
|
|
44
|
+
* const output2 = await Muxer.open('rtp://239.0.0.1:5006');
|
|
45
|
+
* await output2.addStream(encoder2);
|
|
46
|
+
*
|
|
47
|
+
* // Generate SDP for multicast streaming
|
|
48
|
+
* const sdp = StreamingUtils.createSdp([output1.getFormatContext(), output2.getFormatContext()]);
|
|
49
|
+
* if (sdp) {
|
|
50
|
+
* // Write to file for VLC or other players
|
|
51
|
+
* await fs.writeFile('stream.sdp', sdp);
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
static createSdp(contexts: FormatContext[]): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Generate SDP for RTP/SRTP input using FFmpeg's native SDP generator
|
|
58
|
+
*
|
|
59
|
+
* Creates an RFC-compliant SDP description using FFmpeg's internal logic.
|
|
60
|
+
* This ensures correct codec names, clock rates, and formatting for all codecs.
|
|
61
|
+
*
|
|
62
|
+
* @param configs - Array of stream configurations
|
|
63
|
+
*
|
|
64
|
+
* @param sessionName - Optional session name for the SDP (default: 'RTP Stream')
|
|
65
|
+
*
|
|
66
|
+
* @returns SDP string with proper rtpmap and optional crypto attributes
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { StreamingUtils } from 'node-av/api';
|
|
71
|
+
* import { AV_CODEC_ID_OPUS, AV_CODEC_ID_H264 } from 'node-av/constants';
|
|
72
|
+
*
|
|
73
|
+
* // Single audio stream with SRTP
|
|
74
|
+
* const sdp = StreamingUtils.createInputSDP([{
|
|
75
|
+
* port: 5004,
|
|
76
|
+
* codecId: AV_CODEC_ID_OPUS,
|
|
77
|
+
* payloadType: 111,
|
|
78
|
+
* clockRate: 48000,
|
|
79
|
+
* channels: 2,
|
|
80
|
+
* srtp: {
|
|
81
|
+
* key: Buffer.alloc(16, 0x12),
|
|
82
|
+
* salt: Buffer.alloc(14, 0x34)
|
|
83
|
+
* }
|
|
84
|
+
* }]);
|
|
85
|
+
*
|
|
86
|
+
* // Multi-stream (video + audio)
|
|
87
|
+
* const sdp = StreamingUtils.createInputSDP([
|
|
88
|
+
* { port: 5006, codecId: AV_CODEC_ID_H264, payloadType: 96, clockRate: 90000 },
|
|
89
|
+
* { port: 5004, codecId: AV_CODEC_ID_OPUS, payloadType: 111, clockRate: 48000, channels: 2 }
|
|
90
|
+
* ], 'My Stream');
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
static createInputSDP(configs: {
|
|
94
|
+
port: number;
|
|
95
|
+
codecId: AVCodecID;
|
|
96
|
+
payloadType: number;
|
|
97
|
+
clockRate: number;
|
|
98
|
+
channels?: number;
|
|
99
|
+
fmtp?: string;
|
|
100
|
+
srtp?: {
|
|
101
|
+
key: Buffer;
|
|
102
|
+
salt: Buffer;
|
|
103
|
+
suite?: 'AES_CM_128_HMAC_SHA1_80' | 'AES_CM_256_HMAC_SHA1_80';
|
|
104
|
+
};
|
|
105
|
+
}[], sessionName?: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Validate if an output is configured for RTP streaming
|
|
108
|
+
*
|
|
109
|
+
* @param output - Muxer to check
|
|
110
|
+
*
|
|
111
|
+
* @returns true if configured for RTP
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const output = await Muxer.open('rtp://127.0.0.1:5004');
|
|
116
|
+
* if (StreamingUtils.isRtpOutput(output)) {
|
|
117
|
+
* const sdp = StreamingUtils.createSdpForOutput(output);
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
static isRtpOutput(output: Muxer): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Build RTP URL from components
|
|
124
|
+
*
|
|
125
|
+
* Helper to construct RTP URLs with proper formatting.
|
|
126
|
+
*
|
|
127
|
+
* @param host - IP address or hostname
|
|
128
|
+
*
|
|
129
|
+
* @param port - Port number
|
|
130
|
+
*
|
|
131
|
+
* @param options - Additional options
|
|
132
|
+
*
|
|
133
|
+
* @param options.ttl - Time-to-live for multicast
|
|
134
|
+
*
|
|
135
|
+
* @param options.localrtpport - Local RTP port
|
|
136
|
+
*
|
|
137
|
+
* @param options.localrtcpport - Local RTCP port
|
|
138
|
+
*
|
|
139
|
+
* @param options.pkt_size - Packet size
|
|
140
|
+
*
|
|
141
|
+
* @returns Formatted RTP URL
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* // Unicast
|
|
146
|
+
* const url1 = StreamingUtils.buildRtpUrl('127.0.0.1', 5004);
|
|
147
|
+
* // 'rtp://127.0.0.1:5004'
|
|
148
|
+
*
|
|
149
|
+
* // Multicast
|
|
150
|
+
* const url2 = StreamingUtils.buildRtpUrl('239.0.0.1', 5004, { ttl: 64 });
|
|
151
|
+
* // 'rtp://239.0.0.1:5004?ttl=64'
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
static buildRtpUrl(host: string, port: number, options?: {
|
|
155
|
+
ttl?: number;
|
|
156
|
+
localrtpport?: number;
|
|
157
|
+
localrtcpport?: number;
|
|
158
|
+
pkt_size?: number;
|
|
159
|
+
}): string;
|
|
160
|
+
/**
|
|
161
|
+
* Extract all UDP ports from SDP content
|
|
162
|
+
*
|
|
163
|
+
* @param sdp - SDP content string
|
|
164
|
+
*
|
|
165
|
+
* @returns Array of port numbers (one per stream)
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* import { StreamingUtils } from 'node-av/api';
|
|
170
|
+
*
|
|
171
|
+
* const sdp = `v=0
|
|
172
|
+
* o=- 0 0 IN IP4 127.0.0.1
|
|
173
|
+
* s=Test Stream
|
|
174
|
+
* c=IN IP4 127.0.0.1
|
|
175
|
+
* t=0 0
|
|
176
|
+
* m=audio 5004 RTP/AVP 111
|
|
177
|
+
* a=rtpmap:111 OPUS/48000/2
|
|
178
|
+
* m=video 5006 RTP/AVP 96
|
|
179
|
+
* a=rtpmap:96 H264/90000`;
|
|
180
|
+
*
|
|
181
|
+
* const ports = StreamingUtils.extractPortsFromSDP(sdp);
|
|
182
|
+
* console.log(ports); // [5004, 5006]
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
static extractPortsFromSDP(sdp: string): number[];
|
|
186
|
+
}
|