From 13e75a6415b8a92d049c172b25420611e14d72bc Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Wed, 6 Sep 2017 02:02:50 -0400 Subject: [PATCH] Add a stage to resynth test's output pipeline to permit patching timestamps --- src/bin/resynth.rs | 7 +++++-- src/lib.rs | 1 + src/timecode_fixer.rs | 18 ++++++++++++++++++ src/webm.rs | 4 ++-- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 src/timecode_fixer.rs diff --git a/src/bin/resynth.rs b/src/bin/resynth.rs index 0419eb1..70526f3 100644 --- a/src/bin/resynth.rs +++ b/src/bin/resynth.rs @@ -4,6 +4,7 @@ use std::io::{Cursor, stdout, Write}; use lab_ebml::Schema; use lab_ebml::webm::*; use lab_ebml::webm::WebmElement::*; +use lab_ebml::timecode_fixer::TimecodeFixer; const SRC_FILE: &'static [u8] = include_bytes!("../data/test1.webm"); @@ -34,12 +35,14 @@ pub fn main() { let mut output = Vec::new(); let mut cursor = Cursor::new(output); + let mut fixer = TimecodeFixer::new(); + for element in &head { - encode_webm_element(element, &mut cursor).unwrap(); + encode_webm_element(&fixer.process(element), &mut cursor).unwrap(); } for element in &body { - encode_webm_element(element, &mut cursor).unwrap(); + encode_webm_element(&fixer.process(element), &mut cursor).unwrap(); } output = cursor.into_inner(); diff --git a/src/lib.rs b/src/lib.rs index db405a5..b20111c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ extern crate futures; pub mod ebml; mod iterator; +pub mod timecode_fixer; pub mod webm; pub use ebml::{Error, Schema}; diff --git a/src/timecode_fixer.rs b/src/timecode_fixer.rs new file mode 100644 index 0000000..17aecab --- /dev/null +++ b/src/timecode_fixer.rs @@ -0,0 +1,18 @@ +// TODO: (iterator? stream?) adapter that fixes SimpleBlock/Cluster timecodes +use webm::WebmElement; + +pub struct TimecodeFixer { +} + +impl TimecodeFixer { + pub fn new() -> TimecodeFixer { + TimecodeFixer { + } + } + + pub fn process<'b>(&mut self, element: &WebmElement<'b>) -> WebmElement<'b> { + match element { + _ => *element + } + } +} diff --git a/src/webm.rs b/src/webm.rs index 21ebb61..3123977 100644 --- a/src/webm.rs +++ b/src/webm.rs @@ -12,7 +12,7 @@ const TIMECODE_ID: u64 = 0x67; const SIMPLE_BLOCK_ID: u64 = 0x23; pub struct Webm; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Copy, Clone)] pub struct SimpleBlock<'b> { pub track: u64, pub timecode: i16, @@ -20,7 +20,7 @@ pub struct SimpleBlock<'b> { pub data: &'b[u8] } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Copy, Clone)] pub enum WebmElement<'b> { EbmlHead, Void,