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
impl History
Sourcepub fn add_outgoing(
&mut self,
ssrc: u32,
rtp_sequence_number: u16,
is_twcc: bool,
twcc_sequence_number: u16,
size: usize,
departure: Instant,
) -> u64
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).
Sourcepub fn on_twcc_feedback(
&mut self,
received_at: Instant,
acknowledgement: Acknowledgement,
) -> Option<Duration>
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.
Sourcepub fn on_ccfb_feedback(
&mut self,
received_at: Instant,
ssrc: u32,
acknowledgement: Acknowledgement,
) -> Option<Duration>
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.
Sourcepub fn take_reports(&mut self) -> Vec<PacketReport>
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.
Sourcepub fn prune_before(&mut self, cutoff: Instant)
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.