pub struct CodecRegistryHandle { /* private fields */ }Expand description
Thread-safe handle for codec registration/lookups.
§Example
use std::sync::Arc;
use styx_codec::{Codec, CodecDescriptor, CodecError, CodecKind, CodecRegistry};
use styx_core::prelude::{FourCc, FrameLease};
struct Passthrough {
desc: CodecDescriptor,
}
impl Codec for Passthrough {
fn descriptor(&self) -> &CodecDescriptor { &self.desc }
fn process(&self, input: FrameLease) -> Result<FrameLease, CodecError> { Ok(input) }
}
let registry = CodecRegistry::new();
registry.register(
FourCc::new(*b"RG24"),
Arc::new(Passthrough {
desc: CodecDescriptor {
kind: CodecKind::Decoder,
input: FourCc::new(*b"RG24"),
output: FourCc::new(*b"RG24"),
name: "passthrough",
impl_name: "passthrough",
},
}),
);
let handle = registry.handle();
let _ = handle.lookup(FourCc::new(*b"RG24"))?;Implementations§
Source§impl CodecRegistryHandle
impl CodecRegistryHandle
Sourcepub fn lookup(&self, fourcc: FourCc) -> Result<Arc<dyn Codec>, RegistryError>
pub fn lookup(&self, fourcc: FourCc) -> Result<Arc<dyn Codec>, RegistryError>
Lookup a codec by FourCc.
Sourcepub fn lookup_named(
&self,
fourcc: FourCc,
impl_name: &str,
) -> Result<Arc<dyn Codec>, RegistryError>
pub fn lookup_named( &self, fourcc: FourCc, impl_name: &str, ) -> Result<Arc<dyn Codec>, RegistryError>
Lookup a codec by FourCc and implementation name.
Sourcepub fn lookup_named_kind(
&self,
fourcc: FourCc,
kind: CodecKind,
impl_name: &str,
) -> Result<Arc<dyn Codec>, RegistryError>
pub fn lookup_named_kind( &self, fourcc: FourCc, kind: CodecKind, impl_name: &str, ) -> Result<Arc<dyn Codec>, RegistryError>
Lookup a codec by FourCc, kind, and implementation name.
Sourcepub fn lookup_preferred(
&self,
fourcc: FourCc,
preferred_impls: &[&str],
prefer_hardware: bool,
) -> Result<Arc<dyn Codec>, RegistryError>
pub fn lookup_preferred( &self, fourcc: FourCc, preferred_impls: &[&str], prefer_hardware: bool, ) -> Result<Arc<dyn Codec>, RegistryError>
Lookup a codec by FourCc honoring an ordered list of preferred impl names and hardware preference.
Sourcepub fn lookup_by_impl(
&self,
kind: CodecKind,
impl_name: &str,
) -> Result<(FourCc, Arc<dyn Codec>), RegistryError>
pub fn lookup_by_impl( &self, kind: CodecKind, impl_name: &str, ) -> Result<(FourCc, Arc<dyn Codec>), RegistryError>
Find a codec by implementation name and kind across all FourCc entries.
Sourcepub fn process(
&self,
fourcc: FourCc,
frame: FrameLease,
) -> Result<FrameLease, RegistryError>
pub fn process( &self, fourcc: FourCc, frame: FrameLease, ) -> Result<FrameLease, RegistryError>
Process a frame with the registered codec.
Sourcepub fn process_named(
&self,
fourcc: FourCc,
impl_name: &str,
frame: FrameLease,
) -> Result<FrameLease, RegistryError>
pub fn process_named( &self, fourcc: FourCc, impl_name: &str, frame: FrameLease, ) -> Result<FrameLease, RegistryError>
Process with a specific implementation name.
Sourcepub fn process_preferred(
&self,
fourcc: FourCc,
preferred_impls: &[&str],
prefer_hardware: bool,
frame: FrameLease,
) -> Result<FrameLease, RegistryError>
pub fn process_preferred( &self, fourcc: FourCc, preferred_impls: &[&str], prefer_hardware: bool, frame: FrameLease, ) -> Result<FrameLease, RegistryError>
Process with an ordered implementation preference and optional hardware bias.
Sourcepub fn set_preference(&self, fourcc: FourCc, preference: Preference)
pub fn set_preference(&self, fourcc: FourCc, preference: Preference)
Configure preferences for a FourCc (impl order + hardware bias).
Sourcepub fn disable_impl(&self, fourcc: FourCc, impl_name: &str)
pub fn disable_impl(&self, fourcc: FourCc, impl_name: &str)
Disable a codec implementation by impl_name for the given FourCc.
Sourcepub fn enable_only(&self, fourcc: FourCc, impl_names: &[&str])
pub fn enable_only(&self, fourcc: FourCc, impl_names: &[&str])
Enable only the listed impl_names for a FourCc (removes others).
Sourcepub fn register_dynamic(&self, fourcc: FourCc, codec: Arc<dyn Codec>)
pub fn register_dynamic(&self, fourcc: FourCc, codec: Arc<dyn Codec>)
Dynamically register a new codec impl at runtime.
Sourcepub fn set_impl_priority(&self, fourcc: FourCc, impl_name: &str, priority: i32)
pub fn set_impl_priority(&self, fourcc: FourCc, impl_name: &str, priority: i32)
Assign an explicit priority for an impl name (lower wins).
Sourcepub fn set_default_hardware_bias(&self, prefer: bool)
pub fn set_default_hardware_bias(&self, prefer: bool)
Toggle the default bias toward hardware implementations.
Sourcepub fn set_policy(&self, policy: CodecPolicy)
pub fn set_policy(&self, policy: CodecPolicy)
Install a full policy for a FourCc.
Sourcepub fn lookup_auto(
&self,
fourcc: FourCc,
) -> Result<Arc<dyn Codec>, RegistryError>
pub fn lookup_auto( &self, fourcc: FourCc, ) -> Result<Arc<dyn Codec>, RegistryError>
Lookup honoring stored preferences when present.
Sourcepub fn lookup_auto_kind(
&self,
fourcc: FourCc,
kind: CodecKind,
) -> Result<Arc<dyn Codec>, RegistryError>
pub fn lookup_auto_kind( &self, fourcc: FourCc, kind: CodecKind, ) -> Result<Arc<dyn Codec>, RegistryError>
Lookup honoring stored preferences when present, constrained to a codec kind.
Sourcepub fn lookup_auto_kind_by_name(
&self,
fourcc: FourCc,
kind: CodecKind,
codec_name: &str,
) -> Result<Arc<dyn Codec>, RegistryError>
pub fn lookup_auto_kind_by_name( &self, fourcc: FourCc, kind: CodecKind, codec_name: &str, ) -> Result<Arc<dyn Codec>, RegistryError>
Lookup honoring stored preferences, constrained to a codec kind and algorithm family name.
Sourcepub fn process_auto(
&self,
fourcc: FourCc,
frame: FrameLease,
) -> Result<FrameLease, RegistryError>
pub fn process_auto( &self, fourcc: FourCc, frame: FrameLease, ) -> Result<FrameLease, RegistryError>
Process honoring stored preferences when present.
Sourcepub fn process_auto_kind(
&self,
fourcc: FourCc,
kind: CodecKind,
frame: FrameLease,
) -> Result<FrameLease, RegistryError>
pub fn process_auto_kind( &self, fourcc: FourCc, kind: CodecKind, frame: FrameLease, ) -> Result<FrameLease, RegistryError>
Process honoring stored preferences when present, constrained to a codec kind.
Sourcepub fn process_auto_kind_by_name(
&self,
fourcc: FourCc,
kind: CodecKind,
codec_name: &str,
frame: FrameLease,
) -> Result<FrameLease, RegistryError>
pub fn process_auto_kind_by_name( &self, fourcc: FourCc, kind: CodecKind, codec_name: &str, frame: FrameLease, ) -> Result<FrameLease, RegistryError>
Process honoring stored preferences, constrained to a codec kind and algorithm family name.
Sourcepub fn stats(&self) -> CodecStats
pub fn stats(&self) -> CodecStats
Stats snapshot.
Sourcepub fn list_registered(&self) -> Vec<(FourCc, Vec<CodecDescriptor>)>
pub fn list_registered(&self) -> Vec<(FourCc, Vec<CodecDescriptor>)>
Snapshot of all registered codecs grouped by FourCc (descriptor-only).
Sourcepub fn list_registered_by_kind(
&self,
kind: CodecKind,
) -> Vec<(FourCc, Vec<CodecDescriptor>)>
pub fn list_registered_by_kind( &self, kind: CodecKind, ) -> Vec<(FourCc, Vec<CodecDescriptor>)>
List registered codecs filtered by kind.
Trait Implementations§
Source§impl Clone for CodecRegistryHandle
impl Clone for CodecRegistryHandle
Source§fn clone(&self) -> CodecRegistryHandle
fn clone(&self) -> CodecRegistryHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CodecRegistryHandle
impl RefUnwindSafe for CodecRegistryHandle
impl Send for CodecRegistryHandle
impl Sync for CodecRegistryHandle
impl Unpin for CodecRegistryHandle
impl UnwindSafe for CodecRegistryHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more