aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2020-05-30 11:51:38 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2020-05-30 11:51:38 +0200
commitf0081142878786d1a07c61e4df2d2a318609b478 (patch)
tree0a238dafb729f8fa250e8e5dfcae381c0d7794a4
parent575c0b27ffcb7440620222e6e78c9ecb4006cf99 (diff)
downloadnihav-f0081142878786d1a07c61e4df2d2a318609b478.tar.gz
make muxers report their capabilities
-rw-r--r--nihav-commonfmt/src/muxers/avi.rs1
-rw-r--r--nihav-commonfmt/src/muxers/wav.rs1
-rw-r--r--nihav-core/src/muxers/mod.rs23
3 files changed, 25 insertions, 0 deletions
diff --git a/nihav-commonfmt/src/muxers/avi.rs b/nihav-commonfmt/src/muxers/avi.rs
index 8920b48..ac13cb2 100644
--- a/nihav-commonfmt/src/muxers/avi.rs
+++ b/nihav-commonfmt/src/muxers/avi.rs
@@ -295,6 +295,7 @@ impl MuxerCreator for AVIMuxerCreator {
Box::new(AVIMuxer::new(bw))
}
fn get_name(&self) -> &'static str { "avi" }
+ fn get_capabilities(&self) -> MuxerCapabilities { MuxerCapabilities::Universal }
}
#[cfg(test)]
diff --git a/nihav-commonfmt/src/muxers/wav.rs b/nihav-commonfmt/src/muxers/wav.rs
index 163a977..a11bb2a 100644
--- a/nihav-commonfmt/src/muxers/wav.rs
+++ b/nihav-commonfmt/src/muxers/wav.rs
@@ -105,6 +105,7 @@ impl MuxerCreator for WAVMuxerCreator {
Box::new(WAVMuxer::new(bw))
}
fn get_name(&self) -> &'static str { "wav" }
+ fn get_capabilities(&self) -> MuxerCapabilities { MuxerCapabilities::SingleAudio("any") }
}
#[cfg(test)]
diff --git a/nihav-core/src/muxers/mod.rs b/nihav-core/src/muxers/mod.rs
index ba6f780..e8a1afb 100644
--- a/nihav-core/src/muxers/mod.rs
+++ b/nihav-core/src/muxers/mod.rs
@@ -28,6 +28,27 @@ pub enum 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 }
}
@@ -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;
+ /// Returns muxer capabilities for the current muxer.
+ fn get_capabilities(&self) -> MuxerCapabilities;
}
/// Creates muxer for a provided bytestream writer.