Repository navigation
feat(disc): play a Blu-ray BDMV folder over HTTP - #734
superuser404notfound merged 2 commits into
Conversation
A Blu-ray ripped as a folder rather than an image could only reach the engine as one file at a time, so a host had to remux the selected title on its origin before playback. A host now hands the folder to load(source: .custom(reader)) as a DiscDirectoryReader (the listing of root-relative paths and sizes, and a way to open one file), or as the ready-made HTTPDiscDirectoryReader with one URL per file. DiscReader.wrap recognizes the conformance before it reads a byte and takes the image path with files in place of UDF extents: the same bounded playlist scan (NET-103) and title selection, the selected title's clips concatenated in playlist order by a reader that opens a clip's file on demand and keeps at most three open, and the same AE#105 clip timeline. scanPlaylists and assembleBluRayTitle are generalized over their entries for this; the image path is unchanged. An optional preferredPlaylist names the main title so only that playlist is read. A playlist file opens with its listed size instead of a range probe, which halved the requests recognition made on a real folder (162 to 81 for 81 playlists); a clip keeps the probe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bandwidth libavformat estimates bit_rate as the source size over the duration it read off the timestamps, and over a multi-clip disc title whose clips restart their clock that duration is as wrong as it is for `duration` (AE#105). A 6537 s UHD title whose two clips both start at 11.6 s probed as 388 s, so its 54.6 GB declared BANDWIDTH=2253434656; AVPlayer never chose the variant and waited with no item to play. Demuxer.bitRate now takes a disc title's rate as its size over its playlist duration whenever libavformat produced one (66.9 Mbit/s there, and the title starts). A title with no libavformat rate, such as a remote ISO opened by URL, keeps the over-declared fallback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
MultiFileConcatIOReader held one lock across the network read and took the same lock in cancel(), so the cancel meant to unblock a parked read waited for that read to finish on its own (up to the HTTP timeout times its retries). The lock is now split: ioLock serializes read, seek and close and is held across the network; stateLock guards the open-file table and is only held briefly, and cancel() takes only that one. A cancel that arrives while a clip is still opening (its range probe) is remembered and cancels that clip's reader once it exists. Evicted readers close outside the lock. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
bc50c91
into
superuser404notfound:main
|
Merged, thank you! This is exactly the focused shape that works well here: an opt-in path that leaves every existing source untouched, the shared scan and assembly generalized instead of copied, and a test plan against real discs. The bandwidth fix is welcome in the same PR. The full suite was green on the PR merged with current main (4,295 Swift Testing cases plus XCTest). One follow-up landed on top in 600fb6a: Still open, as you noted: a controlled probe does not recognize a folder yet, and seeking across clips with overlapping timestamps needs the CLPI EP maps. Recognition itself is also not interruptible yet (the folder's own |
|
Released in 7.35.0, together with the follow-up that lets a stop unblock a read parked in a folder clip ( |
#736 built the EP-map seek table only on the image path; the BDMV folder recognition from #734 landed first and still sought by timestamp, which is the shape (two clips both from 11.6 s) that motivated the change. The folder now reads BDMV/CLIPINF/<clip>.clpi through its DiscDirectoryReader, bounded by the same readAll cap, and falls back to the timestamp search without it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
Summary
A Blu-ray ripped as a
BDMVfolder can only reach the engine one file at a time, so a host has to remux the selected title on its origin before playback (on MovieClaw's origin that remux also cost the Dolby Vision enhancement layer, TrueHD and the PGS tracks). This lets a host hand the folder itself toload(source: .custom(reader)), and the engine recognizes it the way it recognizes a Blu-ray ISO. It is the remote BDMV reader from #703 (MovieClaw P5) that you named as a candidate; VIDEO_TS folders (P26) would follow on top of it.Nothing changes for a host that does not pass a folder reader. The second commit fixes a declared-bandwidth bug that the first multi-clip folder hit, which custom-source ISOs share; I can split it into its own PR if you prefer.
What changed
DiscDirectoryReader(public protocol, anIOReaderthat carries no bytes itself):discFileslists root-relative paths and sizes,openDiscFile(_:)opens one file as an independent reader, and an optionalpreferredPlaylistnames the title's.mpls.HTTPDiscDirectoryReaderis the ready-made one: oneFile(path:size:url:)per file, each read through its ownHTTPDiscIOReader, withhttpHeaderson every request.DiscReader.wraprecognizes the conformance before it reads a byte, ahead of the recognition cache, which rebuilds a reader from extents of a single image.wrapBluRayFolderiswrapBluRaywith files in place of UDF extents:scanPlaylistsandassembleBluRayTitleare generalized over their entries, so the folder gets the same NET-103 bounds, title selection, decoy filtering and AE#105 clip timeline. The image path calls them exactly as before.MultiFileConcatIOReaderpresents the title's clips in playlist order as one seekable stream. A clip's file opens when the read reaches it, at most three stay open, and closed readers keep counting towardSourceTransferCounting. It declaresdiscImageProbeEnabled = false.maxSmallFileBytes) opens with its listed size instead of thebytes=0-0range probe. It is read whole, so a range-blind origin costs nothing there; a clip keeps the probe, which is what refuses an origin that would answer a range with the whole file. On a real folder with 81 playlists this took recognition from 162 playlist requests to 81.HTTPDiscIOReader's convenience init gained an internalknownSize:for it.Demuxer.bitRatewas libavformat'sbit_rate, which it estimates as the source size over the duration it reads off the timestamps. Over a title whose clips restart their clock that duration is as wrong asduration(AE#105): a 6537 s UHD title whose two clips both start at 11.6 s probed as 388 s, so 54.6 GB declaredBANDWIDTH=2253434656, and AVPlayer waited withAVPlayerWaitingWithNoItemToPlayReasonforever. A disc title now takes its size over its playlist duration whenever libavformat produced a rate (66.9 Mbit/s there, and it starts). When libavformat gives no rate, as for a remote ISO opened by URL (bitrate=0in the probe), the over-declared fallback is unchanged.docs/formats.md(Disc) anddocs/api.md(Loading), CHANGELOG under Unreleased.Not covered yet: a controlled probe (
limits/cancellation) wraps the reader inProbeIOReaderand does not recognize a folder; an uncontrolledprobe(source:)andload(source:)do. This is in the docs and the CHANGELOG.Test plan
Device / OS: MacBook Pro (Mac14,5, M2 Max), macOS 27.0.1, Xcode 27.0 (27A266a).
Real folders: a local
Rangeorigin serving each disc's folder from a NAS mount. A temporaryaetherctlcommand (not part of this PR) listed the folder intoHTTPDiscDirectoryReader, ranload(source: .custom(reader)), sampledcurrentTimefor 6 s, then sought to 50 %, 90 % and 20 % of the duration and sampled 6 s after each seek:Titles and STN track languages came through on all four (for example
dca:deu,dca:engandpgssub:zhoon the first).Known limitation, unchanged from ISO: on The Equalizer 3 a seek to 3000 s lands in the second clip, because both clips cover overlapping timestamps and the timestamp search cannot tell them apart. Stock 7.33.2 has the same failure on an ISO of this shape: Kotonoha no Niwa (2 clips with AE#105 spans), opened by URL with
aetherctl play --seek-pattern 1500,3000, ends the session withDemuxer: read failed (-1)at the first seek. Seeking by the clips' CLPI EP maps (feat(engine): contribute MovieClaw VOD and remote-disc extensions #703, P7) is what fixes it for both, and would be the next PR.New
BluRayFolderTests(12): main-title concatenation byte for byte; AE#105 spans for clips that restart their clock;preferredPlaylistreads only that playlist, and a missing one scans all;selectTitleIDand clamping; missing clips; reads across files and every seek origin; at most three files open, with transfer counting across eviction; a file shorter than listed; the same folder over loopback HTTP, plus its independent reader;AetherEngine.probe(source: .custom(folder)); and the bandwidth test, which fails without the second commit.Full
swift test --jobs 8: 4,210 Swift Testing cases in 584 suites and the XCTest suite. One issue:ItemSwapStillTests"a playing native item hands over the frame on screen" (frame != nil), which fails the same way on an untouched 7.33.2 checkout on this machine.Scripts/check-doc-links.pypasses.Checklist
CHANGELOG.mdupdatedfeat(...),fix(...),chore(...))DiscDirectoryReader,HTTPDiscDirectoryReader)🤖 Generated with Claude Code