DiscStream implements InputStream — produces PES frames

DiscStream now has TsDemuxer + CodecParsers internally.
next_frame() reads sectors → decrypts → demuxes → parses → returns PesFrame.
Old Read/Write impls preserved alongside for backward compatibility.
This commit is contained in:
MattJackson
2026-04-15 02:54:08 +00:00
parent ccb1fadedf
commit cab87ffdf4
2 changed files with 110 additions and 2 deletions
+14 -2
View File
@@ -4,13 +4,13 @@
//! 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,
//! an audio frame, a subtitle packet. It carries 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).
/// Track index (0-based, matches stream info track order).
pub track: usize,
/// Presentation timestamp in nanoseconds.
pub pts: i64,
@@ -20,6 +20,18 @@ pub struct PesFrame {
pub data: Vec<u8>,
}
impl PesFrame {
/// Create from a codec::Frame with a track index.
pub fn from_codec_frame(track: usize, frame: crate::mux::codec::Frame) -> Self {
Self {
track,
pts: frame.pts_ns,
keyframe: frame.keyframe,
data: frame.data,
}
}
}
/// Input stream — produces PES frames from any source.
pub trait InputStream {
/// Get the next frame. Returns None at end of stream.