fix(calls): mic gets ML noise suppression by default
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -330,6 +330,12 @@ dependencies = [
330
330
"syn 2.0.119",
331
331
]
332
332
333
[[package]]
334
name = "array-init"
335
version = "2.1.0"
336
source = "registry+https://github.com/rust-lang/crates.io-index"
337
checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc"
338
333
339
[[package]]
334
340
name = "arraydeque"
335
341
version = "0.5.1"
@@ -1109,6 +1115,7 @@ dependencies = [
1109
1115
"futures-util",
1110
1116
"image",
1111
1117
"libwebrtc",
1118
"nnnoiseless",
1112
1119
"nokhwa",
1113
1120
"serde",
1114
1121
"serde_json",
@@ -2300,6 +2307,19 @@ version = "1.0.0"
2300
2307
source = "registry+https://github.com/rust-lang/crates.io-index"
2301
2308
checksum = "5fdab65db9274e0168143841eb8f864a0a21f8b1b8d2ba6812bbe6024346e99e"
2302
2309
2310
[[package]]
2311
name = "easyfft"
2312
version = "0.4.2"
2313
source = "registry+https://github.com/rust-lang/crates.io-index"
2314
checksum = "767e39eef2ad8a3b6f1d733be3ec70364d21d437d06d4f18ea76ce08df20b75f"
2315
dependencies = [
2316
"array-init",
2317
"generic_singleton",
2318
"num-complex",
2319
"realfft",
2320
"rustfft",
2321
]
2322
2303
2323
[[package]]
2304
2324
name = "ego-tree"
2305
2325
version = "0.10.0"
@@ -2998,6 +3018,16 @@ dependencies = [
2998
3018
"version_check",
2999
3019
]
3000
3020
3021
[[package]]
3022
name = "generic_singleton"
3023
version = "0.5.3"
3024
source = "registry+https://github.com/rust-lang/crates.io-index"
3025
checksum = "ab6e923c8e978e57cf63e2e200ca967d1d20f0ea2662b28f6d4e11c44aa6ab16"
3026
dependencies = [
3027
"anymap3",
3028
"parking_lot",
3029
]
3030
3001
3031
[[package]]
3002
3032
name = "gethostname"
3003
3033
version = "1.1.0"
@@ -5621,6 +5651,16 @@ version = "1.0.6"
5621
5651
source = "registry+https://github.com/rust-lang/crates.io-index"
5622
5652
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
5623
5653
5654
[[package]]
5655
name = "nnnoiseless"
5656
version = "0.5.2"
5657
source = "registry+https://github.com/rust-lang/crates.io-index"
5658
checksum = "805d5964d1e7a0006a7fdced7dae75084d66d18b35f1dfe81bd76929b1f8da0c"
5659
dependencies = [
5660
"easyfft",
5661
"once_cell",
5662
]
5663
5624
5664
[[package]]
5625
5665
name = "no_std_io2"
5626
5666
version = "0.9.4"
@@ -5853,6 +5893,7 @@ checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
5853
5893
dependencies = [
5854
5894
"bytemuck",
5855
5895
"num-traits",
5896
"serde",
5856
5897
]
5857
5898
5858
5899
[[package]]
@@ -7359,6 +7400,15 @@ dependencies = [
7359
7400
"once_cell",
7360
7401
]
7361
7402
7403
[[package]]
7404
name = "realfft"
7405
version = "3.5.0"
7406
source = "registry+https://github.com/rust-lang/crates.io-index"
7407
checksum = "f821338fddb99d089116342c46e9f1fbf3828dba077674613e734e01d6ea8677"
7408
dependencies = [
7409
"rustfft",
7410
]
7411
7362
7412
[[package]]
7363
7413
name = "reborrow"
7364
7414
version = "0.5.5"
@@ -330,6 +330,12 @@ dependencies = [330
"syn 2.0.119",330
"syn 2.0.119",331
]331
]332
332
333
[[package]]334
name = "array-init"335
version = "2.1.0"336
source = "registry+https://github.com/rust-lang/crates.io-index"337
checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc"338
333
[[package]]339
[[package]]334
name = "arraydeque"340
name = "arraydeque"335
version = "0.5.1"341
version = "0.5.1"@@ -1109,6 +1115,7 @@ dependencies = [1109
"futures-util",1115
"futures-util",1110
"image",1116
"image",1111
"libwebrtc",1117
"libwebrtc",1118
"nnnoiseless",1112
"nokhwa",1119
"nokhwa",1113
"serde",1120
"serde",1114
"serde_json",1121
"serde_json",@@ -2300,6 +2307,19 @@ version = "1.0.0"2300
source = "registry+https://github.com/rust-lang/crates.io-index"2307
source = "registry+https://github.com/rust-lang/crates.io-index"2301
checksum = "5fdab65db9274e0168143841eb8f864a0a21f8b1b8d2ba6812bbe6024346e99e"2308
checksum = "5fdab65db9274e0168143841eb8f864a0a21f8b1b8d2ba6812bbe6024346e99e"2302
2309
2310
[[package]]2311
name = "easyfft"2312
version = "0.4.2"2313
source = "registry+https://github.com/rust-lang/crates.io-index"2314
checksum = "767e39eef2ad8a3b6f1d733be3ec70364d21d437d06d4f18ea76ce08df20b75f"2315
dependencies = [2316
"array-init",2317
"generic_singleton",2318
"num-complex",2319
"realfft",2320
"rustfft",2321
]2322
2303
[[package]]2323
[[package]]2304
name = "ego-tree"2324
name = "ego-tree"2305
version = "0.10.0"2325
version = "0.10.0"@@ -2998,6 +3018,16 @@ dependencies = [2998
"version_check",3018
"version_check",2999
]3019
]3000
3020
3021
[[package]]3022
name = "generic_singleton"3023
version = "0.5.3"3024
source = "registry+https://github.com/rust-lang/crates.io-index"3025
checksum = "ab6e923c8e978e57cf63e2e200ca967d1d20f0ea2662b28f6d4e11c44aa6ab16"3026
dependencies = [3027
"anymap3",3028
"parking_lot",3029
]3030
3001
[[package]]3031
[[package]]3002
name = "gethostname"3032
name = "gethostname"3003
version = "1.1.0"3033
version = "1.1.0"@@ -5621,6 +5651,16 @@ version = "1.0.6"5621
source = "registry+https://github.com/rust-lang/crates.io-index"5651
source = "registry+https://github.com/rust-lang/crates.io-index"5622
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"5652
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"5623
5653
5654
[[package]]5655
name = "nnnoiseless"5656
version = "0.5.2"5657
source = "registry+https://github.com/rust-lang/crates.io-index"5658
checksum = "805d5964d1e7a0006a7fdced7dae75084d66d18b35f1dfe81bd76929b1f8da0c"5659
dependencies = [5660
"easyfft",5661
"once_cell",5662
]5663
5624
[[package]]5664
[[package]]5625
name = "no_std_io2"5665
name = "no_std_io2"5626
version = "0.9.4"5666
version = "0.9.4"@@ -5853,6 +5893,7 @@ checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"5853
dependencies = [5893
dependencies = [5854
"bytemuck",5894
"bytemuck",5855
"num-traits",5895
"num-traits",5896
"serde",5856
]5897
]5857
5898
5858
[[package]]5899
[[package]]@@ -7359,6 +7400,15 @@ dependencies = [7359
"once_cell",7400
"once_cell",7360
]7401
]7361
7402
7403
[[package]]7404
name = "realfft"7405
version = "3.5.0"7406
source = "registry+https://github.com/rust-lang/crates.io-index"7407
checksum = "f821338fddb99d089116342c46e9f1fbf3828dba077674613e734e01d6ea8677"7408
dependencies = [7409
"rustfft",7410
]7411
7362
[[package]]7412
[[package]]7363
name = "reborrow"7413
name = "reborrow"7364
version = "0.5.5"7414
version = "0.5.5"@@ -180,7 +180,7 @@ Feature parity with the Microsoft Teams desktop client.
180
180
| Recording | Done | Organizer "..." > Record and transcribe: Start recording, Record audio only, Start transcription only; Stop recording / Stop transcription / Stop both (confirm) through the recorder bot; header chip red "Recording" / "Recording audio" or blue "Transcribing" for everyone from the meeting state, consent notice that keeps mic and camera off until OK. Bodies unit tested; video, audio only, transcription only and every stop variant run live; a stop sent while the recorder still settles is retried. Consent needs a tenant with the policy on |
181
181
| Meeting recap tab | Partial | Recap in meeting chats with a recording: occurrence picker, recording card (duration, Audio only, expiry amber under 7 days), Play in the browser, Download with save dialog and percent, organizer Delete with confirm, searchable read-only transcript with .vtt and .docx download, attendance (muted note when the tenant has reports off), files shared in the chat. Parsing and expiry unit tested, demo checked; occurrences, details and delete run live against real recordings. Transcription-only sessions (item media source `Transcript`) show the transcript without a recording card. "Audio only" comes from the chat event (`videoContent="CurtainOnly"`), with the video size check as fallback. Both signals read live on real recordings, fixtures unit tested; the transcript-only path was not run live |
182
182
| Hold, resume, transfer | Partial | 1:1 "..." > Hold renegotiates every line inactive, "On hold" view with Resume, "You're on hold" when the other side holds, Transfer... person picker with Transfer now (blind) and Consult first (second call, first held, Transfer now). Needs a second person; redirect and park not built |
183
| Noise suppression, music mode | Partial | Mic menu and Settings > Devices: Auto (device track with WebRTC echo cancellation, AGC, NS) or Off, Music mode keeps echo cancellation only. No Low/High, the APM has on/off flags only. Off and Music mode run a cpal mic through our own APM; checked with synthetic sources only, not with a real mic in a call |
183
| Noise suppression, music mode | Partial | Mic menu and Settings > Devices: Auto (device track with WebRTC echo cancellation, AGC, NS plus RNNoise ML suppression), Low (same without RNNoise) or Off, Music mode keeps echo cancellation only. No High level. Off and Music mode run a cpal mic through our own APM; checked with synthetic sources only, not with a real mic in a call |
184
184
| Push to talk | Partial | Hold Ctrl+Space while muted to talk, release to mute; main window focused, not inside text fields; hint chip on the stage. Unit tested, not tried on the Windows build |
185
185
| Breakout rooms (participant) | Partial | Move message from the participant update or the replacement invite: notice "Moving you to <room>", leave and join the room, "Return to main meeting" in the header, a closed room goes back to the main meeting. Parsing unit tested; needs an organizer who moves people |
186
186
| Call health and encryption | Partial | Header shows signal bars and a shield; click opens "Call health" with loss, round trip, jitter, bitrate, "Secured by Teams encryption", DTLS-SRTP cipher and media path (direct or via Microsoft media server). Unstable network banner with "Turn off incoming video", overloaded computer banner with "Turn off effects". Thresholds unit tested; not yet seen on a bad live network |
@@ -180,7 +180,7 @@ Feature parity with the Microsoft Teams desktop client.180
| Recording | Done | Organizer "..." > Record and transcribe: Start recording, Record audio only, Start transcription only; Stop recording / Stop transcription / Stop both (confirm) through the recorder bot; header chip red "Recording" / "Recording audio" or blue "Transcribing" for everyone from the meeting state, consent notice that keeps mic and camera off until OK. Bodies unit tested; video, audio only, transcription only and every stop variant run live; a stop sent while the recorder still settles is retried. Consent needs a tenant with the policy on |180
| Recording | Done | Organizer "..." > Record and transcribe: Start recording, Record audio only, Start transcription only; Stop recording / Stop transcription / Stop both (confirm) through the recorder bot; header chip red "Recording" / "Recording audio" or blue "Transcribing" for everyone from the meeting state, consent notice that keeps mic and camera off until OK. Bodies unit tested; video, audio only, transcription only and every stop variant run live; a stop sent while the recorder still settles is retried. Consent needs a tenant with the policy on |181
| Meeting recap tab | Partial | Recap in meeting chats with a recording: occurrence picker, recording card (duration, Audio only, expiry amber under 7 days), Play in the browser, Download with save dialog and percent, organizer Delete with confirm, searchable read-only transcript with .vtt and .docx download, attendance (muted note when the tenant has reports off), files shared in the chat. Parsing and expiry unit tested, demo checked; occurrences, details and delete run live against real recordings. Transcription-only sessions (item media source `Transcript`) show the transcript without a recording card. "Audio only" comes from the chat event (`videoContent="CurtainOnly"`), with the video size check as fallback. Both signals read live on real recordings, fixtures unit tested; the transcript-only path was not run live |181
| Meeting recap tab | Partial | Recap in meeting chats with a recording: occurrence picker, recording card (duration, Audio only, expiry amber under 7 days), Play in the browser, Download with save dialog and percent, organizer Delete with confirm, searchable read-only transcript with .vtt and .docx download, attendance (muted note when the tenant has reports off), files shared in the chat. Parsing and expiry unit tested, demo checked; occurrences, details and delete run live against real recordings. Transcription-only sessions (item media source `Transcript`) show the transcript without a recording card. "Audio only" comes from the chat event (`videoContent="CurtainOnly"`), with the video size check as fallback. Both signals read live on real recordings, fixtures unit tested; the transcript-only path was not run live |182
| Hold, resume, transfer | Partial | 1:1 "..." > Hold renegotiates every line inactive, "On hold" view with Resume, "You're on hold" when the other side holds, Transfer... person picker with Transfer now (blind) and Consult first (second call, first held, Transfer now). Needs a second person; redirect and park not built |182
| Hold, resume, transfer | Partial | 1:1 "..." > Hold renegotiates every line inactive, "On hold" view with Resume, "You're on hold" when the other side holds, Transfer... person picker with Transfer now (blind) and Consult first (second call, first held, Transfer now). Needs a second person; redirect and park not built |183
| Noise suppression, music mode | Partial | Mic menu and Settings > Devices: Auto (device track with WebRTC echo cancellation, AGC, NS) or Off, Music mode keeps echo cancellation only. No Low/High, the APM has on/off flags only. Off and Music mode run a cpal mic through our own APM; checked with synthetic sources only, not with a real mic in a call |183
| Noise suppression, music mode | Partial | Mic menu and Settings > Devices: Auto (device track with WebRTC echo cancellation, AGC, NS plus RNNoise ML suppression), Low (same without RNNoise) or Off, Music mode keeps echo cancellation only. No High level. Off and Music mode run a cpal mic through our own APM; checked with synthetic sources only, not with a real mic in a call |184
| Push to talk | Partial | Hold Ctrl+Space while muted to talk, release to mute; main window focused, not inside text fields; hint chip on the stage. Unit tested, not tried on the Windows build |184
| Push to talk | Partial | Hold Ctrl+Space while muted to talk, release to mute; main window focused, not inside text fields; hint chip on the stage. Unit tested, not tried on the Windows build |185
| Breakout rooms (participant) | Partial | Move message from the participant update or the replacement invite: notice "Moving you to <room>", leave and join the room, "Return to main meeting" in the header, a closed room goes back to the main meeting. Parsing unit tested; needs an organizer who moves people |185
| Breakout rooms (participant) | Partial | Move message from the participant update or the replacement invite: notice "Moving you to <room>", leave and join the room, "Return to main meeting" in the header, a closed room goes back to the main meeting. Parsing unit tested; needs an organizer who moves people |186
| Call health and encryption | Partial | Header shows signal bars and a shield; click opens "Call health" with loss, round trip, jitter, bitrate, "Secured by Teams encryption", DTLS-SRTP cipher and media path (direct or via Microsoft media server). Unstable network banner with "Turn off incoming video", overloaded computer banner with "Turn off effects". Thresholds unit tested; not yet seen on a bad live network |186
| Call health and encryption | Partial | Header shows signal bars and a shield; click opens "Call health" with loss, round trip, jitter, bitrate, "Secured by Teams encryption", DTLS-SRTP cipher and media path (direct or via Microsoft media server). Unstable network banner with "Turn off incoming video", overloaded computer banner with "Turn off effects". Thresholds unit tested; not yet seen on a bad live network |@@ -51,6 +51,17 @@ mod tests {
51
51
assert_eq!(parse(&serialize(settings)), settings);
52
52
}
53
53
54
#[test]
55
fn every_noise_level_round_trips() {
56
for noise_suppression in NoiseSuppression::ALL {
57
let settings = MicSettings {
58
noise_suppression,
59
music_mode: false,
60
};
61
assert_eq!(parse(&serialize(settings)), settings);
62
}
63
}
64
54
65
#[test]
55
66
fn garbage_gives_defaults() {
56
67
assert_eq!(parse(""), MicSettings::default());
@@ -51,6 +51,17 @@ mod tests {51
assert_eq!(parse(&serialize(settings)), settings);51
assert_eq!(parse(&serialize(settings)), settings);52
}52
}53
53
54
#[test]55
fn every_noise_level_round_trips() {56
for noise_suppression in NoiseSuppression::ALL {57
let settings = MicSettings {58
noise_suppression,59
music_mode: false,60
};61
assert_eq!(parse(&serialize(settings)), settings);62
}63
}64
54
#[test]65
#[test]55
fn garbage_gives_defaults() {66
fn garbage_gives_defaults() {56
assert_eq!(parse(""), MicSettings::default());67
assert_eq!(parse(""), MicSettings::default());@@ -14,6 +14,7 @@ flate2 = "1"
14
14
image = { version = "0.25", default-features = false, features = ["jpeg", "png"] }
15
15
futures-util.workspace = true
16
16
libwebrtc = { version = "=0.3.51", features = ["glib-main-loop"] }
17
nnnoiseless = { version = "0.5", default-features = false }
17
18
nokhwa = { version = "0.10", default-features = false, features = ["input-native"] }
18
19
serde.workspace = true
19
20
webrtc-sys = "=0.3.48"
@@ -14,6 +14,7 @@ flate2 = "1"14
image = { version = "0.25", default-features = false, features = ["jpeg", "png"] }14
image = { version = "0.25", default-features = false, features = ["jpeg", "png"] }15
futures-util.workspace = true15
futures-util.workspace = true16
libwebrtc = { version = "=0.3.51", features = ["glib-main-loop"] }16
libwebrtc = { version = "=0.3.51", features = ["glib-main-loop"] }17
nnnoiseless = { version = "0.5", default-features = false }17
nokhwa = { version = "0.10", default-features = false, features = ["input-native"] }18
nokhwa = { version = "0.10", default-features = false, features = ["input-native"] }18
serde.workspace = true19
serde.workspace = true19
webrtc-sys = "=0.3.48"20
webrtc-sys = "=0.3.48"@@ -829,6 +829,7 @@ async fn drive(
829
829
let mut software_audio: Option<SoftwareAudio> = None;
830
830
let mut share_sound_wanted = false;
831
831
let mut mic_settings = MicSettings::default();
832
crate::noise_stage::apply(mic_settings);
832
833
let mut audio_disabled = false;
833
834
let mut remote_audio: Option<RtcAudioTrack> = None;
834
835
let mut own_hand: Option<String> = None;
@@ -1349,9 +1350,13 @@ async fn drive(
1349
1350
}
1350
1351
Some(CallCommand::SetMicSettings(settings)) if !audio_disabled => {
1351
1352
mic_settings = settings;
1353
crate::noise_stage::apply(mic_settings);
1352
1354
sync_software_audio(&factory, options, &input, muted, remote_audio.clone(), ¤t.peer, &track, software_wanted(mic_settings, share_sound_wanted, &local_video, live.audio.as_ref()), false, &mut software_audio, control, timeline);
1353
1355
}
1354
Some(CallCommand::SetMicSettings(settings)) => mic_settings = settings,
1356
Some(CallCommand::SetMicSettings(settings)) => {
1357
mic_settings = settings;
1358
crate::noise_stage::apply(mic_settings);
1359
}
1355
1360
Some(CallCommand::SelectOutput(choice)) => {
1356
1361
if live.audio.as_ref().is_some_and(AudioSetup::uses_devices) {
1357
1362
timeline.record("output device", format!("{choice:?} applied={}", devices::select_output(&factory, &choice)));
@@ -829,6 +829,7 @@ async fn drive(829
let mut software_audio: Option<SoftwareAudio> = None;829
let mut software_audio: Option<SoftwareAudio> = None;830
let mut share_sound_wanted = false;830
let mut share_sound_wanted = false;831
let mut mic_settings = MicSettings::default();831
let mut mic_settings = MicSettings::default();832
crate::noise_stage::apply(mic_settings);832
let mut audio_disabled = false;833
let mut audio_disabled = false;833
let mut remote_audio: Option<RtcAudioTrack> = None;834
let mut remote_audio: Option<RtcAudioTrack> = None;834
let mut own_hand: Option<String> = None;835
let mut own_hand: Option<String> = None;@@ -1349,9 +1350,13 @@ async fn drive(1349
}1350
}1350
Some(CallCommand::SetMicSettings(settings)) if !audio_disabled => {1351
Some(CallCommand::SetMicSettings(settings)) if !audio_disabled => {1351
mic_settings = settings;1352
mic_settings = settings;1353
crate::noise_stage::apply(mic_settings);1352
sync_software_audio(&factory, options, &input, muted, remote_audio.clone(), ¤t.peer, &track, software_wanted(mic_settings, share_sound_wanted, &local_video, live.audio.as_ref()), false, &mut software_audio, control, timeline);1354
sync_software_audio(&factory, options, &input, muted, remote_audio.clone(), ¤t.peer, &track, software_wanted(mic_settings, share_sound_wanted, &local_video, live.audio.as_ref()), false, &mut software_audio, control, timeline);1353
}1355
}1354
Some(CallCommand::SetMicSettings(settings)) => mic_settings = settings,1356
Some(CallCommand::SetMicSettings(settings)) => {1357
mic_settings = settings;1358
crate::noise_stage::apply(mic_settings);1359
}1355
Some(CallCommand::SelectOutput(choice)) => {1360
Some(CallCommand::SelectOutput(choice)) => {1356
if live.audio.as_ref().is_some_and(AudioSetup::uses_devices) {1361
if live.audio.as_ref().is_some_and(AudioSetup::uses_devices) {1357
timeline.record("output device", format!("{choice:?} applied={}", devices::select_output(&factory, &choice)));1362
timeline.record("output device", format!("{choice:?} applied={}", devices::select_output(&factory, &choice)));@@ -29,6 +29,7 @@ pub mod meeting;
29
29
pub mod meeting_options;
30
30
pub mod mic_processing;
31
31
pub mod mixer;
32
pub mod noise_stage;
32
33
pub mod mute;
33
34
pub mod organizer;
34
35
pub mod pcm;
@@ -29,6 +29,7 @@ pub mod meeting;29
pub mod meeting_options;29
pub mod meeting_options;30
pub mod mic_processing;30
pub mod mic_processing;31
pub mod mixer;31
pub mod mixer;32
pub mod noise_stage;32
pub mod mute;33
pub mod mute;33
pub mod organizer;34
pub mod organizer;34
pub mod pcm;35
pub mod pcm;@@ -4,15 +4,17 @@ use libwebrtc::native::apm::AudioProcessingModule;
4
4
pub enum NoiseSuppression {
5
5
#[default]
6
6
Auto,
7
Low,
7
8
Off,
8
9
}
9
10
10
11
impl NoiseSuppression {
11
pub const ALL: [NoiseSuppression; 2] = [NoiseSuppression::Auto, NoiseSuppression::Off];
12
pub const ALL: [NoiseSuppression; 3] = [NoiseSuppression::Auto, NoiseSuppression::Low, NoiseSuppression::Off];
12
13
13
14
pub fn label(self) -> &'static str {
14
15
match self {
15
16
NoiseSuppression::Auto => "Auto",
17
NoiseSuppression::Low => "Low",
16
18
NoiseSuppression::Off => "Off",
17
19
}
18
20
}
@@ -20,6 +22,7 @@ impl NoiseSuppression {
20
22
pub fn key(self) -> &'static str {
21
23
match self {
22
24
NoiseSuppression::Auto => "auto",
25
NoiseSuppression::Low => "low",
23
26
NoiseSuppression::Off => "off",
24
27
}
25
28
}
@@ -60,12 +63,16 @@ impl MicSettings {
60
63
if self.music_mode {
61
64
return ApmConfig { echo_canceller: true, gain_controller: false, high_pass_filter: false, noise_suppression: false };
62
65
}
63
let on = self.noise_suppression == NoiseSuppression::Auto;
66
let on = self.noise_suppression != NoiseSuppression::Off;
64
67
ApmConfig { echo_canceller: on, gain_controller: on, high_pass_filter: on, noise_suppression: on }
65
68
}
66
69
67
70
pub fn uses_device_track(self) -> bool {
68
self == MicSettings::default()
71
!self.music_mode && self.noise_suppression != NoiseSuppression::Off
72
}
73
74
pub fn ml_noise_suppression(self) -> bool {
75
!self.music_mode && self.noise_suppression == NoiseSuppression::Auto
69
76
}
70
77
}
71
78
@@ -83,6 +90,21 @@ mod tests {
83
90
);
84
91
}
85
92
93
#[test]
94
fn low_keeps_the_device_track_with_the_apm_only() {
95
let settings = MicSettings { noise_suppression: NoiseSuppression::Low, music_mode: false };
96
assert!(settings.uses_device_track());
97
assert!(!settings.ml_noise_suppression());
98
assert_eq!(settings.apm_config(), MicSettings::default().apm_config());
99
}
100
101
#[test]
102
fn only_auto_outside_music_mode_runs_the_ml_stage() {
103
assert!(MicSettings::default().ml_noise_suppression());
104
assert!(!MicSettings { noise_suppression: NoiseSuppression::Off, music_mode: false }.ml_noise_suppression());
105
assert!(!MicSettings { noise_suppression: NoiseSuppression::Auto, music_mode: true }.ml_noise_suppression());
106
}
107
86
108
#[test]
87
109
fn off_leaves_the_device_track_and_processes_nothing() {
88
110
let settings = MicSettings { noise_suppression: NoiseSuppression::Off, music_mode: false };
@@ -109,5 +131,7 @@ mod tests {
109
131
assert_eq!(NoiseSuppression::from_key(level.key()), Some(level));
110
132
}
111
133
assert_eq!(NoiseSuppression::from_key("high"), None);
134
assert_eq!(NoiseSuppression::Low.key(), "low");
135
assert_eq!(NoiseSuppression::Low.label(), "Low");
112
136
}
113
137
}
@@ -4,15 +4,17 @@ use libwebrtc::native::apm::AudioProcessingModule;4
pub enum NoiseSuppression {4
pub enum NoiseSuppression {5
#[default]5
#[default]6
Auto,6
Auto,7
Low,7
Off,8
Off,8
}9
}9
10
10
impl NoiseSuppression {11
impl NoiseSuppression {11
pub const ALL: [NoiseSuppression; 2] = [NoiseSuppression::Auto, NoiseSuppression::Off];12
pub const ALL: [NoiseSuppression; 3] = [NoiseSuppression::Auto, NoiseSuppression::Low, NoiseSuppression::Off];12
13
13
pub fn label(self) -> &'static str {14
pub fn label(self) -> &'static str {14
match self {15
match self {15
NoiseSuppression::Auto => "Auto",16
NoiseSuppression::Auto => "Auto",17
NoiseSuppression::Low => "Low",16
NoiseSuppression::Off => "Off",18
NoiseSuppression::Off => "Off",17
}19
}18
}20
}@@ -20,6 +22,7 @@ impl NoiseSuppression {20
pub fn key(self) -> &'static str {22
pub fn key(self) -> &'static str {21
match self {23
match self {22
NoiseSuppression::Auto => "auto",24
NoiseSuppression::Auto => "auto",25
NoiseSuppression::Low => "low",23
NoiseSuppression::Off => "off",26
NoiseSuppression::Off => "off",24
}27
}25
}28
}@@ -60,12 +63,16 @@ impl MicSettings {60
if self.music_mode {63
if self.music_mode {61
return ApmConfig { echo_canceller: true, gain_controller: false, high_pass_filter: false, noise_suppression: false };64
return ApmConfig { echo_canceller: true, gain_controller: false, high_pass_filter: false, noise_suppression: false };62
}65
}63
let on = self.noise_suppression == NoiseSuppression::Auto;66
let on = self.noise_suppression != NoiseSuppression::Off;64
ApmConfig { echo_canceller: on, gain_controller: on, high_pass_filter: on, noise_suppression: on }67
ApmConfig { echo_canceller: on, gain_controller: on, high_pass_filter: on, noise_suppression: on }65
}68
}66
69
67
pub fn uses_device_track(self) -> bool {70
pub fn uses_device_track(self) -> bool {68
self == MicSettings::default()71
!self.music_mode && self.noise_suppression != NoiseSuppression::Off72
}73
74
pub fn ml_noise_suppression(self) -> bool {75
!self.music_mode && self.noise_suppression == NoiseSuppression::Auto69
}76
}70
}77
}71
78
@@ -83,6 +90,21 @@ mod tests {83
);90
);84
}91
}85
92
93
#[test]94
fn low_keeps_the_device_track_with_the_apm_only() {95
let settings = MicSettings { noise_suppression: NoiseSuppression::Low, music_mode: false };96
assert!(settings.uses_device_track());97
assert!(!settings.ml_noise_suppression());98
assert_eq!(settings.apm_config(), MicSettings::default().apm_config());99
}100
101
#[test]102
fn only_auto_outside_music_mode_runs_the_ml_stage() {103
assert!(MicSettings::default().ml_noise_suppression());104
assert!(!MicSettings { noise_suppression: NoiseSuppression::Off, music_mode: false }.ml_noise_suppression());105
assert!(!MicSettings { noise_suppression: NoiseSuppression::Auto, music_mode: true }.ml_noise_suppression());106
}107
86
#[test]108
#[test]87
fn off_leaves_the_device_track_and_processes_nothing() {109
fn off_leaves_the_device_track_and_processes_nothing() {88
let settings = MicSettings { noise_suppression: NoiseSuppression::Off, music_mode: false };110
let settings = MicSettings { noise_suppression: NoiseSuppression::Off, music_mode: false };@@ -109,5 +131,7 @@ mod tests {109
assert_eq!(NoiseSuppression::from_key(level.key()), Some(level));131
assert_eq!(NoiseSuppression::from_key(level.key()), Some(level));110
}132
}111
assert_eq!(NoiseSuppression::from_key("high"), None);133
assert_eq!(NoiseSuppression::from_key("high"), None);134
assert_eq!(NoiseSuppression::Low.key(), "low");135
assert_eq!(NoiseSuppression::Low.label(), "Low");112
}136
}113
}137
}@@ -0,0 +1,116 @@
1
use std::sync::atomic::{AtomicBool, Ordering};
2
use std::sync::Mutex;
3
4
use nnnoiseless::{DenoiseState, FRAME_SIZE};
5
6
use crate::mic_processing::MicSettings;
7
8
static ENABLED: AtomicBool = AtomicBool::new(false);
9
static STAGE: Mutex<NoiseStage> = Mutex::new(NoiseStage::new());
10
11
pub struct NoiseStage {
12
channels: Vec<Box<DenoiseState<'static>>>,
13
}
14
15
impl NoiseStage {
16
pub const fn new() -> Self {
17
NoiseStage { channels: Vec::new() }
18
}
19
20
pub fn process(&mut self, channel_index: usize, samples: &mut [f32]) {
21
if samples.len() != FRAME_SIZE {
22
return;
23
}
24
while self.channels.len() <= channel_index {
25
self.channels.push(DenoiseState::new());
26
}
27
let input: [f32; FRAME_SIZE] = std::array::from_fn(|index| samples[index]);
28
self.channels[channel_index].process_frame(samples, &input);
29
}
30
}
31
32
impl Default for NoiseStage {
33
fn default() -> Self {
34
NoiseStage::new()
35
}
36
}
37
38
fn process_capture(channel_index: usize, samples: &mut [f32]) {
39
if !ENABLED.load(Ordering::Relaxed) {
40
return;
41
}
42
let mut stage = STAGE.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
43
stage.process(channel_index, samples);
44
}
45
46
pub fn apply(settings: MicSettings) {
47
webrtc_sys::noise_hook::set_capture_hook(Some(process_capture));
48
ENABLED.store(settings.ml_noise_suppression(), Ordering::Relaxed);
49
}
50
51
#[cfg(test)]
52
mod tests {
53
use super::*;
54
55
fn white_noise(frame_len: usize) -> Vec<f32> {
56
let mut state = 0x2545_f491_u32;
57
(0..frame_len)
58
.map(|_| {
59
state ^= state << 13;
60
state ^= state >> 17;
61
state ^= state << 5;
62
(state as f32 / u32::MAX as f32 - 0.5) * 6000.0
63
})
64
.collect()
65
}
66
67
fn energy(samples: &[f32]) -> f32 {
68
samples.iter().map(|sample| sample * sample).sum::<f32>() / samples.len() as f32
69
}
70
71
#[test]
72
fn white_noise_loses_most_of_its_energy() {
73
let mut stage = NoiseStage::new();
74
let mut last_energy_ratio = 1.0;
75
for _ in 0..50 {
76
let mut frame = white_noise(FRAME_SIZE);
77
let before = energy(&frame);
78
stage.process(0, &mut frame);
79
last_energy_ratio = energy(&frame) / before;
80
}
81
assert!(last_energy_ratio < 0.1, "energy ratio {last_energy_ratio}");
82
}
83
84
#[test]
85
fn other_frame_lengths_pass_through_unchanged() {
86
let mut stage = NoiseStage::new();
87
for frame_len in [160, 441, FRAME_SIZE * 2] {
88
let original = white_noise(frame_len);
89
let mut frame = original.clone();
90
stage.process(0, &mut frame);
91
assert_eq!(frame, original);
92
}
93
}
94
95
#[test]
96
fn each_channel_keeps_its_own_state() {
97
let mut stage = NoiseStage::new();
98
let mut frame = white_noise(FRAME_SIZE);
99
stage.process(1, &mut frame);
100
assert_eq!(stage.channels.len(), 2);
101
}
102
103
#[test]
104
fn rnnoise_costs_little_per_ten_ms_frame() {
105
let mut stage = NoiseStage::new();
106
let frames = 500;
107
let started = std::time::Instant::now();
108
for _ in 0..frames {
109
let mut frame = white_noise(FRAME_SIZE);
110
stage.process(0, &mut frame);
111
}
112
let per_frame = started.elapsed() / frames;
113
eprintln!("rnnoise per 10 ms frame (incl. noise generation): {per_frame:?}");
114
assert!(per_frame < std::time::Duration::from_millis(5));
115
}
116
}
@@ -0,0 +1,116 @@1
use std::sync::atomic::{AtomicBool, Ordering};2
use std::sync::Mutex;3
4
use nnnoiseless::{DenoiseState, FRAME_SIZE};5
6
use crate::mic_processing::MicSettings;7
8
static ENABLED: AtomicBool = AtomicBool::new(false);9
static STAGE: Mutex<NoiseStage> = Mutex::new(NoiseStage::new());10
11
pub struct NoiseStage {12
channels: Vec<Box<DenoiseState<'static>>>,13
}14
15
impl NoiseStage {16
pub const fn new() -> Self {17
NoiseStage { channels: Vec::new() }18
}19
20
pub fn process(&mut self, channel_index: usize, samples: &mut [f32]) {21
if samples.len() != FRAME_SIZE {22
return;23
}24
while self.channels.len() <= channel_index {25
self.channels.push(DenoiseState::new());26
}27
let input: [f32; FRAME_SIZE] = std::array::from_fn(|index| samples[index]);28
self.channels[channel_index].process_frame(samples, &input);29
}30
}31
32
impl Default for NoiseStage {33
fn default() -> Self {34
NoiseStage::new()35
}36
}37
38
fn process_capture(channel_index: usize, samples: &mut [f32]) {39
if !ENABLED.load(Ordering::Relaxed) {40
return;41
}42
let mut stage = STAGE.lock().unwrap_or_else(|poisoned| poisoned.into_inner());43
stage.process(channel_index, samples);44
}45
46
pub fn apply(settings: MicSettings) {47
webrtc_sys::noise_hook::set_capture_hook(Some(process_capture));48
ENABLED.store(settings.ml_noise_suppression(), Ordering::Relaxed);49
}50
51
#[cfg(test)]52
mod tests {53
use super::*;54
55
fn white_noise(frame_len: usize) -> Vec<f32> {56
let mut state = 0x2545_f491_u32;57
(0..frame_len)58
.map(|_| {59
state ^= state << 13;60
state ^= state >> 17;61
state ^= state << 5;62
(state as f32 / u32::MAX as f32 - 0.5) * 6000.063
})64
.collect()65
}66
67
fn energy(samples: &[f32]) -> f32 {68
samples.iter().map(|sample| sample * sample).sum::<f32>() / samples.len() as f3269
}70
71
#[test]72
fn white_noise_loses_most_of_its_energy() {73
let mut stage = NoiseStage::new();74
let mut last_energy_ratio = 1.0;75
for _ in 0..50 {76
let mut frame = white_noise(FRAME_SIZE);77
let before = energy(&frame);78
stage.process(0, &mut frame);79
last_energy_ratio = energy(&frame) / before;80
}81
assert!(last_energy_ratio < 0.1, "energy ratio {last_energy_ratio}");82
}83
84
#[test]85
fn other_frame_lengths_pass_through_unchanged() {86
let mut stage = NoiseStage::new();87
for frame_len in [160, 441, FRAME_SIZE * 2] {88
let original = white_noise(frame_len);89
let mut frame = original.clone();90
stage.process(0, &mut frame);91
assert_eq!(frame, original);92
}93
}94
95
#[test]96
fn each_channel_keeps_its_own_state() {97
let mut stage = NoiseStage::new();98
let mut frame = white_noise(FRAME_SIZE);99
stage.process(1, &mut frame);100
assert_eq!(stage.channels.len(), 2);101
}102
103
#[test]104
fn rnnoise_costs_little_per_ten_ms_frame() {105
let mut stage = NoiseStage::new();106
let frames = 500;107
let started = std::time::Instant::now();108
for _ in 0..frames {109
let mut frame = white_noise(FRAME_SIZE);110
stage.process(0, &mut frame);111
}112
let per_frame = started.elapsed() / frames;113
eprintln!("rnnoise per 10 ms frame (incl. noise generation): {per_frame:?}");114
assert!(per_frame < std::time::Duration::from_millis(5));115
}116
}@@ -9,3 +9,4 @@ Upstream: crates.io `webrtc-sys 0.3.48` (livekit/rust-sdks). Wired in via `[patc
9
9
| `src/adm_proxy.cpp`, `include/livekit/adm_proxy.h` | `Init()` re-inits terminated sub ADMs; `EnsurePlatformAdmCreated()` re-inits a terminated platform ADM; `InitPlatformAdm()` replays transport, devices, observer, stereo; `Terminate()` stops synthetic playout and clears `playing_` / `recording_` | `WebRtcVoiceEngine::Terminate()` terminates the ADM after every call, `Init()` was a no-op: from the second call on 0 devices, no mic, no sound |
10
10
| `src/adm_proxy.cpp` | `BuiltInAECIsAvailable()` returns false on Windows | the voice capture DMO fails `StartRecording` ("Playout must be started before recording") when no remote audio plays yet - mic silent for the whole call (seen in the app log 2026-10-13) |
11
11
| `src/adm_proxy.cpp`, `include/livekit/adm_proxy.h` | `SetPlayoutDevice` / `SetRecordingDevice(WindowsDeviceType)` turn `kDefaultCommunicationDevice` into `kDefaultDevice` | `WebRtcVoiceEngine::Init` selects the communications default at every call start; the app's "Default device" means the Windows default device (seen 2026-10-14: speaker came up on the communications default, user picked the default device by hand every call) |
12
| `src/noise_hook.rs`, `src/noise_hook.cpp`, `include/livekit/noise_hook.h`, `build.rs`, `src/lib.rs`, `src/peer_connection_factory.cpp` | The factory's APM gets a capture post processor that calls a Rust hook (`noise_hook::set_capture_hook`) on the full-band capture buffer | ML noise suppression (RNNoise) on the device track, keeping echo cancellation on the real playout reference |
@@ -9,3 +9,4 @@ Upstream: crates.io `webrtc-sys 0.3.48` (livekit/rust-sdks). Wired in via `[patc9
| `src/adm_proxy.cpp`, `include/livekit/adm_proxy.h` | `Init()` re-inits terminated sub ADMs; `EnsurePlatformAdmCreated()` re-inits a terminated platform ADM; `InitPlatformAdm()` replays transport, devices, observer, stereo; `Terminate()` stops synthetic playout and clears `playing_` / `recording_` | `WebRtcVoiceEngine::Terminate()` terminates the ADM after every call, `Init()` was a no-op: from the second call on 0 devices, no mic, no sound |9
| `src/adm_proxy.cpp`, `include/livekit/adm_proxy.h` | `Init()` re-inits terminated sub ADMs; `EnsurePlatformAdmCreated()` re-inits a terminated platform ADM; `InitPlatformAdm()` replays transport, devices, observer, stereo; `Terminate()` stops synthetic playout and clears `playing_` / `recording_` | `WebRtcVoiceEngine::Terminate()` terminates the ADM after every call, `Init()` was a no-op: from the second call on 0 devices, no mic, no sound |10
| `src/adm_proxy.cpp` | `BuiltInAECIsAvailable()` returns false on Windows | the voice capture DMO fails `StartRecording` ("Playout must be started before recording") when no remote audio plays yet - mic silent for the whole call (seen in the app log 2026-10-13) |10
| `src/adm_proxy.cpp` | `BuiltInAECIsAvailable()` returns false on Windows | the voice capture DMO fails `StartRecording` ("Playout must be started before recording") when no remote audio plays yet - mic silent for the whole call (seen in the app log 2026-10-13) |11
| `src/adm_proxy.cpp`, `include/livekit/adm_proxy.h` | `SetPlayoutDevice` / `SetRecordingDevice(WindowsDeviceType)` turn `kDefaultCommunicationDevice` into `kDefaultDevice` | `WebRtcVoiceEngine::Init` selects the communications default at every call start; the app's "Default device" means the Windows default device (seen 2026-10-14: speaker came up on the communications default, user picked the default device by hand every call) |11
| `src/adm_proxy.cpp`, `include/livekit/adm_proxy.h` | `SetPlayoutDevice` / `SetRecordingDevice(WindowsDeviceType)` turn `kDefaultCommunicationDevice` into `kDefaultDevice` | `WebRtcVoiceEngine::Init` selects the communications default at every call start; the app's "Default device" means the Windows default device (seen 2026-10-14: speaker came up on the communications default, user picked the default device by hand every call) |12
| `src/noise_hook.rs`, `src/noise_hook.cpp`, `include/livekit/noise_hook.h`, `build.rs`, `src/lib.rs`, `src/peer_connection_factory.cpp` | The factory's APM gets a capture post processor that calls a Rust hook (`noise_hook::set_capture_hook`) on the full-band capture buffer | ML noise suppression (RNNoise) on the device track, keeping echo cancellation on the real playout reference |@@ -54,6 +54,7 @@ fn main() {
54
54
"src/android.rs",
55
55
"src/prohibit_libsrtp_initialization.rs",
56
56
"src/apm.rs",
57
"src/noise_hook.rs",
57
58
"src/audio_mixer.rs",
58
59
"src/packet_trailer.rs",
59
60
];
@@ -95,6 +96,7 @@ fn main() {
95
96
"src/global_task_queue.cpp",
96
97
"src/prohibit_libsrtp_initialization.cpp",
97
98
"src/apm.cpp",
99
"src/noise_hook.cpp",
98
100
"src/audio_mixer.cpp",
99
101
"src/av1_bitstream.cpp",
100
102
"src/packet_trailer.cpp",
@@ -54,6 +54,7 @@ fn main() {54
"src/android.rs",54
"src/android.rs",55
"src/prohibit_libsrtp_initialization.rs",55
"src/prohibit_libsrtp_initialization.rs",56
"src/apm.rs",56
"src/apm.rs",57
"src/noise_hook.rs",57
"src/audio_mixer.rs",58
"src/audio_mixer.rs",58
"src/packet_trailer.rs",59
"src/packet_trailer.rs",59
];60
];@@ -95,6 +96,7 @@ fn main() {95
"src/global_task_queue.cpp",96
"src/global_task_queue.cpp",96
"src/prohibit_libsrtp_initialization.cpp",97
"src/prohibit_libsrtp_initialization.cpp",97
"src/apm.cpp",98
"src/apm.cpp",99
"src/noise_hook.cpp",98
"src/audio_mixer.cpp",100
"src/audio_mixer.cpp",99
"src/av1_bitstream.cpp",101
"src/av1_bitstream.cpp",100
"src/packet_trailer.cpp",102
"src/packet_trailer.cpp",@@ -0,0 +1,11 @@
1
#pragma once
2
3
#include <memory>
4
5
#include "api/audio/audio_processing.h"
6
7
namespace livekit_ffi {
8
9
std::unique_ptr<webrtc::CustomProcessing> create_capture_post_processor();
10
11
} // namespace livekit_ffi
@@ -0,0 +1,11 @@1
#pragma once2
3
#include <memory>4
5
#include "api/audio/audio_processing.h"6
7
namespace livekit_ffi {8
9
std::unique_ptr<webrtc::CustomProcessing> create_capture_post_processor();10
11
} // namespace livekit_ffi@@ -15,6 +15,7 @@
15
15
#[cfg(target_os = "android")]
16
16
pub mod android;
17
17
pub mod apm;
18
pub mod noise_hook;
18
19
pub mod audio_device_controller;
19
20
pub mod audio_mixer;
20
21
pub mod audio_resampler;
@@ -15,6 +15,7 @@15
#[cfg(target_os = "android")]15
#[cfg(target_os = "android")]16
pub mod android;16
pub mod android;17
pub mod apm;17
pub mod apm;18
pub mod noise_hook;18
pub mod audio_device_controller;19
pub mod audio_device_controller;19
pub mod audio_mixer;20
pub mod audio_mixer;20
pub mod audio_resampler;21
pub mod audio_resampler;@@ -0,0 +1,36 @@
1
#include "livekit/noise_hook.h"
2
3
#include <string>
4
5
#include "modules/audio_processing/audio_buffer.h"
6
#include "rust/cxx.h"
7
#include "webrtc-sys/src/noise_hook.rs.h"
8
9
namespace livekit_ffi {
10
11
namespace {
12
13
class CapturePostProcessor : public webrtc::CustomProcessing {
14
public:
15
void Initialize(int sample_rate_hz, int num_channels) override {}
16
17
void Process(webrtc::AudioBuffer* audio) override {
18
for (size_t channel = 0; channel < audio->num_channels(); ++channel) {
19
capture_post_process(
20
channel,
21
rust::Slice<float>(audio->channels()[channel], audio->num_frames()));
22
}
23
}
24
25
std::string ToString() const override { return "livekit_capture_post_processor"; }
26
27
void SetRuntimeSetting(webrtc::AudioProcessing::RuntimeSetting setting) override {}
28
};
29
30
} // namespace
31
32
std::unique_ptr<webrtc::CustomProcessing> create_capture_post_processor() {
33
return std::make_unique<CapturePostProcessor>();
34
}
35
36
} // namespace livekit_ffi
@@ -0,0 +1,36 @@1
#include "livekit/noise_hook.h"2
3
#include <string>4
5
#include "modules/audio_processing/audio_buffer.h"6
#include "rust/cxx.h"7
#include "webrtc-sys/src/noise_hook.rs.h"8
9
namespace livekit_ffi {10
11
namespace {12
13
class CapturePostProcessor : public webrtc::CustomProcessing {14
public:15
void Initialize(int sample_rate_hz, int num_channels) override {}16
17
void Process(webrtc::AudioBuffer* audio) override {18
for (size_t channel = 0; channel < audio->num_channels(); ++channel) {19
capture_post_process(20
channel,21
rust::Slice<float>(audio->channels()[channel], audio->num_frames()));22
}23
}24
25
std::string ToString() const override { return "livekit_capture_post_processor"; }26
27
void SetRuntimeSetting(webrtc::AudioProcessing::RuntimeSetting setting) override {}28
};29
30
} // namespace31
32
std::unique_ptr<webrtc::CustomProcessing> create_capture_post_processor() {33
return std::make_unique<CapturePostProcessor>();34
}35
36
} // namespace livekit_ffi@@ -0,0 +1,23 @@
1
use std::sync::RwLock;
2
3
pub type CaptureHook = fn(channel_index: usize, samples: &mut [f32]);
4
5
static CAPTURE_HOOK: RwLock<Option<CaptureHook>> = RwLock::new(None);
6
7
pub fn set_capture_hook(hook: Option<CaptureHook>) {
8
*CAPTURE_HOOK.write().unwrap_or_else(|poisoned| poisoned.into_inner()) = hook;
9
}
10
11
fn capture_post_process(channel_index: usize, samples: &mut [f32]) {
12
let hook = *CAPTURE_HOOK.read().unwrap_or_else(|poisoned| poisoned.into_inner());
13
if let Some(hook) = hook {
14
hook(channel_index, samples);
15
}
16
}
17
18
#[cxx::bridge(namespace = "livekit_ffi")]
19
pub mod ffi {
20
extern "Rust" {
21
fn capture_post_process(channel_index: usize, samples: &mut [f32]);
22
}
23
}
@@ -0,0 +1,23 @@1
use std::sync::RwLock;2
3
pub type CaptureHook = fn(channel_index: usize, samples: &mut [f32]);4
5
static CAPTURE_HOOK: RwLock<Option<CaptureHook>> = RwLock::new(None);6
7
pub fn set_capture_hook(hook: Option<CaptureHook>) {8
*CAPTURE_HOOK.write().unwrap_or_else(|poisoned| poisoned.into_inner()) = hook;9
}10
11
fn capture_post_process(channel_index: usize, samples: &mut [f32]) {12
let hook = *CAPTURE_HOOK.read().unwrap_or_else(|poisoned| poisoned.into_inner());13
if let Some(hook) = hook {14
hook(channel_index, samples);15
}16
}17
18
#[cxx::bridge(namespace = "livekit_ffi")]19
pub mod ffi {20
extern "Rust" {21
fn capture_post_process(channel_index: usize, samples: &mut [f32]);22
}23
}@@ -37,6 +37,7 @@
37
37
#include "api/audio_options.h"
38
38
#include "livekit/adm_proxy.h"
39
39
#include "livekit/audio_track.h"
40
#include "livekit/noise_hook.h"
40
41
#include "livekit/peer_connection.h"
41
42
#include "livekit/rtc_error.h"
42
43
#include "livekit/rtp_parameters.h"
@@ -192,7 +193,10 @@ PeerConnectionFactory::PeerConnectionFactory(
192
193
std::move(std::make_unique<livekit_ffi::VideoDecoderFactory>());
193
194
dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();
194
195
dependencies.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory();
195
dependencies.audio_processing_builder = std::make_unique<webrtc::BuiltinAudioProcessingBuilder>();
196
auto audio_processing_builder = std::make_unique<webrtc::BuiltinAudioProcessingBuilder>();
197
audio_processing_builder->SetCapturePostProcessing(
198
livekit_ffi::create_capture_post_processor());
199
dependencies.audio_processing_builder = std::move(audio_processing_builder);
196
200
197
201
webrtc::EnableMedia(dependencies);
198
202
peer_factory_ =
@@ -37,6 +37,7 @@37
#include "api/audio_options.h"37
#include "api/audio_options.h"38
#include "livekit/adm_proxy.h"38
#include "livekit/adm_proxy.h"39
#include "livekit/audio_track.h"39
#include "livekit/audio_track.h"40
#include "livekit/noise_hook.h"40
#include "livekit/peer_connection.h"41
#include "livekit/peer_connection.h"41
#include "livekit/rtc_error.h"42
#include "livekit/rtc_error.h"42
#include "livekit/rtp_parameters.h"43
#include "livekit/rtp_parameters.h"@@ -192,7 +193,10 @@ PeerConnectionFactory::PeerConnectionFactory(192
std::move(std::make_unique<livekit_ffi::VideoDecoderFactory>());193
std::move(std::make_unique<livekit_ffi::VideoDecoderFactory>());193
dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();194
dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();194
dependencies.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory();195
dependencies.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory();195
dependencies.audio_processing_builder = std::make_unique<webrtc::BuiltinAudioProcessingBuilder>();196
auto audio_processing_builder = std::make_unique<webrtc::BuiltinAudioProcessingBuilder>();197
audio_processing_builder->SetCapturePostProcessing(198
livekit_ffi::create_capture_post_processor());199
dependencies.audio_processing_builder = std::move(audio_processing_builder);196
200
197
webrtc::EnableMedia(dependencies);201
webrtc::EnableMedia(dependencies);198
peer_factory_ =202
peer_factory_ =