pub struct Viewers { /* private fields */ }Expand description
Divides one connection’s receive estimate among the broadcasts watched over it.
The receive-side mirror of Allocator. Every player on a connection reads the
same receive estimate, so N players each selecting against all of it oversubscribe
the downlink N times over. watch a broadcast here and its
Viewer reports only its own slice, split max-min fair by each viewer’s ceiling,
so the slices sum to the estimate instead of each matching it. Viewers carry no
priority: a viewer asking for less than an even cut takes all it asked for and
leaves the rest to the others.
The viewers’ ceilings summed are also the PROBE target the session sends its
peer, which probes the connection up to it when it advertised Increase, so the
estimate can rise to fund a larger rendition. The target never leaves this hop:
a relay probes its own downlink for its viewers, and never forwards them upstream.
The ceilings may sum to at most MAX_TARGET, which every PROBE
encoding carries: a viewer or override that would pass it is refused with
Error::BoundsExceeded.
Holding a Viewer (or a Consumer read from one) requests PROBE, like
holding Session::recv_bandwidth. Take it from Session::viewers (with the
async feature) rather than building one, since only a session sends the target.
Clones share one registry.
Implementations§
Source§impl Viewers
impl Viewers
Sourcepub const MAX_TARGET: Rate
pub const MAX_TARGET: Rate
The largest PROBE target: the most the viewers’ ceilings, summed, or an override may be.
2^53 - 1 bits per second, the largest integer a JavaScript peer decodes exactly,
and well inside the wire’s varint.
Sourcepub fn new(estimate: Weak) -> Self
pub fn new(estimate: Weak) -> Self
Divide the receive estimate estimate mints, with no session sending the target.
For an estimate that outlives a session, such as one a reconnect loop feeds
from each session it dials. Hand the same registry to Client::with_viewers
(with the async feature) so every session it dials sends the target.
Sourcepub fn watch(&self, max: Rate) -> Result<Viewer>
pub fn watch(&self, max: Rate) -> Result<Viewer>
Watch a broadcast receiving at most max, returning its viewer.
max is a ceiling: what the largest rendition the player would switch to
needs, not what it happens to be receiving. The claim lasts as long as the
returned Viewer: change the ceiling with update, and drop
it once the broadcast stops being watched.
§Errors
Error::BoundsExceeded, watching nothing, when the ceilings would sum above
MAX_TARGET.
Sourcepub fn set_target(&self, target: Option<Rate>) -> Result<()>
pub fn set_target(&self, target: Option<Rate>) -> Result<()>
Send target as the PROBE target instead of the viewers’ sum, or None to follow them again.
Some(Rate::ZERO) sends no target, so the peer stops probing for these viewers. The
override is the registry’s, so it holds for every clone and across the reconnects a
persistent registry spans.
§Errors
Error::BoundsExceeded, keeping the previous override, for a target above
MAX_TARGET.