Skip to main content

DemuxLimits

Struct DemuxLimits 

Source
pub struct DemuxLimits { /* private fields */ }
Expand description

What one demux session may spend: on any single packet, on any single attachment, on every attachment in the file together, and on the container’s chapter table.

Handed to FfmpegDemuxer::open_with rather than set afterwards, because the attachment budget is spent during the open — every attachment payload is captured before the first timed packet is read, which is what makes the demux tier’s delivery contract true by construction.

Implementations§

Source§

impl DemuxLimits

Source

pub const fn new() -> Self

Source

pub const fn max_probe_bytes(&self) -> u64

The ceiling on bytes libavformat may read while probing and analysing a container.

§What this bounds, and what it does not

Bounded: the total bytes libavformat is handed during avformat_open_input and avformat_find_stream_info. It reaches two ways — as probesize and formatprobesize, which every entrypoint sets before the open, and, on the reader entrypoint, as a hard byte meter on the AVIOContext itself: past the budget the reader answers an I/O error, so the parser gets nothing more whatever it asks for.

Not bounded: allocation amplification inside a parser. A container can describe, in a handful of bytes, a structure whose in-memory form is much larger, and nothing outside libavformat can see that happen. What this seat guarantees is that the input to that amplification is finite and small; bounding its output is the substrate’s own hardening territory, and FFmpeg has its own max_streams / max_index_size / max_picture_buffer seats for exactly that — Self::max_streams sets the first of them.

Not bounded on the path entrypoint: the byte meter needs an AVIOContext this crate owns, and a path is opened by libavformat’s own protocol layer. probesize and formatprobesize still apply there; the hard meter does not. A caller who wants the meter on a file can open it as a reader.

Source

pub const fn max_streams(&self) -> u32

The ceiling on streams a container may declare. See Self::max_probe_bytes for why a seat inside libavformat is worth setting at all.

Source

pub const fn with_max_probe_bytes(self, value: u64) -> Self

Sets the probe-read ceiling (consuming builder).

Source

pub const fn with_max_streams(self, value: u32) -> Self

Sets the declared-stream ceiling (consuming builder).

Source

pub const fn max_chapters(&self) -> u32

The ceiling on chapters a container may declare.

Judged before the chapter table is reserved, so a header claiming an enormous table is refused rather than mirrored. Unlike Self::max_streams, which is handed to libavformat and enforced inside it, this one is this crate’s own: libavformat has no max_chapters knob, and an AVChapter is cheap enough there that the probe budget does not reach the count either.

A file over the ceiling fails to open, with TooManyChapters naming the declared count.

Source

pub const fn max_total_chapter_title_bytes(&self) -> usize

The ceiling on bytes every chapter title in the file may hold together.

Charged title by title as the table is mirrored, and the open fails with ChapterTitleBudgetExhausted at the title that crosses it. The charge is made after that one title is read rather than before, the same way Self::max_total_attachment_bytes is charged: what bounds the overshoot is the 64 KiB the metadata reader already refuses any single value past.

Source

pub const fn with_max_chapters(self, value: u32) -> Self

Sets the declared-chapter ceiling (consuming builder).

Source

pub const fn with_max_total_chapter_title_bytes(self, value: usize) -> Self

Sets the whole-file chapter-title budget (consuming builder).

Source

pub const fn set_max_chapters(&mut self, value: u32) -> &mut Self

Sets the declared-chapter ceiling in place.

Source

pub const fn set_max_total_chapter_title_bytes( &mut self, value: usize, ) -> &mut Self

Sets the whole-file chapter-title budget in place.

Source

pub const fn max_total_stream_metadata_bytes(&self) -> usize

The ceiling on bytes every stream’s retained metadata may hold together — the filename, mimetype and language a track row keeps, across every admitted stream.

Charged value by value as the track table is built, and the open fails with TrackMetadataBudgetExhausted at the value that crosses it — before that value is copied. The charge is the decoded size, because lossy decoding expands bytes that are not UTF-8 threefold, so the raw length would under-charge exactly the hostile case.

Source

pub const fn with_max_total_stream_metadata_bytes(self, value: usize) -> Self

Sets the whole-file stream-metadata budget (consuming builder).

Source

pub const fn set_max_total_stream_metadata_bytes( &mut self, value: usize, ) -> &mut Self

Sets the whole-file stream-metadata budget in place.

Source

pub const fn packet(&self) -> PacketLimits

The per-packet budget timed packets are checked against.

Source

pub const fn max_attachment_bytes(&self) -> usize

Most bytes one attachment may carry.

Source

pub const fn max_total_attachment_bytes(&self) -> usize

Most bytes every attachment in the file may carry together.

Source

pub const fn max_codec_parameter_bytes(&self) -> usize

Most heap bytes one stream’s codec parameters may hold — extradata, coded_side_data and a custom channel map together.

Source

pub const fn max_total_codec_parameter_bytes(&self) -> usize

Most heap bytes every stream’s codec parameters may hold together.

Source

pub const fn with_packet(self, value: PacketLimits) -> Self

Sets the per-packet budget (consuming builder).

Source

pub const fn with_max_attachment_bytes(self, value: usize) -> Self

Sets the per-attachment ceiling (consuming builder).

Source

pub const fn with_max_total_attachment_bytes(self, value: usize) -> Self

Sets the whole-file attachment budget (consuming builder).

Source

pub const fn with_max_codec_parameter_bytes(self, value: usize) -> Self

Sets the per-stream codec-parameter ceiling (consuming builder).

Source

pub const fn with_max_total_codec_parameter_bytes(self, value: usize) -> Self

Sets the whole-file codec-parameter budget (consuming builder).

Source

pub const fn set_packet(&mut self, value: PacketLimits) -> &mut Self

Sets the per-packet budget in place.

Source

pub const fn set_max_attachment_bytes(&mut self, value: usize) -> &mut Self

Sets the per-attachment ceiling in place.

Source

pub const fn set_max_total_attachment_bytes( &mut self, value: usize, ) -> &mut Self

Sets the whole-file attachment budget in place.

Source

pub const fn set_max_codec_parameter_bytes(&mut self, value: usize) -> &mut Self

Sets the per-stream codec-parameter ceiling in place.

Source

pub const fn set_max_total_codec_parameter_bytes( &mut self, value: usize, ) -> &mut Self

Sets the whole-file codec-parameter budget in place.

Trait Implementations§

Source§

impl Clone for DemuxLimits

Source§

fn clone(&self) -> DemuxLimits

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DemuxLimits

Source§

impl Debug for DemuxLimits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DemuxLimits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for DemuxLimits

Source§

impl Hash for DemuxLimits

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DemuxLimits

Source§

fn eq(&self, other: &DemuxLimits) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DemuxLimits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more