#[cfg(feature="decoder_pcm")]
fn get_duration(ainfo: &NAAudioInfo, duration: Option<u64>, data_size: usize) -> u64 {
- if duration == None {
+ if let Some(dur) = duration {
+ dur
+ } else {
let size_bits = (data_size as u64) * 8;
let blk_size = u64::from(ainfo.get_channels()) * u64::from(ainfo.get_format().get_bits());
size_bits / blk_size
- } else {
- duration.unwrap()
}
}
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
NACodecTypeInfo::None => {
- let mut ofmt = EncodeParameters::default();
- ofmt.format = NACodecTypeInfo::Audio(NAAudioInfo::new(0, 0, SND_S16P_FORMAT, 0));
- Ok(ofmt)
+ Ok(EncodeParameters {
+ format: NACodecTypeInfo::Audio(NAAudioInfo::new(0, 0, SND_S16P_FORMAT, 0)),
+ ..Default::default()
+ })
},
NACodecTypeInfo::Video(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Audio(_) => {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_CBR }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),