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
impl PacerBuilder
Sourcepub fn with_target_bitrate(self, bits_per_second: f64) -> Self
pub fn with_target_bitrate(self, bits_per_second: f64) -> Self
The rate to pace at, in bits per second.
Sourcepub fn with_burst_bits(self, burst_bits: f64) -> Self
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.
Sourcepub fn with_queue_limit(self, queue_limit: usize) -> Self
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.
Sourcepub fn with_queue_time_limit(self, limit: Option<Duration>) -> Self
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.
Sourcepub fn with_queue_overflow(self, overflow: QueueOverflow) -> Self
pub fn with_queue_overflow(self, overflow: QueueOverflow) -> Self
What happens to media the target has no room for (QueueOverflow::Drop by default).
Sourcepub fn with_backlog(self, backlog: Backlog) -> Self
pub fn with_backlog(self, backlog: Backlog) -> Self
What happens to the queue when the path’s capacity collapses (Backlog::Flush by
default).
Sourcepub fn with_immediate_release(self, immediate_release: bool) -> Self
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.
Whether audio takes part in the share by priority (true, the default; see “Order of
service” on PacerInterceptor). RFC 8835 section 4.1 gives each stream at each level
of priority about twice the capacity of the level below, “independent of the media
type”: with it on, an audio stream that writes above its share while other streams
wait is held to its share (only those of its packets that would take more than it wait,
the rest leave as they are written); audio within its share is never delayed. false
is libwebrtc’s pacer (modules/pacing/pacing_controller.cc: audio is not paced unless
the WebRTC-Pacer-BlockAudio field trial is on, and leaves ahead of every other packet,
prioritized_packet_queue.cc): every audio packet leaves when it is written, whatever
it takes from the other streams.
Sourcepub fn build(self) -> PacerInterceptor
pub fn build(self) -> PacerInterceptor
Build the interceptor.