From: Kostya Shishkov Date: Fri, 7 Dec 2018 14:02:30 +0000 (+0100) Subject: find decoder by stream ID instead of relying on index directly X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=417ba15eea92979575a8452f6b34162330b56e1f;p=nihav-tool.git find decoder by stream ID instead of relying on index directly --- 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>> = Vec::new(); + let mut sids: Vec = Vec::new(); let mut writers: Vec = 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); }, _ => {},