Move codec_privates onto DiscTitle, eliminate duplicate methods

Design fix: codec_privates are now a field on DiscTitle, not a separate
parameter passed through the pipeline. This eliminates the root cause of
the network codec_private bug (forgot to pass the separate param).

API changes:
- output() takes (url, &DiscTitle) — no separate codec_privates param
- MkvOutputStream::create, M2tsOutputStream::create, NetworkOutputStream::connect
  all read codec_privates from title.codec_privates
- M2tsMeta::from_title() takes only &DiscTitle — reads privates from title
- Deleted from_title_with_privates (was the wrong-name duplicate)
- Merged read_header + read_header_from_stream into one read_header(impl Read)
- Deleted finish(self) from TsMuxer, keep only finish(&mut self)

Rule: ONE public method per action. No _with_X, _from_Y, _ref variants.
This commit is contained in:
MattJackson
2026-04-15 16:52:06 +00:00
parent 5287dd65ce
commit 75066744d1
12 changed files with 45 additions and 94 deletions
+2 -5
View File
@@ -15,13 +15,10 @@ pub struct MkvOutputStream {
}
impl MkvOutputStream {
/// Create an MKV output stream.
/// `codec_privates` provides initialization data per track (from InputStream).
/// Tracks without codec_private get None.
/// Create an MKV output stream. Codec privates come from title.codec_privates.
pub fn create(
writer: Box<dyn WriteSeek>,
title: &DiscTitle,
codec_privates: &[Option<Vec<u8>>],
) -> io::Result<Self> {
let mut tracks = Vec::new();
for (idx, s) in title.streams.iter().enumerate() {
@@ -30,7 +27,7 @@ impl MkvOutputStream {
crate::disc::Stream::Audio(a) => MkvTrack::audio(a),
crate::disc::Stream::Subtitle(s) => MkvTrack::subtitle(s),
};
if let Some(cp) = codec_privates.get(idx).and_then(|c| c.as_ref()) {
if let Some(cp) = title.codec_privates.get(idx).and_then(|c| c.as_ref()) {
track.codec_private = Some(cp.clone());
}
tracks.push(track);