Skip to content

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.

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

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

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

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.

FeaturePluginDescription
rtmpplugin-rtmpRTMP/RTMPS ingest and playback
rtspplugin-rtspRTSP/RTSPS ingest and playback
flvplugin-flvHTTP-FLV playback
hlsplugin-hlsHLS segment output
webrtcplugin-webrtcWebRTC ingest and playback
srtplugin-srtSRT ingest and playback
webtransportplugin-webtransportWebTransport/QUIC
gb28181plugin-gb28181GB/T 28181 national standard device access
FeaturePluginDescription
mp4plugin-mp4MP4 recording
snapplugin-snapSnapshot service
ffmpeg_transcodeplugin-transcodeFFmpeg transcoding
logrotateplugin-logrotateLog rotation
debugplugin-debugDebugging tools
seiplugin-seiSEI data injection/extraction
crontabplugin-crontabScheduled tasks
reportplugin-reportData reporting
mixplugin-mixStream mixing
cryptoplugin-cryptoStream encryption
transcodeBuilt-in Opus↔AAC transcoding (codec crate feature)
FeaturePluginDescription
onvifplugin-onvifONVIF device discovery and management
v4l2plugin-v4l2V4L2 camera capture (Linux)
alsaplugin-alsaALSA audio capture (Linux)
homekitplugin-homekitHomeKit camera emulation
FeaturePluginDescription
liveplugin-liveLive room
meetingplugin-meetingMeeting room
Built-in roomRoom service (engine built-in, not a plugin)
FeaturePluginDescription
clusterplugin-clusterCluster deployment
authAuthentication and authorization
licenseLicense management

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:

config.yaml
rtmp:
enable: true
rtsp:
enable: true
webrtc:
enable: true
hls:
enable: false # Set to false for plugins you don't need

Monibuca V6 has a total of 25 independent plugin crates, plus 1 built-in room service:

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)

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)
[package]
name = "plugin-xxx"
version = "0.1.0"
edition = "2024"
[dependencies]
sdk = { git = "https://github.com/langhuihui/monibuca-sdk" }

Static plugins are registered in the main crate via pub use:

src/plugins/mod.rs
#[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;

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,
}

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.