XTurn Plugin API

The plugin contract for xturn data-plane plugins:

Why this exists

XTurn implements and drives plugins; a plugin package (such as xturn-plugins) implements this contract and therefore depends on XTurn's types.

Usage

defp deps do
[
{:xturn_plugin_api, "~> 0.1.0"}
]
end

Then implement the behaviour:

defmodule MyApp.Plugin do
@behaviour Xirsys.XTurn.Plugin
@impl true
def mode, do: :active
@impl true
def hooks, do: [:egress]
@impl true
def attach?(%Xirsys.XTurn.Plugin.Allocation{}, _opts), do: true
@impl true
def init(_allocation, _opts), do: {:ok, nil}
@impl true
def handle_frame(payload, %Xirsys.XTurn.Plugin.Frame{}, _state), do: {:ok, payload}
end