diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2018-12-07 15:02:30 +0100 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2018-12-07 15:02:30 +0100 |
commit | 417ba15eea92979575a8452f6b34162330b56e1f (patch) | |
tree | 7d318a8fd3d486925151382a561eda89f56fcc6c | |
parent | 44939c842b9aa76838dae8064d1b13bb47960efb (diff) | |
download | nihav-tool-417ba15eea92979575a8452f6b34162330b56e1f.tar.gz |
find decoder by stream ID instead of relying on index directly
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index b5653f4..b57e361 100644 --- a/src/main.rs +++ b/src/main.rs @@ -122,13 +122,16 @@ println!("trying demuxer {} on {}", dmx_name, name); let mut dmx = create_demuxer(dmx_fact, &mut br).unwrap(); let mut decs: Vec<Option<Box<NADecoder>>> = Vec::new(); + let mut sids: Vec<u32> = Vec::new(); let mut writers: Vec<Outputter> = Vec::new(); for i in 0..dmx.get_num_streams() { let s = dmx.get_stream(i).unwrap(); let info = s.get_info(); let decfunc = find_decoder(info.get_name()); println!("stream {} - {} {}", i, s, info.get_name()); + let str_id = s.get_id(); let mut has_out = false; + sids.push(str_id); if info.is_video() { if decode_video { if decfunc.is_none() { @@ -177,11 +180,13 @@ panic!("decoder {} not found", info.get_name()); if e == DemuxerError::EOF { break; } } let pkt = pktres.unwrap(); - let streamno = pkt.get_stream().get_id() as usize; - if let Some(ref mut dec) = decs[streamno] { + let streamno = pkt.get_stream().get_id(); + let sr = sids.iter().position(|x| *x == streamno); + let idx = sr.unwrap(); + if let Some(ref mut dec) = decs[idx] { let frm = dec.decode(&pkt).unwrap(); if !noout { - match writers[streamno] { + match writers[idx] { Outputter::Video(ref mut wr) => { wr.output_frame(&pkt, frm); }, Outputter::Audio(ref mut wr) => { wr.output_frame(&pkt, frm); }, _ => {}, |