#[non_exhaustive]pub struct CodecInfo {
pub id: CodecId,
pub capabilities: CodecCapabilities,
pub decoder_factory: Option<fn(&CodecParameters) -> Result<Box<dyn Decoder>, Error>>,
pub encoder_factory: Option<fn(&CodecParameters) -> Result<Box<dyn Encoder>, Error>>,
pub probe: Option<fn(&ProbeContext<'_>) -> f32>,
pub tags: Vec<CodecTag>,
pub encoder_options_schema: Option<&'static [OptionField]>,
pub decoder_options_schema: Option<&'static [OptionField]>,
}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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: CodecId§capabilities: CodecCapabilities§decoder_factory: Option<fn(&CodecParameters) -> Result<Box<dyn Decoder>, Error>>§encoder_factory: Option<fn(&CodecParameters) -> Result<Box<dyn Encoder>, Error>>§probe: Option<fn(&ProbeContext<'_>) -> f32>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 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).
encoder_options_schema: Option<&'static [OptionField]>Schema of the encoder’s recognised option keys
(CodecParameters::options). Attached with
Self::encoder_options. Used for validation / oxideav list
/ pipeline JSON checks.
decoder_options_schema: Option<&'static [OptionField]>Schema of the decoder’s recognised option keys.
Implementations§
Source§impl CodecInfo
impl CodecInfo
Sourcepub fn new(id: CodecId) -> CodecInfo
pub fn new(id: CodecId) -> CodecInfo
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.
Sourcepub fn capabilities(self, caps: CodecCapabilities) -> CodecInfo
pub fn capabilities(self, caps: CodecCapabilities) -> CodecInfo
Replace the capability description. The default built by
Self::new is a placeholder (audio-flavoured, no flags); every
real registration should call this.
pub fn decoder( self, factory: fn(&CodecParameters) -> Result<Box<dyn Decoder>, Error>, ) -> CodecInfo
pub fn encoder( self, factory: fn(&CodecParameters) -> Result<Box<dyn Encoder>, Error>, ) -> CodecInfo
pub fn probe(self, probe: fn(&ProbeContext<'_>) -> f32) -> CodecInfo
Sourcepub fn tag(self, tag: CodecTag) -> CodecInfo
pub fn tag(self, tag: CodecTag) -> CodecInfo
Claim a single container tag for this codec. Equivalent to
.tags([tag]) but avoids the array ceremony for single-tag
claims.
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.
Sourcepub fn encoder_options<T>(self) -> CodecInfowhere
T: CodecOptionsStruct,
pub fn encoder_options<T>(self) -> CodecInfowhere
T: CodecOptionsStruct,
Declare the options struct this codec’s encoder factory expects.
Attaches T::SCHEMA so the registry can enumerate recognised
option keys (for oxideav list, pipeline JSON validation, etc.).
The factory itself still has to call
crate::parse_options::<T>() against
CodecParameters::options at init time.
Sourcepub fn decoder_options<T>(self) -> CodecInfowhere
T: CodecOptionsStruct,
pub fn decoder_options<T>(self) -> CodecInfowhere
T: CodecOptionsStruct,
Declare the options struct this codec’s decoder factory expects.
See Self::encoder_options for the encoder counterpart.