tidy, set max bitrate

This commit is contained in:
Hailey Somerville 2023-12-27 16:49:07 +11:00
parent 4aa5850055
commit 077d22429e
2 changed files with 5 additions and 15 deletions

View file

@ -28,17 +28,10 @@ impl Display for OpusDecoder {
impl Decode for OpusDecoder {
fn decode_packet(&mut self, bytes: Option<&[u8]>, out: &mut SampleBuffer) -> Result<(), DecodeError> {
let expected = out.len() / 2;
let length;
match bytes {
Some(bytes) => {
length = self.opus.decode_float(bytes, out, false)?;
log::debug!("opus decode: bytes={} -> frames={}", bytes.len(), length);
}
None => {
length = self.opus.decode_float(&[], out, true)?;
log::debug!("opus decode: correcting packet loss! frames={}", length);
}
let length = match bytes {
Some(bytes) => self.opus.decode_float(bytes, out, false)?,
None => self.opus.decode_float(&[], out, true)?,
};
if expected != length {

View file

@ -18,6 +18,7 @@ impl OpusEncoder {
opus.set_inband_fec(true)?;
opus.set_packet_loss_perc(50)?;
opus.set_bitrate(opus::Bitrate::Max)?;
Ok(OpusEncoder { opus })
}
@ -35,10 +36,6 @@ impl Encode for OpusEncoder {
}
fn encode_packet(&mut self, samples: &[f32], out: &mut [u8]) -> Result<usize, EncodeError> {
let len = self.opus.encode_float(samples, out)?;
log::debug!("opus encode: frames={} -> bytes={}", samples.len() / 2, len);
Ok(len)
Ok(self.opus.encode_float(samples, out)?)
}
}