import { AudioSample } from 'mediabunny'; import { AudioSampleResource } from 'mediabunny'; import { MaybePromise } from 'mediabunny'; import * as NodeAv from 'node-av'; import { ReadableStreamSource } from 'mediabunny'; import { SetRequired } from 'mediabunny'; import { VideoDataPlane } from 'mediabunny'; import { VideoSample } from 'mediabunny'; import { VideoSampleColorSpace } from 'mediabunny'; import { VideoSampleInit } from 'mediabunny'; import { VideoSamplePixelFormat } from 'mediabunny'; import { VideoSampleResource } from 'mediabunny'; /** * A custom `AudioSampleResource` backed by NodeAV's * [`Frame`](https://seydx.github.io/node-av/api/lib/classes/Frame.html), which in turn is backed by FFmpeg's * [`AVFrame`](https://ffmpeg.org/doxygen/2.7/structAVFrame.html). You can use this resource to create `AudioSample` * instances that are directly backed by FFmpeg's `AVFrame` without data having to be copied. * * When passed, the `Frame` is now owned by resource, meaning it takes care of closing the frame later. If you want to * keep a copy for your own use, clone the frame first. * * @group \@mediabunny/server * @public */ export declare class AvFrameAudioSampleResource extends AudioSampleResource { /** * The NodeAV [`Frame`](https://seydx.github.io/node-av/api/lib/classes/Frame.html) instance backing this resource. * Access throws if the resource has already been closed. */ get frame(): NodeAv.Frame; constructor(frame: NodeAv.Frame); /** WebCodecs sample format mapped from the underlying AvFrame. */ getFormat(): AudioSampleFormat; /** Sample rate in Hz. */ getSampleRate(): number; /** Number of audio channels. */ getNumberOfChannels(): number; /** Number of audio frames (samples per channel) in this resource. */ getNumberOfFrames(): number; /** Presentation timestamp in seconds. */ getTimestamp(): number; /** Release the underlying AvFrame; after this call the resource is unusable. */ close(): void; /** Return the raw bytes for the given plane (planar layouts have one plane per channel). */ getDataPlane(planeIndex: number): Uint8Array; } /** * A custom `VideoSampleResource` backed by NodeAV's * [`Frame`](https://seydx.github.io/node-av/api/lib/classes/Frame.html), which in turn is backed by FFmpeg's * [`AVFrame`](https://ffmpeg.org/doxygen/2.7/structAVFrame.html). You can use this resource to create `VideoSample` * instances that are directly backed by FFmpeg's `AVFrame` without data having to be copied. Since `AVFrame`s can * themselves be backed by data on the GPU, this enables zero-copy hardware-accelerated decode and encode paths. * * When using Electron, you can directly create `Frame` instances without the data having to leave the GPU. For more, * see [NodeAV's docs](https://seydx.github.io/node-av/api/lib/classes/Frame.html). * * When passed, the `Frame` is now owned by resource, meaning it takes care of closing the frame later. If you want to * keep a copy for your own use, clone the frame first. * * @group \@mediabunny/server * @public */ export declare class AvFrameVideoSampleResource extends VideoSampleResource { /** * The NodeAV [`Frame`](https://seydx.github.io/node-av/api/lib/classes/Frame.html) instance backing this resource. * Access throws if the resource has already been closed. */ get frame(): NodeAv.Frame; constructor(frame: NodeAv.Frame); /** WebCodecs pixel format mapped from the underlying AvFrame, or `null` if unsupported. */ getFormat(): VideoSamplePixelFormat | null; /** Coded frame width in pixels (may differ from display width when SAR ≠ 1). */ getCodedWidth(): number; /** Coded frame height in pixels (may differ from display height when SAR ≠ 1). */ getCodedHeight(): number; /** Display width after applying the sample aspect ratio. */ getSquarePixelWidth(): number; /** Display height after applying the sample aspect ratio. */ getSquarePixelHeight(): number; /** Color space (primaries / transfer / matrix / full-range) of the underlying frame. */ getColorSpace(): VideoSampleColorSpace; /** Release the underlying AvFrame; after this call the resource is unusable. */ close(): void; /** Return one entry per plane (`data` + per-line `stride` in bytes). */ getDataPlanes(): MaybePromise; /** Convert the frame to a packed RGBA `VideoSample`. The `colorSpace` argument is currently unused. */ toRgbSample(init: SetRequired, colorSpace: PredefinedColorSpace): Promise; } /** * Options for configuring Mediabunny's server-side polyfills. * @group \@mediabunny/server * @public */ export declare type MediabunnyServerOptions = { /** * The hardware context to use for hardware-accelerated decoding and encoding. When set to a * `NodeAv.HardwareContext`, that context is used directly. When set to a function, the function is invoked (with * no caching) every time a hardware decoder or encoder codec is resolved, receiving the codec ID and returning the * context to use for it (or `null` for no hardware acceleration). * * When not set, a context is automatically detected on first use and then cached. */ hardwareContext?: NodeAv.HardwareContext | null | ((codecId: NodeAv.AVCodecID) => MaybePromise); }; /** * A {@link https://mediabunny.dev/guide/reading-media-files#source | Source} that reads a live network * stream — SRT, or MPEG-TS over UDP, RTP, TCP or HTTP — so an `Input` can read it like any other source. * * Supplies bytes only; Mediabunny does the demuxing. The socket is opened on the first read, so * constructing one never blocks. Listens (`srt://0.0.0.0:9000?mode=listener`) or calls out * (`srt://host:9000`). RTMP is not supported; see FORK.md. * * @example * ```ts * const input = new Input({ * source: new NetworkSource('srt://0.0.0.0:9000?mode=listener'), * formats: ALL_FORMATS, * }); * ``` * * @group \@mediabunny/server * @public */ export declare class NetworkSource extends ReadableStreamSource { constructor(url: string, options?: NetworkSourceOptions); } /** * Options for {@link NetworkSource}. * * @group \@mediabunny/server * @public */ export declare type NetworkSourceOptions = { /** * Seconds to wait for a sender to appear, listening or connecting out. Defaults to 30. Never * infinite: a wait cannot be cancelled once started. */ connectTimeout?: number; /** * Seconds to wait for data from a connected sender before failing. Defaults to 30. When calling * out, the protocol bounds the connect with this same option, so the larger of the two applies. */ readTimeout?: number; /** Maximum bytes to keep for re-reads. Passed through to Mediabunny's `ReadableStreamSource`. */ maxCacheSize?: number; }; /** * Registers video and audio decoders and encoders for all codecs, using FFmpeg's libavcodec under the hood. * Additionally, a custom `VideoSample` transformer based on libavfilter is registered to enable resizing, rotation, * flipping and cropping of video frames. * * Make sure to call this function before interacting with Mediabunny. * * The decoders and encoders will automatically detect hardware acceleration support for each codec and platform and * make use of it if applicable. * * You can pass optional {@link MediabunnyServerOptions} for additional configuration. * * @group \@mediabunny/server * @public */ export declare const registerMediabunnyServer: (options?: MediabunnyServerOptions) => void; /** * Copies a `VideoSample` or `AudioSample` into the given NodeAV * [`Frame`](https://seydx.github.io/node-av/api/lib/classes/Frame.html), setting up the frame's format, media type, * timing and data. When the sample is already backed by an `AVFrame` (via `AvFrameVideoSampleResource` or * `AvFrameAudioSampleResource`), the frame is ref'd instead of copied for zero-copy reuse. * * For video samples, the frame's time base is always set to 1/1000000 (microsecond accuracy). For audio samples, the * frame's time base is always set to 1/sampleRate. * * @group \@mediabunny/server * @public */ export declare const toAvFrame: (sample: VideoSample | AudioSample, frame: NodeAv.Frame) => Promise; export { } export as namespace MediabunnyServer;