]> git.nihav.org Git - nihav-encoder.git/commitdiff
make demuxer print information only when requested
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 3 Oct 2023 15:14:40 +0000 (17:14 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 3 Oct 2023 15:14:40 +0000 (17:14 +0200)
src/demux.rs
src/main.rs

index 9f6739de3bd4559184ad2ff22adc81e147c193b2..19b5f242c337ec4047624c44acb8db3683ff9ca4 100644 (file)
@@ -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<String>, is_raw: bool) -> DemuxerObject<'a> {
+    pub fn create(mut brb: ReaderBox<'a>, reg: &FullRegister, name: &str, ifmt: &Option<String>, 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 {
index 90a871154122bcd01760db3afefabf682f1ea479..73c4c435affe1574fa08c8ed282eb3017c5aa075 100644 (file)
@@ -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;