pub struct CodecRegistry { /* private fields */ }Implementations§
Source§impl CodecRegistry
impl CodecRegistry
pub fn new() -> Self
Sourcepub fn register(&mut self, id: CodecId, implementation: CodecImplementation)
pub fn register(&mut self, id: CodecId, implementation: CodecImplementation)
Register a codec implementation. The same codec id may be registered
multiple times — for example a software FLAC decoder and (later) a
hardware one would both register under id "flac".
Sourcepub fn register_decoder_impl(
&mut self,
id: CodecId,
caps: CodecCapabilities,
factory: DecoderFactory,
)
pub fn register_decoder_impl( &mut self, id: CodecId, caps: CodecCapabilities, factory: DecoderFactory, )
Convenience: register a decoder-only implementation built from a caps + factory pair.
Sourcepub fn register_encoder_impl(
&mut self,
id: CodecId,
caps: CodecCapabilities,
factory: EncoderFactory,
)
pub fn register_encoder_impl( &mut self, id: CodecId, caps: CodecCapabilities, factory: EncoderFactory, )
Convenience: register an encoder-only implementation.
Sourcepub fn register_both(
&mut self,
id: CodecId,
caps: CodecCapabilities,
decode: DecoderFactory,
encode: EncoderFactory,
)
pub fn register_both( &mut self, id: CodecId, caps: CodecCapabilities, decode: DecoderFactory, encode: EncoderFactory, )
Convenience: register a single implementation that handles both decode and encode for a codec id.
Sourcepub fn register_decoder(&mut self, id: CodecId, factory: DecoderFactory)
pub fn register_decoder(&mut self, id: CodecId, factory: DecoderFactory)
Backwards-compat shim: register a decoder-only impl with default
software capabilities. Prefer register_decoder_impl for new code.
Sourcepub fn register_encoder(&mut self, id: CodecId, factory: EncoderFactory)
pub fn register_encoder(&mut self, id: CodecId, factory: EncoderFactory)
Backwards-compat shim: register an encoder-only impl with default software capabilities.
pub fn has_decoder(&self, id: &CodecId) -> bool
pub fn has_encoder(&self, id: &CodecId) -> bool
Sourcepub fn make_decoder_with(
&self,
params: &CodecParameters,
prefs: &CodecPreferences,
) -> Result<Box<dyn Decoder>>
pub fn make_decoder_with( &self, params: &CodecParameters, prefs: &CodecPreferences, ) -> Result<Box<dyn Decoder>>
Build a decoder for params. Walks all implementations matching the
codec id in increasing priority order, skipping any excluded by the
caller’s preferences. Init-time fallback: if a higher-priority impl’s
constructor returns an error, the next candidate is tried.
Sourcepub fn make_encoder_with(
&self,
params: &CodecParameters,
prefs: &CodecPreferences,
) -> Result<Box<dyn Encoder>>
pub fn make_encoder_with( &self, params: &CodecParameters, prefs: &CodecPreferences, ) -> Result<Box<dyn Encoder>>
Build an encoder, with the same priority + fallback semantics.
Sourcepub fn make_decoder(&self, params: &CodecParameters) -> Result<Box<dyn Decoder>>
pub fn make_decoder(&self, params: &CodecParameters) -> Result<Box<dyn Decoder>>
Default-preference shorthand for make_decoder_with.
Sourcepub fn make_encoder(&self, params: &CodecParameters) -> Result<Box<dyn Encoder>>
pub fn make_encoder(&self, params: &CodecParameters) -> Result<Box<dyn Encoder>>
Default-preference shorthand for make_encoder_with.
Sourcepub fn decoder_ids(&self) -> impl Iterator<Item = &CodecId>
pub fn decoder_ids(&self) -> impl Iterator<Item = &CodecId>
Iterate codec ids that have at least one decoder implementation.
pub fn encoder_ids(&self) -> impl Iterator<Item = &CodecId>
Sourcepub fn implementations(&self, id: &CodecId) -> &[CodecImplementation]
pub fn implementations(&self, id: &CodecId) -> &[CodecImplementation]
All registered implementations of a given codec id.
Sourcepub fn all_implementations(
&self,
) -> impl Iterator<Item = (&CodecId, &CodecImplementation)>
pub fn all_implementations( &self, ) -> impl Iterator<Item = (&CodecId, &CodecImplementation)>
Iterator over every (codec_id, impl) pair — useful for oxideav list
to show capability flags per implementation.
Sourcepub fn claim_tag(
&mut self,
id: CodecId,
tag: CodecTag,
priority: u8,
probe: Option<CodecProbe>,
)
pub fn claim_tag( &mut self, id: CodecId, tag: CodecTag, priority: u8, probe: Option<CodecProbe>, )
Attach a codec id to a container tag so demuxers can look up the right decoder without each container maintaining its own hand-written FourCC / WAVEFORMATEX / Matroska table.
A single tag may be claimed by multiple codecs — the typical
reason is mislabelling in the wild: e.g. AVI FourCC DIV3
legally means MS-MPEG4v3 but in practice is applied to real
MPEG-4 Part 2 streams often enough that both oxideav-msmpeg4
and oxideav-mpeg4video want to claim it, each with a probe
that accepts the bitstream it actually understands.
Claims are stored sorted by priority descending;
Self::resolve_tag walks them in order and returns the
first whose probe accepts (or the first with no probe).
Sourcepub fn resolve_tag(
&self,
tag: &CodecTag,
probe_data: Option<&[u8]>,
) -> Option<&CodecId>
pub fn resolve_tag( &self, tag: &CodecTag, probe_data: Option<&[u8]>, ) -> Option<&CodecId>
Resolve a container tag to a codec id. Walks the priority- ordered claim list and returns the first matching one:
- Claim has a probe +
probe_dataisSome(d)→ accept iffprobe(d)returns true; otherwise skip and try the next. - Claim has a probe +
probe_dataisNone→ accept (probing without bytes is impossible; fall back to priority). - Claim has no probe → accept (catch-all).
Returns None if the tag has no claimants.
§Example
use oxideav_codec::CodecRegistry;
use oxideav_core::{CodecId, CodecTag};
let mut reg = CodecRegistry::new();
reg.claim_tag(CodecId::new("flac"), CodecTag::fourcc(b"FLAC"), 10, None);
let resolved = reg.resolve_tag(&CodecTag::fourcc(b"FLAC"), None);
assert_eq!(resolved.map(|c| c.as_str()), Some("flac"));Sourcepub fn claims_for_tag(&self, tag: &CodecTag) -> &[(CodecId, TagClaim)]
pub fn claims_for_tag(&self, tag: &CodecTag) -> &[(CodecId, TagClaim)]
Return the full list of claims for a tag in priority order —
useful for diagnostics (oxideav tags / error messages when
no claim accepts the probed bytes).