English | 简体中文
A fresh WebRTC implementation built on C++23, Boost.Asio, and stdexec.
If your project uses Boost.Asio and needs to establish WebRTC connections with browsers or SFU servers, asio-rtc is a great fit because:
- asio-rtc has no internal threads; all logic runs on an
executor. - asio-rtc supports both the traditional asio async model and the C++26 Senders/Receivers model.
- asio-rtc provides JavaScript-like interfaces; if you are familiar with browser WebRTC, asio-rtc will feel familiar.
- All async operations support cancellation.
- The code is readable and easy to modify.
- PeerConnection — offer/answer, ICE, DTLS-SRTP, SCTP DataChannel
- Transceiver — add_transceiver, get_transceivers, replace_track
- DataChannel — RFC 8832 DCEP over SCTP-over-DTLS
- SDP — parse/generate, BUNDLE, codec negotiation, extmaps
- Jitter buffer — RTP reorder and frame assembly
- NACK — packet loss retransmission
- TWCC — TWCC receive-side feedback
- mDNS
- Trickle-ICE
- ICE-Lite Client Side
- ICE-Lite Server Side
- GCC — TWCC send-side congestion control
- Bandwidth estimation — REMB send/receive
- Simulcast
- send
- recv
- FEC — RED, ULPFEC
- Renegotiation
- DTMF sender
- Audio PLC
- TCP candidate
- TURN
- UDP
- TCP
- TLS
- asio completion token compatible interfaces
- Browser interop test suite
| Dependency | Version | Notes |
|---|---|---|
| Boost (headers only) | 1.89+ | boost.container, boost.intrusive, etc.; required even with standalone Asio |
| stdexec | — | std::execution reference implementation |
| OpenSSL | 3.0+ | DTLS/SCTP |
| asio-ice | git submodule | ICE/DTLS/SCTP transport layer |
| libsrtp | git submodule | SRTP encryption |
| Clang / GCC / MSVC | 20+ / 13+ / 19+ | C++23 |
git clone --recurse-submodules https://github.com/SamGaaWaa/asio-rtc.git
./debug-build.sh # Clang 20 debug + ASan → clang-build/Or manually:
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DBoost_DIR=/path/to/boost/lib/cmake/Boost-1.91.0 \
-DSTDEXEC_DIR=/path/to/stdexec/include
make -j$(nproc)| CMake option | Default | Description |
|---|---|---|
ASIORTC_USE_STANDALONE_ASIO |
OFF |
Use standalone Asio instead of Boost.Asio (still requires other Boost headers) |
ASIORTC_TEST |
ON |
Build tests |
All async interfaces are available in two forms:
- Sender interface (default): returns a
stdexecsender, which can beco_awaited in coroutines, or composed with algorithms likestdexec::then/stdexec::when_all/exec::async_scope. - Completion token interface: methods additionally accept an asio completion token (
use_awaitable,use_future,deferred,use_sender, plain callbacks, etc.), allowingco_awaitin asio coroutines or composition with other completion tokens.
#include "asiortc.hpp"
namespace rtc = asiortc;
boost::asio::io_context ctx;
rtc::peer_connection conn(ctx.get_executor(), rtc::configuration{
.ice_servers = {.urls = {"stun:stun.l.google.com:19302"}}
});
auto tr = conn.add_transceiver(
rtc::media_description::make_default(rtc::media_format::vp8),
{.direction = rtc::sdp_direction::sendrecv, .streams = {"my-video"}});
co_await conn.set_remote_description(parse_sdp(browser_offer, "offer"));
auto answer = co_await conn.create_answer();
co_await conn.set_local_description(std::move(answer));Both interface styles:
// sender interface: co_await directly in a stdexec coroutine
rtc::task<void> f(rtc::peer_connection &conn) {
auto offer = co_await conn.create_offer();
}
// completion token interface: co_await in an asio coroutine
boost::asio::awaitable<void> g(rtc::peer_connection &conn) {
auto offer = co_await conn.create_offer(boost::asio::use_awaitable);
}| Example | Description |
|---|---|
chat |
SDP exchanged via copy-paste, DataChannel chat |
sfu |
Browser video SFU loopback |
test |
Browser UI-driven negotiation test |
cd clang-build
./srtp_test
./rtp_rtcp_test
./sdp_test
./any_stream_track_test ../test.webm # needs ASIORTC_ENABLE_FFMPEG=ONMIT
🚧 This project is under heavy development. Bug reports, feature suggestions, and pull requests are welcome!