From: Kostya Shishkov Date: Fri, 19 May 2017 13:17:13 +0000 (+0200) Subject: prettier demuxers module X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=3f7c7cfd270b5b75917508aee6ca5877433a984d;p=nihav.git prettier demuxers module --- diff --git a/src/demuxers/mod.rs b/src/demuxers/mod.rs index 707984b..5e337a5 100644 --- a/src/demuxers/mod.rs +++ b/src/demuxers/mod.rs @@ -9,13 +9,19 @@ use frame::*; use std::collections::HashMap; use io::byteio::*; +/// Possible stream types. #[derive(Debug,Clone,Copy)] #[allow(dead_code)] pub enum StreamType { + /// video stream Video, + /// audio stream Audio, + /// subtitles Subtitles, + /// any data stream (or might be an unrecognized audio/video stream) Data, + /// nonexistent stream None, } @@ -194,8 +200,11 @@ impl FrameFromPacket for NAFrame { } } +///The structure used to create demuxers. pub trait DemuxerCreator { + /// Create new demuxer instance that will use `ByteReader` source as an input. fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box + 'a>; + /// Get the name of current demuxer creator. fn get_name(&self) -> &'static str; } @@ -207,9 +216,9 @@ const DEMUXERS: &[&'static DemuxerCreator] = &[ ]; pub fn find_demuxer(name: &str) -> Option<&DemuxerCreator> { - for i in 0..DEMUXERS.len() { - if DEMUXERS[i].get_name() == name { - return Some(DEMUXERS[i]); + for &dmx in DEMUXERS { + if dmx.get_name() == name { + return Some(dmx); } } None