Repository navigation
Report presentation times on both the source and item axes (native path) - #263
Merged
Merged
Conversation
…260) Cue times, chapters and sourceTime are source PTS; AVPlayerItem's timebase reads what the producer muxes. The two differ by the producer shift, and a host compositing its own overlay had no exact way to cross between them: playlistShiftSeconds is a scalar that only holds until the next producer epoch, the clock ticks at ~10 Hz and a clock reading is not a frame boundary, and the per-segment pair is six seconds granular. PresentationAxisMap models the relation as what it is, a step function of item time, and replaces the seam array the live path already carried. A VOD restart now records a seam at the item position the new producer starts writing from, instead of collapsing the history onto one entry: content below it was muxed under the previous shift and can still be in AVPlayer's buffer. A backward restart drops only the seams it actually rewrites. Live program boundaries are unchanged. Note the #65 shift-fold hypotheses were refuted by measurement (that burst ran with an invariant shift), so this is not a retroactive explanation for it. setNativeVideoFrameTimeObserver reports both axes per muxed frame, plus segment index, keyframe flag and producer epoch. The item value comes back out of writePacket rather than off the packet: av_interleaved_write_frame blanks it ("as if returned from av_packet_alloc(), even on error"), and the final-stage sanitizer can move the timestamp, so a rescale of the source value is not the same number. Delivery is decode order, so source is not monotonic under B-frames; documented rather than sorted, since sorting would mean buffering in the pump. Both surfaces return nil when no axis is established. A defaulted shift is indistinguishable from a measured one at the call site, which is what #259 cost. currentAVPlayerItem publishes alongside, because items swap in place and a host holding a timebase otherwise gets no signal. Requested by edde746 for frame-accurate libass rendering. Verify: 1340 tests green, strict-concurrency clean build, tvOS Simulator build clean. The frame-time tests run against Fixtures/restart-witness-av.mp4, whose two-frame reorder makes the axes distinguishable (a zero shift would make the witness vacuous, so the test requires a non-zero one). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
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.
Closes the API gap in #260.
What a host could not do before
Cue times, chapters and
sourceTimeare source PTS.AVPlayerItem.currentTime()and its timebase read what the producer muxes into the segments. The two differ by the producer shift, and nothing published closed that gap exactly:playlistShiftSecondsclock.sourceTimeSegment.startPts/startSecondsa53CaptionObserverTwo pieces
PresentationAxisMapmodels the relation as what it actually is, a step function of item time, and replaces the seam array the live path already carried.sourceSeconds(forItemSeconds:)anditemSeconds(forSourceSeconds:)convert at any position; the map is readable off the main actor.A VOD restart now records a seam at the item-axis position the new producer starts writing from, instead of collapsing the history to one entry. Content below that position was muxed under the previous shift and can still be in AVPlayer's buffer, so it has to keep folding with that shift. A backward restart drops only the seams it rewrites. Live program boundaries are unchanged. (The #65 shift-fold hypotheses were refuted by measurement at the time; that burst ran with an invariant shift, so this is not a retroactive explanation for it.)
setNativeVideoFrameTimeObserverreportsNativeVideoFrameTimeper muxed frame: both axes, segment index, keyframe flag, and a producer epoch so a consumer can drop entries a restart has rewritten.Two things the issue's proposed shape would have hit
writePacketreads a blank packet.av_interleaved_write_frametakes ownership and the packet comes back "as if returned fromav_packet_alloc(), even on error", soptsisAV_NOPTS_VALUEthere. The written value now comes back out ofwritePacket. It also matters that it is that value and not a rescale of the source one: the final-stage sanitizer moves timestamps on SSAI splices.sourceis not monotonic under B-frames. Documented rather than sorted, since sorting would mean buffering inside the pump.Both surfaces return nil when no axis has been established, rather than defaulting the shift to zero: at the call site a defaulted shift is indistinguishable from a measured one, which is what #259 cost.
currentAVPlayerItempublishes alongside, since items are swapped in place and a host holding a timebase gets no signal fromcurrentAVPlayeralone.Verification
PresentationAxisMapTests(step behaviour, backward-restart truncation, history-cap re-anchoring) andIssue260FrameTimeAxisTestsagainstFixtures/restart-witness-av.mp4.-strict-concurrency=completebuild, tvOS Simulator build clean.Requested by @edde746, who measured the axis gap and offered a PR; the shape here differs in the two points above.
🤖 Generated with Claude Code
https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE