diff --git a/src/demux/input.rs b/src/demux/input.rs new file mode 100644 index 0000000..0e8942c --- /dev/null +++ b/src/demux/input.rs @@ -0,0 +1,21 @@ +use std::error::Error; +use std::io; +use std::io::Read; + +use crate::util; +use crate::demux::flv; + +pub trait FileReader { + fn init(&mut self) -> Result>; + fn read_nalu(&mut self) -> Result>; +} + +pub fn new_reader() -> Result> { + let mut stdin_hndl = io::stdin(); + let mut byte1 = [0u8; 1]; + stdin_hndl.read_exact(&mut byte1)?; + match &byte1[0] { + 0x46 => flv::new_reader(stdin_hndl), + _ => Err(Box::new(util::GenericError::UnknownSyncByte)) + } +}