From 5c323970a3c0fb7a0782d43fa23b423a956ffb63 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Wed, 25 Oct 2023 15:00:59 +0500 Subject: [PATCH] parse hls args from cmd args --- src/main.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8ca946a..520d155 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,11 +9,11 @@ use std::sync::mpsc; use std::thread; use std::time::Duration; -fn init() -> Result<[mpsc::Receiver>; 4], Box>{ +fn init(args: util::HLSArgs) -> 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.clone())?; let (enc_v_out, enc_a_out, encode_err_recv) = encode::spawn(raw_v_out, raw_a_out, metadata.clone(), util::VideoCodec::AV1, util::AudioCodec::OPUS)?; - let muxer_err_recv = muxer::spawn(enc_v_out, enc_a_out, metadata.clone(), util::HLSArgs{segment_time: 4, segment_prepend: String::from("/vid/tmp/"), max_segments: 4})?; + let muxer_err_recv = muxer::spawn(enc_v_out, enc_a_out, metadata.clone(), args)?; return Ok([demux_err_recv, decode_err_recv, encode_err_recv, muxer_err_recv]); } @@ -42,8 +42,18 @@ fn process(error_handles: [mpsc::Receiver util::HLSArgs { + let mut args = std::env::args(); + args.next(); + util::HLSArgs { + segment_time: args.next().expect("no time interval").parse().expect("not int"), + segment_prepend: args.next().expect("no prepend"), + max_segments: args.next().expect("no max list size").parse().expect("not int"), + } +} + fn main() { - let error_handles = match init() { + let error_handles = match init(parse_args()) { Ok(x) => x, Err(err) => {dbg!(err); exit(1);} };