macro_rules! declare_plugin {
($plugin_type:ty, $create_fn:ident) => { ... };
}Expand description
Macro for defining a plugin entry point in a shared library.
This macro generates the two required extern "C" functions
that the host uses to load the plugin:
oximedia_plugin_api_version() -> u32- returns the API versionoximedia_plugin_create() -> *mut dyn CodecPlugin- creates the plugin
§Usage
In your plugin crate’s lib.rs:
ⓘ
use oximedia_plugin::{CodecPlugin, CodecPluginInfo};
struct MyPlugin;
impl CodecPlugin for MyPlugin {
// ... implement trait methods
}
fn create_my_plugin() -> MyPlugin {
MyPlugin
}
oximedia_plugin::declare_plugin!(MyPlugin, create_my_plugin);§Safety
The generated functions use unsafe extern "C" ABI. The create
function allocates the plugin on the heap and returns a raw pointer.
The host is responsible for taking ownership (via Arc::from_raw).