Async-friendly WebRTC implementation in Rust
Async-friendly WebRTC implementation in Rust
Sponsored with ๐ by
Silver Sponsors:
Bronze Sponsors:
AdrianEddy
Overview
WebRTC.rs is an async-friendly WebRTC implementation in Rust, originally inspired by and largely rewriting the Pion stack. The v0.20.x line is a clean, ergonomic, runtime-agnostic rewrite on top of a Sans-I/O core; as of v0.20.0-rc.1 it ships with Tokio and smol runtime backends, with async-std and embassy on the roadmap.
Architecture:
- rtc: Sans-I/O protocol core with complete WebRTC stack (95%+ W3C API
- webrtc (this crate): a thin async layer over
rtc:
PeerConnection โ the user-facing async API handle; all operations (create offers/answers, add tracks,
create data channels) are async
- PeerConnectionDriver โ an internal background event loop, spawned automatically, that owns the sockets,
drives the Sans-I/O rtc core, handles timeouts, and dispatches events
- Runtime โ a trait abstracting timers, task spawning, and sockets, so the crate is runtime-agnostic
๐ Learn more: Read our architecture blog post for design details and roadmap.
๐จ v0.17.x โ v0.20.0: the Sans-I/O rewrite (Release Candidate)
v0.20.0-rc.1 is the first release candidate of the new Sans-I/O, runtime-agnostic architecture. It supersedes the Tokio-coupled v0.17.x line, which is now in bug-fix-only maintenance.
Current Status
v0.17.x: Receives bug fixes only (no new features). The mature choice for Tokio-based production
v0.20.0-rc.1(master): The new architecture, published as a pre-release. As a release candidate, no further API
What v0.20.0 delivers
The rewrite resolves the core pain points of v0.17.x โ callback hell and Arc explosion, resource leaks in callbacks, and tight Tokio coupling:
โ Runtime independence
- Runtime-agnostic via a Quinn-style
Runtimeabstraction (timers, task spawning, sockets) - Feature flags:
runtime-tokio(default) andruntime-smol; additional runtimes (async-std, embassy) are on
โ Clean event handling
- Trait-based event handlers using native
async fn in trait - No more callback
Arccloning orBox::new(move |...| Box::pin(async move { ... })) - Centralized state management with
&mut self
- Protocol logic completely separate from I/O (via the rtc core)
- Deterministic testing without real network I/O
- A thin async driver (
PeerConnectionhandle + backgroundPeerConnectionDriver) over the core
How to Provide Feedback
We welcome your input while v0.20.0 stabilizes:
- Review the architecture blog post
- Join discussions on GitHub Issues
- Chat with us on Discord
v0.17.x branch.
Early adopters / new projects: try v0.20.0-rc.1 and report issues!
Building and Testing
# Update rtc submodule first
git submodule update --init --recursive
Build the library
cargo build
Run tests
cargo test
Build documentation
cargo doc --open
Run examples
cargo run --example data-channels
Semantic Versioning
This project follows Semantic Versioning:
- Patch (
0.x.Y): Bug fixes and internal improvements with no public API changes. - Minor (
0.X.0): Backwards-compatible additions or deprecations to the public API. - Major (
X.0.0): Breaking changes to the public API.
0.x, the minor version acts as the major โ i.e., a minor bump may include breaking changes. Once
1.0.0 is released, full semver stability guarantees apply.
Pre-release versions are published with the following suffixes, in order of increasing stability:
-alpha.N: Early preview. API is unstable and may change significantly.-beta.N: Feature-complete for the release. API may still have minor changes.-rc.N: Release candidate. No further API changes are expected unless critical issues are found.
1.0.0-alpha.1 โ 1.0.0-beta.1 โ 1.0.0-rc.1 โ 1.0.0.
Open Source License
Dual licensing under both MIT and Apache-2.0 is the currently accepted standard by the Rust language community and has been used for both the compiler and many public libraries since ( see
Contributing
Contributors or Pull Requests are Welcome!!!
