baseline implementations so testing can happen

This commit is contained in:
Muaz Ahmad 2023-10-06 23:43:50 +05:00
parent f84237b0be
commit a0dcd5d6f1
5 changed files with 39 additions and 9 deletions

View file

@ -14,5 +14,8 @@ pub fn spawn(
),
Box<dyn Error>
> {
todo!();
let (_raw_v_in, raw_v_out) = mpsc::channel();
let (_raw_a_in, raw_a_out) = mpsc::channel();
let (_err_in, err_out) = mpsc::channel();
return Ok((raw_v_out, raw_a_out, err_out));
}

View file

@ -15,5 +15,8 @@ pub fn spawn(
),
Box<dyn Error>
> {
todo!();
let (v_in, v_out) = mpsc::channel();
let (a_in, a_out) = mpsc::channel();
let (err_in, err_out) = mpsc::channel();
return Ok((v_out, a_out, err_out));
}

View file

@ -6,6 +6,8 @@ mod muxer;
use std::process::exit;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
fn init() -> Result<[mpsc::Receiver<Box<dyn std::error::Error + Send + Sync>>; 4], Box<dyn std::error::Error>>{
let (v_out, a_out, metadata, demux_err_recv) = demux::spawn()?;
@ -16,7 +18,16 @@ fn init() -> Result<[mpsc::Receiver<Box<dyn std::error::Error + Send + Sync>>; 4
}
fn process(error_handles: [mpsc::Receiver<Box<dyn std::error::Error + Send + Sync>>; 4]) -> Result<(), Box<dyn std::error::Error>> {
todo!();
loop {
for i in 0..4 {
match error_handles[i].try_recv() {
Ok(err) => return Err(err),
Err(mpsc::TryRecvError::Empty) => (),
Err(err) => return Err(Box::new(util::ThreadError(i))),
}
}
thread::sleep(Duration::from_millis(100));
}
}
fn main() {

View file

@ -11,5 +11,6 @@ pub fn spawn(
mpsc::Receiver<Box<dyn Error + Send + Sync>>,
Box<dyn Error>
> {
todo!();
let (err_in, err_out) = mpsc::channel();
return Ok(err_out);
}

View file

@ -49,11 +49,6 @@ impl Metadata {
}
}
pub enum FileType {
FLV,
MPEGTS,
}
pub enum NALUPacketType {
Audio,
Video,
@ -76,6 +71,23 @@ pub struct RawMedia {
// Errors
pub struct ThreadError(pub usize);
impl Error for ThreadError {}
impl fmt::Debug for ThreadError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Disconnect Error in thread index {}, data pipe broken", self.0)
}
}
impl fmt::Display for ThreadError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
pub enum DemuxerError {
UnknownSyncByte,
FLVUnknownTagType,