Skip to main content

GccInterceptorBuilder

Struct GccInterceptorBuilder 

Source
pub struct GccInterceptorBuilder<P> { /* private fields */ }
Expand description

Builder for GccInterceptor, for a chain assembled by hand.

Create with GccInterceptorBuilder::new, which returns (builder, handle); build returns a factory closure for Interceptor::with.

§In a peer connection: use the default interceptors’ handle instead

The rtci peer connection’s default interceptors already run this estimator (Gcc in a CongestionControlInterceptor, one per transport, with the pacer, the circuit breaker and the behaviour profile’s settings). The supported way to read the target there is rtci’s register_default_interceptors_with_handles (or register_default_interceptors_with_options), which returns DefaultInterceptorHandles: congestion_control (CongestionControlHandle::target_bitrate, the first transport’s target; every transport’s in transports), and per encoding, with the pacer’s pause as 0, RTCRtpSender::target_bitrates.

A GccInterceptor put in Slot::CongestionControl of that registry replaces the controller registered there (a slot holds one interceptor): it is then one estimator for every transport, without the circuit breaker link or the profile’s settings (only what this builder sets), and DefaultInterceptorHandles::congestion_control no longer reads a controller in the chain.

§In a chain assembled by hand

Put it in Slot::CongestionControl, nearer the wire than Slot::TwccSender, around a PassThroughInterceptor (never a NoopInterceptor, the chain’s RTCP terminus):

use rtci_interceptor::{
    GccInterceptorBuilder, Interceptor, PassThroughInterceptor, Registry, Slot,
    TwccSenderBuilder,
};

let (gcc_builder, gcc_handle) = GccInterceptorBuilder::new();
let gcc = PassThroughInterceptor::new().with(gcc_builder.with_max_bitrate(1_500_000).build());
let chain = Registry::new()
    .with(Slot::CongestionControl, gcc)
    .with(Slot::TwccSender, TwccSenderBuilder::new().build())
    .build();

// In the application's polling loop: `None` until the first transport-wide feedback.
if let Some(bits_per_second) = gcc_handle.target_bitrate_bps() {
    // the encoder's target
}

Implementations§

Source§

impl<P> GccInterceptorBuilder<P>

Source

pub fn new() -> (Self, GccHandle)

Create a new builder and the associated GccHandle.

The handle can be shared with the application so it can read the latest bitrate estimate each polling tick.

Source

pub fn with_min_bitrate(self, bps: u32) -> Self

Minimum send rate floor (default 30 kbps).

Source

pub fn with_max_bitrate(self, bps: u32) -> Self

Maximum send rate ceiling (default 2.5 Mbps).

Source

pub fn with_received_rate_bound( self, received_rate_bound: ReceivedRateBound, ) -> Self

What the bound of the estimate by the received rate does to an estimate above it (Gcc::with_received_rate_bound): by default it only stops the increase, so the estimate is kept while the application sends less than it.

Source

pub fn with_bandwidth_probing(self, bandwidth_probing: bool) -> Self

Whether the path is probed for capacity above the estimate (the default), as the peer connection’s default interceptors do (CongestionControlBuilder::with_bandwidth_probing): two clusters at the start, at three and six times the 300 kbit/s the estimate starts at, and further ones while the path carries what is asked, so an open path is found within a second instead of by the 8% a second of draft-ietf-rmcat-gcc-02 section 5.5 (300 kbit/s to 2.5 Mbit/s: 28 s). RFC 8836 section 2, requirement 4: the algorithm “SHOULD adapt as quickly as possible to initial network conditions at the start of a flow”.

This chain has no pacer. A cluster is the NACK responder’s padding on the RTX stream, sent as one burst and measured by how far apart the path delivers it (burst_estimate); it needs a NackResponderInterceptor in the chain and RTX negotiated for the stream. Without them no cluster can be sent: the first one asked for goes unanswered and no more are asked, and the estimate climbs as the draft has it. Clusters are asked for at the start and while the application sends less than the target allows; not after a large drop of the target, which a chain with the pacer probes too (a burst of padding into the queue that caused the drop costs more than it finds: ProbeController::set_unpaced).

A call that finds the path’s rate at the start meets a later capacity collapse from that rate, and loses more at it than one that was still climbing (about twice the retransmissions when 2.5 Mbit/s drop to 300 kbit/s; the changelog has the measured figures). with_bandwidth_probing(false) is the start without probes.

Source

pub fn build(self) -> impl FnOnce(P) -> GccInterceptor<P>

The interceptor factory: a closure that takes the inner interceptor P (a PassThroughInterceptor, never a NoopInterceptor) and returns the GccInterceptor around it. Apply it with Interceptor::with: PassThroughInterceptor::new().with(builder.build()).

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.