Skip to main content

CodecPlugin

Trait CodecPlugin 

Source
pub trait CodecPlugin: Send + Sync {
    // Required methods
    fn info(&self) -> CodecPluginInfo;
    fn capabilities(&self) -> Vec<PluginCapability>;
    fn create_decoder(
        &self,
        codec_name: &str,
    ) -> CodecResult<Box<dyn VideoDecoder>>;
    fn create_encoder(
        &self,
        codec_name: &str,
        config: EncoderConfig,
    ) -> CodecResult<Box<dyn VideoEncoder>>;

    // Provided methods
    fn supports_codec(&self, codec_name: &str) -> bool { ... }
    fn can_decode(&self, codec_name: &str) -> bool { ... }
    fn can_encode(&self, codec_name: &str) -> bool { ... }
}
Expand description

The main plugin trait that external codec libraries implement.

A plugin provides one or more codecs, each with optional decode and encode support. The host application uses the registry to discover plugins and create decoder/encoder instances on demand.

§Thread Safety

Plugins must be Send + Sync because the registry may be shared across threads. Individual decoder/encoder instances returned by the factory methods need only be Send.

§Implementing a Plugin

For simple cases, use StaticPlugin with the builder pattern. For shared libraries, implement this trait on your own type and use the declare_plugin! macro.

Required Methods§

Source

fn info(&self) -> CodecPluginInfo

Get plugin metadata and identification.

Source

fn capabilities(&self) -> Vec<PluginCapability>

List all capabilities (codecs) provided by this plugin.

Source

fn create_decoder(&self, codec_name: &str) -> CodecResult<Box<dyn VideoDecoder>>

Create a decoder instance for the given codec name.

§Errors

Returns CodecError if the codec is not supported or decoder creation fails.

Source

fn create_encoder( &self, codec_name: &str, config: EncoderConfig, ) -> CodecResult<Box<dyn VideoEncoder>>

Create an encoder instance for the given codec name with configuration.

§Errors

Returns CodecError if the codec is not supported or encoder creation fails.

Provided Methods§

Source

fn supports_codec(&self, codec_name: &str) -> bool

Check if this plugin supports a specific codec (decode or encode).

Source

fn can_decode(&self, codec_name: &str) -> bool

Check if this plugin can decode a specific codec.

Source

fn can_encode(&self, codec_name: &str) -> bool

Check if this plugin can encode a specific codec.

Implementors§