Skip to main content

Module tracks

Module tracks 

Source
Expand description

Per-track media ends and the effective (minimum) media end.

A TS mux sends video well ahead of its play time and audio close to real time, so the amount of media that can actually be played is bounded by the least advanced rendered track, not by video alone. The set keeps the end of the last delivered sample per track and reduces them to one position:

  • a track becomes active on its first delivery;
  • a track announced with BufferController::register_track that has not delivered yet blocks the reduction (no effective end) until it delivers or has been silent for silence_timeout_us;
  • a track removed with BufferController::unregister_track (a replaced or dead track) leaves the reduction at once; if no track is left there is no effective end until one delivers;
  • a track is excluded when it is silent relative to the other tracks: its own last delivery (or, if it never delivered, its registration) lies at least silence_timeout_us before the most recent delivery on ANY track. A dead track therefore cannot starve playback while the others keep delivering, but the clock is the arrival time of the latest delivery, not wall time, advanced towards now by at most the largest held delivery step (the time the next delivery is expected; a source delivering every 2.3 s is not charged the quantisation of its own cadence): when nothing at all is delivered (a global stall such as a reconnect or server restart) nobody becomes excluded, however long the gap, and the stall is not mistaken for the tracks being dead. Before any delivery (or after a rebaseline) nothing is excluded either;
  • the effective end is the earliest end over the non-excluded tracks, so a global stall keeps the MIN of the tracks’ last ends (there is no “all silent” fallback: the most recently delivering track is never excluded).

Delivery granularity. Each track also remembers the largest step its end advanced between two distinct delivery instants, as a max-hold with a hold and a linear decay (the stall-memory max-hold, bounded memory: a few scalars per track, at most MAX_TRACKS tracks). A step counts only when it looks like a delivery cadence: it advanced forward, the instants are less than the silence timeout apart, it is no more than the arrival interval plus nodata_after_us (a catch-up burst or a forward jump is not a cadence; the PDV and the stall memory cover those), and the caller reports no global data gap (a chunk gap of nodata_after_us or more) inside the interval (a gap is PDV, which the stall memory already covers). The policy keeps the target at least the largest held step plus the margin.

Delivery instant. A track’s delivery instant is the chunk boundary: all on_track_media calls for a track between two on_chunk calls are ONE delivery, and the step is end after the last call - end before the first call. A caller that never calls on_chunk gets the fallback: calls less than COALESCE_US apart are one delivery. So a caller reporting one end per delivered chunk and a caller reporting one per demuxed sample (a 0.3 s MP2 PES as 12 frames of 24 ms) produce the same floor. The step is folded into the memory when the window closes (at the next on_chunk, or at the next call that does not belong to it), so the floor rises at the chunk boundary that ends the delivery, with identical events however the calls were split.

Start gate. TrackSet::granularity_known tells the controller whether every delivering track has shown LEARN_STEPS closed steps (or has been delivering for a bounded wait), so a start/resume is never granted before the floor could have been learnt.

All position comparisons are wrap-safe (broadcast_common::clock33).

Constants§

COALESCE_US
Fallback coalescing window (microseconds) for a caller that never calls on_chunk: calls this close are one delivery.
DEFAULT_TRACK
The track BufferController::on_media reports as.
LEARN_STEPS
Delivery steps a track must have shown before a start/resume is granted on its granularity (see TrackSet::granularity_known): the third delivery’s window has closed, so two steps were measured.
MAX_TRACKS
Most tracks tracked at once; deliveries for further tracks are ignored.