make muxers report their capabilities
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 30 May 2020 09:51:38 +0000 (11:51 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 30 May 2020 09:51:38 +0000 (11:51 +0200)
nihav-commonfmt/src/muxers/avi.rs
nihav-commonfmt/src/muxers/wav.rs
nihav-core/src/muxers/mod.rs

index 8920b48d28d96d79f2ef2b78da1df5401f6055d2..ac13cb231fbd51b456199f874050273303674c51 100644 (file)
@@ -295,6 +295,7 @@ impl MuxerCreator for AVIMuxerCreator {
         Box::new(AVIMuxer::new(bw))
     }
     fn get_name(&self) -> &'static str { "avi" }
         Box::new(AVIMuxer::new(bw))
     }
     fn get_name(&self) -> &'static str { "avi" }
+    fn get_capabilities(&self) -> MuxerCapabilities { MuxerCapabilities::Universal }
 }
 
 #[cfg(test)]
 }
 
 #[cfg(test)]
index 163a977e5d7c2c248f042223159a275455a8713d..a11bb2a510eb6406d5cb8962ea5693495e49514f 100644 (file)
@@ -105,6 +105,7 @@ impl MuxerCreator for WAVMuxerCreator {
         Box::new(WAVMuxer::new(bw))
     }
     fn get_name(&self) -> &'static str { "wav" }
         Box::new(WAVMuxer::new(bw))
     }
     fn get_name(&self) -> &'static str { "wav" }
+    fn get_capabilities(&self) -> MuxerCapabilities { MuxerCapabilities::SingleAudio("any") }
 }
 
 #[cfg(test)]
 }
 
 #[cfg(test)]
index ba6f780081297c52b8c7e9eade5dfc7db16ada25..e8a1afbcab46d871a4bf7244ffc086c993310751 100644 (file)
@@ -28,6 +28,27 @@ pub enum MuxerError {
 /// A specialised `Result` type for muxing operations.
 pub type MuxerResult<T> = Result<T, MuxerError>;
 
 /// A specialised `Result` type for muxing operations.
 pub type MuxerResult<T> = Result<T, MuxerError>;
 
+/// Muxer capabilities.
+#[derive(Clone,Copy,Debug,PartialEq)]
+pub enum MuxerCapabilities {
+    /// Muxer accepts single video stream with certain codec.
+    ///
+    /// Codec name `"any"` means various codecs are supported.
+    SingleVideo(&'static str),
+    /// Muxer accepts single audio stream with certain codec.
+    ///
+    /// Codec name `"any"` means various codecs are supported.
+    SingleAudio(&'static str),
+    /// Muxer accepts single video stream and single audio stream with defined codecs.
+    SingleVideoAndAudio(&'static str, &'static str),
+    /// Muxer accepts only video streams but can mux several video streams.
+    OnlyVideo,
+    /// Muxer accepts only audio streams but can mux several video streams..
+    OnlyAudio,
+    /// Muxer accepts variable amount of streams of any type.
+    Universal,
+}
+
 impl From<ByteIOError> for MuxerError {
     fn from(_: ByteIOError) -> Self { MuxerError::IOError }
 }
 impl From<ByteIOError> for MuxerError {
     fn from(_: ByteIOError) -> Self { MuxerError::IOError }
 }
@@ -95,6 +116,8 @@ pub trait MuxerCreator {
     fn new_muxer<'a>(&self, bw: &'a mut ByteWriter<'a>) -> Box<dyn MuxCore<'a> + 'a>;
     /// Returns the name of current muxer creator (equal to the container name it can create).
     fn get_name(&self) -> &'static str;
     fn new_muxer<'a>(&self, bw: &'a mut ByteWriter<'a>) -> Box<dyn MuxCore<'a> + 'a>;
     /// Returns the name of current muxer creator (equal to the container name it can create).
     fn get_name(&self) -> &'static str;
+    /// Returns muxer capabilities for the current muxer.
+    fn get_capabilities(&self) -> MuxerCapabilities;
 }
 
 /// Creates muxer for a provided bytestream writer.
 }
 
 /// Creates muxer for a provided bytestream writer.