Add a stage to resynth test's output pipeline to permit patching timestamps

This commit is contained in:
Tangent 128 2017-09-06 02:02:50 -04:00
parent 9b3a6db074
commit 13e75a6415
4 changed files with 26 additions and 4 deletions

View File

@ -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();

View File

@ -4,6 +4,7 @@ extern crate futures;
pub mod ebml;
mod iterator;
pub mod timecode_fixer;
pub mod webm;
pub use ebml::{Error, Schema};

18
src/timecode_fixer.rs Normal file
View File

@ -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
}
}
}

View File

@ -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,