Expand description
Rendition choice and decoder handover for adaptive video playback.
This crate is pure logic. It does no I/O, spawns nothing, and depends on
neither tokio nor any media or transport type. Every method that depends on
time takes a std::time::Instant argument, so the tests drive the state
machines with a fake clock and run in microseconds.
There are two state machines, which a player wires together:
Bounddecides which rendition of a ladder should play. Each pass it gets the ranked ladder (Rungs, best first), the caller’sConstraintsand aNetworkSample, and returns the best rung the link carries. Time enters only as hysteresis, tuned byAdaptation.choosewraps it with theRenditionMode(automatic, pinned or off), andBackoffstracks renditions whose decoders failed.step_downtells whether a switch moves down the ladder.Switcherhands the picture from one decoder to the next. It tracks one incumbent and at most one replacement, and takes over once the replacement has decoded a picture close to the incumbent’s playhead, or has run out of patience. The decoders themselves are opaque type parameters.
The async loops that feed these machines, with their channels and timers, live in the player.
Structs§
- Adaptation
- The player’s adaptation thresholds and timers.
- Backoffs
- The renditions whose decoders failed, and until when each is left alone.
- Bound
- The selection state carried from one tick to the next.
- Choice
- What
choosedecided. - Constraints
- What the caller rules out, whatever the network says.
- Network
Sample - One reading of the link a broadcast arrives over.
- Rung
- One rendition, as the bound sees it.
- Switcher
- One incumbent and at most one replacement.
- Target
- What a decoder is built for: a rendition, under one decoder configuration.
Enums§
- Abandoned
- Why a replacement did not take over.
- Outcome
- What a transition did, for the caller to act on.
- PinProblem
- Why a pin could not be honoured.
- Rendition
Mode - How the rendition is chosen.
- Verdict
- What to do with a picture the replacement decoded.
Constants§
- CATCH_
UP_ PATIENCE - How long a replacement waits to catch up after its first picture.
- CATCH_
UP_ SLACK - How far a replacement may trail the incumbent’s playhead when it takes over.