pub struct RedDecoder { /* private fields */ }Expand description
Unpacks RED packets and recovers lost primaries from later packets’ redundant blocks (RFC 2198 section 3), without delivering anything twice.
Each decode returns, in timestamp order, the redundant blocks whose
timestamp was not delivered yet, then the packet’s primary (unless the same sequence
number, or a timestamp already recovered, was delivered). It remembers the last window
sequence numbers and timestamps it delivered; older duplicates can come through again.
The decoder exposes nothing of the RTP header for recovered data (section 4): its marker bit was lost with the primary, and the RED packet’s CSRC list, which the caller has, is the one to apply to it.
Implementations§
Source§impl RedDecoder
impl RedDecoder
Sourcepub fn new(window: usize) -> Self
pub fn new(window: usize) -> Self
A decoder remembering the last window deliveries (1 to
RED_MAX_DUPLICATE_WINDOW; out-of-range values are clamped).
Sourcepub fn decode(
&mut self,
sequence_number: u16,
timestamp: u32,
payload: &Bytes,
) -> Result<Vec<RecoveredBlock>>
pub fn decode( &mut self, sequence_number: u16, timestamp: u32, payload: &Bytes, ) -> Result<Vec<RecoveredBlock>>
Decodes one RED packet with RTP sequence_number and timestamp.
The primary is matched against earlier primaries by sequence number (several packets may share a timestamp) and against recoveries by timestamp; a redundant block is matched against everything delivered by timestamp.
§Errors
Fails on a malformed payload (see RedPacket::parse); state is unchanged then.