introduce option handling for demuxers
[nihav.git] / nihav-core / src / demuxers / mod.rs
index 8857cee560b23d452b5ef1fcb85d4720fcdef558..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.
@@ -348,6 +349,10 @@ impl<'a> Demuxer<'a> {
     pub fn get_num_streams(&self) -> usize {
         self.streams.get_num_streams()
     }
+    /// Returns a reference to the internal stream manager.
+    pub fn get_stream_manager(&self) -> &StreamManager {
+        &self.streams
+    }
     /// Returns an iterator over streams.
     pub fn get_streams(&self) -> StreamIter {
         self.streams.iter()
@@ -390,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 }
 }