Add keys() to IOStream trait — streams know their own decrypt keys
- IOStream::keys() default returns DecryptKeys::None - IsoStream and DiscStream override with real AACS/CSS keys - Pipeline calls input.keys() instead of separate scan_keys() - Streams are self-contained: read bytes + provide keys
This commit is contained in:
+9
-1
@@ -23,6 +23,7 @@ use std::path::Path;
|
|||||||
pub struct DiscStream {
|
pub struct DiscStream {
|
||||||
drive: Drive,
|
drive: Drive,
|
||||||
title: DiscTitle,
|
title: DiscTitle,
|
||||||
|
decrypt_keys: crate::decrypt::DecryptKeys,
|
||||||
|
|
||||||
// What to read
|
// What to read
|
||||||
mode: ReadMode,
|
mode: ReadMode,
|
||||||
@@ -120,7 +121,9 @@ impl DiscStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let title = disc.titles[title_index].clone();
|
let title = disc.titles[title_index].clone();
|
||||||
let stream = Self::title(drive, title);
|
let keys = disc.decrypt_keys();
|
||||||
|
let mut stream = Self::title(drive, title);
|
||||||
|
stream.decrypt_keys = keys;
|
||||||
|
|
||||||
Ok(DiscOpenResult { stream, disc })
|
Ok(DiscOpenResult { stream, disc })
|
||||||
}
|
}
|
||||||
@@ -155,6 +158,7 @@ impl DiscStream {
|
|||||||
Self {
|
Self {
|
||||||
drive,
|
drive,
|
||||||
title,
|
title,
|
||||||
|
decrypt_keys: crate::decrypt::DecryptKeys::None,
|
||||||
mode,
|
mode,
|
||||||
current_lba: 0,
|
current_lba: 0,
|
||||||
current_extent: 0,
|
current_extent: 0,
|
||||||
@@ -293,6 +297,10 @@ impl IOStream for DiscStream {
|
|||||||
ReadMode::Sequential { capacity } => Some(*capacity as u64 * 2048),
|
ReadMode::Sequential { capacity } => Some(*capacity as u64 * 2048),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn keys(&self) -> crate::decrypt::DecryptKeys {
|
||||||
|
self.decrypt_keys.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Read for DiscStream {
|
impl Read for DiscStream {
|
||||||
|
|||||||
+3
-1
@@ -231,13 +231,15 @@ impl IOStream for IsoStream {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn total_bytes(&self) -> Option<u64> {
|
fn total_bytes(&self) -> Option<u64> {
|
||||||
// Read mode: size is known from disc scan
|
|
||||||
if self.reader.is_some() {
|
if self.reader.is_some() {
|
||||||
Some(self.disc_title.size_bytes)
|
Some(self.disc_title.size_bytes)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn keys(&self) -> DecryptKeys {
|
||||||
|
self.decrypt_keys.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Read for IsoStream {
|
impl Read for IsoStream {
|
||||||
|
|||||||
+8
-2
@@ -36,8 +36,8 @@ pub mod resolve;
|
|||||||
pub mod stdio;
|
pub mod stdio;
|
||||||
pub mod ts;
|
pub mod ts;
|
||||||
|
|
||||||
pub use disc::{DiscOptions, DiscStream};
|
pub use disc::{DiscOpenResult, DiscStream};
|
||||||
pub use iso::IsoStream;
|
pub use iso::{IsoSectorReader, IsoStream};
|
||||||
pub use m2ts::M2tsStream;
|
pub use m2ts::M2tsStream;
|
||||||
pub use mkvstream::MkvStream;
|
pub use mkvstream::MkvStream;
|
||||||
pub use network::NetworkStream;
|
pub use network::NetworkStream;
|
||||||
@@ -63,6 +63,12 @@ pub trait IOStream: Read + Write {
|
|||||||
fn total_bytes(&self) -> Option<u64> {
|
fn total_bytes(&self) -> Option<u64> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Decryption keys for this stream. Default: no encryption.
|
||||||
|
/// Overridden by DiscStream and IsoStream for AACS/CSS.
|
||||||
|
fn keys(&self) -> crate::decrypt::DecryptKeys {
|
||||||
|
crate::decrypt::DecryptKeys::None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Combined traits for internal trait objects.
|
// Combined traits for internal trait objects.
|
||||||
|
|||||||
Reference in New Issue
Block a user