Skip to main content

RtcpSessionBuilder

Struct RtcpSessionBuilder 

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

Builder for RtcpSessionInterceptor.

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

let chain = Registry::new()
    .with(Slot::RtcpSession, RtcpSessionBuilder::new().build())
    .build();

Implementations§

Source§

impl RtcpSessionBuilder

Source

pub fn new() -> Self

A builder with the defaults: RTP/AVPF timing, a T_rr_interval of one second, RTCP at 5% of the measured media bitrate (a start-up value before it is measured), compound packets only, congestion control feedback sent as it is built.

Source

pub fn with_profile(self, profile: RtcpProfile) -> Self

The profile whose timing rules apply. Default: RtcpProfile::Avpf.

Source

pub fn with_t_rr_interval(self, t_rr_interval: Duration) -> Self

T_rr_interval (RFC 4585 3.4): the minimum interval between regular (full compound) reports under RTP/AVPF. Feedback is not held by it.

RFC 4585 4.2 makes the value zero when trr-int is not negotiated, which lets regular reports use the whole RTCP bandwidth: a report every few tens of milliseconds beside a video stream. The default here is one second (what this engine sent before, and what browsers send); a negotiated trr-int (RtcpSessionControl::TrrInt) replaces it, and zero gives the RFC’s default.

Source

pub fn with_bandwidth(self, bandwidth: RtcpBandwidth) -> Self

The bandwidth the session description gives (b=AS / b=TIAS, b=RS, b=RR). Default: none, so the media bitrate is measured and RTCP gets 5% of it.

Source

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

The share of the session bandwidth RTCP uses when b=RS / b=RR do not say. Default: 0.05, the value RFC 3550 6.2 recommends.

Source

pub fn with_reduced_minimum(self, reduced_minimum: bool) -> Self

Under RTP/AVP, use the reduced minimum interval of RFC 3550 6.2 (360 divided by the session bandwidth in kbit/s) instead of five seconds.

Source

pub fn with_reduced_size(self, reduced_size: bool) -> Self

Whether reduced-size RTCP (RFC 5506) was negotiated. Default: no, every packet is a compound packet.

Source

pub fn with_mtu(self, mtu: usize) -> Self

The size compound packets are kept under (RFC 3550 6.1). Default: RTCP_SESSION_DEFAULT_MTU.

Source

pub fn with_cname(self, cname: impl Into<String>) -> Self

The CNAME to use. Default: one generated as RFC 7022 section 4.2 describes.

Source

pub fn with_point_to_point(self, point_to_point: bool) -> Self

Says whether the session is point to point instead of leaving it to the count of remote CNAMEs (RFC 8108 5.4.2: “unless signaling indicates”).

Source

pub fn with_report_from_every_ssrc(self, every: bool) -> Self

RFC 8108 5.1: “each SSRC will send RTCP reports for all other SSRCs, including those co-located at the same endpoint”: every local SSRC carries a report block for every remote SSRC and for each of the endpoint’s other SSRCs that has sent (true, the StrictRfc behaviour profile). Default false: the blocks are carried once, by the first local media SSRC, and none about the co-located SSRCs, as libwebrtc does and as RFC 8861 reporting groups allow where they are signalled.

The default is a measured choice. The RFC form’s compound packets are about twice the size, and RFC 3550 section 6.3’s interval does not make up for all of it (the average packet size it is computed from counts the small congestion control feedback packets too): an endpoint of a 2.5 Mbit/s audio and video call sent 149 instead of 122 kbit/s of RTCP, and 93 instead of 80 kbit/s on a link that had collapsed to 300 kbit/s. In the capacity instrument (tests/capacity_instrument.rs, chain every against paced, the same seeds) the picture through the collapse was 0.5 s older, the send target under the cap 24 kbit/s lower and three times as many calls took over 20 s to recover.

Source

pub fn with_immediate_congestion_feedback(self, immediate: bool) -> Self

Whether congestion control feedback (transport-wide feedback, RFC 8888 reports) leaves as soon as its generator writes it (the default), or waits its turn under RFC 4585 section 3.5.2 like other feedback: at most one Early packet per regular interval.

The generators size their own cadence to 5% of the media they report on, between 50 and 250 ms (TwccReceiverBuilder::with_adaptive_interval): congestion control feedback is the sender’s congestion signal and is not held to the RTCP bandwidth the regular reports share, as libwebrtc and the browsers send it. It goes as a reduced-size packet where a=rtcp-rsize was negotiated, else in a minimal compound packet, and counts in the average RTCP packet size (RFC 4585 3.5.4: “avg_rtcp_size … MUST be updated accordingly”, Early or Regular), sent as received. false is RFC 4585 as written: at low media rates the session then sends feedback a few times a second, with gaps a sender’s estimator does not climb through.

Source

pub fn with_congestion_feedback_in_budget(self, in_budget: bool) -> Self

