pub struct NackGeneratorBuilder { /* private fields */ }Expand description
Builder for the NackGeneratorInterceptor.
§Example
use rtci_interceptor::{Slot, Registry, NackGeneratorBuilder};
use std::time::Duration;
let chain = Registry::new()
.with(Slot::NackGenerator, NackGeneratorBuilder::new()
.with_size(512)
.with_interval(Duration::from_millis(100))
.with_skip_last_n(2)
.build())
.build();Implementations§
Source§impl NackGeneratorBuilder
impl NackGeneratorBuilder
Sourcepub fn with_size(self, size: u16) -> Self
pub fn with_size(self, size: u16) -> Self
Set the size of the receive log.
Size must be a power of 2 between 64 and 32768 (inclusive).
Sourcepub fn with_interval(self, interval: Duration) -> Self
pub fn with_interval(self, interval: Duration) -> Self
Set the interval between NACK generation cycles.
Sourcepub fn with_skip_last_n(self, skip_last_n: u16) -> Self
pub fn with_skip_last_n(self, skip_last_n: u16) -> Self
Set the number of most recent packets to skip when generating NACKs.
This helps avoid generating NACKs for packets that are simply delayed and haven’t arrived yet.
Sourcepub fn with_max_nacks_per_packet(self, max: u16) -> Self
pub fn with_max_nacks_per_packet(self, max: u16) -> Self
Set the maximum number of NACKs to send per missing packet (RFC 4588 Appendix A: a receiver limits how often it asks again).
Default: 0, unlimited: a missing packet is asked for again a round trip after each
request (RFC 4588 6.3) for as long as it is missing and the receive log holds it. RFC
4588 gives no number (“the absolute minimum should be one”, Appendix A). A limit makes a
packet that the limit’s requests did not bring lost for good, and a receiver that holds
later frames back for it (a sample builder, a jitter buffer) freezes until it gives the
packet up as well: in tests/capacity_cap_video_rtc2rtc.rs, with retransmissions not held
to the target, ten requests (and no age limit) left the picture frozen for 4.8 to 5.4 s on
every seed, against 1.0 to 1.6 s without a limit. SUGGESTED_MAX_NACKS_PER_PACKET is
those ten; libwebrtc gives a packet up after 100 requests (kMaxNackRetries,
modules/video_coding/nack_requester.cc at a222406d, line 39), a request at most every
round trip, and counts its other limits in packets: a packet more than 10,000 sequence
numbers behind the newest is not asked for (kMaxPacketAge), and a NACK list that would
pass 1000 entries is cleared and a key frame requested instead (kMaxNackPackets).
Sourcepub fn with_max_packet_age(self, max_packet_age: Option<Duration>) -> Self
pub fn with_max_packet_age(self, max_packet_age: Option<Duration>) -> Self
Set how long a missing packet is asked for (RFC 4588 6.3: a retransmission is only
requested while it can still be of use). Give the sender’s rtx-time (RFC 4588 8.1)
when it signals one: past it the sender no longer has the packet.
Default: None, unlimited, unless the sender signals rtx-time. How long a packet stays
useful is the receiving application’s playout (RFC 4588 6.3), which this interceptor
does not know: a fixed two seconds left a call frozen for 5.9 to 6.8 s after a capacity
drop in tests/capacity_cap_video_rtc2rtc.rs, packets whose requests stopped at two
seconds staying lost while the receiver still waited for them. An application that plays
out within a known time gives that time here (SUGGESTED_MAX_PACKET_AGE is two
seconds).
Sourcepub fn with_reorder_delay(self, reorder_delay: Duration) -> Self
pub fn with_reorder_delay(self, reorder_delay: Duration) -> Self
Set how long a packet has to be missing before the first NACK for it (RFC 4588 6.3: the request is delayed to allow for reordering). Default: zero.
On top of it the generator learns each stream’s reordering: a first request also waits for as long as the stream’s out-of-order packets arrived late in the last ten seconds (a quarter more, at most 500 ms), so a path that reorders does not have every overtaken packet asked for and retransmitted.
Sourcepub fn with_round_trip_time(self, round_trip_time: Duration) -> Self
pub fn with_round_trip_time(self, round_trip_time: Duration) -> Self
Set the round-trip time assumed until the RTCP session measures one
(RtcpSessionEvent::RoundTripTime). A
packet is not asked for again before a round trip has passed since the last request
(RFC 4588 6.3: “the timer value shall be based on the observed round-trip time”): the
retransmission could not have arrived sooner.
Sourcepub fn build(self) -> NackGeneratorInterceptor
pub fn build(self) -> NackGeneratorInterceptor
Build the interceptor.