basic abstracted input demuxing
This commit is contained in:
parent
9c0df440c5
commit
c1ac9397a5
1 changed files with 21 additions and 0 deletions
21
src/demux/input.rs
Normal file
21
src/demux/input.rs
Normal file
|
@ -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<util::Metadata, Box<dyn Error>>;
|
||||
fn read_nalu(&mut self) -> Result<util::NALUPacket, Box<dyn Error>>;
|
||||
}
|
||||
|
||||
pub fn new_reader() -> Result<impl FileReader, Box<dyn Error>> {
|
||||
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))
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue