]> git.nihav.org Git - nihav-tool.git/commitdiff
add option for printing MOV chunks hierarchy
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 17 Dec 2022 10:45:54 +0000 (11:45 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 17 Dec 2022 10:45:54 +0000 (11:45 +0100)
src/demux.rs
src/main.rs

index 56659c76a4cb928b2cce4144b34c8753dfce0588..9c65b85614387b0089bd86c15881f2ccf37beee0 100644 (file)
@@ -98,14 +98,14 @@ pub enum DemuxerObject<'a> {
 }
 
 impl<'a> DemuxerObject<'a> {
-    pub fn create(br: &'a mut ByteReader<'a>, reg: &FullRegister, name: &str, force_dmx: Option<&str>, is_raw: bool) -> DemuxerObject<'a> {
+    pub fn create(br: &'a mut ByteReader<'a>, reg: &FullRegister, name: &str, force_dmx: Option<&str>, is_raw: bool, opts: &[NAOption]) -> DemuxerObject<'a> {
         if !is_raw {
             let res = detect::detect_format(name, br);
             if let Some(dmx_name) = force_dmx {
                 println!("forcing demuxer {} on {}", dmx_name, name);
                 if let Some(dmx_fact) = reg.dmx_reg.find_demuxer(dmx_name) {
                     br.seek(SeekFrom::Start(0)).unwrap();
-                    let dmx = create_demuxer(dmx_fact, br).unwrap();
+                    let dmx = create_demuxer_with_options(dmx_fact, br, opts).unwrap();
                     return DemuxerObject::Normal(dmx);
                 } else {
                     return DemuxerObject::None
@@ -116,7 +116,7 @@ impl<'a> DemuxerObject<'a> {
                 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();
-                    let dmx = create_demuxer(dmx_fact, br).unwrap();
+                    let dmx = create_demuxer_with_options(dmx_fact, br, opts).unwrap();
                     return DemuxerObject::Normal(dmx);
                 }
             }
@@ -124,7 +124,7 @@ impl<'a> DemuxerObject<'a> {
                 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 = create_raw_demuxer(rdmx_fact, br).unwrap();
+                    let dmx = create_raw_demuxer_with_options(rdmx_fact, br, opts).unwrap();
                     let mut pkts = Vec::new();
                     for stream in dmx.get_streams() {
                         if let Some(pcreate) = reg.pkt_reg.find_packetiser(stream.get_info().get_name()) {
@@ -141,7 +141,7 @@ impl<'a> DemuxerObject<'a> {
                 if rdmx.check_format(br) {
                     println!("detected {} as {}", name, rdmx.get_name());
                     br.seek(SeekFrom::Start(0)).unwrap();
-                    let dmx = create_raw_demuxer(*rdmx, br).unwrap();
+                    let dmx = create_raw_demuxer_with_options(*rdmx, br, opts).unwrap();
                     let mut pkts = Vec::new();
                     for stream in dmx.get_streams() {
                         if let Some(pcreate) = reg.pkt_reg.find_packetiser(stream.get_info().get_name()) {
index 929ab6eddebf72a67680e7853c2a795a3ec463b8..fcf6a56f8408d0a233fdd881f6db196d892ae7fd 100644 (file)
@@ -105,6 +105,7 @@ fn main() {
     let mut ignore_errors = false;
     let mut dump_frames = false;
     let mut force_dmx: Option<&str> = None;
+    let mut demux_opts: Vec<NAOption> = Vec::new();
 
     while (cur_arg < args.len()) && args[cur_arg].starts_with('-') {
         match args[cur_arg].as_str() {
@@ -154,6 +155,9 @@ fn main() {
                 }
                 force_dmx = Some(&args[cur_arg]);
             },
+            "-print_mov_chunks" => {
+                demux_opts.push(NAOption{name: "print_chunks", value: NAValue::Bool(true) });
+            },
             "-ignerr"   => { ignore_errors = true; },
             "-dumpfrm"  => { dump_frames = true; },
             _           => { println!("unknown option {}", args[cur_arg]); return; },
@@ -188,7 +192,7 @@ fn main() {
     }
     let mut br = ByteReader::new(nfr.as_mut());
     let full_reg = FullRegister::new();
-    let mut demuxer = DemuxerObject::create(&mut br, &full_reg, name, force_dmx, is_raw);
+    let mut demuxer = DemuxerObject::create(&mut br, &full_reg, name, force_dmx, is_raw, &demux_opts);
     if demuxer.is_none() {
         println!("No demuxer found!");
         return;