Expand description
Redundant audio data, RED (RFC 2198). Redundant audio data, RED (RFC 2198).
A RED payload is a list of block headers followed by the data blocks in the same order, with no padding between them (section 3):
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1| block PT | timestamp offset | block length | redundant block header
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0| block PT | primary block header
+-+-+-+-+-+-+-+-+The RTP header of a RED packet (sequence number, timestamp, marker, CSRCs) belongs to the
primary block; a redundant block’s timestamp is the RTP timestamp minus its offset, and it
must use the same clock rate as the primary. Two things are not carried for redundant data
(section 4): the marker bit of a lost primary is lost with it, and the CSRC list of the RED
packet that carried a recovered block is the one to apply to it. RedDecoder exposes
neither; the caller takes the CSRCs from the RED packet it fed in.
RedPacketreads and writes one payload, strictly bounds-checked.RedEncoderbuilds each payload from a new primary plus copies of the previous ones (section 3: “a copy of the primary MAY be used as the redundancy”, the mode Chrome uses for Opus).RedDecoderreturns each packet’s primary and recovers lost earlier primaries from later packets’ redundant blocks.parse_red_fmtp/format_red_fmtphandle thea=fmtp:<pt> 111/111list (section 5).
An empty primary block is accepted and produced: nothing in RFC 2198 forbids a zero-length block, and RFC 4103 (T.140 text over RED) sends empty primaries while idle.
Structs§
- Recovered
Block - A payload a
RedDecoderdelivers. - Recovered
Media - A block
RedDecoder::decode_rtpdelivers, with what of the RED packet’s header applies to it (RFC 2198 section 4). - RedBlock
- One block of a RED payload.
- RedDecoder
- Unpacks RED packets and recovers lost primaries from later packets’ redundant blocks (RFC 2198 section 3), without delivering anything twice.
- RedDepacketizer
- Returns a RED payload’s primary data, for audio streams whose RED payload type is
depacketized like a codec. Redundant blocks are dropped; use
RedDecoderto recover from them. - RedEncoder
- Builds RED payloads whose redundancy is copies of the previous primaries (RFC 2198 section 3), the way Chrome sends Opus RED.
- RedPacket
- One RED payload: redundant blocks in header order, then the primary.
Constants§
- RED_
DEFAULT_ DUPLICATE_ WINDOW - The default number of recent deliveries a
RedDecoderremembers. - RED_
MAX_ BLOCKS - The most blocks (redundant ones plus the primary) a
RedPacketmay have. RFC 2198 sets no limit; one or two levels of redundancy are usual, and 32 bounds the parser’s work. - RED_
MAX_ BLOCK_ LENGTH - The largest redundant block length (10 bits).
- RED_
MAX_ DUPLICATE_ WINDOW - The largest duplicate window a
RedDecoderaccepts. - RED_
MAX_ PAYLOAD_ TYPE - The largest RTP payload type (7 bits).
- RED_
MAX_ TIMESTAMP_ OFFSET - The largest timestamp offset (14 bits).
- RED_
PRIMARY_ HEADER_ SIZE - Size of the primary block header.
- RED_
REDUNDANT_ HEADER_ SIZE - Size of a redundant block header.
Functions§
- format_
red_ fmtp - Formats a RED fmtp list: payload types joined by
/. - parse_
red_ fmtp - Parses the RED fmtp list,
a=fmtp:<pt> 111/111(section 5): the payload types of the primary and then the redundant encodings, slash-separated.