fix(dash): share one ABR availabilityStart + stop non-audio shards waiting for audio#19
Merged
Merged
Conversation
…iting for audio In an ABR DASH ladder each shard anchored its OWN availabilityStartTime at its first flush. The audio-packing shard flushes at ~segDur, but a non-audio shard never has audioReady true so it only flushed at the pairing deadline — ~1s later. That skew meant: the single published AST was wrong for every rendition but the slug-sorted winner; behindPrevSegEnd paced each shard against its own later AST so non-audio reps published every segment ~1s late forever; and if the audio shard wasn't the slug-first one the published AST could change mid-stream, violating dynamic-MPD AST constancy. Two changes, no StartTicks rebase (timelines are already media-aligned): 1. A non-audio shard pairs on video alone: audioReady is now `!PackAudio || (haveAudio && queue.AudioLen()>0)`, so it cuts at the first IDR instead of waiting out the pairing window — collapsing the per-shard availStart skew to inter-shard IDR jitter (≤~150 ms). 2. ABRMaster.SharedAST(candidate) returns one ladder-wide AST, set once by whichever shard flushes first; each shard adopts it at its first flush (single-rendition streams have no master and keep their own now). All shards now anchor tfdt + behindPrevSegEnd pacing to the same origin, and the published AST is correct for every rendition and constant for the session. Tests: TestABRMaster_SharedAST (set-once / zero-candidate), TestPackager_NonAudioShardEmitsBeforePairingDeadline (non-audio shard emits well within a 30s pairing window). Existing DASH table tests pass unchanged.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (audit B-4, MEDIUM)
In an ABR DASH ladder each shard anchored its own
availabilityStartTimeat its first flush. The audio-packing shard flushes at ~segDur, but a non-audio shard never hasaudioReadytrue, so it only flushed at the pairing deadline — ~1 s later. That per-shard AST skew (Δ≈1 s) caused:behindPrevSegEndpaces each shard against its own later AST, so non-audio reps publish every segment Δ late forever (availability over-promise / edge-switch stall risk);(On default config Δ≈1 s is absorbed by
suggestedPresentationDelay=6 s, hence Medium.)Fix
Two changes — no
StartTicksrebase (timelines are already media-PTS-aligned):tryCutnow computesaudioReady := !p.cfg.PackAudio || (haveAudio && queue.AudioLen()>0), so an ABR non-primary shard cuts at the first IDR instead of waiting out the pairing window for audio it will never pack — collapsing the per-shardavailStartskew to inter-shard IDR jitter (≤~150 ms).ABRMaster.SharedAST(candidate)returns a single AST, set once by whichever shard flushes first; at its first flush each shard adopts it (p.availStart = ABRMaster.SharedAST(now)). Single-rendition streams have no master and keep their ownnow. All shards now anchor tfdt +behindPrevSegEndpacing to the same origin → AST correct for every rendition (a, b) and constant for the session regardless of flush order (c).Test
TestABRMaster_SharedAST(set-once semantics + zero-candidate guard),TestPackager_NonAudioShardEmitsBeforePairingDeadline(aPackAudio=falseshard emits its first segment well within a 30 s pairing window — proving it paired on video alone).go test -race ./internal/publisher/dash/green incl. all existing table tests (no timeline regression),golangci-lint0 issues, fullgo build ./...green.