fix some warnings (unneeded parentheses, missing dyn keyword)
[nihav.git] / nihav-core / src / muxers / mod.rs
index 9f40d54424349bd8c1914e31f1f0d9bb36220212..40a6eb353f919f7cb5f7d3a601d82222b32af170 100644 (file)
@@ -97,11 +97,11 @@ impl<'a> Muxer<'a> {
         self.streams.iter()
     }
 
-    /// Demuxes a new packet from the container.
+    /// Queues a new packet for muxing.
     pub fn mux_frame(&mut self, pkt: NAPacket) -> MuxerResult<()> {
         self.mux.mux_frame(&self.streams, pkt)
     }
-    /// Returns internal seek index.
+    /// Flushes the current muxing state.
     pub fn flush(&mut self) -> MuxerResult<()> {
         self.mux.flush()
     }
@@ -111,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.
@@ -122,7 +134,7 @@ pub trait MuxerCreator {
 }
 
 /// Creates muxer for a provided bytestream writer.
-pub fn create_muxer<'a>(mxcr: &MuxerCreator, str: StreamManager, bw: &'a mut ByteWriter<'a>) -> MuxerResult<Muxer<'a>> {
+pub fn create_muxer<'a>(mxcr: &dyn MuxerCreator, str: StreamManager, bw: &'a mut ByteWriter<'a>) -> MuxerResult<Muxer<'a>> {
     let mut mux = mxcr.new_muxer(bw);
     mux.create(&str)?;
     Ok(Muxer::new(mux, str))
@@ -131,7 +143,7 @@ pub fn create_muxer<'a>(mxcr: &MuxerCreator, str: StreamManager, bw: &'a mut Byt
 /// List of registered muxers.
 #[derive(Default)]
 pub struct RegisteredMuxers {
-    muxes:  Vec<&'static MuxerCreator>,
+    muxes:  Vec<&'static dyn MuxerCreator>,
 }
 
 impl RegisteredMuxers {
@@ -140,11 +152,11 @@ impl RegisteredMuxers {
         Self { muxes: Vec::new() }
     }
     /// Registers a new muxer.
-    pub fn add_muxer(&mut self, mux: &'static MuxerCreator) {
+    pub fn add_muxer(&mut self, mux: &'static dyn MuxerCreator) {
         self.muxes.push(mux);
     }
     /// Searches for a muxer that supports requested container format.
-    pub fn find_muxer(&self, name: &str) -> Option<&MuxerCreator> {
+    pub fn find_muxer(&self, name: &str) -> Option<&dyn MuxerCreator> {
         for &mux in self.muxes.iter() {
             if mux.get_name() == name {
                 return Some(mux);
@@ -152,4 +164,8 @@ impl RegisteredMuxers {
         }
         None
     }
+    /// Provides an iterator over currently registered muxers.
+    pub fn iter(&self) -> std::slice::Iter<&dyn MuxerCreator> {
+        self.muxes.iter()
+    }
 }