From 9c0df440c513e1a36ec4d6da2a9de905b1cd1cf1 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Thu, 5 Oct 2023 14:59:51 +0500 Subject: [PATCH] Handler function typing --- src/decode/mod.rs | 18 ++++++++++++++++++ src/demux/mod.rs | 16 ++++++++++++++++ src/encode/mod.rs | 19 +++++++++++++++++++ src/main.rs | 24 ++++++++++++++++++++---- src/muxer/mod.rs | 15 +++++++++++++++ 5 files changed, 88 insertions(+), 4 deletions(-) diff --git a/src/decode/mod.rs b/src/decode/mod.rs index e69de29..094ac03 100644 --- a/src/decode/mod.rs +++ b/src/decode/mod.rs @@ -0,0 +1,18 @@ +use std::sync::mpsc; +use std::error::Error; +use crate::util; + +pub fn spawn( + v: mpsc::Receiver, + a: mpsc::Receiver, + metadata: &util::Metadata + ) -> Result< + ( + mpsc::Receiver, + mpsc::Receiver, + mpsc::Receiver> + ), + Box + > { + todo!(); +} diff --git a/src/demux/mod.rs b/src/demux/mod.rs index e69de29..5fbb4aa 100644 --- a/src/demux/mod.rs +++ b/src/demux/mod.rs @@ -0,0 +1,16 @@ +use std::sync::mpsc; +use std::error::Error; + +use crate::util; + +pub fn spawn() -> Result< + ( + mpsc::Receiver, + mpsc::Receiver, + util::Metadata, + mpsc::Receiver> + ), + Box + > { + todo!(); +} diff --git a/src/encode/mod.rs b/src/encode/mod.rs index e69de29..9572052 100644 --- a/src/encode/mod.rs +++ b/src/encode/mod.rs @@ -0,0 +1,19 @@ +use std::sync::mpsc; +use std::error::Error; + +use crate::util; + +pub fn spawn( + v: mpsc::Receiver, + a: mpsc::Receiver, + metadata: &util::Metadata + ) -> Result< + ( + mpsc::Receiver, + mpsc::Receiver, + mpsc::Receiver> + ), + Box + > { + todo!(); +} diff --git a/src/main.rs b/src/main.rs index 10e51d8..18b9060 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,13 +4,29 @@ mod decode; mod encode; mod muxer; -fn init() { +use std::process::exit; +use std::sync::mpsc; + +fn init() -> Result<[mpsc::Receiver>; 4], Box>{ + let (v_out, a_out, metadata, demux_err_recv) = demux::spawn()?; + let (raw_v_out, raw_a_out, decode_err_recv) = decode::spawn(v_out, a_out, &metadata)?; + let (enc_v_out, enc_a_out, encode_err_recv) = encode::spawn(raw_v_out, raw_a_out, &metadata)?; + let muxer_err_recv = muxer::spawn(enc_v_out, enc_a_out, &metadata)?; + return Ok([demux_err_recv, decode_err_recv, encode_err_recv, muxer_err_recv]); } -fn process() { +fn process(error_handles: [mpsc::Receiver>; 4]) -> Result<(), Box> { + todo!(); } fn main() { - init(); - process(); + let error_handles = match init() { + Ok(x) => x, + Err(x) => {dbg!(x); exit(1);} + }; + match process(error_handles) { + Ok(_) => (), + Err(x) => {dbg!(x); exit(1)} + }; + exit(0); } diff --git a/src/muxer/mod.rs b/src/muxer/mod.rs index e69de29..b5540f8 100644 --- a/src/muxer/mod.rs +++ b/src/muxer/mod.rs @@ -0,0 +1,15 @@ +use std::sync::mpsc; +use std::error::Error; + +use crate::util; + +pub fn spawn( + v: mpsc::Receiver, + a: mpsc::Receiver, + metadata: &util::Metadata + ) -> Result< + mpsc::Receiver>, + Box + > { + todo!(); +}