Skip to main content

Module rtp

Module rtp 

Source
Available on crate feature ingest and (crate features rtsp or webrtc) only.
Expand description

Shared RTP/RTCP parsing and NAL-codec (de)packetization — RFC 3550 framing plus H.264 (RFC 6184) and H.265 (RFC 7798) payload formats.

Gated behind the internal _rtp marker, pulled in by both rtsp and webrtc. The two transports differ only in how RTP packets reach the process (TCP-interleaved / UDP for RTSP, DTLS-SRTP for WebRTC); once a packet is in hand, reassembling NAL units into an Annex-B access unit is identical, so it lives here once.

§What it does

  • RtpHeader::parse decodes the fixed RTP header (RFC 3550 §5.1), honoring the CSRC count and the extension-header flag to locate the payload.
  • H264Depacketizer / H265Depacketizer turn a sequence of RTP payloads into complete access units in Annex-B form. Each handles the three NALU packetization modes for its codec — single NAL, aggregation (STAP-A type 24 / AP type 48), and fragmentation (FU-A type 28 / FU type 49) — emitting an access unit when the marker bit is set or the timestamp advances.
  • RtpPacketizer performs the reverse for egress (e.g. WebRTC WHEP), selecting the H.264 or H.265 payload format.

§What it does not do

Jitter-buffer reordering and loss concealment are the caller’s concern — the depacketizer assumes in-order delivery (true for TCP-interleaved RTSP; for UDP/SRTP a small reorder buffer should sit in front of it). It reports a DepacketizeError::OutOfOrder gap so a handler can request a keyframe (PLI/FIR) rather than emit a corrupt access unit.

Structs§

AacDepacketizer
Depacketizes RFC 3640 AAC-hbr RTP payloads into raw AAC access units.
AccessUnit
A reassembled coded video frame from the RTP bus.
Av1Depacketizercodec-av1
Reassembles AV1 RTP payloads into temporal units. Counterpart to Av1Packetizer: it concatenates each packet’s OBU-element bytes (past the aggregation header) and, on the RTP marker, parses the length-delimited elements back into low-overhead OBUs (re-adding each obu_has_size_field).
Av1Packetizercodec-av1
Packetizes an AV1 temporal unit into RTP using the AOMedia payload format.
H264Depacketizer
Reassembles RFC 6184 H.264 RTP payloads into Annex-B access units.
H265Depacketizer
Reassembles RFC 7798 H.265 (HEVC) RTP payloads into Annex-B access units.
RtpHeader
A parsed RTP fixed header (RFC 3550 §5.1).
RtpPacketizer
Packetizes H.264 Annex-B access units into RFC 6184 RTP packets — the inverse of H264Depacketizer, used for WebRTC/WHEP egress.
Vp9Depacketizer
Reassembles VP9 RTP payloads (draft-ietf-payload-vp9, non-flexible single layer) into coded frames. Counterpart to Vp9Packetizer.
Vp9Packetizer
Packetizes VP9 coded frames into RTP, using a flexible-mode-off payload descriptor for the common single-layer (non-scalable) case.

Enums§

DepacketizeError
Errors surfaced while depacketizing an RTP stream.