| Crates.io | rustrtc |
| lib.rs | rustrtc |
| version | 0.3.9 |
| created_at | 2025-11-27 02:57:43.697026+00 |
| updated_at | 2026-01-24 16:26:54.465245+00 |
| description | A high-performance implementation of WebRTC |
| homepage | |
| repository | https://github.com/restsend/rustrtc |
| max_upload_size | |
| id | 1952994 |
| size | 2,210,876 |
A high-performance implementation of WebRTC.
pion (go version).CPU: AMD Ryzen 7 5700X 8-Core Processor
OS 5.15.0-118-generic #128-Ubuntu
Compiler rustc 1.91.0 (f8297e351 2025-10-28), go version go1.23.0 linux/amd64
nice@miuda.ai rustrtc % cargo run -r --example benchmark
Comparison (Baseline: webrtc)
Metric | webrtc | rustrtc | pion
--------------------------------------------------------------------------------
Duration (s) | 10.07 | 10.02 | 10.13
Setup Latency (ms) | 1.36 | 0.22 | 0.90
Throughput (MB/s) | 254.55 | 713.66 | 309.11
Msg Rate (msg/s) | 260659.38 | 730788.92 | 316533.37
CPU Usage (%) | 1480.45 | 1497.50 | 1121.20
Memory (MB) | 29.00 | 15.00 | 44.00
--------------------------------------------------------------------------------
Performance Charts
==================
Throughput (MB/s) (Higher is better)
webrtc | ββββββββββββββ 254.55
rustrtc | ββββββββββββββββββββββββββββββββββββββββ 713.66
pion | βββββββββββββββββ 309.11
Message Rate (msg/s) (Higher is better)
webrtc | ββββββββββββββ 260659.38
rustrtc | ββββββββββββββββββββββββββββββββββββββββ 730788.92
pion | βββββββββββββββββ 316533.37
Setup Latency (ms) (Lower is better)
webrtc | ββββββββββββββββββββββββββββββββββββββββ 1.36
rustrtc | ββββββ 0.22
pion | ββββββββββββββββββββββββββ 0.90
CPU Usage (%) (Lower is better)
webrtc | βββββββββββββββββββββββββββββββββββββββ 1480.45
rustrtc | ββββββββββββββββββββββββββββββββββββββββ 1497.50
pion | βββββββββββββββββββββββββββββ 1121.20
Memory (MB) (Lower is better)
webrtc | ββββββββββββββββββββββββββ 29.00
rustrtc | βββββββββββββ 15.00
pion | ββββββββββββββββββββββββββββββββββββββββ 44.00
Key Findings:
rustrtc is ~2.8x faster than webrtc-rs and ~2.3x faster than pion.rustrtc uses ~48% less memory than webrtc-rs and ~66% less than pion.Here is a simple example of how to create a PeerConnection and handle an offer:
use rustrtc::{PeerConnection, RtcConfiguration, SessionDescription, SdpType};
#[tokio::main]
async fn main() {
let config = RtcConfiguration::default();
let pc = PeerConnection::new(config);
// Create a Data Channel
let dc = pc.create_data_channel("data", None).unwrap();
// Handle received messages
let dc_clone = dc.clone();
tokio::spawn(async move {
while let Some(event) = dc_clone.recv().await {
if let rustrtc::DataChannelEvent::Message(data) = event {
println!("Received: {:?}", String::from_utf8_lossy(&data));
}
}
});
// Create an offer
let offer = pc.create_offer().unwrap();
pc.set_local_description(offer).unwrap();
// Wait for ICE gathering to complete
pc.wait_for_gathering_complete().await;
// Get the complete SDP with candidates
let complete_offer = pc.local_description().unwrap();
println!("Offer SDP: {}", complete_offer.to_sdp_string());
}
rustrtc allows customizing the WebRTC session via RtcConfiguration:
All, Relay).use rustrtc::{PeerConnection, RtcConfiguration, IceServer, IceTransportPolicy, config::MediaCapabilities};
let mut config = RtcConfiguration::default();
// Configure ICE servers
config.ice_servers.push(IceServer::new(vec!["stun:stun.l.google.com:19302"]));
// Set ICE transport policy (optional)
config.ice_transport_policy = IceTransportPolicy::All;
config.ssrc_start = 10000;
// Customize media capabilities
let mut caps = MediaCapabilities::default();
// ... configure audio/video/application caps ...
config.media_capabilities = Some(caps);
let pc = PeerConnection::new(config);
You can run the examples provided in the repository.
A multi-user video conferencing server. It receives media from each participant and forwards it to others.
Run the server:
cargo run --example rustrtc_sfu
Open your browser and navigate to http://127.0.0.1:8081. Open multiple tabs/windows to simulate multiple users.

The echo server example demonstrates how to accept a WebRTC connection, receive data on a data channel, and echo it back. It also supports video playback if an IVF file is provided.
Run the server:
cargo run --example echo_server
Open your browser and navigate to http://127.0.0.1:3000.
A multi-user chat room using WebRTC DataChannels.
Run the server:
cargo run --example datachannel_chat
Open your browser and navigate to http://127.0.0.1:3000. Open multiple tabs to chat between them.
Records audio from the browser's microphone and saves it to a file (output.ulaw) on the server.
Run the server:
cargo run --example audio_saver
Open your browser and navigate to http://127.0.0.1:3000. Click "Start" to begin recording.
Streams a video file (examples/static/output.ivf) via RTP to a UDP port, which can be played back using ffplay.
Run the server:
cargo run --example rtp_play
In a separate terminal, run ffplay (requires ffmpeg installed):
ffplay -protocol_whitelist file,udp,rtp -i examples/rtp_play.sdp
This project is licensed under the MIT License.