sip/audio/rtp library

Minimal RFC 3550 RTP packet builder + parser — pure Dart.

Trimmed port of KellyKinyama/dart-rtp-packet (lib/src/rtp.dart), keeping only what an audio-only G.711 sender/receiver needs:

  • fixed 12-byte header
  • single-payload packet (no fragmentation; G.711 frames at 20ms are ~160 bytes, well under any MTU)
  • sequence + timestamp + SSRC bookkeeping in RtpState

SRTP, RTCP, header extensions and FU-A fragmentation are intentionally omitted — they don't apply to plain SIP/G.711 calls.

Classes

RtpPacket
Decoded inbound RTP packet.
RtpState
Mutable per-stream state. One instance per outbound RTP stream.

Constants

rtpHeaderSize → const int
rtpVersion → const int

Functions

makeRtpPacket(RtpState state, Uint8List payload, int rtpTimestamp, {bool marker = false}) Uint8List
Builds an RTP packet (RFC 3550 §5.1). Returns the wire bytes ready for RawDatagramSocket.send. Increments state.seq by one.
parseRtp(Uint8List data) RtpPacket?
Parses an inbound RTP datagram. Returns null if the buffer is too short or the version isn't 2. Skips past CSRC list and any header extension.