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 on_twcc_feedback_count(&mut self, feedback_packet_count: u8) -> u8
pub fn on_twcc_feedback_count(&mut self, feedback_packet_count: u8) -> u8
Note the feedback packet count of a TWCC feedback just read, and return how many feedback packets the receiver sent between the previous one and this one that never arrived.
The count is the only thing that tells a lost feedback packet from a quiet receiver
(draft-holmer-rmcat-transport-wide-cc-extensions-01 section 3.1). The packets a lost
feedback would have described get no verdict at all, see
take_reports; this is the measure of how often that happened.
Sourcepub fn lost_feedback(&self) -> u64
pub fn lost_feedback(&self) -> u64
How many TWCC feedback packets were sent by the receiver and never read here.
Sourcepub fn unreported(&self) -> u64
pub fn unreported(&self) -> u64
How many sent packets were released without any feedback describing them.
Sourcepub fn take_reports(&mut self) -> Vec<PacketReport>
pub fn take_reports(&mut self) -> Vec<PacketReport>
Take every packet a feedback described, up to the highest arrived one, since the last call, in send order.
A packet the receiver reported as not received is a loss. A packet below the highest arrival that no feedback described is neither: the feedback that covered it was lost, or the receiver does not report on its stream (no transport-wide sequence number, an SSRC outside the RFC 8888 report). The draft is explicit that such packets are ignored, not counted as lost or received (section 3), so they are released here without a report. Loss feedback alone does not advance the reporting window; losses are emitted when a later packet is reported as arrived.
Sourcepub fn forget_sent(&mut self)
pub fn forget_sent(&mut self)
Forget every packet sent so far, as on a new path: those went into the path that was
left, and what a later feedback says of them is neither a loss nor a delivery of the new
one’s. libwebrtc’s TransportFeedbackAdapter::SetNetworkRoute does the same, so that
“the feedback adapter only reports packets sent on the new route”
(RtpTransportControllerSend::OnNetworkRouteChanged). A feedback that names one of
them later matches nothing, as for a packet pruned.
Sourcepub fn recovered(&self) -> u64
pub fn recovered(&self) -> u64
Packets reported as not received that a later feedback reported as received.
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.