Expand description
The buffer controller: estimator + policy + state machine + events.
Two clock domains, kept apart. The jitter estimator is fed the 27 MHz
PCR through BufferController::on_chunk (when a chunk carries one).
The lead is measured in the playback (PTS) domain: the caller reports
the end of the last demuxed sample with BufferController::on_media and
the renderer clock with BufferController::on_tick, both PTS-derived
(PTS90k x 300, see crate::pts90k_to_27mhz). PCR typically runs ahead
of PTS by the mux/decoder delay, so a lead taken from PCR would overstate
what can play; every position in an Event is in the PTS domain.
PCR-less fallback. If no chunk with a PCR has ever been fed, the
estimator is fed from on_media (its media_end is the media time), one
track’s own series: the first track to deliver, until it is removed or
silent. Never the minimum over tracks, which jumps whenever a track joins
behind or the limiting track changes. The first PCR seen switches the estimator to PCR for good (its baseline is
reset once because the two clocks differ); from then on on_media never
feeds the estimator.
Several tracks. A TS mux sends video well ahead of play time and audio
close to real time, so the media that can be played ends at the least
advanced rendered track. The lead is therefore measured against the
minimum media end over the rendered tracks: either the caller reduces
them and calls BufferController::on_media with that minimum, or it
reports each track with BufferController::on_track_media and the
controller does it (see crate::tracks for the active/silent rules).
Structs§
- Buffer
Controller - The decision engine. Sans-IO: the caller passes every clock reading.