From e4ffe7cc912a8aef0aafef8c805391f2bf63ad21 Mon Sep 17 00:00:00 2001 From: MattJackson <1085847+MattJackson@users.noreply.github.com> Date: Wed, 15 Apr 2026 01:38:18 +0000 Subject: [PATCH] Wire --raw through InputOptions to streams set_raw() on IsoStream and DiscStream sets keys to None. open_input passes raw flag to streams via InputOptions. Streams skip decrypt when raw=true. --- src/mux/disc.rs | 5 ++++ src/mux/iso.rs | 5 ++++ src/mux/resolve.rs | 57 +++++++++++++++++++++++++++++++++------------- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/mux/disc.rs b/src/mux/disc.rs index 0d73606..0813f38 100644 --- a/src/mux/disc.rs +++ b/src/mux/disc.rs @@ -172,6 +172,11 @@ impl DiscStream { } } + /// Skip decryption — return raw encrypted bytes. + pub fn set_raw(&mut self) { + self.decrypt_keys = crate::decrypt::DecryptKeys::None; + } + /// Lock the tray. pub fn lock_tray(&mut self) { self.drive.lock_tray(); diff --git a/src/mux/iso.rs b/src/mux/iso.rs index d5910c3..1513b33 100644 --- a/src/mux/iso.rs +++ b/src/mux/iso.rs @@ -220,6 +220,11 @@ impl IsoStream { Ok(true) } + + /// Skip decryption — return raw encrypted bytes. + pub fn set_raw(&mut self) { + self.decrypt_keys = DecryptKeys::None; + } } impl IOStream for IsoStream { diff --git a/src/mux/resolve.rs b/src/mux/resolve.rs index 68d9627..e9be9e2 100644 --- a/src/mux/resolve.rs +++ b/src/mux/resolve.rs @@ -14,7 +14,7 @@ //! //! Bare paths without a scheme are rejected. -use super::disc::{DiscOptions, DiscStream}; +use super::disc::DiscStream; use super::iso::IsoStream; use super::network::NetworkStream; use super::null::NullStream; @@ -104,17 +104,25 @@ pub fn parse_url(url: &str) -> StreamUrl { return if rest.is_empty() { StreamUrl::Disc { device: None } } else { - StreamUrl::Disc { device: Some(PathBuf::from(rest)) } + StreamUrl::Disc { + device: Some(PathBuf::from(rest)), + } }; } if let Some(rest) = url.strip_prefix("m2ts://") { - return StreamUrl::M2ts { path: PathBuf::from(rest) }; + return StreamUrl::M2ts { + path: PathBuf::from(rest), + }; } if let Some(rest) = url.strip_prefix("mkv://") { - return StreamUrl::Mkv { path: PathBuf::from(rest) }; + return StreamUrl::Mkv { + path: PathBuf::from(rest), + }; } if let Some(rest) = url.strip_prefix("network://") { - return StreamUrl::Network { addr: rest.to_string() }; + return StreamUrl::Network { + addr: rest.to_string(), + }; } if url == "null://" || url.starts_with("null://") { return StreamUrl::Null; @@ -123,9 +131,13 @@ pub fn parse_url(url: &str) -> StreamUrl { return StreamUrl::Stdio; } if let Some(rest) = url.strip_prefix("iso://") { - return StreamUrl::Iso { path: PathBuf::from(rest) }; + return StreamUrl::Iso { + path: PathBuf::from(rest), + }; + } + StreamUrl::Unknown { + raw: url.to_string(), } - StreamUrl::Unknown { raw: url.to_string() } } /// Validate that a file path is non-empty and has a filename component. @@ -139,7 +151,10 @@ fn validate_file_path(path: &Path, scheme: &str) -> io::Result<()> { if path.file_name().is_none() { return Err(io::Error::new( io::ErrorKind::InvalidInput, - format!("{scheme}://{} is not a valid file path — must include a filename", path.display()), + format!( + "{scheme}://{} is not a valid file path — must include a filename", + path.display() + ), )); } Ok(()) @@ -168,13 +183,17 @@ pub fn open_input(url: &str, opts: &InputOptions) -> io::Result { - let disc_opts = DiscOptions { - device, - keydb_path: opts.keydb_path.as_ref().map(|p| p.into()), - title_index: opts.title_index, - }; - let stream = DiscStream::open(disc_opts) - .map_err(|e| io::Error::other(e.to_string()))?; + let result = DiscStream::open( + device.as_deref(), + opts.keydb_path.as_deref(), + opts.title_index.unwrap_or(0), + None, + ) + .map_err(|e| io::Error::other(e.to_string()))?; + let mut stream = result.stream; + if opts.raw { + stream.set_raw(); + } Ok(Box::new(stream)) } StreamUrl::M2ts { ref path } => { @@ -206,7 +225,11 @@ pub fn open_input(url: &str, opts: &InputOptions) -> io::Result crate::disc::ScanOptions::with_keydb(p), None => crate::disc::ScanOptions::default(), }; - Ok(Box::new(IsoStream::open(&path.to_string_lossy(), opts.title_index, &scan_opts)?)) + let mut stream = IsoStream::open(&path.to_string_lossy(), opts.title_index, &scan_opts)?; + if opts.raw { + stream.set_raw(); + } + Ok(Box::new(stream)) } StreamUrl::Null => { Err(io::Error::new(io::ErrorKind::InvalidInput, @@ -275,4 +298,6 @@ pub fn open_output(url: &str, meta: &DiscTitle) -> io::Result> pub struct InputOptions { pub keydb_path: Option, pub title_index: Option, + /// Skip decryption — return raw encrypted bytes. + pub raw: bool, }