2018-04-11 21:54:02 -04:00
|
|
|
use std::{
|
|
|
|
error::Error,
|
2018-04-12 00:14:16 -04:00
|
|
|
io
|
2018-04-11 21:54:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
use clap::{App, AppSettings, ArgMatches, SubCommand};
|
2018-04-12 00:14:16 -04:00
|
|
|
use futures::Async;
|
2018-04-11 21:54:02 -04:00
|
|
|
|
2018-04-12 00:14:16 -04:00
|
|
|
use super::StdinStream;
|
2018-04-11 21:54:02 -04:00
|
|
|
use webmetro::{
|
|
|
|
stream_parser::StreamEbml,
|
|
|
|
webm::{
|
|
|
|
SimpleBlock,
|
|
|
|
WebmElement::*
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
pub fn options() -> App<'static, 'static> {
|
|
|
|
SubCommand::with_name("dump")
|
|
|
|
.setting(AppSettings::Hidden)
|
|
|
|
.about("Dumps WebM parsing events from parsing stdin")
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn run(_args: &ArgMatches) -> Result<(), Box<Error>> {
|
|
|
|
|
|
|
|
let stdin = io::stdin();
|
2018-04-12 00:14:16 -04:00
|
|
|
let mut events = StdinStream::new(stdin.lock()).parse_ebml();
|
2018-04-11 21:54:02 -04:00
|
|
|
|
|
|
|
// stdin is sync so Async::NotReady will never happen
|
|
|
|
while let Ok(Async::Ready(Some(element))) = events.poll_event() {
|
|
|
|
match element {
|
|
|
|
// suppress printing byte arrays
|
|
|
|
Tracks(slice) => println!("Tracks[{}]", slice.len()),
|
|
|
|
SimpleBlock(SimpleBlock {timecode, ..}) => println!("SimpleBlock@{}", timecode),
|
|
|
|
other => println!("{:?}", other)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|