Selkies

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.0
attributeHOLD_BAND
= 0.05
attributekbpsOptional[float]
= None
attributesince
= 0.0
attributetold
= False

Functions

constructor__init__() -> None
Source Code
def __init__(self) -> None:
    self.kbps: Optional[float] = None
    self.since = 0.0
    self.told = False

Returns

None
funcnote(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)
paramkbpsfloat
paramnowfloat

Returns

typing.Optional[int]