From c1ac9397a521b35c030631d5aa192888816d4f5a Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Thu, 5 Oct 2023 15:35:02 +0500 Subject: [PATCH] basic abstracted input demuxing --- src/demux/input.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/demux/input.rs 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)) + } +}