#[cfg(test)]
mod test {
use super::*;
- use demuxers::avi::*;
+ use demuxers::*;
use io::byteio::*;
use std::fs::File;
use std::io::prelude::*;
#[test]
fn test_indeo2() {
+ let avi_dmx = find_demuxer("avi").unwrap();
let mut file = File::open("assets/laser05.avi").unwrap();
let mut fr = FileReader::new_read(&mut file);
let mut br = ByteReader::new(&mut fr);
- let mut dmx = AVIDemuxer::new(&mut br);
+ let mut dmx = avi_dmx.new_demuxer(&mut br);
dmx.open().unwrap();
let mut dec = Indeo2Decoder::new();
}
#[allow(dead_code)]
-pub struct AVIDemuxer<'a> {
+struct AVIDemuxer<'a> {
opened: bool,
src: &'a mut ByteReader<'a>,
cur_frame: Vec<u64>,
}
impl<'a> AVIDemuxer<'a> {
- pub fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut ByteReader<'a>) -> Self {
AVIDemuxer {
cur_frame: Vec::new(),
num_streams: 0,
Ok(size)
}
+pub struct AVIDemuxerCreator { }
+
+impl DemuxerCreator for AVIDemuxerCreator {
+ fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<Demux<'a> + 'a> {
+ Box::new(AVIDemuxer::new(br))
+ }
+ fn get_name(&self) -> &'static str { "avi" }
+}
+
#[cfg(test)]
mod test {
use super::*;
}
#[allow(dead_code)]
-pub struct GremlinVideoDemuxer<'a> {
+struct GremlinVideoDemuxer<'a> {
opened: bool,
src: &'a mut ByteReader<'a>,
frames: u16,
}
}*/
impl<'a> GremlinVideoDemuxer<'a> {
- pub fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut ByteReader<'a>) -> Self {
GremlinVideoDemuxer {
cur_frame: 0,
frames: 0,
}
}
+pub struct GDVDemuxerCreator { }
+
+impl DemuxerCreator for GDVDemuxerCreator {
+ fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<Demux<'a> + 'a> {
+ Box::new(GremlinVideoDemuxer::new(br))
+ }
+ fn get_name(&self) -> &'static str { "gdv" }
+}
+
#[cfg(test)]
mod test {
use super::*;
self.set_duration(pkt.duration);
}
}
+
+pub trait DemuxerCreator {
+ fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<Demux<'a> + 'a>;
+ fn get_name(&self) -> &'static str;
+}
+
+const DEMUXERS: &[&'static DemuxerCreator] = &[
+#[cfg(feature="demuxer_avi")]
+ &avi::AVIDemuxerCreator {},
+#[cfg(feature="demuxer_gdv")]
+ &gdv::GDVDemuxerCreator {},
+];
+
+pub fn find_demuxer(name: &str) -> Option<&DemuxerCreator> {
+ for i in 0..DEMUXERS.len() {
+ if DEMUXERS[i].get_name() == name {
+ return Some(DEMUXERS[i]);
+ }
+ }
+ None
+}