RateHold
Whether a display's steered rate has held long enough for its page to
keep: a rate that stays within HOLD_BAND of where it settled for HOLD_S is
returned by note once, and a move out of the band starts over. The page
sends it back when it next connects (start_kbps), so a restarted server
starts that page's stream at what its path carried rather than at the
configured rate and the queue a start at the configured rate builds.
Attributes
attributeHOLD_S= 10.0attributeHOLD_BAND= 0.05attributekbpsOptional[float]= Noneattributesince= 0.0attributetold= FalseFunctions
constructor__init__() -> NoneSource Code
def __init__(self) -> None:
self.kbps: Optional[float] = None
self.since = 0.0
self.told = FalseReturns
Nonefuncnote(kbps, now) -> Optional[int]Fold in the rate in force at now; the rate to tell the page, or None.
Source Code
def note(self, kbps: float, now: float) -> Optional[int]:
"""Fold in the rate in force at `now`; the rate to tell the page, or None."""
if self.kbps is None or abs(kbps - self.kbps) > self.HOLD_BAND * self.kbps:
self.kbps, self.since, self.told = kbps, now, False
return None
if self.told or now - self.since < self.HOLD_S:
return None
self.told = True
return round(self.kbps)paramkbpsfloatparamnowfloatReturns
typing.Optional[int]