From: Kostya Shishkov Date: Sun, 31 May 2020 16:19:52 +0000 (+0200) Subject: introduce option handling for encoders X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=20766f15236404c4eb336229d4a9d202d107bb99;p=nihav.git introduce option handling for encoders --- diff --git a/nihav-core/src/codecs/mod.rs b/nihav-core/src/codecs/mod.rs index 5470325..86441e6 100644 --- a/nihav-core/src/codecs/mod.rs +++ b/nihav-core/src/codecs/mod.rs @@ -3,6 +3,7 @@ pub use crate::frame::*; use crate::io::byteio::ByteIOError; use crate::io::bitreader::BitReaderError; use crate::io::codebook::CodebookError; +pub use crate::options::*; /// A list specifying general decoding errors. #[derive(Debug,Clone,Copy,PartialEq)] @@ -231,7 +232,7 @@ impl Default for EncodeParameters { /// [`negotiate_format`]: ./trait.NAEncoder.html#tymethod.negotiate_format /// [`encode`]: ./trait.NAEncoder.html#tymethod.encode /// [`get_packet`]: ./trait.NAEncoder.html#tymethod.get_packet -pub trait NAEncoder { +pub trait NAEncoder: NAOptionHandler { /// Tries to negotiate input format. /// /// This function takes input encoding parameters and returns adjusted encoding parameters if input ones make sense. diff --git a/nihav-ms/src/codecs/msadpcm.rs b/nihav-ms/src/codecs/msadpcm.rs index b41333f..d906e4c 100644 --- a/nihav-ms/src/codecs/msadpcm.rs +++ b/nihav-ms/src/codecs/msadpcm.rs @@ -385,6 +385,12 @@ impl NAEncoder for MSADPCMEncoder { } } +impl NAOptionHandler for MSADPCMEncoder { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + pub fn get_encoder() -> Box { Box::new(MSADPCMEncoder::new()) } diff --git a/nihav-ms/src/codecs/msvideo1enc.rs b/nihav-ms/src/codecs/msvideo1enc.rs index f9b06cf..6ddae64 100644 --- a/nihav-ms/src/codecs/msvideo1enc.rs +++ b/nihav-ms/src/codecs/msvideo1enc.rs @@ -479,6 +479,12 @@ impl NAEncoder for MSVideo1Encoder { } } +impl NAOptionHandler for MSVideo1Encoder { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + pub fn get_encoder() -> Box { Box::new(MSVideo1Encoder::new()) }