rtciv0.5.0

Congestion control and pacing

The default interceptors run GCC bandwidth estimation with a pacer, transport-wide congestion feedback (TWCC and RFC 8888), NACK and the RTP circuit breaker. The bare builder runs none of them.

Install the default interceptors

RTCPeerConnectionBuilder::new() without with_interceptor_registry runs the RTCP session and key-frame requests only: no NACK, no transport-wide feedback, no GCC, no pacer, no circuit breaker. Build the registry from the media engine and keep the handles:

  • register_default_interceptors(registry, &mut media_engine): the standard set;
  • register_default_interceptors_with_handles: the same, returning DefaultInterceptorHandles, "the supported way for an application" to read the congestion controller and the circuit breaker it installs;
  • register_default_interceptors_with_options: with DefaultInterceptorOptions other than the defaults (DefaultInterceptorOptions::for_profile(profile) takes a behaviour profile's);
  • register_default_interceptors_without_congestion_control: no estimator, no pacer, no transport-wide sequence numbers, no circuit breaker.

All are in rtci::peer_connection::configuration::interceptor_registry. The interceptors take the media engine's profile:

use rtci::interceptor::Registry;
use rtci::peer_connection::configuration::BehaviourProfile;
use rtci::peer_connection::configuration::interceptor_registry::register_default_interceptors;
use rtci::peer_connection::configuration::media_engine::MediaEngine;
use rtci::peer_connection::configuration::setting_engine::SettingEngineBuilder;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Chosen at run time, here by name ("rfc", "chrome", "strict-rfc", "performance"), or
    // written as BehaviourProfile::Chrome.
    let profile = BehaviourProfile::from_name("chrome").unwrap_or_default();
    let setting_engine = SettingEngineBuilder::new()
        .with_behaviour_profile(profile)
        // A setting given after the profile overrides it.
        .with_sctp_message_size_limit_without_interleaving(true)
        .build();
    let mut media_engine = MediaEngine::for_profile(profile);
    media_engine.register_default_codecs()?;
    // The interceptors take the media engine's profile.
    let registry = register_default_interceptors(Registry::new(), &mut media_engine)?;
    let _ = (setting_engine, registry);
    Ok(())
}

From README.md, “Behaviour profiles” at v0.5.0.

The target bitrate for your encoder

The engine does not encode, so it hands the congestion controller's target to you: read handles.congestion_control.target_bitrate() (CongestionControlHandle), or per encoding RTCRtpSender::target_bitrates(). GccInterceptorBuilder / GccHandle are for a chain assembled by hand.

The target before feedback is a seed. Until the first congestion feedback, CongestionControlHandle::target_bitrate() returns the estimator's start (300 kbit/s by default), never zero, and stats().delay_based_bitrate / loss_based_bitrate are already Some; stats().packet_loss is None until feedback was folded in.

The estimator's floor and ceiling are DefaultInterceptorOptions::congestion_min_bitrate (100 kbit/s) and congestion_max_bitrate (100 Mbit/s) in every profile; a remote description's b=TIAS / b=AS bounds the estimate during a call (remote_bitrate_limit).

What runs in the chain

From rtci-interceptor's README: the RTCP session (sender and receiver reports, SDES, BYE, compound packets and their timing), NACK generation and retransmission (with RTX), transport-wide congestion control feedback, bandwidth estimation (GCC, draft-ietf-rmcat-gcc), pacing, FEC encoders and decoders, a jitter buffer, key-frame requests and RTCP extended reports. rtci's default interceptors run the GCC estimator (Gcc in a CongestionControlInterceptor, one per transport) with the pacer. Each interceptor is a sansio::Protocol: packets in, packets out, timeouts polled and handled, no clock.

Opt-in pieces have their own configure_* functions in interceptor_registry, among them configure_remb (receive-side REMB), configure_abs_send_time, configure_tmmbr, configure_extended_reports, configure_pause_resume (RFC 7728) and configure_congestion_control_feedback (RFC 8888 feedback without a controller).

The circuit breaker

The default set installs the RTP circuit breaker (RFC 8083); OnCircuitBreaker events say what it did, and its handle is in DefaultInterceptorHandles. Its packet size is one of the three standing departures from a MUST: RFC 8083 section 3 takes s over the last four frames, which ceased talking calls with silences in the repository's measurement; libwebrtc has no RTP circuit breaker to follow, so the default (s over the window the sending rate is measured over) is a choice of rtci's default profile, and StrictRfc selects the RFC form. See Conformance and the cb.packet-size row of the profiles table.

The Performance profile

BehaviourProfile::Performance keeps the defaults, with each behaviour where an RFC permits a cheaper form that does the same thing set to it: RTCP T_rr_interval 1 s, and congestion control feedback and reports inside RFC 3550's 5%. Each of its values, with the clause that permits it and its measured saving and cost, is section 1a of the behaviour profiles page.

Measured decisions

Every performance decision that was measured and accepted, and every measured alternative that was refused, is a row of docs/performance.md, with its figures, its guard and its evidence.