Skip to main content

StaticPlugin

Struct StaticPlugin 

Source
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

Source

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.

Source

pub fn with_decoder<F>(self, factory: F) -> Self
where F: Fn(&str) -> CodecResult<Box<dyn VideoDecoder>> + Send + Sync + 'static,

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.

Source

pub fn with_encoder<F>(self, factory: F) -> Self
where F: Fn(&str, EncoderConfig) -> CodecResult<Box<dyn VideoEncoder>> + Send + Sync + 'static,

Register an encoder factory function.

The factory receives the codec name and encoder configuration, and should return a new encoder instance or an error.

Source

pub fn add_capability(self, cap: PluginCapability) -> Self

Add a codec capability to this plugin.

Trait Implementations§

Source§

impl CodecPlugin for StaticPlugin

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. Read more
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. Read more
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.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more