Skip to main content

NackGeneratorBuilder

Struct NackGeneratorBuilder 

Source
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

Source

pub fn new() -> Self

Create a new builder with default settings.

Source

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

Source

pub fn with_interval(self, interval: Duration) -> Self

Set the interval between NACK generation cycles.

Source

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.

Source

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

Source

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

Source

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.

Source

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.

Source

pub fn build(self) -> NackGeneratorInterceptor

Build the interceptor.

Trait Implementations§

Source§

impl Default for NackGeneratorBuilder

Source§

fn default() -> Self

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.