pure_dart_webrtc 1.0.4 copy "pure_dart_webrtc: ^1.0.4" to clipboard
pure_dart_webrtc: ^1.0.4 copied to clipboard

A pure Dart implementation of WebRTC, including support for ICE, STUN, TURN, DTLS, TLS, SRTP, RTP, RTCP, and SDP.

dart_webrtc #

dart_webrtc (WebrTC Implementation for The Dart language)

A pure Dart implementation of WebRTC — ICE, STUN, TURN, DTLS, TLS, SRTP, RTP, RTCP, SDP — with no native dependencies. Includes a full ion-style SFU (example/ion_style_sfu/) with sharding, clustering, simulcast, TWCC/REMB, NACK/RTX, audio observer, and Prometheus stats.

Inspired by webrtc-nuts-and-bolts


✨ Highlights #

  • Pure Dart end-to-end stack — no libwebrtc / libsrtp / libnice. Easy to embed and audit.
  • Ion-style SFU with isolate-based sharding, cluster coordinator, UDP relay transport, leaky-bucket pacer, BWE, jitter buffer, simulcast layer rewriter, and audio-level observer.
  • 516 unit tests in the SFU package, 93–100 % line coverage across major files.
  • VP8 / VP9 / Opus / PCMA / PCMU, RTX (RFC 4588), NACK, PLI, FIR, REMB, TWCC, audio level (RFC 6464), playout-delay codec.
  • Built-in load-test harness and synthetic loss simulator.
  • Prometheus metrics + JSON /stats endpoint.

📦 Installation #

clone the repo

Then run:

dart pub get

Requires Dart 3.x or later.


📚 Documentation (WIP) #


💡 Examples #

GitHub: examples

Ion-style SFU server #

dart run example/ion_style_sfu/bin/sfu_server.dart \
  --ip 0.0.0.0 \
  --ws-port 9091 \
  --rtp-base 51000 \
  --announce-ip <your-public-ip> \
  --ice-server stun:stun.l.google.com:19302

Browser demo client:

cd example/ion_style_sfu/web
python -m http.server 8000 --bind 0.0.0.0
# open http://localhost:8000/meet.html

Run the SFU test suite:

cd example/ion_style_sfu
dart test

Walkie-talkie SFU + Flutter PTT client #

Push-to-talk multi-channel walkie-talkie built on top of example/ion_style_sfu/. Server adds in-memory user accounts (PBKDF2 + JWT), /auth/register, /auth/login, /channels, and a JWT-gated /ws upgrade. Flutter client (Android / iOS / macOS / Windows / Linux / Web) ships an auth screen, channel list, PTT screen with optional per-peer camera toggle (publisher renegotiation).

# server
dart run example/ion_style_sfu/bin/walkie_sfu.dart \
  --ip 0.0.0.0 --ws-port 7080 --announce-ip <public-ip>

# client
cd example/walkie_talkie_client
flutter run

See example/walkie_talkie_client/README.md.

WHIP recorder + security-camera Flutter client #

Cloud / on-prem video-recording pipeline: a pure-Dart WHIP ingest server that depacketizes VP8 RTP and writes each publisher session to its own .ivf file on disk, paired with a Flutter app that captures the device camera + microphone and publishes via WHIP. Intended for unattended security-camera deployments — drop a phone or tablet running the client at every site, point it at the recorder, done.

# server (writes IVF files to ./recordings)
dart run example/whip_recorder/bin/whip_recorder.dart \
  --ip 0.0.0.0 --token <secret> --out ./recordings

# list / download recordings
curl -H "Authorization: Bearer <secret>" http://<host>:8080/recordings

# client
cd example/security_camera_client
flutter run

See example/whip_recorder/README.md and example/security_camera_client/README.md.

DTLS server #

dart bin/srtp_webrtc.dart
dart bin/dart_webrtc.dart
dart lib/src/dtls/examples/server/psk_ccm8.dart
dart lib/src/dtls/examples/server/psk_ccm.dart

SRTP/DTLS server #

dart bin/srtp_webrtc.dart

DTLS client #

dart lib/src/dtls3/handshaker/client/dtls_client.dart

