Skip to main content

FlexFec03Encoder

Struct FlexFec03Encoder 

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

Builds FlexFEC draft-03 repair packets.

Draft-03 rather than RFC 8627 because draft-03 is what browsers negotiate as video/flexfec-03. The RFC states its payload formats are not backward compatible with the earlier drafts, so the two are separate implementations with separate vectors — a draft-03 round trip is evidence about browsers, not about the RFC.

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|0| P|X|  CC  |M| PT recovery |         length recovery       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          TS recovery                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   SSRCCount   |                    reserved                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             SSRC_i                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           SN base_i           |k|          Mask [0-14]        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|k|                   Mask [15-45] (optional)                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|k|                                                             |
+-+                   Mask [46-108] (optional)                  |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Implementations§

Source§

impl FlexFec03Encoder

Source

pub fn new(payload_type: u8, ssrc: u32) -> Self

A repair-stream encoder sending payload_type on ssrc.

The repair stream has its own SSRC and its own sequence-number space, both negotiated separately from the media it protects.

Source

pub fn with_base_sequence_number(self, sequence_number: u16) -> Self

Start the repair stream’s sequence numbers at sequence_number.

Source

pub fn next_sequence_number(&self) -> u16

The sequence number the next repair packet will carry.

Source

pub fn encode( &mut self, media_packets: &[Packet], num_fec_packets: u32, ) -> Vec<Packet>

Build up to num_fec_packets repair packets protecting media_packets.

Returns nothing when the media packets are not a consecutive run: a packet mask describes positions relative to one base sequence number, so a gap would silently shift every position after it and protect the wrong packets. A caller that has lost a packet should start a new block rather than encode across the hole.

Trait Implementations§

Source§

impl Debug for FlexFec03Encoder

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 = 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.