pub struct StaticPlugin { /* private fields */ }Expand description
A static plugin that wraps decoder/encoder factory functions.
Use the builder pattern to construct a plugin with custom factories:
use oximedia_plugin::{StaticPlugin, CodecPluginInfo, PluginCapability, PLUGIN_API_VERSION};
use std::collections::HashMap;
let info = CodecPluginInfo {
name: "my-plugin".to_string(),
version: "1.0.0".to_string(),
author: "Me".to_string(),
description: "My custom plugin".to_string(),
api_version: PLUGIN_API_VERSION,
license: "MIT".to_string(),
patent_encumbered: false,
};
let plugin = StaticPlugin::new(info)
.add_capability(PluginCapability {
codec_name: "custom-codec".to_string(),
can_decode: true,
can_encode: false,
pixel_formats: vec!["yuv420p".to_string()],
properties: HashMap::new(),
});Implementations§
Source§impl StaticPlugin
impl StaticPlugin
Sourcepub fn new(info: CodecPluginInfo) -> Self
pub fn new(info: CodecPluginInfo) -> Self
Create a new static plugin with the given metadata.
The plugin starts with no capabilities and no factories.
Use add_capability,
with_decoder, and
with_encoder to configure it.
Sourcepub fn with_decoder<F>(self, factory: F) -> Self
pub fn with_decoder<F>(self, factory: F) -> Self
Register a decoder factory function.
The factory receives the codec name and should return a new decoder instance or an error if the codec is not supported.
Sourcepub fn with_encoder<F>(self, factory: F) -> Self
pub fn with_encoder<F>(self, factory: F) -> Self
Register an encoder factory function.
The factory receives the codec name and encoder configuration, and should return a new encoder instance or an error.
Sourcepub fn add_capability(self, cap: PluginCapability) -> Self
pub fn add_capability(self, cap: PluginCapability) -> Self
Add a codec capability to this plugin.
Trait Implementations§
Source§impl CodecPlugin for StaticPlugin
impl CodecPlugin for StaticPlugin
Source§fn info(&self) -> CodecPluginInfo
fn info(&self) -> CodecPluginInfo
Get plugin metadata and identification.
Source§fn capabilities(&self) -> Vec<PluginCapability>
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>>
fn create_decoder(&self, codec_name: &str) -> CodecResult<Box<dyn VideoDecoder>>
Create a decoder instance for the given codec name. Read more
Source§fn create_encoder(
&self,
codec_name: &str,
config: EncoderConfig,
) -> CodecResult<Box<dyn VideoEncoder>>
fn create_encoder( &self, codec_name: &str, config: EncoderConfig, ) -> CodecResult<Box<dyn VideoEncoder>>
Create an encoder instance for the given codec name with configuration. Read more
Source§fn supports_codec(&self, codec_name: &str) -> bool
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
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
fn can_encode(&self, codec_name: &str) -> bool
Check if this plugin can encode a specific codec.
Auto Trait Implementations§
impl Freeze for StaticPlugin
impl !RefUnwindSafe for StaticPlugin
impl Send for StaticPlugin
impl Sync for StaticPlugin
impl Unpin for StaticPlugin
impl UnsafeUnpin for StaticPlugin
impl !UnwindSafe for StaticPlugin
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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