Repository navigation
fix(airplay): keep the SDR master so native subtitles reach the receiver (#227) - #228
Merged
Merged
Conversation
…ver (#227) A SUBTITLES rendition can only be declared in a master playlist, but the #86 AirPlay rewrite forced the media playlist for every source on its way to the LAN IP, so the receiver got a manifest with no EXT-X-MEDIA tags: setNativeSubtitleSelected(track:) had no legible group to select against, succeeded, and rendered nothing. The constraint behind the blanket downgrade is narrower than the rule built on it: AVPlayer rejects an HDR/DV master on a receiver that is not in HDR or DV mode. An SDR variant is routing-safe on any receiver, so it keeps its master and the renditions travel (the master's rendition URIs are relative and resolve against the LAN base). HDR/DV keeps the downgrade, since an SDR-signalled master over HDR content does not fool the compatibility gate either (#98 Stage 1.5). - AirPlayPlaylistDecision: pure keep-master gate plus the LAN-IP URL rewrite, in the style of MasterFallbackDecision. - HLSVideoEngine.servedSourceIsHDR: what the served variant signals, so the gate does not have to re-derive it. - nativeSubtitleRenditionsServed now reports the playlist actually served to the receiver, not the one the local session resolved, so a host can tell the user that subtitles will not travel on an HDR/DV AirPlay hop. - The master-rejection fallback rewrites onto the LAN IP too; it previously reloaded the 127.0.0.1 media playlist, which a receiver cannot reach. Reported by thatcube. Tests: AirPlayPlaylistDecisionTests (6), full suite 1106 green, iOS + tvOS builds clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QYhPvBB1sLCYoZNasEXFeB
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.
Refs #227 (reported by @thatcube).
Root cause
The reporter's reading of the code is correct.
HLSVideoEngine.resolveUseMasterPlaylistalready forces the master playlist for any routing-safe subtitled source (#15), so an SDR source with text tracks resolves tomaster.m3u8with itsEXT-X-MEDIA:TYPE=SUBTITLESrenditions. The #86 AirPlay rewrite then discarded that: while external playback is active it rebuilt the playback URL on the device's LAN IP and forced/media.m3u8for every source. A media playlist has noEXT-X-MEDIAtags, so the receiver was handed a manifest with no legible group,setNativeSubtitleSelected(track:)had nothing to select against, and the call succeeded while changing nothing. Mutually exclusive by construction, exactly as described.The constraint that motivated the blanket downgrade is narrower than the rule built on it. DrHurt's caveat in #86 was specifically that "AVPlayer will reject a DV/HDR master playlist on an SDR receiver and will not automatically switch"; the safe-universal media routing was his suggestion on top of it. An SDR variant is routing-safe on any receiver.
Fix
EXT-X-MEDIAURIs are relative, so they resolve against the LAN base with no extra work.VIDEO-RANGE=SDRdoes not fool the external-display compatibility gate, which reads the realcolr/codec rather than the manifest string. So the second direction, master only when the source is SDR, is the one the manifests actually allow.nativeSubtitleRenditionsServedreports the playlist actually served to the receiver instead of the one the local session resolved, so it goes false on an HDR/DV AirPlay hop and a host can tell the user their subtitles will not travel. No new API needed; the flag already promised exactly this and was simply lying on that path.session.mediaPlaylistURL, the127.0.0.1loopback the receiver cannot reach. A receiver that rejects the kept SDR master (an older receiver with no 4K HEVC, say) now recovers onto the LAN media playlist instead of loading nothing. This was latent before the change:servingMasterPlaylistread true on the AirPlay path while media was actually served, so a rejection already routed into that dead fallback.AirPlayPlaylistDecisionholds the keep-master gate and the URL rewrite as pure functions, in the style ofMasterFallbackDecision/StartupReadinessGate.HLSVideoEngine.servedSourceIsHDRpublishes what the served variant signals so the gate does not re-derive it.The
#35startup-readiness gate also loads loopback URLs, but it arms only on a real display-criteria panel switch, which is tvOS-only, so it cannot collide with the iOS AirPlay path.Verification
AirPlayPlaylistDecisionTests, 6 new cases (keep/downgrade gate, host swap keeps the port, media path forcing, idempotent re-rewrite).swift build -Xswiftc -strict-concurrency=completeclean; standalone iOS and tvOS builds clean, no warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01QYhPvBB1sLCYoZNasEXFeB