Skip to main content

CodecInfo

Struct CodecInfo 

Source
#[non_exhaustive]
pub struct CodecInfo { pub id: CodecId, pub capabilities: CodecCapabilities, pub decoder_factory: Option<DecoderFactory>, pub encoder_factory: Option<EncoderFactory>, pub probe: Option<ProbeFn>, pub tags: Vec<CodecTag>, }
Expand description

A single registration: capabilities, decoder/encoder factories, optional probe, and the container tags this codec claims.

Codec crates build one of these per codec id inside their register(reg) function and hand it to CodecRegistry::register. The struct is #[non_exhaustive] so additional fields can be added without breaking existing codec crates — construction is only possible through CodecInfo::new plus the builder methods below.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: CodecId§capabilities: CodecCapabilities§decoder_factory: Option<DecoderFactory>§encoder_factory: Option<EncoderFactory>§probe: Option<ProbeFn>

Probe function that returns a confidence in 0.0..=1.0 for a given ProbeContext. None means “confidence 1.0 for every claimed tag” — the correct default for codecs whose tag claims are unambiguous.

§tags: Vec<CodecTag>

Tags this codec is willing to be looked up under. One codec may claim many tags (an AAC decoder covers several WaveFormat ids, a FourCC, an MP4 OTI, and a Matroska CodecID string at once).

Implementations§

Source§

impl CodecInfo

Source

pub fn new(id: CodecId) -> Self

Start a new registration for id with empty capabilities, no factories, no probe, and no tags. Chain the builder methods below to fill it in, then hand the result to CodecRegistry::register.

Source

pub fn capabilities(self, caps: CodecCapabilities) -> Self

Replace the capability description. The default built by Self::new is a placeholder (audio-flavoured, no flags); every real registration should call this.

Source

pub fn decoder(self, factory: DecoderFactory) -> Self

Source

pub fn encoder(self, factory: EncoderFactory) -> Self

Source

pub fn probe(self, probe: ProbeFn) -> Self

Source

pub fn tag(self, tag: CodecTag) -> Self

Claim a single container tag for this codec. Equivalent to .tags([tag]) but avoids the array ceremony for single-tag claims.

Source

pub fn tags(self, tags: impl IntoIterator<Item = CodecTag>) -> Self

Claim a set of container tags for this codec. Takes any iterable (arrays, Vec, Option, …) so the common case of a codec with 3-6 tags reads as one clean block.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.