Skip to main content

History

Struct History 

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

Records outgoing packets and matches incoming feedback against them.

The two feedback formats identify a packet differently — TWCC by its own transport-wide sequence number, RFC 8888 by the stream’s SSRC and RTP sequence number — so both indexes are kept, pointing at one record.

Implementations§

Source§

impl History

Source

pub fn new() -> Self

An empty history.

Source

pub fn len(&self) -> usize

How many packets are being tracked.

Source

pub fn is_empty(&self) -> bool

Whether nothing is being tracked.

Source

pub fn add_outgoing( &mut self, ssrc: u32, rtp_sequence_number: u16, is_twcc: bool, twcc_sequence_number: u16, size: usize, departure: Instant, ) -> u64

Record a packet as it leaves.

departure must be the instant the packet was released to the network, not the instant the application handed it over. A pacer can hold a packet for tens of milliseconds, and counting that as network delay is exactly the error that makes a bandwidth estimate collapse (chain contract rule 3).

Source

pub fn on_twcc_feedback( &mut self, received_at: Instant, acknowledgement: Acknowledgement, ) -> Option<Duration>

Apply TWCC feedback, returning the round trip time it implies.

None when the feedback names a packet this endpoint has no record of — which happens routinely at startup and after the history has been pruned, and is not an error.

Source

pub fn on_ccfb_feedback( &mut self, received_at: Instant, ssrc: u32, acknowledgement: Acknowledgement, ) -> Option<Duration>

Apply RFC 8888 feedback for one stream, returning the round trip time it implies.

Source

pub fn take_reports(&mut self) -> Vec<PacketReport>

Take everything up to the highest arrived packet since the last call, in send order.

Packets older than that which are still unreported are treated as lost and then dropped. Loss feedback alone does not advance the reporting window; losses are emitted when a later packet is reported as arrived.

Source

pub fn prune_before(&mut self, cutoff: Instant)

Drop records of packets sent before cutoff that were never acknowledged.

Without this the history grows without bound on a lossy path: an unacknowledged packet is never reported and never removed, so nothing else would ever release it.

Trait Implementations§

Source§

impl Debug for History

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for History

Source§

fn default() -> History

Returns the “default value” for a type. 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.