STUN Server #

dart lib/src/stun3/stun_server7.dart

STUN client #

dart lib/src/stun3/stun_client.dart

STUN/DTLS/SRTP/RTCP multiplexing #

This example recieves stun, dtls, rtp packets. It decrypts, encrypts and sends the packets back to the sender. copy the sdp offer from this file:

lib\src\sdp8\sdp_test.dart

Adjust the the fingerprint and ice candidate

cd WebRTC-Simple-SDP-Handshake-Demo
php -S localhost:3000

Navigate to the link in your browser=> localhost:3000 Paste the sdp in the sdp offer box

Run this command

dart bin\srtp_webrtc.dart

In your browser, click create answer


🎯 Roadmap #

✅ Shipped #

Signaling & NAT traversal

  • ✅ STUN (client + server)
  • ✅ SIP
  • ❌ TURN (UDP)

ICE

  • ✅ Vanilla ICE
  • ✅ Trickle ICE
  • ✅ ICE-Lite (client + server)
  • ❌ ICE Restart

Security

  • ✅ DTLS 1.2 + DTLS-SRTP
    • ✅ Curve25519, P-256
    • ✅ PSK (CCM, CCM-8)
  • ❌ TLS 1.2

RTP / RTCP

  • ✅ RFC 3550 RTP base + header extensions (audio level, playout delay, abs-send-time, TWCC)
  • ✅ Payload formats: VP8, VP9, Opus, PCMA, PCMU
  • ✅ RTX (RFC 4588), RED scaffolding
  • ✅ RTCP: SR/RR, NACK, PLI, FIR, REMB, TWCC
  • ❌ H264, AV1, SVC

SDP / PeerConnection

  • ✅ SDP parsing + generation, m-line reuse
  • ✅ PeerConnection API
  • ✅ Simulcast (RID + SIM SSRC group, recv + forward)
  • ✅ Bandwidth estimation (sender-side TWCC + REMB)

SFU (example/ion_style_sfu/)

  • ✅ Session / Peer / Publisher / Subscriber / Router / Receiver / DownTrack
  • ✅ Isolate-based session sharding (SessionShard, ShardedSfu)
  • ✅ Cluster coordinator + UDP relay transport (cascade between SFUs)
  • ✅ Audio observer (RFC 6464) + audio-level forwarding policy
  • ✅ Leaky-bucket pacer, byte budget, NACK buffer, RTCP rewrite
  • ✅ Synthetic loss simulator + load-test harness
  • ✅ Prometheus stats + JSON snapshot, /streams aggregator (Phase B11)
  • ✅ WebSocket signalling server (runIonStyleSfuServer)
  • ✅ Multi-room cluster snapshot rehydration

Compatibility

  • ✅ Chrome / Edge / Firefox
  • ✅ webrtc-rs interop
  • ❌ Pion / aiortc / sipsorcery interop suite

🔜 Roadmap #

  • ❌ VP9 SVC layer selector
  • ❌ H264 forwarding
  • ❌ Insertable streams / SFrame (E2EE)
  • ✅ Recording (VP8 → IVF, via example/whip_recorder/)
  • ❌ Recording (Opus, VP9 → IVF, MP4 remux)
  • ❌ Published throughput benchmarks + Helm chart
  • ❌ DataChannel (SCTP)
  • ❌ TURN (UDP + TCP)
  • getStats() browser-compatible API
  • ❌ ICE Restart

🔗 References #

2
likes
130
points
15
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A pure Dart implementation of WebRTC, including support for ICE, STUN, TURN, DTLS, TLS, SRTP, RTP, RTCP, and SDP.

Repository (GitHub)
View/report issues

License

GPL-3.0 (license)

Dependencies

archive, args, asn1lib, basic_utils, bits, collection, convert, crypto, cryptography, dotenv, dtls2, ecdsa, elliptic, events_emitter, ffi, ffigen, fixnum, hex, image, intl, pointycastle, sdp_transform, shelf, shelf_web_socket, uuid, web_socket_channel, x25519, x509b

More

Packages that depend on pure_dart_webrtc