From 044c7e1c75145f1ec9d002b4f6fc4433ff7f9540 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 13 Sep 2025 16:08:42 +0200 Subject: start remuxer crate rewrite; added matroska demuxer and format detection --- matroska/src/unflatten.rs | 83 ----------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 matroska/src/unflatten.rs (limited to 'matroska/src/unflatten.rs') diff --git a/matroska/src/unflatten.rs b/matroska/src/unflatten.rs deleted file mode 100644 index d5fb887..0000000 --- a/matroska/src/unflatten.rs +++ /dev/null @@ -1,83 +0,0 @@ -/* - This file is part of jellything (https://codeberg.org/metamuffin/jellything) - which is licensed under the GNU Affero General Public License (version 3); see /COPYING. - Copyright (C) 2025 metamuffin -*/ -use crate::{matroska::MatroskaTag, Master, Result}; - -pub struct Unflat<'a> { - pub item: MatroskaTag, - pub children: Option>, - pub position: Option, -} - -pub struct Unflatten<'a> { - inner: &'a mut dyn Iterator, MatroskaTag)>>, - stop: bool, - end: Option, -} - -impl<'a> Unflatten<'a> { - pub fn new(inner: &'a mut dyn Iterator, MatroskaTag)>>) -> Self { - Self { - inner, - stop: false, - end: None, - } - } - pub fn new_with_end( - inner: &'a mut dyn Iterator, MatroskaTag)>>, - start: MatroskaTag, - ) -> Self { - Self { - inner, - stop: false, - end: Some(MatroskaTag::construct_master(start.id(), Master::End).unwrap()), - } - } - pub fn exit_dirty(&mut self) { - self.stop = true; - } - - pub fn n(&mut self) -> Option>> { - if self.stop { - return None; - } - match self.inner.next() { - None => None, - Some(Err(e)) => Some(Err(e)), - Some(Ok((position, item))) => { - let master = MatroskaTag::is_master(item.id()).unwrap(); - if Some(&item) == self.end.as_ref() { - self.stop = true; - None - } else { - Some(Ok(Unflat { - position, - children: if master { - let end = - MatroskaTag::construct_master(item.id(), Master::End).unwrap(); - if end == item { - return None; - } - Some(Unflatten { - inner: self.inner, - stop: false, - end: Some(end), - }) - } else { - None - }, - item, - })) - } - } - } - } -} - -impl Drop for Unflatten<'_> { - fn drop(&mut self) { - while self.n().is_some() {} - } -} -- cgit v1.2.3-70-g09d2