Skip to main content

NackResponderBuilder

Struct NackResponderBuilder 

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

Builder for the NackResponderInterceptor.

§Example

use rtci_interceptor::{Slot, Registry, NackResponderBuilder};

let chain = Registry::new()
    .with(Slot::NackResponder, NackResponderBuilder::new()
        .with_size(1024)
        .build())
    .build();

Implementations§

Source§

impl NackResponderBuilder

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 send buffer.

Size must be a power of 2 between 1 and 32768 (inclusive). Larger buffers can retransmit older packets but use more memory.

Source

pub fn with_max_packet_age(self, max_packet_age: Option<Duration>) -> Self

Set how long a sent packet is kept for retransmission: the rtx-time of RFC 4588 8.1, when one is signalled. A NACK for a packet sent longer ago is not answered.

Default: None, a packet is available for as long as the buffer holds it.

Source

pub fn with_rate_limit(self, rate_limit: RetransmissionRateLimit) -> Self

Set how retransmissions are held to the congestion controller’s target (RFC 4588 section 7). Default: RetransmissionRateLimit::WithinTarget, the RFC’s form; RetransmissionRateLimit::UpToTarget is the limiter libwebrtc’s RtpSender has when it is given one.

Source

pub fn with_max_reserve_fraction(self, fraction: f64) -> Self

Set the most of the congestion controller’s target the retransmission reserve of RetransmissionRateLimit::WithinTarget takes, from 0 (no reserve: the target is never lowered) to 1. Default: MAX_RETRANSMISSION_RESERVE.

Source

pub fn with_max_repair_age(self, max_repair_age: Option<Duration>) -> Self

Set how old a packet may be and still be repaired: a NACK for a packet written to the responder longer ago is declined (RFC 8834 section 6.1: “the likelihood of them arriving in time to be useful need[s] to be considered before RTP retransmission is used”; RFC 4588 section 7: the sender “MAY selectively retransmit only the packets that it deems important and ignore NACK messages for other packets”).

A receiver that still asks for a video packet that old is waiting for a picture nobody can use, so the first such request gives the stream up: everything sent on it so far is forgotten (its buffer, the requests waiting), the retransmission reserve they held is released at once, and the application is asked for a key frame (a Picture Loss Indication with sender SSRC 0, RTCPeerConnectionEvent::OnKeyFrameRequest, as at the pacer’s flush). What is written afterwards is buffered and repaired as ever. An audio packet that old is not retransmitted and nothing else happens.

Default: MAX_REPAIR_AGE. None: a packet is repaired for as long as the buffer holds it. This is the sender’s own judgement and is not announced.

An rtx-time takes its place. RFC 4588 section 8.1: rtx-time is “the maximum time a sender will keep an original RTP packet in its buffers available for retransmission”. Where one is in force for a stream (announced in the session description or set by the application for its retransmission format, NackControl::LocalRtxTime, or configured with with_max_packet_age), that is how old a packet of the stream may be and still be repaired, whether shorter or longer than this setting, and this setting does nothing for the stream: a packet older than the rtx-time is not retransmitted and nothing else happens (the stream is not given up, no key frame is asked for: the receiver was told the time and “should take into account the signalled sender retransmission buffer length”, section 8.8).

The rtx-time is that of the packet’s own retransmission format (RFC 4588 section 8.6: a parameter of each RTX payload type, which apt ties to one original payload type): a RED packet’s is the one announced for the RTX of red, a plain packet’s the one of its codec’s RTX. That one value decides all three for the packet: the cut at the time, this setting where there is no time, and whether the packet’s age gives the stream up. A packet that is never sent again (a FEC packet in RED on a stream without RTX, a payload type without an RTX format on a stream that has RTX) gives nothing up by its age: the receiver is not waiting for a picture because of it.

Source

pub fn with_repair_backlog_bound(self, bound: Option<Duration>) -> Self

Set the backlog of repairs past which they are given up when the path’s capacity has collapsed: the requests waiting would take this long or more to leave at the congestion controller’s whole target, and the target is at most half of the highest in force within the last two seconds. Every video stream with a request waiting is then given up as with_max_repair_age describes (forgotten, the reserve released, a key frame asked for). The targets from before a give-up no longer count: the next one needs the target to halve again. RFC 4588 section 7: “If congestion is not kept under control, then retransmission SHOULD NOT be used”: such a backlog is repaired at a rate the path drops again, for seconds, while the original media is held at the reserve’s floor.

A backlog at a steady target (ordinary loss, however heavy) is never given up: it is repaired within the target. Audio requests count toward the backlog and are never given up. Without a congestion controller’s target there is no such rule. An rtx-time does not change it: the time is the most a packet is kept, and a collapse ends the repairs of what was sent before it as the pacer’s flush does.

Default: REPAIR_BACKLOG_BOUND. None: every request is served in order.

Source

pub fn build(self) -> NackResponderInterceptor

Build the interceptor.

Trait Implementations§

Source§

impl Default for NackResponderBuilder

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.