diff options
-rw-r--r-- | matroska/src/unflatten.rs | 3 | ||||
-rw-r--r-- | remuxer/src/import/mod.rs | 28 |
2 files changed, 22 insertions, 9 deletions
diff --git a/matroska/src/unflatten.rs b/matroska/src/unflatten.rs index 57fd35b..e220689 100644 --- a/matroska/src/unflatten.rs +++ b/matroska/src/unflatten.rs @@ -15,6 +15,7 @@ pub trait IterWithPos { pub struct Unflat<'a> { pub item: MatroskaTag, pub children: Option<Unflatten<'a>>, + pub position: usize, } pub struct Unflatten<'a> { @@ -50,6 +51,7 @@ impl<'a> Unflatten<'a> { if self.stop { return None; } + let position = self.inner.position(); match self.inner.next() { None => None, Some(Err(e)) => Some(Err(e)), @@ -60,6 +62,7 @@ impl<'a> Unflatten<'a> { None } else { Some(Ok(Unflat { + position, children: if master { let end = MatroskaTag::construct_master(item.id(), Master::End).unwrap(); diff --git a/remuxer/src/import/mod.rs b/remuxer/src/import/mod.rs index b57db15..886c5f1 100644 --- a/remuxer/src/import/mod.rs +++ b/remuxer/src/import/mod.rs @@ -26,7 +26,10 @@ pub fn import_read(path: &PathBuf, input: &mut EbmlReader, iteminfo: &mut ItemIn match item { MatroskaTag::Ebml(_) => { let mut iter = Unflatten::new_with_end(input, item); - while let Some(Ok(Unflat { children: _, item })) = iter.n() { + while let Some(Ok(Unflat { + children: _, item, .. + })) = iter.n() + { match item { MatroskaTag::DocType(t) => { if !matches!(t.as_str(), "matroska" | "webm") { @@ -58,12 +61,15 @@ fn import_read_segment( let (mut timestamp_scale, mut duration) = (None, None); let mut seek_index = HashMap::new(); - while let Some(Ok(Unflat { children, item })) = segment.n() { + while let Some(Ok(Unflat { children, item, .. })) = segment.n() { match item { MatroskaTag::SeekHead(_) => {} MatroskaTag::Info(_) => { let mut children = children.unwrap(); - while let Some(Ok(Unflat { children: _, item })) = children.n() { + while let Some(Ok(Unflat { + children: _, item, .. + })) = children.n() + { match item { MatroskaTag::TimestampScale(v) => timestamp_scale = Some(v), MatroskaTag::Duration(v) => duration = Some(v), @@ -76,7 +82,7 @@ fn import_read_segment( MatroskaTag::Chapters(_) => {} MatroskaTag::Tracks(_) => { let mut children = children.unwrap(); - while let Some(Ok(Unflat { children, item })) = children.n() { + while let Some(Ok(Unflat { children, item, .. })) = children.n() { match item { MatroskaTag::TrackEntry(_) => { let mut children = children.unwrap(); @@ -98,7 +104,7 @@ fn import_read_segment( None, None, None, None, None, None, None, None, None, None, None, None, None, ); - while let Some(Ok(Unflat { children, item })) = children.n() { + while let Some(Ok(Unflat { children, item, .. })) = children.n() { match item { MatroskaTag::CodecID(b) => codec = Some(b), MatroskaTag::Language(v) => language = Some(v), @@ -176,14 +182,19 @@ fn import_read_segment( let mut position = children.position(); loop { - if let Some(Ok(Unflat { children, item })) = children.n() { + if let Some(Ok(Unflat { children, item, .. })) = children.n() { match item { MatroskaTag::Timestamp(ts) => pts = ts, MatroskaTag::BlockGroup(_) => { debug!("group"); let mut children = children.unwrap(); - let position = children.position(); //? TODO where should this point to? cluster or block? - while let Some(Ok(Unflat { children: _, item })) = children.n() { + // let position = children.position(); //? TODO where should this point to? cluster or block? // probably block + while let Some(Ok(Unflat { + children: _, + item, + position, + })) = children.n() + { match item { MatroskaTag::Block(ref buf) => { let block = Block::parse(buf)?; @@ -230,7 +241,6 @@ fn import_read_segment( position = children.position(); } } - _ => debug!("(rs) tag ignored: {item:?}"), }; } |