]> git.nihav.org Git - nihav.git/blobdiff - nihav-core/src/muxers/mod.rs
core: add iterator for the lists of registered demuxers and muxers
[nihav.git] / nihav-core / src / muxers / mod.rs
index e8a1afbcab46d871a4bf7244ffc086c993310751..6194f518c092e75e68493883470f2a3f76139159 100644 (file)
@@ -2,6 +2,7 @@
 pub use crate::frame::*;
 pub use crate::io::byteio::*;
 pub use crate::demuxers::{StreamManager, StreamIter};
+pub use crate::options::*;
 
 /// A list specifying general muxing errors.
 #[derive(Debug,Clone,Copy,PartialEq)]
@@ -54,7 +55,7 @@ impl From<ByteIOError> for MuxerError {
 }
 
 /// A trait for muxing operations.
-pub trait MuxCore<'a> {
+pub trait MuxCore<'a>: NAOptionHandler {
     /// Prepares everything for packet muxing.
     fn create(&mut self, strmgr: &StreamManager) -> MuxerResult<()>;
     /// Queues a packet for muxing.
@@ -110,6 +111,18 @@ impl<'a> Muxer<'a> {
     }
 }
 
+impl<'a> NAOptionHandler for Muxer<'a> {
+    fn get_supported_options(&self) -> &[NAOptionDefinition] {
+        self.mux.get_supported_options()
+    }
+    fn set_options(&mut self, options: &[NAOption]) {
+        self.mux.set_options(options);
+    }
+    fn query_option_value(&self, name: &str) -> Option<NAValue> {
+        self.mux.query_option_value(name)
+    }
+}
+
 /// The trait for creating muxers.
 pub trait MuxerCreator {
     /// Creates new muxer instance that will use `ByteWriter` for output.
@@ -151,4 +164,8 @@ impl RegisteredMuxers {
         }
         None
     }
+    /// Provides an iterator over currently registered muxers.
+    pub fn iter(&self) -> std::slice::Iter<&MuxerCreator> {
+        self.muxes.iter()
+    }
 }