A fast media relay for SIP voice and video calls, written in Rust.
rtpflux sits between the phones (or browsers) in a call and forwards their
audio and video. A SIP proxy such as Kamailio
or OpenSIPS tells it about each call over the
ng protocol, the same control protocol their rtpengine modules
already speak. So rtpflux can take the place of
rtpengine without changing how the
proxy is set up.
-
Relays RTP and RTCP between the two sides of a call, including callers behind NAT. It learns where media really comes from ("latching").
-
Bridges WebRTC and SIP phones. It speaks ICE (a full agent with consent freshness and trickled candidates, or ICE-lite), DTLS-SRTP,
rtcp-muxand BUNDLE towards browsers, and plain RTP or SDES-SRTP towards phones. -
Encrypts and decrypts SRTP on either side. It supports AES-CM (128- and 256-bit) with HMAC-SHA1, and AES-GCM.
-
Transcodes audio between PCMU, PCMA (G.711), G.722, G.729 and Opus (and AMR / AMR-WB with the
amrbuild feature), and relays T.38 fax. rtpengine's codec options choose what each side is offered (transcode,mask,strip,except,offer) and the packet time (ptime, with repacketisation), and itsSDES,DTLSandrtcp-muxoptions shape the encryption and RTCP of each side. An option it does not implement is named in the reply'swarning, not silently dropped. -
Call features: DTMF detection and injection (
play DTMF, as RFC 4733 events or in-band tones), muting a participant (block media or only DTMF, or silence it while the stream goes on), call recording to WAV, FLAC, Ogg Opus or MP3 (stereo or mono, the rate and bitrate you choose; kept locally or uploaded to an S3 bucket, with an optional signed webhook after each upload), playing announcements, and per-stream statistics including packet loss, jitter and round-trip time. -
Handles re-INVITEs from either party, hold and resume, and adding or removing streams; forked INVITEs, and calls with more than two parties (a party in dialogs with several others, labels to address them).
-
A media engine for a B2BUA or softswitch:
- the ng commands
createandcreate from offer, and a native control API on a Unix socket; - endpoints negotiated either way, parked, bridged across calls, renegotiated with commit or abort, destroyed with tombstones;
- generations, idempotency keys, leases and tenants;
- events: DTMF, announcements, recordings, ICE, DTLS, speech, bridges;
- PCM streams to external audio services (speech recognition, voice bots), with barge-in and playout marks;
- N − 1 conference mixing with active-speaker events, and recording of the conference's mix;
- echo (an endpoint hears itself), for echo tests;
- video in conference rooms: selective forwarding of VP8 (an SFU), cameras and a screen, NACK/RTX from the relay's cache, keyframes on every switch.
A Rust client is in
crates/rtpflux-client. See Media engine for its status. - the ng commands
-
Keeps calls across restarts when a state file or Redis is configured; with Redis, another host can take them over.
-
Optional kernel fast path. Settled RTP calls can be forwarded in the network driver with XDP, without passing through userspace, including calls with DTMF detection, blocking, announcements or recording. Encrypted and WebRTC calls can be received through AF_XDP sockets.
-
Operations: a read-only web UI with live traffic, calls, recordings (a pcap viewer) and logs, Prometheus metrics, structured logs, and a hardened systemd unit.
An optional, read-only website shows what the relay is doing right now.
Turn it on with a [webui] section; see Web UI.
SIP signalling SIP signalling
Alice ───────────────► SIP proxy (Kamailio) ◄─────────────── Bob
│ │ ng commands over UDP
│ ▼ (offer / answer / delete …)
│ RTP/SRTP ┌─────────┐ RTP/SRTP │
└────────────────────►│ rtpflux │◄────────────────────────────┘
└─────────┘
- Alice's INVITE reaches the proxy. The proxy sends the SDP offer to rtpflux.
- rtpflux reserves ports and rewrites the SDP so that media goes to rtpflux, not straight to Alice. The proxy forwards the rewritten offer to Bob.
- Bob's answer goes through rtpflux the same way.
- Both phones now send media to rtpflux, which forwards it to the other side. It also translates encryption and codecs when needed.
You need Rust; the toolchain version is pinned in rust-toolchain.toml.
rtpflux is pure Rust, so no C libraries or C compiler are needed. (Two
optional features build C code: mp3, for MP3 recordings, and s3, for
recordings in S3: cargo build --release --features mp3,s3.)
git clone https://github.com/RustedBytes/rtpflux.git
cd rtpflux
cargo build --releaseWrite a minimal configuration. Only the media interface is required:
# rtpflux.toml
[control]
listen = ["127.0.0.1:2223"] # where the SIP proxy sends ng commands
[[interface]]
name = "default"
address = "203.0.113.10" # the address phones send media toCheck it and start the relay:
./target/release/rtpflux --check -c rtpflux.toml
./target/release/rtpflux -c rtpflux.tomlThen point Kamailio's rtpengine module at it:
loadmodule "rtpengine.so"
modparam("rtpengine", "rtpengine_sock", "udp:127.0.0.1:2223")
route[MEDIA] {
if (has_body("application/sdp")) {
rtpengine_manage("trust-address replace-origin");
}
}
Or run it in a container on the host network:
docker compose up -d --build # edit config/docker.toml firstSee Getting started for a full walk-through with a test call, and Integration for tested Kamailio, OpenSIPS, ferrosip and FreeSWITCH configurations.
These numbers come from a loopback benchmark on one 4-core Xeon E5-1620
v3: G.711 calls with 50 packets per second each way, four relay threads,
measured in November 2026 with all current features (bench/compare.sh).
| Load | rtpflux, io_uring (default) |
rtpflux, recvmmsg |
rtpengine 13.5 |
|---|---|---|---|
| 2,000 calls (200k packets/s) | all delivered, p99 0.14 ms, 294% CPU | all delivered, p99 0.17 ms, 302% CPU | all delivered, p99 0.24 ms, 374% CPU |
| 3,000 calls (300k packets/s) | all delivered, p99 0.12 ms | all delivered, p99 0.11 ms | all delivered, 23–47 ms queueing |
| 4,000 calls (400k packets/s) | all delivered, 35–53 ms queueing | all delivered, 23–50 ms queueing | 97% lost |
With the XDP fast path, the relay itself used 7% of one CPU for 4,000
calls (an earlier measurement, bench/fastpath.sh, which needs root);
the userspace path uses all four threads at that load. See
Benchmarks for the method, all results and how to
reproduce them.
The guides in docs/ are also published as a book at
https://rustedbytes.github.io/rtpflux/ (build it locally with
mdbook build, or preview it with mdbook serve --open).
| Guide | What it covers |
|---|---|
| Getting started | Build, install, configure and make a first test call |
| Configuration | Every configuration section, with examples |
| Control protocol | The ng commands and options, and how SIP proxies use them |
| Integration | Tested Kamailio, OpenSIPS, ferrosip and FreeSWITCH configurations, and the bench that runs real calls through them |
| Media handling | NAT, SRTP, WebRTC (ICE, DTLS, BUNDLE), re-INVITEs and hold |
| Call features | DTMF, blocking, recording, announcements, transcoding, statistics |
| XDP fast path | Forwarding calls in the network driver |
| Operations | Metrics, logs, restarts and systemd |
| Web UI | The read-only website: live traffic, calls, statistics, recordings and logs |
| Architecture | How the code is organised and why it is fast |
| Testing | Test suites, browser tests and kernel tests |
| Conformance | Checking rtpflux against an independent reference model |
| Benchmarks | Method and results |
| Glossary | The terms used in these documents, in plain English |
New to VoIP terms like SDP, SRTP or latching? Start with the Glossary.
Contributor guidelines, including the performance and safety rules every change must follow, are in AGENTS.md. Before sending a change, run:
cargo fmt --check
cargo clippy --workspace --all-targets
cargo test --workspaceCopyright (C) 2026 Yehor Smoliakov egorsmkv@gmail.com.
GNU General Public License, version 3 only (GPL-3.0-only). See LICENSE.









