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_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.
Sourcepub fn build(self) -> PacerInterceptor
pub fn build(self) -> PacerInterceptor
Build the interceptor.