Add support for toggling noise suppression effect on Android
Change-Id: I4868bd6531bde08c4108b0941086add210660dcb Bug: b/279738239 Change-Id: I4868bd6531bde08c4108b0941086add210660dcb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/318320 Reviewed-by: Xavier Lepaul <xalep@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40672}
This commit is contained in:
parent
fe57cecdfe
commit
9acda0b8ac
@ -35,4 +35,12 @@ public interface AudioDeviceModule {
|
||||
|
||||
/** Control muting/unmuting the microphone. */
|
||||
void setMicrophoneMute(boolean mute);
|
||||
|
||||
/**
|
||||
* Enable or disable built in noise suppressor. Returns true if the enabling was successful,
|
||||
* otherwise false is returned.
|
||||
*/
|
||||
default boolean setNoiseSuppressorEnabled(boolean enabled) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,6 +418,12 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
audioInput.setMicrophoneMute(mute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setNoiseSuppressorEnabled(boolean enabled) {
|
||||
Logging.d(TAG, "setNoiseSuppressorEnabled: " + enabled);
|
||||
return audioInput.setNoiseSuppressorEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start to prefer a specific {@link AudioDeviceInfo} device for recording. Typically this should
|
||||
* only be used if a client gives an explicit option for choosing a physical device to record
|
||||
|
||||
@ -104,6 +104,19 @@ class WebRtcAudioEffects {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Toggles an existing NoiseSuppressor to be enabled or disabled.
|
||||
// Returns true if the toggling was successful, otherwise false is returned (this is also the case
|
||||
// if no NoiseSuppressor was present).
|
||||
public boolean toggleNS(boolean enable) {
|
||||
if (ns == null) {
|
||||
Logging.e(TAG, "Attempting to enable or disable nonexistent NoiseSuppressor.");
|
||||
return false;
|
||||
}
|
||||
Logging.d(TAG, "toggleNS(" + enable + ")");
|
||||
boolean toggling_succeeded = ns.setEnabled(enable) == AudioEffect.SUCCESS;
|
||||
return toggling_succeeded;
|
||||
}
|
||||
|
||||
public void enable(int audioSession) {
|
||||
Logging.d(TAG, "enable(audioSession=" + audioSession + ")");
|
||||
assertTrue(aec == null);
|
||||
|
||||
@ -511,6 +511,18 @@ class WebRtcAudioRecord {
|
||||
microphoneMute = mute;
|
||||
}
|
||||
|
||||
// Sets whether NoiseSuppressor should be enabled or disabled.
|
||||
// Returns true if the enabling was successful, otherwise false is returned (this is also the case
|
||||
// if the NoiseSuppressor effect is not supported).
|
||||
public boolean setNoiseSuppressorEnabled(boolean enabled) {
|
||||
if (!WebRtcAudioEffects.isNoiseSuppressorSupported()) {
|
||||
Logging.e(TAG, "Noise suppressor is not supported.");
|
||||
return false;
|
||||
}
|
||||
Logging.w(TAG, "SetNoiseSuppressorEnabled(" + enabled + ")");
|
||||
return effects.toggleNS(enabled);
|
||||
}
|
||||
|
||||
// Releases the native AudioRecord resources.
|
||||
private void releaseAudioResources() {
|
||||
Logging.d(TAG, "releaseAudioResources");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user