Plugin System
Monibuca V6 adopts a plugin-based architecture where all protocol support and extended functionality are implemented as plugins. The engine itself only provides core stream management, frame dispatch, and the configuration framework, while protocol encoding/decoding and business logic are handled by plugins.
Three Plugin Modes
Section titled “Three Plugin Modes”Static Compilation (Static Plugins)
Section titled “Static Compilation (Static Plugins)”Plugins are linked directly into the main engine binary at compile time. This is the default mode and offers the best performance. Precompiled binaries and Docker images use this mode and include all official plugins.
Advantages: No runtime overhead, cross-crate compiler optimizations, best LTO optimization results
Dynamic Loading (Dynamic Plugins)
Section titled “Dynamic Loading (Dynamic Plugins)”Plugins are compiled as shared libraries (.so/.dylib/.dll) and loaded at runtime.
[features]dynamic-plugins = []Advantages: Add/update plugins without recompiling the main program
Use cases: Deployments requiring hot plugin updates, or scenarios where plugins are provided by third parties
WASM Sandbox (WASM Plugins)
Section titled “WASM Sandbox (WASM Plugins)”Plugins are compiled as WebAssembly modules and executed in isolation within a WASM runtime.
Advantages: Highest security; plugins cannot access host memory
Use cases: Running untrusted third-party plugins
Built-in Plugin List
Section titled “Built-in Plugin List”Monibuca V6 uses Feature Flags for fine-grained control over compiled content. Precompiled binaries include all plugins by default, and individual plugins can be enabled or disabled as needed via the configuration file.
Protocol Plugins
Section titled “Protocol Plugins”| Feature | Plugin | Description |
|---|---|---|
rtmp | plugin-rtmp | RTMP/RTMPS ingest and playback |
rtsp | plugin-rtsp | RTSP/RTSPS ingest and playback |
flv | plugin-flv | HTTP-FLV playback |
hls | plugin-hls | HLS segment output |
webrtc | plugin-webrtc | WebRTC ingest and playback |
srt | plugin-srt | SRT ingest and playback |
webtransport | plugin-webtransport | WebTransport/QUIC |
gb28181 | plugin-gb28181 | GB/T 28181 national standard device access |
Feature Plugins
Section titled “Feature Plugins”| Feature | Plugin | Description |
|---|---|---|
mp4 | plugin-mp4 | MP4 recording |
snap | plugin-snap | Snapshot service |
ffmpeg_transcode | plugin-transcode | FFmpeg transcoding |
logrotate | plugin-logrotate | Log rotation |
debug | plugin-debug | Debugging tools |
sei | plugin-sei | SEI data injection/extraction |
crontab | plugin-crontab | Scheduled tasks |
report | plugin-report | Data reporting |
mix | plugin-mix | Stream mixing |
crypto | plugin-crypto | Stream encryption |
transcode | — | Built-in Opus↔AAC transcoding (codec crate feature) |
Device Plugins
Section titled “Device Plugins”| Feature | Plugin | Description |
|---|---|---|
onvif | plugin-onvif | ONVIF device discovery and management |
v4l2 | plugin-v4l2 | V4L2 camera capture (Linux) |
alsa | plugin-alsa | ALSA audio capture (Linux) |
homekit | plugin-homekit | HomeKit camera emulation |
Room/Interactive Plugins
Section titled “Room/Interactive Plugins”| Feature | Plugin | Description |
|---|---|---|
live | plugin-live | Live room |
meeting | plugin-meeting | Meeting room |
| — | Built-in room | Room service (engine built-in, not a plugin) |
Enterprise Plugins
Section titled “Enterprise Plugins”| Feature | Plugin | Description |
|---|---|---|
cluster | plugin-cluster | Cluster deployment |
auth | — | Authentication and authorization |
license | — | License management |
All Plugins
Section titled “All Plugins”Precompiled releases and Docker images include all of the above plugins. Enable or disable them as needed via enable: true/false in the configuration file:
rtmp: enable: truertsp: enable: truewebrtc: enable: truehls: enable: false # Set to false for plugins you don't needComplete Plugin List
Section titled “Complete Plugin List”Monibuca V6 has a total of 25 independent plugin crates, plus 1 built-in room service:
By Category
Section titled “By Category”plugins/├── Protocol (8)│ ├── rtmp/ RTMP/RTMPS│ ├── rtsp/ RTSP/RTSPS│ ├── flv/ HTTP-FLV│ ├── hls/ HLS│ ├── webrtc/ WebRTC│ ├── srt/ SRT│ ├── webtransport/ WebTransport│ └── gb28181/ GB/T 28181│├── Feature (10)│ ├── mp4/ MP4 Recording│ ├── snap/ Snapshot│ ├── transcode/ FFmpeg Transcoding│ ├── logrotate/ Log Rotation│ ├── debug/ Debugging│ ├── sei/ SEI│ ├── crontab/ Scheduled Tasks│ ├── report/ Reporting│ ├── crypto/ Encryption│ └── mix/ Stream Mixing│├── Device (4)│ ├── onvif/ ONVIF│ ├── v4l2/ V4L2│ ├── alsa/ ALSA│ └── homekit/ HomeKit│├── Room/Interactive (2)│ ├── live/ Live Room│ └── meeting/ Meeting Room│└── Test/Development (1) └── test/ Test Plugin
Built-in service:└── src/room/ Room Service (RoomService)Plugin Development
Section titled “Plugin Development”Dependency Structure
Section titled “Dependency Structure”Plugins depend only on the open-source SDK crate and do not directly depend on engine internals:
Your custom plugin │ └──▶ sdk (monibuca-sdk) ← Open source │ └──▶ codec (monibuca-codec)Plugin Cargo.toml Example
Section titled “Plugin Cargo.toml Example”[package]name = "plugin-xxx"version = "0.1.0"edition = "2024"
[dependencies]sdk = { git = "https://github.com/langhuihui/monibuca-sdk" }Plugin Registration
Section titled “Plugin Registration”Static plugins are registered in the main crate via pub use:
#[cfg(feature = "rtmp")]pub use plugin_rtmp as rtmp;
#[cfg(feature = "rtsp")]pub use plugin_rtsp as rtsp;
#[cfg(feature = "webrtc")]pub use plugin_webrtc as webrtc;ConfigSchema Macro
Section titled “ConfigSchema Macro”Plugin configuration uses the ConfigSchema derive macro, which requires specifying sdk_path:
use sdk::ConfigSchema;
#[derive(ConfigSchema)]#[config_schema(sdk_path = "sdk")]pub struct MyPluginConfig { /// Listen port #[schema(default = 1935)] pub port: u16,
/// Timeout in seconds #[schema(default = 30)] pub timeout: u32,}EngineContext (IoC Container)
Section titled “EngineContext (IoC Container)”Plugins access engine capabilities through EngineContext rather than depending on engine internal types directly:
pub struct EngineContext { // Required capabilities pub stream_manager: Arc<dyn StreamManagerApi>,
// Optional capabilities pub database: Option<Arc<dyn DatabaseApi>>, pub transform: Option<Arc<dyn TransformApi>>, pub playback: Option<Arc<dyn PlaybackApi>>,}The engine constructs EngineContext during PluginManager::init_all() and injects it into each plugin.