Add PES frame types and FileSectorReader — foundation for stream refactor

- pes.rs: PesFrame, InputStream, OutputStream traits
- sector.rs: SectorReader now public, added FileSectorReader (ISO = file)
- Foundation for unified DiscStream that handles both disc and ISO
This commit is contained in:
MattJackson
2026-04-15 02:37:54 +00:00
parent 610f1b62b6
commit ccb1fadedf
3 changed files with 88 additions and 8 deletions
+39
View File
@@ -0,0 +1,39 @@
//! PES frame — the universal intermediate format.
//!
//! Every input stream produces PES frames. Every output stream consumes them.
//! The pipeline just moves frames: input.next_frame() → output.write_frame().
//!
//! A PES frame is one unit of elementary stream data: a video frame,
//! an audio frame, a subtitle packet. It has a track ID, timestamp,
//! and the raw codec data.
/// One frame of elementary stream data.
#[derive(Debug, Clone)]
pub struct PesFrame {
/// Track index (0-based, matches StreamInfo track order).
pub track: usize,
/// Presentation timestamp in nanoseconds.
pub pts: i64,
/// True if this is a keyframe (IDR for video).
pub keyframe: bool,
/// Raw elementary stream data (NAL units, audio samples, etc).
pub data: Vec<u8>,
}
/// Input stream — produces PES frames from any source.
pub trait InputStream {
/// Get the next frame. Returns None at end of stream.
fn next_frame(&mut self) -> std::io::Result<Option<PesFrame>>;
/// Stream metadata (tracks, duration, etc).
fn info(&self) -> &crate::disc::DiscTitle;
}
/// Output stream — consumes PES frames to any destination.
pub trait OutputStream {
/// Write one frame.
fn write_frame(&mut self, frame: &PesFrame) -> std::io::Result<()>;
/// Finalize (flush, write index, close).
fn finish(&mut self) -> std::io::Result<()>;
}