Skip to main content

PacerBuilder

Struct PacerBuilder 

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

Builder for PacerInterceptor.

§Example

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

let chain = Registry::new()
    .with(Slot::Pacer, PacerBuilder::new().with_target_bitrate(2_000_000.0).build())
    .build();

Implementations§

Source§

impl PacerBuilder

Source

pub fn new() -> Self

Create a builder with the default rate and queue limit.

Source

pub fn with_target_bitrate(self, bits_per_second: f64) -> Self

The rate to pace at, in bits per second.

Source

pub fn with_burst_bits(self, burst_bits: f64) -> Self

How much may be released at once, in bits.

Larger bursts smooth less but cost fewer wake-ups.

Source

pub fn with_queue_limit(self, queue_limit: usize) -> Self

How many packets may be queued. When a packet arrives at a full queue, the oldest one is dropped or leaves over the budget, as Self::with_queue_overflow says.

Source

pub fn with_queue_time_limit(self, limit: Option<Duration>) -> Self

How long a packet may wait in the queue (DEFAULT_QUEUE_TIME_LIMIT by default, None for no bound). When the application writes faster than the congestion controller’s target, the queue grows; a packet that would wait longer than this is dropped or drained above the target, as Self::with_queue_overflow says. The application learns that its source is above the target from the target itself (TargetBitrateChanged, RTCRtpSender::target_bitrates), from PacerInterceptor::queue_time, and, once media had to be discarded, from PacerDiscard (RTCPeerConnectionEvent::OnPacerDiscard in the peer connection) and the key-frame request that goes with it.

Source

pub fn with_queue_overflow(self, overflow: QueueOverflow) -> Self

What happens to media the target has no room for (QueueOverflow::Drop by default).

Source

pub fn with_immediate_release(self, immediate_release: bool) -> Self

Whether a packet the budget already covers leaves when it is written, with nothing queued ahead of it. On by default.

The pacer exists to keep a sender from putting more than its target rate times the burst time on the path at once (draft-ietf-rmcat-gcc-02 section 4: a group of packets of that size every burst_time, 5 ms recommended). The budget is that bound: it never holds more than one burst and refills at the target rate. A packet inside it adds nothing to what the bound allows, and holding it until the next wake-up only adds delay the sender caused itself, which RFC 8836 section 2 (requirement 1) asks a congestion controller for interactive media to keep as low as possible; no RFC asks for the wait. false restores it: every packet is queued and leaves from the next timeout, so departures happen only on the driver’s clock.

Source

pub fn build(self) -> PacerInterceptor

Build the interceptor.

Trait Implementations§

Source§

impl Default for PacerBuilder

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.