Whether the congestion control feedback that leaves at once (Self::with_immediate_congestion_feedback) counts against the RTCP bandwidth the regular reports share (true), or comes on top of it (false, the default).

With true the session measures the congestion control feedback it sends and receives over the last two seconds, and spaces its regular reports so that they and the feedback together stay inside the RTCP bandwidth (RFC 3550 section 6.2: 5% of the session bandwidth): the regular interval computed with what the feedback leaves becomes a T_rr_interval (RFC 4585 section 3.5.3, which suppresses regular reports inside it and lets feedback through), no longer than five seconds. Regular reports become rarer at low media rates and nothing else changes. Part of the Performance behaviour profile.

Source

pub fn with_minimum_session_bandwidth(self, bits_per_second: u64) -> Self

The least session bandwidth the RTCP bandwidth is computed from when no b= line gives one and the media is measured, bits per second. Default RTCP_SESSION_MIN_BANDWIDTH (64 kbit/s). Below it the measured media rate is not used, so a 24 kbit/s audio call reports as a 64 kbit/s one would (RFC 3550 section 6.2 lets the session bandwidth be the expected one). The Performance behaviour profile takes 16 kbit/s, so the RTCP bandwidth follows the media down to there. Held to at least 8 kbit/s, so a session with no media still reports.

Source

pub fn with_share_following_send_rate(self, follows: bool) -> Self

Tuning with no specification behind it, off by default: whether this endpoint’s own share of the RTCP bandwidth follows the rate its congestion controller allows it to send at.

RFC 3550 section 6.2 sizes the RTCP bandwidth from the session bandwidth, here the media measured in both directions, and section 6.3.1 shares it equally among the members; nothing in it, in RFC 4585 or in RFC 8108 ties one endpoint’s share to the rate of its own direction. So when one direction of a call collapses and the other does not, the endpoint behind the collapsed link keeps reporting at the rate the whole session gives it: a fifth of a 300 kbit/s link, measured. With true, the RTCP bandwidth this endpoint’s own SSRCs schedule their regular reports with is at most the session’s RTCP fraction (5%) of the session there would be if every endpoint sent at this endpoint’s rate: fraction x send rate x members / local SSRCs, no less than the fraction of the minimum session bandwidth. The send rate is the congestion controller’s (RtcpSessionControl::SendRate); until one is told, and when the session’s own figure is lower, nothing changes. The intervals calculated for the other members (RtcpReportingInterval) are not touched: the peer shares the bandwidth as RFC 3550 says. Congestion control feedback is not slowed by it (it is sent at once unless Self::with_immediate_congestion_feedback is off); early feedback (NACK, PLI) keeps its rules, on the longer regular interval.

Source

pub fn with_joins_on_start(self, joins_on_start: bool) -> Self

Whether the session joins only when told RtcpSessionControl::Start (true), or at the first control, packet or stream it is given (false, the default).

RFC 3550 section 6: RTCP is the control protocol of an RTP session, and there is none until an RTP m= section is negotiated (RFC 8834 section 4.1). A peer connection knows when that is, per transport, and joins the session then; with true nothing else makes it join: until Start it sends nothing (no report, no SDES, no SSRC of its own), and what is written to it as RTCP is dropped. After RtcpSessionControl::Leave, a Start joins it again (RTCP resumes from a new reporting SSRC).

Source

pub fn with_first_report_at_join(self, at_join: bool) -> Self

Whether the first compound packet goes out when the session joins (true), or after the initial interval of RFC 3550 section 6.2 (false, the default).

RFC 8834 section 4.1, with RFC 3550 section 6.2 as RFC 8108 updates it: “The delay before sending the initial compound RTCP packet can be set to zero.” A peer connection joins a transport’s session when its keys exist, and reporting then tells the peer the endpoint’s SSRCs at once (RFC 3550 section 8.2: an SSRC collision is found from the first packet that shows it) and starts the round-trip and loss reports congestion control reads.

Source

pub fn with_random(self, random: impl RtcpRandom + 'static) -> Self

The source of the session’s random numbers; a test supplies one that repeats.

Source

pub fn with_wall_clock(self, anchor: SystemInstant) -> Self

The wall-clock anchor the session’s NTP times (sender reports, XR receiver reference times) derive from. Default: the process-wide SystemInstant::shared. Give one per peer connection for reproducible virtual-time runs: two runs in one process otherwise map the same instants to NTP times as far apart as the real time between them.

Source

pub fn build_per_rtp_session(self) -> PerRtpSession<RtcpSessionInterceptor>

Builds an RTCP session per RTP session (crate::PerRtpSession): a peer connection with sections on several transports runs an RTCP session on each (RFC 3550 section 6, RFC 8834 section 4.4), every one with these settings, the same CNAME (RFC 7022 section 4.2: one per endpoint) and its own members, bandwidth and timers.

Source

pub fn build(self) -> RtcpSessionInterceptor

Builds the interceptor.

Trait Implementations§

Source§

impl Default for RtcpSessionBuilder

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.