From 15111d544b7db09fc7d140a8bdf2d35a8b7353bd Mon Sep 17 00:00:00 2001 From: MattJackson Date: Tue, 28 Jul 2026 13:35:12 -0700 Subject: [PATCH] disc: add DiscTitle audio_streams/subtitle_streams/video_streams accessors Typed iterators over the audio/subtitle/video streams, cleaner than matching on the Stream enum for the common iterate-the-tracks case (stream selection, the desktop UI info panel, disc-info). Additive; all lib tests pass on 1.86. --- src/disc/mod.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/disc/mod.rs b/src/disc/mod.rs index 21b7c4c..872cd44 100644 --- a/src/disc/mod.rs +++ b/src/disc/mod.rs @@ -1391,6 +1391,33 @@ impl DiscTitle { pub fn total_sectors(&self) -> u64 { self.extents.iter().map(|e| e.sector_count as u64).sum() } + + /// The title's audio streams, in declared order. Cleaner than matching on + /// the [`Stream`] enum for the common "iterate the audio tracks" case + /// (stream selection, the desktop UI's info panel, disc-info listing). + pub fn audio_streams(&self) -> impl Iterator { + self.streams.iter().filter_map(|s| match s { + Stream::Audio(a) => Some(a), + _ => None, + }) + } + + /// The title's subtitle streams, in declared order. + pub fn subtitle_streams(&self) -> impl Iterator { + self.streams.iter().filter_map(|s| match s { + Stream::Subtitle(s) => Some(s), + _ => None, + }) + } + + /// The title's video streams, in declared order (usually one; two for a + /// Blu-ray 3D MVC title — the base view plus the dependent view). + pub fn video_streams(&self) -> impl Iterator { + self.streams.iter().filter_map(|s| match s { + Stream::Video(v) => Some(v), + _ => None, + }) + } } // ─── Encryption ─────────────────────────────────────────────────────────────