From e6308188d03f1811a5cb699a6a5c031d03b3f269 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 3 Oct 2023 17:14:40 +0200 Subject: [PATCH] make demuxer print information only when requested --- src/demux.rs | 22 ++++++++++++++++------ src/main.rs | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/demux.rs b/src/demux.rs index 9f6739d..19b5f24 100644 --- a/src/demux.rs +++ b/src/demux.rs @@ -65,19 +65,23 @@ pub enum DemuxerObject<'a> { } impl<'a> DemuxerObject<'a> { - pub fn create(mut brb: ReaderBox<'a>, reg: &FullRegister, name: &str, ifmt: &Option, is_raw: bool) -> DemuxerObject<'a> { + pub fn create(mut brb: ReaderBox<'a>, reg: &FullRegister, name: &str, ifmt: &Option, is_raw: bool, print_info: bool) -> DemuxerObject<'a> { let br = brb.get_object_mut(); if !is_raw { let dmx_name = if let Some(ref dname) = ifmt { dname.as_str() } else if let Some((dname, score)) = detect::detect_format(name, br) { - println!("detected {} with score {:?}", dname, score); + if print_info { + println!("detected {} with score {:?}", dname, score); + } dname } else { "" }; if !dmx_name.is_empty() { - println!("trying demuxer {} on {}", dmx_name, name); + if print_info { + println!("trying demuxer {} on {}", dmx_name, name); + } if let Some(dmx_fact) = reg.dmx_reg.find_demuxer(dmx_name) { br.seek(SeekFrom::Start(0)).unwrap(); @@ -93,7 +97,9 @@ impl<'a> DemuxerObject<'a> { return DemuxerObject::None; } if !dmx_name.is_empty() { - println!("trying raw demuxer {} on {}", dmx_name, name); + if print_info { + println!("trying raw demuxer {} on {}", dmx_name, name); + } if let Some(rdmx_fact) = reg.rdmx_reg.find_demuxer(dmx_name) { br.seek(SeekFrom::Start(0)).unwrap(); let dmx = SelfBorrow::new(brb, |br_| { @@ -115,7 +121,9 @@ impl<'a> DemuxerObject<'a> { } for rdmx in reg.rdmx_reg.iter() { if rdmx.check_format(br) { - println!("detected {} as {}", name, rdmx.get_name()); + if print_info { + println!("detected {} as {}", name, rdmx.get_name()); + } br.seek(SeekFrom::Start(0)).unwrap(); let dmx = SelfBorrow::new(brb, |br_| { unsafe { @@ -149,7 +157,9 @@ impl<'a> DemuxerObject<'a> { } } if !pname.is_empty() { - println!("found raw stream of type {} for {}", pname, name); + if print_info { + println!("found raw stream of type {} for {}", pname, name); + } let pcreate = reg.pkt_reg.find_packetiser(pname).unwrap(); let rctx = SelfBorrow::new(brb, |br_| { unsafe { diff --git a/src/main.rs b/src/main.rs index 90a8711..73c4c43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1200,7 +1200,7 @@ fn main() { } }); - let mut dmx = DemuxerObject::create(sb, &full_reg, name, ifmt, is_raw); + let mut dmx = DemuxerObject::create(sb, &full_reg, name, ifmt, is_raw, true); if dmx.is_none() { println!("cannot find demuxer for '{}'", name); return; -- 2.39.5