Skip to main content

ProtectionCoverage

Struct ProtectionCoverage 

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

The assignment of media packets to repair packets.

Repair packets are interleaved: with two of them, the first covers media packets 0, 2, 4, … and the second covers 1, 3, 5, …. Interleaving is what makes the scheme tolerate a burst — consecutive losses land in different repair packets, and each can be recovered independently, whereas contiguous blocks would put a burst entirely inside one and recover none of it.

Implementations§

Source§

impl ProtectionCoverage

Source

pub fn new(num_media_packets: u32, num_fec_packets: u32) -> Option<Self>

Assign num_media_packets media packets across num_fec_packets repair packets.

Returns None when the media count is zero or beyond what the masks can describe.

Source

pub fn update(&mut self, num_media_packets: u32, num_fec_packets: u32)

Recompute the assignment for a new block shape.

A no-op when the shape has not changed, which is the common case: a sender protecting a steady stream keeps the same counts block after block.

Source

pub fn num_fec_packets(&self) -> u32

How many repair packets this covers.

Source

pub fn num_media_packets(&self) -> u32

How many media packets this covers.

Source

pub fn mask(&self, fec_index: u32) -> Option<&BitArray>

The packet mask of one repair packet.

Source

pub fn covered_by(&self, fec_index: u32) -> Vec<u32>

The media packet indices that fec_index protects, in order.

Upstream returns a stateful iterator with Reset/First/HasNext, because its encoder walks the same coverage three times. A plain Vec of indices says the same thing without the cursor, and the caller can walk it as often as it likes.

Trait Implementations§

Source§

impl Clone for ProtectionCoverage

Source§

fn clone(&self) -> ProtectionCoverage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProtectionCoverage

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.