webrtc_dart 0.23.0 copy "webrtc_dart: ^0.23.0" to clipboard
webrtc_dart: ^0.23.0 copied to clipboard

Pure Dart WebRTC implementation. DataChannels, media streaming, ICE/DTLS/SCTP/RTP. Port of werift-webrtc. No native dependencies - works on any Dart platform.

webrtc_dart #

Pure Dart WebRTC implementation. No native dependencies - works on any Dart platform.

pub package License: MIT

Features #

  • W3C WebRTC API - Standard RTCPeerConnection interface
  • DataChannels - Reliable/unreliable, ordered/unordered
  • Media streaming - Video (VP8, VP9, H.264, AV1) and Audio (Opus)
  • Full RTP/RTCP - NACK, PLI, FIR, REMB, TWCC, RTX, Simulcast
  • NAT traversal - ICE, STUN, TURN with TCP/UDP support
  • Secure - DTLS-SRTP with modern cipher suites

Installation #

dependencies:
  webrtc_dart: ^0.23.0

Quick Start #

DataChannel #

import 'package:webrtc_dart/webrtc_dart.dart';

void main() async {
  final pc = RTCPeerConnection(RtcConfiguration(
    iceServers: [IceServer(urls: ['stun:stun.l.google.com:19302'])],
  ));

  // Create data channel
  final channel = pc.createDataChannel('chat');

  channel.onOpen.listen((_) {
    channel.sendString('Hello!');
  });

  channel.onMessage.listen((message) {
    print('Received: $message');
  });

  // Handle ICE candidates
  pc.onIceCandidate.listen((candidate) {
    // Send to remote peer via signaling
  });

  // Create and send offer
  final offer = await pc.createOffer();
  await pc.setLocalDescription(offer);
}

Receiving Media #

final pc = RTCPeerConnection();

pc.onTrack.listen((transceiver) {
  print('Received ${transceiver.receiver.track.kind} track');

  // Access RTP packets directly
  transceiver.receiver.onRtp = (packet) {
    // Process video/audio packets
  };
});

Using TURN #

final pc = RTCPeerConnection(RtcConfiguration(
  iceServers: [
    IceServer(urls: ['stun:stun.l.google.com:19302']),
    IceServer(
      urls: ['turn:turn.example.com:3478'],
      username: 'user',
      credential: 'pass',
    ),
  ],
));

API Overview #

Class Purpose
RTCPeerConnection Main WebRTC connection
RTCDataChannel Data messaging
RTCRtpTransceiver Media track handling
RTCRtpSender Send media + DTMF
RTCRtpReceiver Receive media
RTCIceCandidate ICE connectivity
RTCSessionDescription SDP offer/answer

Browser Compatibility #

Tested with Chrome, Firefox, and Safari via automated Playwright tests.

Examples #

See example/ for comprehensive examples:

  • datachannel/ - Data channel patterns
  • mediachannel/ - Media streaming (sendonly, recvonly, sendrecv)
  • save_to_disk/ - Recording to WebM/MP4
  • telephony/ - DTMF tones

Test Coverage #

2587 tests passing with browser interop validation.

dart test                    # Run all tests
dart test test/ice/          # Run specific suite

Contributing #

dart format .     # Format code
dart analyze      # Check for issues
dart test         # Run tests

Acknowledgments #

Port of werift-webrtc by Yuki Shindo.

License #

MIT

2
likes
0
points
814
downloads

Publisher

verified publisherhornmicro.com

Weekly Downloads

Pure Dart WebRTC implementation. DataChannels, media streaming, ICE/DTLS/SCTP/RTP. Port of werift-webrtc. No native dependencies - works on any Dart platform.

Repository (GitHub)
View/report issues

Topics

#webrtc #peer-to-peer #datachannel #real-time #networking

Documentation

Documentation

License

unknown (license)

Dependencies

crypto, cryptography, logging, pointycastle

More

Packages that depend on webrtc_dart