XTurn Plugins

Example plugins for xturn:

Each plugin implements the Xirsys.XTurn.Plugin behaviour from xturn_plugin_api — this package depends only on that contract, not on xturn itself, so it builds and tests standalone. xturn can depend on it directly (as a normal, non-circular dependency) to make these plugins available.

Usage

Add as a dependency, then configure in your xturn config:

defp deps do
[
{:xturn_plugins, "~> 0.1.0"}
]
end
config :xturn,
plugins: [
{Xirsys.XTurn.Plugin.Guard, mode: :monitor, payload_types: [0, 8]},
{Xirsys.XTurn.Plugin.Metrics, flush_ms: 5_000}
]

Guard defaults to :monitor (telemetry only, never drops) so it's safe to deploy before switching to :enforce. Its default payload_types: [0, 8] covers PCMU/PCMA; set it explicitly for WebRTC deployments using dynamic payload types (Opus, VP8, etc.).

Tests

cd xturn-plugins
mix test

Tests drive each plugin's callbacks directly (init/2, handle_frame/3, handle_close/2, ...) against xturn_plugin_api's Allocation/Frame structs, the same way xturn's plugin runtime would. No dependency on xturn itself is needed to build or test this package.