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() {
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); },
_ => {},