From: Kostya Shishkov Date: Sun, 31 May 2020 16:15:50 +0000 (+0200) Subject: introduce option handling for demuxers X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=787b8d03074419d7f8e6b52daba02a3807444bc2;p=nihav.git introduce option handling for demuxers --- diff --git a/nihav-commonfmt/src/demuxers/avi.rs b/nihav-commonfmt/src/demuxers/avi.rs index 4ea4067..cf1b5bf 100644 --- a/nihav-commonfmt/src/demuxers/avi.rs +++ b/nihav-commonfmt/src/demuxers/avi.rs @@ -154,6 +154,12 @@ impl<'a> DemuxCore<'a> for AVIDemuxer<'a> { } } +impl<'a> NAOptionHandler for AVIDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> AVIDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { AVIDemuxer { diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index b7aecd5..29c512d 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -829,6 +829,12 @@ impl<'a> DemuxCore<'a> for MOVDemuxer<'a> { } } +impl<'a> NAOptionHandler for MOVDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> MOVDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { MOVDemuxer { diff --git a/nihav-commonfmt/src/demuxers/wav.rs b/nihav-commonfmt/src/demuxers/wav.rs index 8c41c2d..bf30686 100644 --- a/nihav-commonfmt/src/demuxers/wav.rs +++ b/nihav-commonfmt/src/demuxers/wav.rs @@ -95,6 +95,12 @@ impl<'a> DemuxCore<'a> for WAVDemuxer<'a> { } } +impl<'a> NAOptionHandler for WAVDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> WAVDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { WAVDemuxer { diff --git a/nihav-core/src/demuxers/mod.rs b/nihav-core/src/demuxers/mod.rs index 1d7347b..a0f67a8 100644 --- a/nihav-core/src/demuxers/mod.rs +++ b/nihav-core/src/demuxers/mod.rs @@ -1,6 +1,7 @@ //! Demuxer definitions. pub use crate::frame::*; pub use crate::io::byteio::*; +pub use crate::options::*; /// A list specifying general demuxing errors. #[derive(Debug,Clone,Copy,PartialEq)] @@ -30,7 +31,7 @@ pub enum DemuxerError { pub type DemuxerResult = Result; /// A trait for demuxing operations. -pub trait DemuxCore<'a> { +pub trait DemuxCore<'a>: NAOptionHandler { /// Opens the input stream, reads required headers and prepares everything for packet demuxing. fn open(&mut self, strmgr: &mut StreamManager, seek_idx: &mut SeekIndex) -> DemuxerResult<()>; /// Demuxes a packet. @@ -394,6 +395,18 @@ impl<'a> Demuxer<'a> { } } +impl<'a> NAOptionHandler for Demuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { + self.dmx.get_supported_options() + } + fn set_options(&mut self, options: &[NAOption]) { + self.dmx.set_options(options); + } + fn query_option_value(&self, name: &str) -> Option { + self.dmx.query_option_value(name) + } +} + impl From for DemuxerError { fn from(_: ByteIOError) -> Self { DemuxerError::IOError } } diff --git a/nihav-game/src/demuxers/bmv.rs b/nihav-game/src/demuxers/bmv.rs index 5910342..19019d4 100644 --- a/nihav-game/src/demuxers/bmv.rs +++ b/nihav-game/src/demuxers/bmv.rs @@ -75,6 +75,12 @@ impl<'a> DemuxCore<'a> for BMVDemuxer<'a> { } } +impl<'a> NAOptionHandler for BMVDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> BMVDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { Self { @@ -216,6 +222,12 @@ impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> { } } +impl<'a> NAOptionHandler for BMV3Demuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> BMV3Demuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { Self { diff --git a/nihav-game/src/demuxers/gdv.rs b/nihav-game/src/demuxers/gdv.rs index 438ced2..11d7406 100644 --- a/nihav-game/src/demuxers/gdv.rs +++ b/nihav-game/src/demuxers/gdv.rs @@ -114,6 +114,11 @@ impl<'a> DemuxCore<'a> for GremlinVideoDemuxer<'a> { Err(DemuxerError::NotPossible) } } +impl<'a> NAOptionHandler for GremlinVideoDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} /*impl<'a> Drop for GremlinVideoDemuxer<'a> { #[allow(unused_variables)] fn drop(&mut self) { diff --git a/nihav-game/src/demuxers/vmd.rs b/nihav-game/src/demuxers/vmd.rs index 70bf0fe..c6da8f4 100644 --- a/nihav-game/src/demuxers/vmd.rs +++ b/nihav-game/src/demuxers/vmd.rs @@ -185,6 +185,12 @@ impl<'a> DemuxCore<'a> for VMDDemuxer<'a> { } } +impl<'a> NAOptionHandler for VMDDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> VMDDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { Self { diff --git a/nihav-rad/src/demuxers/bink.rs b/nihav-rad/src/demuxers/bink.rs index e83f123..35bdcbf 100644 --- a/nihav-rad/src/demuxers/bink.rs +++ b/nihav-rad/src/demuxers/bink.rs @@ -165,6 +165,12 @@ impl<'a> DemuxCore<'a> for BinkDemuxer<'a> { } } +impl<'a> NAOptionHandler for BinkDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> BinkDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { Self { diff --git a/nihav-rad/src/demuxers/smacker.rs b/nihav-rad/src/demuxers/smacker.rs index 3fb1a6e..41cad05 100644 --- a/nihav-rad/src/demuxers/smacker.rs +++ b/nihav-rad/src/demuxers/smacker.rs @@ -261,6 +261,12 @@ impl<'a> DemuxCore<'a> for SmackerVideoDemuxer<'a> { } } +impl<'a> NAOptionHandler for SmackerVideoDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> SmackerVideoDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { SmackerVideoDemuxer { diff --git a/nihav-realmedia/src/demuxers/realmedia.rs b/nihav-realmedia/src/demuxers/realmedia.rs index 1fa52f9..d591eab 100644 --- a/nihav-realmedia/src/demuxers/realmedia.rs +++ b/nihav-realmedia/src/demuxers/realmedia.rs @@ -764,6 +764,12 @@ impl<'a> DemuxCore<'a> for RealMediaDemuxer<'a> { } } +impl<'a> NAOptionHandler for RealMediaDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + fn read_chunk(src: &mut ByteReader) -> DemuxerResult<(u32, u32, u16)> { let id = src.read_u32be()?; if id == 0 { return Ok((0, 0, 0)); } @@ -1252,6 +1258,12 @@ println!(" got ainfo {:?}", ainfo); } } +impl<'a> NAOptionHandler for RealAudioDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> RealAudioDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { RealAudioDemuxer { @@ -1591,6 +1603,12 @@ println!("R1M kind"); } } +impl<'a> NAOptionHandler for RealIVRDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> RealIVRDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { RealIVRDemuxer { diff --git a/nihav-vivo/src/demuxers/vivo.rs b/nihav-vivo/src/demuxers/vivo.rs index 06decd1..a55bc41 100644 --- a/nihav-vivo/src/demuxers/vivo.rs +++ b/nihav-vivo/src/demuxers/vivo.rs @@ -134,6 +134,12 @@ impl<'a> DemuxCore<'a> for VivoDemuxer<'a> { } } +impl<'a> NAOptionHandler for VivoDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + impl<'a> VivoDemuxer<'a> { fn new(io: &'a mut ByteReader<'a>) -> Self { VivoDemuxer {