Skip to main content

Crate moq_ext_adaptive

Crate moq_ext_adaptive 

Source
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:

  • Bound decides which rendition of a ladder should play. Each pass it gets the ranked ladder (Rungs, best first), the caller’s Constraints and a NetworkSample, and returns the best rung the link carries. Time enters only as hysteresis, tuned by Adaptation. choose wraps it with the RenditionMode (automatic, pinned or off), and Backoffs tracks renditions whose decoders failed. step_down tells whether a switch moves down the ladder.
  • Switcher hands 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 choose decided.
Constraints
What the caller rules out, whatever the network says.
NetworkSample
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.
RenditionMode
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.

Functions§

best
Returns the best rendition the constraints allow, or the smallest if none is.
choose
Picks the rendition to play, and why a pin could not be honoured.
step_down
Reports whether automatic selection is stepping down from on_screen.