webrtc-rs/webrtc
73.2
Strong · 30 September 2026
12k
lines of production code
Rust
primary language
2
measurements over time
What this system is
This system is a Rust-based WebRTC library that provides a runtime-agnostic, asynchronous API for establishing peer connections, managing media streams, and handling data channels. It features a driver-based architecture that separates protocol state from I/O, supporting pluggable async runtimes like Tokio and smol, as well as configurable cryptographic providers. The library enables robust media handling through local and remote track abstractions, back-pressure-aware data channels, and a Sans-I/O transport layer for UDP, TCP, STUN, and TURN.
How it got here
2019–2021 — async runtime and API redesign
7 changes.
The project underwent a significant architectural overhaul to introduce a runtime-agnostic async API, allowing users to select between Tokio, smol, or custom async runtimes. This period focused on replacing callback-heavy designs with asynchronous polling models for data channels and media tracks, while also enabling pluggable cryptographic providers for enhanced flexibility and stability.
2026 — Async runtime abstraction and media API overhaul
6 changes.
The project introduced a pluggable async runtime with deterministic mocking and a Sans-I/O transport layer to decouple logic from specific runtimes. Concurrently, it replaced synchronous media handling with new asynchronous APIs for local and remote tracks, enabling more flexible RTP and sample processing. These changes were supported by comprehensive integration tests and automated scripts to enforce channel overflow policies and crypto boundaries.
Features
Introduce async RtpTransceiver, RtpSender, and RtpReceiver traits
The \src/rtp\_transceiver\ module now exposes public async traits (\RtpTransceiver\, \RtpSender\, \RtpReceiver\) that manage media tracks over a peer connection. These traits provide methods to control transceiver direction, replace tracks, set parameters, and retrieve statistics, with all async operations routing through a background driver. The implementation uses \Weak\ references to \PeerConnectionRef\ to prevent memory leaks and cycles, ensuring that receivers and senders are properly cleaned up when the connection closes.
_src/rtp\transceiver · high confidence
Introduction of async PeerConnection driver and media track abstractions
This change introduces the core async driver loop for PeerConnection and the new media stream track traits (Track, TrackLocal, TrackRemote) in the src/peer\_connection and src/media\_stream modules. The driver manages the underlying network sockets, ICE, and DTLS state asynchronously, while the new track abstractions provide an async-friendly interface for handling local and remote media, including capabilities, constraints, and encoding parameters.
_src/peer\connection · high confidence
New DataChannel API with event polling and back-pressure support
The \src/data\_channel\ module introduces a new \DataChannel\ trait that replaces the previous callback-heavy design with an asynchronous polling model via the \poll()\ method. Users can now fetch events like opening, closing, and messages in a loop. The API includes methods for sending data (\send\, \send\_text\) and text, with optional blocking behavior when a send-buffer limit is configured to manage memory usage. It also exposes channel properties such as label, state, and buffered amount thresholds, allowing applications to implement flow control and monitor channel health.
_src/data\channel · high confidence
New asynchronous API for receiving remote media tracks
The \src/media\_stream/track\_remote\ module introduces the \TrackRemote\ trait and \TrackRemoteEvent\ enum, providing a new way to handle incoming media from remote peers. Instead of relying on synchronous callbacks, users can now asynchronously poll for events such as incoming RTP/RTCP packets, mute/unmute states, and track lifecycle changes (open, ending, ended) using the \poll()\ method. This change also exposes a \write\_rtcp()\ method to send feedback packets (like PLI or NACK) back to the sender, and clarifies that inbound RTCP is only delivered to the application if explicitly marked with \Attribute::DeliverToApplication\ by an interceptor.
_src/media\_stream/track\remote · high confidence
New examples for bandwidth estimation, broadcasting, and custom async runtimes
The examples directory now includes \bandwidth-estimation-from-disk\, which demonstrates switching between pre-encoded video renditions based on congestion control estimates; \broadcast\, which shows how to relay a single video stream to multiple viewers; and \custom-runtime\, which proves the library is runtime-agnostic by implementing the \Runtime\ trait over \async-executor\ and \async-io\ instead of the default Tokio or smol. A shared \common\ module provides runtime-agnostic helpers for these examples, and the main README has been updated to document all available examples.
examples · high confidence
New local track API for sending media via RTP packets or raw samples
The \src/media\_stream/track\_local\ module introduces a new interface for sending local media to remote peers. It provides the \TrackLocal\ trait with \bind\/\unbind\ lifecycle methods and an asynchronous \poll\ method to receive RTCP feedback events (such as keyframe requests) from the remote peer. Two concrete implementations are added: \TrackLocalStaticRTP\ for forwarding pre-packetized RTP data (useful for SFUs or RTP ingest), and \TrackLocalStaticSample\ for writing raw encoded media frames (VP8/H.264/Opus), which handles packetization, sequencing, and timestamping automatically. This allows applications to either pass through existing RTP streams or generate new ones from raw media samples.
_src/media\_stream/track\local · high confidence
Pluggable async runtime with deterministic mock for testing
The WebRTC stack now abstracts asynchronous operations (task spawning, timers, UDP/TCP sockets, DNS) behind a new \Runtime\ trait, allowing the library to run on different async runtimes (Tokio, smol) or custom implementations. This change introduces a \MockRuntime\ (behind the \runtime-mock\ feature) that uses a \VirtualClock\ to drive timers and an in-memory \MockUDPNetwork\ for synchronous datagram delivery, enabling deterministic, wall-clock-free end-to-end testing of timing-dependent behaviors like ICE and DTLS. Additionally, the Tokio and smol implementations now use a shared, bounded pool of single-threaded reactor threads for peer-connection drivers, replacing the previous one-thread-per-connection model to improve resource utilization and throughput.
src/runtime · high confidence
Behavioural changes
Introduction of runtime-agnostic async WebRTC API with driver-based architecture
The library now exposes a new public API surface in \src/lib.rs\ that separates protocol state from I/O using a driver-based architecture. Users interact with the \PeerConnection\ trait and \PeerConnectionBuilder\ to manage connections, while a background \PeerConnectionDriver\ handles network sockets and timeouts. The API is runtime-agnostic, supporting both Tokio (default) and smol via Cargo features, and re-exports core types like \Error\, \Result\, and event handlers from the underlying \rtc\ crate to simplify imports. This change introduces the foundational modules for peer connections, data channels, media streams, and RTP transceivers, replacing the previous structure with a more extensible and sealed trait design.
src · high confidence
New Sans-I/O transport layer for UDP, TCP, STUN, and TURN
The \src/peer\_connection/transport\ module has been replaced with a new Sans-I/O architecture that separates transport logic from the async runtime. This change introduces dedicated modules for STUN gathering (\stun\_gatherer\), TCP transport (\tcp\_transport\), and TURN relaying (\turn\_relayer\), along with a new \mod.rs\ that defines the public W3C-compliant transport objects (\SctpTransport\, \DtlsTransport\, \IceTransport\). Users benefit from more robust ICE candidate gathering, including fixes for STUN server address family matching and TURN allocation refresh caps, as well as improved TCP stream handling and GRO/GSO buffer optimizations for better performance at scale.
_src/peer\connection/transport · high confidence
New audit scripts for channel overflow policies and crypto boundaries
Added two new Python scripts to enforce critical invariants in the codebase. \check-channel-overflow-policy.py\ scans Rust source files to ensure every send operation on bounded internal channels explicitly declares an overflow handling strategy (such as awaiting, nudging, detaching, retaining, or dropping), preventing silent data loss. \check-crypto-boundary.py\ verifies that the async WebRTC crate does not directly depend on any cryptographic implementations, ensuring it only forwards provider features to the dedicated \rtc-crypto\ layer to maintain a single source of truth for crypto backends.
scripts · high confidence
Per-connection crypto provider selection and resilient bind address handling
Users can now select the cryptographic provider (e.g., \ring\ or \aws-lc-rs\) on a per-peer-connection basis via \SettingEngine\, allowing different connections in the same process to use different providers without affecting each other. Additionally, bind address resolution is now re-evaluated on every bind, meaning wildcards re-enumerate local interfaces and hostnames follow DNS changes; addresses that fail to bind are skipped with a warning rather than failing the connection, improving stability during network handovers.
(repo-wide) · high confidence
Test coverage
Added integration tests for connection lifecycle, resource cleanup, and runtime interoperability
Added a suite of integration tests in the \tests/\ directory to verify critical WebRTC behaviors. These tests confirm that unbindable network addresses are skipped without failing the connection, that closing a connection properly terminates all event streams (DataChannel and Track polls), and that PeerConnection resources are fully released after close and drop, even when transceivers are present. The suite also validates that different async runtimes can interoperate within a single process, that crypto providers (ring and aws-lc-rs) are correctly selected and integrated, and that data channel send back-pressure is correctly woken upon connection close.
tests · high confidence
Dependencies
WebRTC library v0.21.0 with pluggable async runtimes and crypto providers
The webrtc crate has been updated to version 0.21.0, introducing a pluggable async runtime architecture that allows users to choose between Tokio, smol, or a mock runtime via optional features (runtime-tokio, runtime-smol, runtime-mock). The library also supports pluggable crypto providers, defaulting to ring but allowing aws-lc-rs via the crypto-aws-lc-rs feature. This release includes numerous dependency updates (e.g., tokio 1.52.3, smol 2.0.2, bytes 1.12.0) and adds several new examples for data channels, ICE, and media handling.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 73 → 73 (-0.3)
- Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.
Lenses
- Code Health 92 → 92 (+0.0)
- Architecture 100 → 99 (-0.6)
- Maturity 67 → 67 (-0.0)
- Readiness 78 → 76 (-1.9)
- Security 69 → 69 (+0.0)
- Event Sourcing 100 → 100 (+0.0)
- Performance 100 (new)
Resolved (6)
- Boundary-crossing change coupling: mod.rs ↔ smol.rs (src/peer_connection/mod.rs)
- Documentation: no installation or build instructions (README.md)
- Duplicated block (8 lines × 2) (src/rtp_transceiver/rtp_receiver.rs)
- Duplicated block (9 lines × 2) (src/rtp_transceiver/mod.rs)
- Duplicated block (9 lines × 2) (src/rtp_transceiver/mod.rs)
- Off-boarding risk: anonymized user #1
New (11)
- Dependency hygiene PARTLY measured — Cargo dependencies read, no committed lock to grade for currency
- Documentation: no project overview (README.md)
- Documentation: no project overview (examples/play-from-disk-renegotiation/README.md)
- Duplicated block (10 lines × 2) (src/rtp_transceiver/mod.rs)
- Duplicated block (10–11 lines × 2) (src/rtp_transceiver/mod.rs)
- Duplicated block (9 lines × 2) (src/rtp_transceiver/rtp_receiver.rs)
- Inconsistent error handling strategy for send operations. send and send_text likely block or return a Result indicating failure, while try_send and try_send_text imply a non-blocking or immediate-return behavior (often returning an error if the buffer is full). However, the distinction between 'blocking' vs 'non-blocking' is not always clear in async contexts without explicit naming like send_blocking or try_send. More importantly, having both send and try_send variants for both binary and text creates a combinatorial explosion of similar methods.
- Low cohesion: MockRuntime (LCOM4 5) (src/runtime/mock.rs)
- Off-boarding risk: anonymized user #1
- RTCStunGatherer::gather_srflx_candidates (cognitive 27) (src/peer_connection/transport/stun_gatherer.rs)
- Redundant naming for standard WebRTC states. The WebRTC spec defines 'currentLocalDescription', 'pendingLocalDescription', etc. The API exposes both a short form (e.g., local_description) and the full spec-compliant name (e.g., current_local_description). This creates confusion about which method to use, as they likely return the same value or have subtle semantic overlaps that are not immediately obvious from the signature.
Changes since last survey
- 12 commits — 8 feature/other, 4 fixes
By area
- (root) — 4 commits
- src/peer_connection — 4 commits
- (repo) — 2 commits
- .github/workflows — 1 commit
- src/rtp_transceiver — 1 commit
Notable commits
- fix: fix(rtp_transceiver): break the PeerConnectionRef reference cycle (#906) (#909)
- fix: fix(stun_gatherer): complete gathering when a STUN server does not answer (#910)
- fix: fix: release TURN allocations on close() on both runtimes (#903) (#911)
- fix: fix: skip STUN servers without a matching address family (#900)
- change: Merge pull request #898 from webrtc-rs/v0.21.x
- change: Merge pull request #899 from webrtc-rs/v1.x
- change: Retain data-channel events staged before their channel's OnOpen registration (#902)
- change: bump version to v0.21.0
- change: keep master as v0.21.0 to catch breaking publi
- change: make new branch v1.x
- change: update rtc pointer
- change: update rtc pointer
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
webrtc-rs/webrtc was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 30 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit a72f53581d4d435b63cbdcdf670e2958b35f485f — the exact code this score is about.
- Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-cb25ca4feafa.