Skip to main content

UlpfecDecoder

Struct UlpfecDecoder 

Source
pub struct UlpfecDecoder { /* private fields */ }
Expand description

Recovers lost media packets of one stream from ULPFEC packets.

Feed it every media packet of the protected stream (push_media) and every FEC payload (push_fec); each call returns the packets it could rebuild. Recovery is level by level (9.2) and iterated, so one rebuilt packet can complete another FEC packet’s set.

§Partial recovery

With uneven protection a packet may be rebuilt at level 0 and not beyond. Its length is then known and longer than what was rebuilt, which is how 9 tells a partial recovery from a full one. A partial packet is kept, used as input to further recovery, and not returned: the octets after the recovered part are unknown, and a packet with a made-up tail is worse than a lost one. partial_packets counts them.

§Bounds

Media is kept for ULPFEC_MEDIA_WINDOW sequence numbers either side of the newest, FEC packets up to ULPFEC_MAX_HELD_FEC, and a recovered packet is never longer than the FEC data received for it.

Implementations§

Source§

impl UlpfecDecoder

Source

pub fn new(ssrc: u32) -> Self

A decoder for the media stream ssrc.

Source

pub fn with_one_level_only(self, one_level_only: bool) -> Self

Refuse FEC packets with more than one protection level, for a stream that signalled onelevelonly=1 (RFC 5109 13).

Source

pub fn ssrc(&self) -> u32

The media SSRC this decoder protects.

Source

pub fn stats(&self) -> UlpfecDecoderStats

Counters.

Source

pub fn partial_packets(&self) -> usize

Packets rebuilt at some levels only, and so not handed out.

Source

pub fn held_fec_packets(&self) -> usize

FEC packets held.

Source

pub fn held_media_packets(&self) -> usize

Media packets held, complete or partial.

Source

pub fn push_media(&mut self, packet: &Packet) -> Vec<Packet>

A media packet of the protected stream arrived. Returns what it made recoverable.

A packet of another SSRC is ignored.

Source

pub fn push_fec(&mut self, payload: &[u8]) -> Result<Vec<Packet>, UlpfecError>

A FEC payload arrived: the payload of a FEC packet of a separate stream, or the FEC block of a RED packet. Returns the media packets it made recoverable.

A second copy of a FEC packet already held is ignored.

Rule a of 7.4 is checked against the FEC packets held and counted in UlpfecDecoderStats::rule_violations, and the packet is used regardless: the recovery arithmetic does not depend on the rule, and libwebrtc’s masks protect a packet with several FEC packets whose level-0 lengths differ.

Trait Implementations§

Source§

impl Debug for UlpfecDecoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.