Skip to content

Commit

Permalink
chore: Split raw data from processing functions (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 authored Oct 27, 2023
1 parent ac0dbef commit b067f74
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 547 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ impl Framer {
let loudness_calculator = loudness::Calculator::new(frame_size);
let mut buf: Vec<f32> = Vec::new();
buf.reserve(frame_size);
let mut opus_out: Vec<u8> = Vec::new();
opus_out.resize(frame_size * 4, 0);
let opus_out: Vec<u8> = vec![0; frame_size * 4];
let mut encoder = opus::Encoder::new(
webrtc_codec.sample_rate(),
opus::Channels::Mono,
Expand Down
21 changes: 7 additions & 14 deletions extensions/warp-blink-wrtc/src/host_media/audio/opus/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ mod test {
let mut buf1: Vec<f32> = Vec::new();
buf1.resize(buff_size, 0_f32);

let mut buf2: Vec<u8> = Vec::new();
buf2.resize(buff_size * 4, 0);
let mut buf2: Vec<u8> = vec![0; buff_size * 4];

encoder
.encode_float(buf1.as_slice(), buf2.as_mut_slice())
Expand All @@ -343,8 +342,7 @@ mod test {
let mut buf1: Vec<f32> = Vec::new();
buf1.resize(buff_size, 0_f32);

let mut buf2: Vec<u8> = Vec::new();
buf2.resize(buff_size * 4, 0);
let mut buf2: Vec<u8> = vec![0; buff_size * 4];

encoder
.encode_float(buf1.as_slice(), buf2.as_mut_slice())
Expand All @@ -359,8 +357,7 @@ mod test {
let mut buf1: Vec<f32> = Vec::new();
buf1.resize(buff_size, 0_f32);

let mut buf2: Vec<u8> = Vec::new();
buf2.resize(buff_size * 4, 0);
let mut buf2: Vec<u8> = vec![0; buff_size * 4];

encoder
.encode_float(buf1.as_slice(), buf2.as_mut_slice())
Expand All @@ -375,8 +372,7 @@ mod test {
let mut buf1: Vec<f32> = Vec::new();
buf1.resize(buff_size, 0_f32);

let mut buf2: Vec<u8> = Vec::new();
buf2.resize(buff_size * 4, 0);
let mut buf2: Vec<u8> = vec![0; buff_size * 4];

encoder
.encode_float(buf1.as_slice(), buf2.as_mut_slice())
Expand All @@ -391,8 +387,7 @@ mod test {
let mut buf1: Vec<f32> = Vec::new();
buf1.resize(buff_size, 0_f32);

let mut buf2: Vec<u8> = Vec::new();
buf2.resize(buff_size * 4, 0);
let mut buf2: Vec<u8> = vec![0; buff_size * 4];

encoder
.encode_float(buf1.as_slice(), buf2.as_mut_slice())
Expand All @@ -404,11 +399,9 @@ mod test {
let mut encoder =
opus::Encoder::new(48000, opus::Channels::Mono, opus::Application::Voip).unwrap();
let buff_size = 120;
let mut buf1: Vec<i16> = Vec::new();
buf1.resize(buff_size, 0);
let buf1: Vec<i16> = vec![0; buff_size];

let mut buf2: Vec<u8> = Vec::new();
buf2.resize(buff_size * 2, 0);
let mut buf2: Vec<u8> = vec![0; buff_size * 2];

encoder
.encode(buf1.as_slice(), buf2.as_mut_slice())
Expand Down
Loading

0 comments on commit b067f74

Please sign in to comment.