mirror of
https://github.com/haileys/bark
synced 2024-11-28 14:20:23 +00:00
tidy, set max bitrate
This commit is contained in:
parent
4aa5850055
commit
077d22429e
2 changed files with 5 additions and 15 deletions
|
@ -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 {
|
||||
|
|
|
@ -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)?)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue