pub struct PluginRegistry { /* private fields */ }Expand description
Central registry for all loaded codec plugins.
The registry maintains a list of registered plugins ordered by priority (descending) and provides methods to discover codecs, create decoders/encoders, and manage the plugin lifecycle.
§Thread Safety
The registry uses interior mutability (RwLock) so it can be
shared across threads. Multiple readers can query the registry
concurrently; writes (registration) acquire an exclusive lock.
§Priority
Higher priority values take precedence when multiple plugins provide
the same codec. Use register_with_priority
to supply a custom priority (default is 0).
§Example
use oximedia_plugin::{PluginRegistry, StaticPlugin, CodecPluginInfo, PluginCapability};
use std::sync::Arc;
use std::collections::HashMap;
let registry = PluginRegistry::new();
let info = CodecPluginInfo {
name: "example".to_string(),
version: "0.1.0".to_string(),
author: "Test".to_string(),
description: "Example plugin".to_string(),
api_version: oximedia_plugin::PLUGIN_API_VERSION,
license: "MIT".to_string(),
patent_encumbered: false,
};
let plugin = StaticPlugin::new(info)
.add_capability(PluginCapability {
codec_name: "test".to_string(),
can_decode: true,
can_encode: false,
pixel_formats: vec![],
properties: HashMap::new(),
});
registry.register(Arc::new(plugin)).expect("should register");
assert!(registry.has_codec("test"));Implementations§
Source§impl PluginRegistry
impl PluginRegistry
Sourcepub fn add_search_path(&mut self, path: PathBuf)
pub fn add_search_path(&mut self, path: PathBuf)
Add a directory to search for plugins.
Sourcepub fn search_paths(&self) -> &[PathBuf]
pub fn search_paths(&self) -> &[PathBuf]
Get the list of search paths.
Sourcepub fn default_search_paths() -> Vec<PathBuf>
pub fn default_search_paths() -> Vec<PathBuf>
Compute default search paths for plugin discovery.
The following paths are checked (in order):
$OXIMEDIA_PLUGIN_PATH(colon-separated on Unix, semicolon on Windows)~/.oximedia/plugins//usr/lib/oximedia/plugins/(Unix only)/usr/local/lib/oximedia/plugins/(Unix only)
Sourcepub fn register(&self, plugin: Arc<dyn CodecPlugin>) -> PluginResult<()>
pub fn register(&self, plugin: Arc<dyn CodecPlugin>) -> PluginResult<()>
Register a static plugin instance with default priority (0).
The plugin is validated (API version check, duplicate name check) before being added to the registry.
§Errors
Returns PluginError::ApiIncompatible if the API version does
not match, or PluginError::AlreadyRegistered if a plugin
with the same name is already loaded.
Sourcepub fn register_with_priority(
&self,
plugin: Arc<dyn CodecPlugin>,
priority: i32,
) -> PluginResult<()>
pub fn register_with_priority( &self, plugin: Arc<dyn CodecPlugin>, priority: i32, ) -> PluginResult<()>
Sourcepub fn unregister(&self, name: &str) -> PluginResult<()>
pub fn unregister(&self, name: &str) -> PluginResult<()>
Unregister a plugin by name.
§Errors
Returns PluginError::NotFound if no plugin with that name is registered.
Sourcepub fn load_plugin(&self, _path: &Path) -> PluginResult<()>
pub fn load_plugin(&self, _path: &Path) -> PluginResult<()>
Load a plugin from a shared library file.
This is a stub that returns an error when the dynamic-loading
feature is not enabled.
Sourcepub fn discover_plugins(&self) -> PluginResult<Vec<CodecPluginInfo>>
pub fn discover_plugins(&self) -> PluginResult<Vec<CodecPluginInfo>>
Discover plugins stub when dynamic loading is disabled.
Sourcepub fn list_plugins(&self) -> Vec<CodecPluginInfo>
pub fn list_plugins(&self) -> Vec<CodecPluginInfo>
List all registered plugins (in priority order, highest first).
Sourcepub fn list_codecs(&self) -> Vec<PluginCapability>
pub fn list_codecs(&self) -> Vec<PluginCapability>
List all available codecs across all plugins.
Sourcepub fn find_decoder(
&self,
codec_name: &str,
) -> CodecResult<Box<dyn VideoDecoder>>
pub fn find_decoder( &self, codec_name: &str, ) -> CodecResult<Box<dyn VideoDecoder>>
Find and create a decoder for a given codec name.
Searches all registered plugins (in priority order) for one that can decode the requested codec, and creates a new decoder instance.
Uses the capability cache for O(1) plugin lookup.
§Errors
Returns error if no plugin supports decoding the given codec.
Sourcepub fn find_encoder(
&self,
codec_name: &str,
config: EncoderConfig,
) -> CodecResult<Box<dyn VideoEncoder>>
pub fn find_encoder( &self, codec_name: &str, config: EncoderConfig, ) -> CodecResult<Box<dyn VideoEncoder>>
Find and create an encoder for a given codec name.
Searches all registered plugins (in priority order) for one that can encode the requested codec, and creates a new encoder instance.
Uses the capability cache for O(1) plugin lookup.
§Errors
Returns error if no plugin supports encoding the given codec.
Sourcepub fn has_codec(&self, codec_name: &str) -> bool
pub fn has_codec(&self, codec_name: &str) -> bool
Check if any plugin provides a given codec (decode or encode).
Sourcepub fn has_decoder(&self, codec_name: &str) -> bool
pub fn has_decoder(&self, codec_name: &str) -> bool
Check if any plugin can decode a given codec.
Sourcepub fn has_encoder(&self, codec_name: &str) -> bool
pub fn has_encoder(&self, codec_name: &str) -> bool
Check if any plugin can encode a given codec.
Sourcepub fn plugin_count(&self) -> usize
pub fn plugin_count(&self) -> usize
Get the number of registered plugins.
Sourcepub fn find_plugin_for_codec(&self, codec_name: &str) -> Option<CodecPluginInfo>
pub fn find_plugin_for_codec(&self, codec_name: &str) -> Option<CodecPluginInfo>
Find the plugin that provides a given codec (respects priority ordering).
Sourcepub fn plugin_priority(&self, name: &str) -> Option<i32>
pub fn plugin_priority(&self, name: &str) -> Option<i32>
Get the priority of a registered plugin by name.
Returns None if no plugin with that name is registered.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PluginRegistry
impl RefUnwindSafe for PluginRegistry
impl Send for PluginRegistry
impl Sync for PluginRegistry
impl Unpin for PluginRegistry
impl UnsafeUnpin for PluginRegistry
impl UnwindSafe for PluginRegistry
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> 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>
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