pub struct ToneIntervalControl { /* private fields */ }Expand description
The packetization interval of initial and interim tone reports under congestion (RFC 4733 section 4.4.3): “If the sender determines that packets are being lost due to congestion (e.g., through RTCP receiver reports), it SHOULD increase the packetization interval for initial and interim tone reports … Both the maximum packetization interval and maximum increase in packetization interval at any one time are therefore a matter of configuration”.
Feed it the fraction lost of each RTCP receiver report about the stream
(on_receiver_report). A report at or above the high
threshold (TONE_HIGH_LOSS_FRACTION by default) lengthens the interval by at most the
configured increase, up to the configured maximum; one at or below the low threshold
(TONE_LOW_LOSS_FRACTION) shortens it by the same step, back to the initial interval
(the RFC leaves the way back open); one between leaves it. Durations are in timestamp
units of the tone clock.
Implementations§
Source§impl ToneIntervalControl
impl ToneIntervalControl
Sourcepub fn new(initial: u16, maximum: u16, max_increase: u16) -> Self
pub fn new(initial: u16, maximum: u16, max_increase: u16) -> Self
Starts at initial (at least 1), never above maximum (at least initial), and
changes by at most max_increase (at least 1) per receiver report.
Sourcepub fn with_loss_thresholds(self, high: u8, low: u8) -> Self
pub fn with_loss_thresholds(self, high: u8, low: u8) -> Self
The fraction lost (out of 256) at or above which a report means congestion, and the one at or below which it means none. The high threshold is tested first.
Sourcepub fn packet_duration(&self) -> u16
pub fn packet_duration(&self) -> u16
The current packetization interval.
Sourcepub fn on_receiver_report(&mut self, fraction_lost: u8) -> u16
pub fn on_receiver_report(&mut self, fraction_lost: u8) -> u16
Takes the fraction lost (the 8-bit field of an RTCP report block, RFC 3550 section 6.4.1) and returns the packetization interval from now on.
Sourcepub fn sender(&self) -> ToneSender
pub fn sender(&self) -> ToneSender
A ToneSender cutting tones at the current interval.