Skip to main content

CodecRegistry

Struct CodecRegistry 

Source
pub struct CodecRegistry { /* private fields */ }

Implementations§

Source§

impl CodecRegistry

Source

pub fn new() -> Self

Source

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".

Source

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.

Source

pub fn register_encoder_impl( &mut self, id: CodecId, caps: CodecCapabilities, factory: EncoderFactory, )

Convenience: register an encoder-only implementation.

Source

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.

Source

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.

Source

pub fn register_encoder(&mut self, id: CodecId, factory: EncoderFactory)

Backwards-compat shim: register an encoder-only impl with default software capabilities.

Source

pub fn has_decoder(&self, id: &CodecId) -> bool

Source

pub fn has_encoder(&self, id: &CodecId) -> bool

Source

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.

Source

pub fn make_encoder_with( &self, params: &CodecParameters, prefs: &CodecPreferences, ) -> Result<Box<dyn Encoder>>

Build an encoder, with the same priority + fallback semantics.

Source

pub fn make_decoder(&self, params: &CodecParameters) -> Result<Box<dyn Decoder>>

Default-preference shorthand for make_decoder_with.

Source

pub fn make_encoder(&self, params: &CodecParameters) -> Result<Box<dyn Encoder>>

Default-preference shorthand for make_encoder_with.

Source

pub fn decoder_ids(&self) -> impl Iterator<Item = &CodecId>

Iterate codec ids that have at least one decoder implementation.

Source

pub fn encoder_ids(&self) -> impl Iterator<Item = &CodecId>

Source

pub fn implementations(&self, id: &CodecId) -> &[CodecImplementation]

All registered implementations of a given codec id.

Source

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.

Source

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).

Source

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_data is Some(d) → accept iff probe(d) returns true; otherwise skip and try the next.
  • Claim has a probe + probe_data is None → 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"));
Source

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).

Source

pub fn all_tag_claims( &self, ) -> impl Iterator<Item = (&CodecTag, &CodecId, &TagClaim)>

Iterator over every tag claim currently registered — used by oxideav tags debug output and by integration tests that want to verify the full tag surface.

Trait Implementations§

Source§

impl Default for CodecRegistry

Source§

fn default() -> CodecRegistry

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

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.