Skip to main content

Module rtp

Module rtp 

Source
Expand description

RFC references covered:

A complete RTP packet has this outer shape:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P|X|  CC   |M|     PT      |       sequence number         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           timestamp                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             SSRC                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         CSRC list ...                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              extension block if X=1 ...                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         codec payload ...                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Generic NACK is RTCP feedback rather than a field in an RTP packet. One RTPFB packet can carry multiple PID/BLP entries:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P| FMT=1 |    PT=205     |             length              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    SSRC of feedback sender                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     SSRC of primary media                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              PID              |              BLP              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    more PID/BLP entries ...                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

PID names one missing primary RTP sequence number. Zero-based BLP bit i reports (PID + i + 1) mod 2^16 as missing. See RFC 4585 section 6.1 and RFC 4585 section 6.2.1.

RTX is a new RTP packet in the repair stream. Its RTP header has the repair payload type, repair SSRC and an independent repair sequence number. The payload begins with the original sequence number:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P|X|  CC   |M|   RTX PT    |    repair sequence number     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    original RTP timestamp                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          repair SSRC                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         optional CSRC list and RTP header extension ...       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              OSN              |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
|                 original RTP packet payload ...               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

apt binds the RTX payload type to the primary payload type in SDP. It is not carried in either packet. See RFC 4588 section 4 and RFC 4588 section 8.1.

Modulesยง

codec_name
RTP payload-format MIME subtype names commonly used by WebRTC endpoints.
fmtp
Codec fmtp parameter names and canonical valuse
frame_marking
Video Frame Marking RTP header-extension payload values.
g711
G.711 RTP payload-format constants
h264
H264 SDP and payload-format helpers derived from RFC 6184.
header_extension
RTP header-extension profile IDs from RFC 8285.
opus
Opus RTP payload-format constants.
rtcp_feedback_format
RTCP feedback FMT values.
rtcp_packet_type
rtcp common-header PT value namespace
rtcp_sdes_item
rtcp SDES item type value namespace
vp8
VP8 RTP payload helpers.

Structsยง

HeaderExtensionId
Local 4-bit identifier for a header extension (RFC 8285).
InvalidPayloadType
Mid
Media identification (RFC 9143).
PayloadType
7-bit RTP payload type value usable in RTP/RTCP muxed sessions
Rid
Restriction identifier (RFC 8851).
RtpFixedHeader
Parsed fields from an RTP fixed header in an RTP/RTCP muxed session.
Ssrc
Synchronization source identifier for a media stream (RFC 3550).
Vp9ProfileId
VP9 profile identifier defined by RFC 9628 section 6

Enumsยง

AvpStaticPayloadType
Common static RTP/AVP payload type assignments.
CodecName
RTP payload-format MIME subtype names commonly used by WebRTC endpoints.
RtpRtcpMuxPacketKind
RTP or RTCP candidate selected by the RFC 5761 second-octet split.

Constantsยง

GENERIC_NACK_BITMASK_BITS ๐Ÿ”’
Number of sequence numbers represented by the Generic NACK BLP field after its PID.
RTCP_COMMON_HEADER_BYTES ๐Ÿ”’
RTCP common-header length in bytes.
RTCP_RECEIVER_REPORT_WITHOUT_BLOCKS_BYTES
Length of an RTCP Receiver Report with no report blocks.
RTCP_RECEIVER_REPORT_WITHOUT_BLOCKS_LENGTH_WORDS_MINUS_ONE ๐Ÿ”’
RTCP_SSRC_BYTES ๐Ÿ”’
SSRC field length in an RTCP packet.
RTP_CSRC_BYTES ๐Ÿ”’
RTP_CSRC_COUNT_MASK ๐Ÿ”’
RTP_DYNAMIC_PAYLOAD_TYPE_END
RTP_DYNAMIC_PAYLOAD_TYPE_START
Dynamic RTP payload type range in RTP/AVP.
RTP_EXTENSION_MASK ๐Ÿ”’
RTP_FIXED_HEADER_BYTES
Fixed RTP header length in bytes with no CSRC and no extension.
RTP_MARKER_MASK ๐Ÿ”’
RTP_MAX_CSRC_COUNT
Maximum number of CSRC identifiers in the RTP fixed header.
RTP_PADDING_MASK ๐Ÿ”’
RTP_PAYLOAD_TYPE_BITS ๐Ÿ”’
RTP_PAYLOAD_TYPE_COUNT
Number of values representable by the 7-bit RTP payload type field.
RTP_PAYLOAD_TYPE_MASK ๐Ÿ”’
RTP_PAYLOAD_TYPE_MAX
Maximum value representable by the 7-bit RTP payload type field.
RTP_RTCP_MUX_FORBIDDEN_PAYLOAD_TYPE_END
RTP_RTCP_MUX_FORBIDDEN_PAYLOAD_TYPE_START
Payload type range disallowed when RTP and RTCP share one port.
RTP_SEQUENCE_NUMBER_MODULUS
Sequence number rollover modulus for the 16-bit RTP sequence number.
RTP_SEQUENCE_NUMBER_OFFSET ๐Ÿ”’
RTP_SSRC_OFFSET ๐Ÿ”’
RTP_TIMESTAMP_MODULUS
Timestamp rollover modulus for the 32-bit RTP timestamp field.
RTP_TIMESTAMP_OFFSET ๐Ÿ”’
RTP_VERSION
RTP version defined by RFC 3550 section 5.1.
RTP_VERSION_HEADER_BITS ๐Ÿ”’
RTP version bits in the first octet of RTP and RTCP packets.
RTP_VERSION_MASK ๐Ÿ”’
RTP_VERSION_SHIFT ๐Ÿ”’
RTP_VIDEO_CLOCK_RATE_HZ
RTP clock rate used by the supported video payload formats
RTX_ORIGINAL_SEQUENCE_NUMBER_BYTES
Number of octets prepended to an RTX payload for the original sequence number.

Functionsยง

classify_rtp_rtcp_mux
Classifies an RTP or RTCP candidate in an RTP/RTCP muxed datagram.
generic_nack_sequence_numbers
Expands one Generic NACK PID and bitmask into requested RTP sequence numbers.
is_dynamic_payload_type
Returns true if payload_type is an RTP/AVP dynamic payload type.
is_payload_type
Returns true if payload_type fits in the RTP fixed-header PT field.
is_rtcp_mux_dynamic_payload_type
Returns whether payload_type can be assigned dynamically in an RTP/RTCP muxed RTP/AVP session.
is_rtcp_mux_payload_type
Returns true if payload_type can be used with RTP/RTCP mux.
parse_muxed_rtp_fixed_header
Parses the fixed RTP header of an RTP candidate in a muxed session.
read_u16 ๐Ÿ”’
read_u32 ๐Ÿ”’
rtcp_receiver_report_without_report_blocks
Builds an RTCP Receiver Report with no reception report blocks.
rtx_original_sequence_number
Extracts the original RTP sequence number from an RTX payload.