From f0081142878786d1a07c61e4df2d2a318609b478 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 30 May 2020 11:51:38 +0200 Subject: [PATCH] make muxers report their capabilities --- nihav-commonfmt/src/muxers/avi.rs | 1 + nihav-commonfmt/src/muxers/wav.rs | 1 + nihav-core/src/muxers/mod.rs | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+) 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 = Result; +/// 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 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 + '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. -- 2.39.5