introduce option handling for demuxers
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 31 May 2020 16:15:50 +0000 (18:15 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 31 May 2020 16:15:50 +0000 (18:15 +0200)
nihav-commonfmt/src/demuxers/avi.rs
nihav-commonfmt/src/demuxers/mov.rs
nihav-commonfmt/src/demuxers/wav.rs
nihav-core/src/demuxers/mod.rs
nihav-game/src/demuxers/bmv.rs
nihav-game/src/demuxers/gdv.rs
nihav-game/src/demuxers/vmd.rs
nihav-rad/src/demuxers/bink.rs
nihav-rad/src/demuxers/smacker.rs
nihav-realmedia/src/demuxers/realmedia.rs
nihav-vivo/src/demuxers/vivo.rs

index 4ea40673aa40c2be22249d453ea7bc8552857278..cf1b5bfa5fb1b7ebf4f5aa1c80e53faac5244839 100644 (file)
@@ -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<NAValue> { None }
+}
+
 impl<'a> AVIDemuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         AVIDemuxer {
index b7aecd52af18ed0e3c9a50adea471391466d117f..29c512de3ae0039c9f5169d11fd2d0757f3c05e7 100644 (file)
@@ -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<NAValue> { None }
+}
+
 impl<'a> MOVDemuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         MOVDemuxer {
index 8c41c2d35bc5017391ad9c7c409b0e97b6ae66d8..bf30686436273f61ebc35d2d9a8903dce17e5b7c 100644 (file)
@@ -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<NAValue> { None }
+}
+
 impl<'a> WAVDemuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         WAVDemuxer {
index 1d7347b6ac9e0f5847d0abf0237d4782123c99aa..a0f67a84c7d984fad014ece751dbc6b8c1763b06 100644 (file)
@@ -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<T> = Result<T, DemuxerError>;
 
 /// 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<NAValue> {
+        self.dmx.query_option_value(name)
+    }
+}
+
 impl From<ByteIOError> for DemuxerError {
     fn from(_: ByteIOError) -> Self { DemuxerError::IOError }
 }
index 5910342b7df31214ea8ba5ddd623f592aa48efce..19019d450d0c61cb3596a578e83abdbd50908464 100644 (file)
@@ -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<NAValue> { 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<NAValue> { None }
+}
+
 impl<'a> BMV3Demuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         Self {
index 438ced2cf0fc944f02299f7876a188d85a9f8980..11d7406839b25393d9461ae5180dc05f2fb234b6 100644 (file)
@@ -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<NAValue> { None }
+}
 /*impl<'a> Drop for GremlinVideoDemuxer<'a> {
     #[allow(unused_variables)]
     fn drop(&mut self) {
index 70bf0fe15a69aa6400c54e75f60127b44239b1f9..c6da8f46d6810a0603d9543193f158652daaacc8 100644 (file)
@@ -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<NAValue> { None }
+}
+
 impl<'a> VMDDemuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         Self {
index e83f12333ccce44a6a47ef5323886502cd72f8a5..35bdcbf6126234a4030f432412403901e7c9f4e6 100644 (file)
@@ -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<NAValue> { None }
+}
+
 impl<'a> BinkDemuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         Self {
index 3fb1a6ee5963d67ad038a166c3bbb98b35b23ed5..41cad05e853d5bd3527b3d8da737bff660fb40bc 100644 (file)
@@ -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<NAValue> { None }
+}
+
 impl<'a> SmackerVideoDemuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         SmackerVideoDemuxer {
index 1fa52f967283329203518355587c770aaa5cfeb7..d591eab3367b2de9336ea5ac656a32a6833c2d72 100644 (file)
@@ -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<NAValue> { 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<NAValue> { 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<NAValue> { None }
+}
+
 impl<'a> RealIVRDemuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         RealIVRDemuxer {
index 06decd12f1aefc32085994c879d7025a0611bfb7..a55bc41137e46b69c91ff318e92e6e57458b5379 100644 (file)
@@ -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<NAValue> { None }
+}
+
 impl<'a> VivoDemuxer<'a> {
     fn new(io: &'a mut ByteReader<'a>) -> Self {
         VivoDemuxer {