set stream number in encoders too
[nihav.git] / nihav-ms / src / codecs / msadpcm.rs
index b41333f13ab9467edcdceac7cd6e01ea65de794f..d47d9224f083e04bdf5be2acb2ad99a8e2d1d279 100644 (file)
@@ -161,6 +161,12 @@ impl NADecoder for MSADPCMDecoder {
     }
 }
 
+impl NAOptionHandler for MSADPCMDecoder {
+    fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
+    fn set_options(&mut self, _options: &[NAOption]) { }
+    fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
+}
+
 pub fn get_decoder() -> Box<dyn NADecoder + Send> {
     Box::new(MSADPCMDecoder::new())
 }
@@ -314,7 +320,7 @@ impl NAEncoder for MSADPCMEncoder {
                 if (outinfo.channels == 1) && ((outinfo.block_len & 1) == 1) {
                     outinfo.block_len += 1;
                 }
-                let mut ofmt = EncodeParameters::default();
+                let mut ofmt = *encinfo;
                 ofmt.format = NACodecTypeInfo::Audio(outinfo);
                 return Ok(ofmt);
             }
@@ -340,7 +346,9 @@ impl NAEncoder for MSADPCMEncoder {
                 let soniton = NASoniton::new(4, 0);
                 let out_ainfo = NAAudioInfo::new(ainfo.sample_rate, ainfo.channels, soniton, Self::calc_block_size(self.block_len, self.channels));
                 let info = NACodecInfo::new("ms-adpcm", NACodecTypeInfo::Audio(out_ainfo), None);
-                let stream = NAStream::new(StreamType::Audio, stream_id, info.clone(), self.block_len as u32, ainfo.sample_rate).into_ref();
+                let mut stream = NAStream::new(StreamType::Audio, stream_id, info.clone(), self.block_len as u32, ainfo.sample_rate);
+                stream.set_num(stream_id as usize);
+                let stream = stream.into_ref();
 
                 self.stream = Some(stream.clone());
                 self.samples = Vec::with_capacity(self.block_len * self.channels);
@@ -385,6 +393,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<NAValue> { None }
+}
+
 pub fn get_encoder() -> Box<dyn NAEncoder + Send> {
     Box::new(MSADPCMEncoder::new())
 }