Add an option to disable built-in AEC to AppRTC Android Demo
BUG=webrtc:5923 Review-Url: https://codereview.webrtc.org/2002093002 Cr-Commit-Position: refs/heads/master@{#12885}
This commit is contained in:
@ -117,6 +117,12 @@
|
|||||||
<string name="pref_opensles_dlg">Use OpenSL ES for audio playback.</string>
|
<string name="pref_opensles_dlg">Use OpenSL ES for audio playback.</string>
|
||||||
<string name="pref_opensles_default">false</string>
|
<string name="pref_opensles_default">false</string>
|
||||||
|
|
||||||
|
<string name="pref_disable_built_in_aec_key">disable_built_in_aec_preference</string>
|
||||||
|
<string name="pref_disable_built_in_aec_title">Disable built-in AEC.</string>
|
||||||
|
<string name="pref_disable_built_in_aec_dlg">Disable built-in AEC.</string>
|
||||||
|
<string name="pref_disable_built_in_aec_default">false</string>
|
||||||
|
<string name="pref_built_in_aec_not_available">Built-in AEC is not available</string>
|
||||||
|
|
||||||
<string name="pref_miscsettings_key">misc_settings_key</string>
|
<string name="pref_miscsettings_key">misc_settings_key</string>
|
||||||
<string name="pref_miscsettings_title">Miscellaneous settings.</string>
|
<string name="pref_miscsettings_title">Miscellaneous settings.</string>
|
||||||
|
|
||||||
|
|||||||
@ -112,6 +112,12 @@
|
|||||||
android:title="@string/pref_opensles_title"
|
android:title="@string/pref_opensles_title"
|
||||||
android:dialogTitle="@string/pref_opensles_dlg"
|
android:dialogTitle="@string/pref_opensles_dlg"
|
||||||
android:defaultValue="@string/pref_opensles_default" />
|
android:defaultValue="@string/pref_opensles_default" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="@string/pref_disable_built_in_aec_key"
|
||||||
|
android:title="@string/pref_disable_built_in_aec_title"
|
||||||
|
android:dialogTitle="@string/pref_disable_built_in_aec_dlg"
|
||||||
|
android:defaultValue="@string/pref_disable_built_in_aec_default" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|||||||
@ -78,6 +78,8 @@ public class CallActivity extends Activity
|
|||||||
"org.appspot.apprtc.AECDUMP";
|
"org.appspot.apprtc.AECDUMP";
|
||||||
public static final String EXTRA_OPENSLES_ENABLED =
|
public static final String EXTRA_OPENSLES_ENABLED =
|
||||||
"org.appspot.apprtc.OPENSLES";
|
"org.appspot.apprtc.OPENSLES";
|
||||||
|
public static final String EXTRA_DISABLE_BUILT_IN_AEC =
|
||||||
|
"org.appspot.apprtc.DISABLE_BUILT_IN_AEC";
|
||||||
public static final String EXTRA_DISPLAY_HUD =
|
public static final String EXTRA_DISPLAY_HUD =
|
||||||
"org.appspot.apprtc.DISPLAY_HUD";
|
"org.appspot.apprtc.DISPLAY_HUD";
|
||||||
public static final String EXTRA_TRACING = "org.appspot.apprtc.TRACING";
|
public static final String EXTRA_TRACING = "org.appspot.apprtc.TRACING";
|
||||||
@ -234,7 +236,8 @@ public class CallActivity extends Activity
|
|||||||
intent.getStringExtra(EXTRA_AUDIOCODEC),
|
intent.getStringExtra(EXTRA_AUDIOCODEC),
|
||||||
intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false),
|
intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false),
|
||||||
intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false),
|
intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false),
|
||||||
intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false));
|
intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false),
|
||||||
|
intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false));
|
||||||
commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false);
|
commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false);
|
||||||
runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0);
|
runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0);
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,7 @@ public class ConnectActivity extends Activity {
|
|||||||
private String keyprefNoAudioProcessingPipeline;
|
private String keyprefNoAudioProcessingPipeline;
|
||||||
private String keyprefAecDump;
|
private String keyprefAecDump;
|
||||||
private String keyprefOpenSLES;
|
private String keyprefOpenSLES;
|
||||||
|
private String keyprefDisableBuiltInAec;
|
||||||
private String keyprefDisplayHud;
|
private String keyprefDisplayHud;
|
||||||
private String keyprefTracing;
|
private String keyprefTracing;
|
||||||
private String keyprefRoomServerUrl;
|
private String keyprefRoomServerUrl;
|
||||||
@ -99,6 +100,7 @@ public class ConnectActivity extends Activity {
|
|||||||
keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
|
keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
|
||||||
keyprefAecDump = getString(R.string.pref_aecdump_key);
|
keyprefAecDump = getString(R.string.pref_aecdump_key);
|
||||||
keyprefOpenSLES = getString(R.string.pref_opensles_key);
|
keyprefOpenSLES = getString(R.string.pref_opensles_key);
|
||||||
|
keyprefDisableBuiltInAec = getString(R.string.pref_disable_built_in_aec_key);
|
||||||
keyprefDisplayHud = getString(R.string.pref_displayhud_key);
|
keyprefDisplayHud = getString(R.string.pref_displayhud_key);
|
||||||
keyprefTracing = getString(R.string.pref_tracing_key);
|
keyprefTracing = getString(R.string.pref_tracing_key);
|
||||||
keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
|
keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
|
||||||
@ -286,6 +288,11 @@ public class ConnectActivity extends Activity {
|
|||||||
keyprefOpenSLES,
|
keyprefOpenSLES,
|
||||||
Boolean.valueOf(getString(R.string.pref_opensles_default)));
|
Boolean.valueOf(getString(R.string.pref_opensles_default)));
|
||||||
|
|
||||||
|
// Check Disable built-in AEC flag.
|
||||||
|
boolean disableBuiltInAEC = sharedPref.getBoolean(
|
||||||
|
keyprefDisableBuiltInAec,
|
||||||
|
Boolean.valueOf(getString(R.string.pref_disable_built_in_aec_default)));
|
||||||
|
|
||||||
// Get video resolution from settings.
|
// Get video resolution from settings.
|
||||||
int videoWidth = 0;
|
int videoWidth = 0;
|
||||||
int videoHeight = 0;
|
int videoHeight = 0;
|
||||||
@ -370,6 +377,7 @@ public class ConnectActivity extends Activity {
|
|||||||
noAudioProcessing);
|
noAudioProcessing);
|
||||||
intent.putExtra(CallActivity.EXTRA_AECDUMP_ENABLED, aecDump);
|
intent.putExtra(CallActivity.EXTRA_AECDUMP_ENABLED, aecDump);
|
||||||
intent.putExtra(CallActivity.EXTRA_OPENSLES_ENABLED, useOpenSLES);
|
intent.putExtra(CallActivity.EXTRA_OPENSLES_ENABLED, useOpenSLES);
|
||||||
|
intent.putExtra(CallActivity.EXTRA_DISABLE_BUILT_IN_AEC, disableBuiltInAEC);
|
||||||
intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate);
|
intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate);
|
||||||
intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec);
|
intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec);
|
||||||
intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud);
|
intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud);
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import org.webrtc.VideoRenderer;
|
|||||||
import org.webrtc.VideoSource;
|
import org.webrtc.VideoSource;
|
||||||
import org.webrtc.VideoTrack;
|
import org.webrtc.VideoTrack;
|
||||||
import org.webrtc.voiceengine.WebRtcAudioManager;
|
import org.webrtc.voiceengine.WebRtcAudioManager;
|
||||||
|
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -148,13 +149,15 @@ public class PeerConnectionClient {
|
|||||||
public final boolean noAudioProcessing;
|
public final boolean noAudioProcessing;
|
||||||
public final boolean aecDump;
|
public final boolean aecDump;
|
||||||
public final boolean useOpenSLES;
|
public final boolean useOpenSLES;
|
||||||
|
public final boolean disableBuiltInAEC;
|
||||||
|
|
||||||
public PeerConnectionParameters(
|
public PeerConnectionParameters(
|
||||||
boolean videoCallEnabled, boolean loopback, boolean tracing,
|
boolean videoCallEnabled, boolean loopback, boolean tracing,
|
||||||
int videoWidth, int videoHeight, int videoFps, int videoStartBitrate,
|
int videoWidth, int videoHeight, int videoFps, int videoStartBitrate,
|
||||||
String videoCodec, boolean videoCodecHwAcceleration, boolean captureToTexture,
|
String videoCodec, boolean videoCodecHwAcceleration, boolean captureToTexture,
|
||||||
int audioStartBitrate, String audioCodec,
|
int audioStartBitrate, String audioCodec,
|
||||||
boolean noAudioProcessing, boolean aecDump, boolean useOpenSLES) {
|
boolean noAudioProcessing, boolean aecDump, boolean useOpenSLES,
|
||||||
|
boolean disableBuiltInAEC) {
|
||||||
this.videoCallEnabled = videoCallEnabled;
|
this.videoCallEnabled = videoCallEnabled;
|
||||||
this.loopback = loopback;
|
this.loopback = loopback;
|
||||||
this.tracing = tracing;
|
this.tracing = tracing;
|
||||||
@ -170,6 +173,7 @@ public class PeerConnectionClient {
|
|||||||
this.noAudioProcessing = noAudioProcessing;
|
this.noAudioProcessing = noAudioProcessing;
|
||||||
this.aecDump = aecDump;
|
this.aecDump = aecDump;
|
||||||
this.useOpenSLES = useOpenSLES;
|
this.useOpenSLES = useOpenSLES;
|
||||||
|
this.disableBuiltInAEC = disableBuiltInAEC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,6 +343,14 @@ public class PeerConnectionClient {
|
|||||||
WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(false);
|
WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (peerConnectionParameters.disableBuiltInAEC) {
|
||||||
|
Log.d(TAG, "Disable built-in AEC even if device supports it");
|
||||||
|
WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Enable built-in AEC if device supports it");
|
||||||
|
WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Create peer connection factory.
|
// Create peer connection factory.
|
||||||
if (!PeerConnectionFactory.initializeAndroidGlobals(context, true, true,
|
if (!PeerConnectionFactory.initializeAndroidGlobals(context, true, true,
|
||||||
peerConnectionParameters.videoCodecHwAcceleration)) {
|
peerConnectionParameters.videoCodecHwAcceleration)) {
|
||||||
|
|||||||
@ -16,6 +16,8 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
|
||||||
|
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings activity for AppRTC.
|
* Settings activity for AppRTC.
|
||||||
*/
|
*/
|
||||||
@ -38,6 +40,7 @@ public class SettingsActivity extends Activity
|
|||||||
private String keyprefNoAudioProcessing;
|
private String keyprefNoAudioProcessing;
|
||||||
private String keyprefAecDump;
|
private String keyprefAecDump;
|
||||||
private String keyprefOpenSLES;
|
private String keyprefOpenSLES;
|
||||||
|
private String keyprefDisableBuiltInAEC;
|
||||||
|
|
||||||
private String keyPrefRoomServerUrl;
|
private String keyPrefRoomServerUrl;
|
||||||
private String keyPrefDisplayHud;
|
private String keyPrefDisplayHud;
|
||||||
@ -62,6 +65,7 @@ public class SettingsActivity extends Activity
|
|||||||
keyprefNoAudioProcessing = getString(R.string.pref_noaudioprocessing_key);
|
keyprefNoAudioProcessing = getString(R.string.pref_noaudioprocessing_key);
|
||||||
keyprefAecDump = getString(R.string.pref_aecdump_key);
|
keyprefAecDump = getString(R.string.pref_aecdump_key);
|
||||||
keyprefOpenSLES = getString(R.string.pref_opensles_key);
|
keyprefOpenSLES = getString(R.string.pref_opensles_key);
|
||||||
|
keyprefDisableBuiltInAEC = getString(R.string.pref_disable_built_in_aec_key);
|
||||||
|
|
||||||
keyPrefRoomServerUrl = getString(R.string.pref_room_server_url_key);
|
keyPrefRoomServerUrl = getString(R.string.pref_room_server_url_key);
|
||||||
keyPrefDisplayHud = getString(R.string.pref_displayhud_key);
|
keyPrefDisplayHud = getString(R.string.pref_displayhud_key);
|
||||||
@ -99,10 +103,23 @@ public class SettingsActivity extends Activity
|
|||||||
updateSummaryB(sharedPreferences, keyprefNoAudioProcessing);
|
updateSummaryB(sharedPreferences, keyprefNoAudioProcessing);
|
||||||
updateSummaryB(sharedPreferences, keyprefAecDump);
|
updateSummaryB(sharedPreferences, keyprefAecDump);
|
||||||
updateSummaryB(sharedPreferences, keyprefOpenSLES);
|
updateSummaryB(sharedPreferences, keyprefOpenSLES);
|
||||||
|
updateSummaryB(sharedPreferences, keyprefDisableBuiltInAEC);
|
||||||
|
|
||||||
updateSummary(sharedPreferences, keyPrefRoomServerUrl);
|
updateSummary(sharedPreferences, keyPrefRoomServerUrl);
|
||||||
updateSummaryB(sharedPreferences, keyPrefDisplayHud);
|
updateSummaryB(sharedPreferences, keyPrefDisplayHud);
|
||||||
updateSummaryB(sharedPreferences, keyPrefTracing);
|
updateSummaryB(sharedPreferences, keyPrefTracing);
|
||||||
|
|
||||||
|
// Disable forcing WebRTC based AEC so it won't affect our value.
|
||||||
|
// Otherwise, if it was enabled, isAcousticEchoCancelerSupported would always return false.
|
||||||
|
WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(false);
|
||||||
|
if (!WebRtcAudioUtils.isAcousticEchoCancelerSupported()) {
|
||||||
|
Preference disableBuiltInAECPreference =
|
||||||
|
settingsFragment.findPreference(keyprefDisableBuiltInAEC);
|
||||||
|
|
||||||
|
|
||||||
|
disableBuiltInAECPreference.setSummary(getString(R.string.pref_built_in_aec_not_available));
|
||||||
|
disableBuiltInAECPreference.setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -135,6 +152,7 @@ public class SettingsActivity extends Activity
|
|||||||
|| key.equals(keyprefNoAudioProcessing)
|
|| key.equals(keyprefNoAudioProcessing)
|
||||||
|| key.equals(keyprefAecDump)
|
|| key.equals(keyprefAecDump)
|
||||||
|| key.equals(keyprefOpenSLES)
|
|| key.equals(keyprefOpenSLES)
|
||||||
|
|| key.equals(keyprefDisableBuiltInAEC)
|
||||||
|| key.equals(keyPrefDisplayHud)) {
|
|| key.equals(keyPrefDisplayHud)) {
|
||||||
updateSummaryB(sharedPreferences, key);
|
updateSummaryB(sharedPreferences, key);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -263,9 +263,24 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
|
|||||||
private PeerConnectionParameters createParametersForAudioCall() {
|
private PeerConnectionParameters createParametersForAudioCall() {
|
||||||
PeerConnectionParameters peerConnectionParameters =
|
PeerConnectionParameters peerConnectionParameters =
|
||||||
new PeerConnectionParameters(
|
new PeerConnectionParameters(
|
||||||
false, true, false, // videoCallEnabled, loopback, tracing.
|
false, /* videoCallEnabled */
|
||||||
0, 0, 0, 0, "", true, false, // video codec parameters.
|
true, /* loopback */
|
||||||
0, "OPUS", false, false, false); // audio codec parameters.
|
false, /* tracing */
|
||||||
|
// Video codec parameters.
|
||||||
|
0, /* videoWidth */
|
||||||
|
0, /* videoHeight */
|
||||||
|
0, /* videoFps */
|
||||||
|
0, /* videoStartBitrate */
|
||||||
|
"", /* videoCodec */
|
||||||
|
true, /* videoCodecHwAcceleration */
|
||||||
|
false, /* captureToToTexture */
|
||||||
|
// Audio codec parameters.
|
||||||
|
0, /* audioStartBitrate */
|
||||||
|
"OPUS", /* audioCodec */
|
||||||
|
false, /* noAudioProcessing */
|
||||||
|
false, /* aecDump */
|
||||||
|
false /* useOpenSLES */,
|
||||||
|
false /* disableBuiltInAEC */);
|
||||||
return peerConnectionParameters;
|
return peerConnectionParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,9 +288,24 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
|
|||||||
String videoCodec, boolean captureToTexture) {
|
String videoCodec, boolean captureToTexture) {
|
||||||
PeerConnectionParameters peerConnectionParameters =
|
PeerConnectionParameters peerConnectionParameters =
|
||||||
new PeerConnectionParameters(
|
new PeerConnectionParameters(
|
||||||
true, true, false, // videoCallEnabled, loopback, tracing.
|
true, /* videoCallEnabled */
|
||||||
0, 0, 0, 0, videoCodec, true, captureToTexture, // video codec parameters.
|
true, /* loopback */
|
||||||
0, "OPUS", false, false, false); // audio codec parameters.
|
false, /* tracing */
|
||||||
|
// Video codec parameters.
|
||||||
|
0, /* videoWidth */
|
||||||
|
0, /* videoHeight */
|
||||||
|
0, /* videoFps */
|
||||||
|
0, /* videoStartBitrate */
|
||||||
|
videoCodec, /* videoCodec */
|
||||||
|
true, /* videoCodecHwAcceleration */
|
||||||
|
captureToTexture, /* captureToToTexture */
|
||||||
|
// Audio codec parameters.
|
||||||
|
0, /* audioStartBitrate */
|
||||||
|
"OPUS", /* audioCodec */
|
||||||
|
false, /* noAudioProcessing */
|
||||||
|
false, /* aecDump */
|
||||||
|
false /* useOpenSLES */,
|
||||||
|
false /* disableBuiltInAEC */);
|
||||||
return peerConnectionParameters;
|
return peerConnectionParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,13 +42,6 @@ class WebRtcAudioEffects {
|
|||||||
private static final UUID AOSP_NOISE_SUPPRESSOR =
|
private static final UUID AOSP_NOISE_SUPPRESSOR =
|
||||||
UUID.fromString("c06c8400-8e06-11e0-9cb6-0002a5d5c51b");
|
UUID.fromString("c06c8400-8e06-11e0-9cb6-0002a5d5c51b");
|
||||||
|
|
||||||
// Static Boolean objects used to avoid expensive queries more than once.
|
|
||||||
// The first result is cached in these members and then reused if needed.
|
|
||||||
// Each member is null until it has been evaluated/set for the first time.
|
|
||||||
private static Boolean canUseAcousticEchoCanceler = null;
|
|
||||||
private static Boolean canUseAutomaticGainControl = null;
|
|
||||||
private static Boolean canUseNoiseSuppressor = null;
|
|
||||||
|
|
||||||
// Contains the audio effect objects. Created in enable() and destroyed
|
// Contains the audio effect objects. Created in enable() and destroyed
|
||||||
// in release().
|
// in release().
|
||||||
private AcousticEchoCanceler aec = null;
|
private AcousticEchoCanceler aec = null;
|
||||||
@ -160,44 +153,38 @@ class WebRtcAudioEffects {
|
|||||||
// Returns true if all conditions for supporting the HW AEC are fulfilled.
|
// Returns true if all conditions for supporting the HW AEC are fulfilled.
|
||||||
// It will not be possible to enable the HW AEC if this method returns false.
|
// It will not be possible to enable the HW AEC if this method returns false.
|
||||||
public static boolean canUseAcousticEchoCanceler() {
|
public static boolean canUseAcousticEchoCanceler() {
|
||||||
if (canUseAcousticEchoCanceler == null) {
|
boolean canUseAcousticEchoCanceler =
|
||||||
canUseAcousticEchoCanceler = new Boolean(
|
|
||||||
isAcousticEchoCancelerSupported()
|
isAcousticEchoCancelerSupported()
|
||||||
&& !WebRtcAudioUtils.useWebRtcBasedAcousticEchoCanceler()
|
&& !WebRtcAudioUtils.useWebRtcBasedAcousticEchoCanceler()
|
||||||
&& !isAcousticEchoCancelerBlacklisted()
|
&& !isAcousticEchoCancelerBlacklisted()
|
||||||
&& !isAcousticEchoCancelerExcludedByUUID());
|
&& !isAcousticEchoCancelerExcludedByUUID();
|
||||||
Logging.d(TAG, "canUseAcousticEchoCanceler: "
|
Logging.d(TAG, "canUseAcousticEchoCanceler: "
|
||||||
+ canUseAcousticEchoCanceler);
|
+ canUseAcousticEchoCanceler);
|
||||||
}
|
|
||||||
return canUseAcousticEchoCanceler;
|
return canUseAcousticEchoCanceler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if all conditions for supporting the HW AGC are fulfilled.
|
// Returns true if all conditions for supporting the HW AGC are fulfilled.
|
||||||
// It will not be possible to enable the HW AGC if this method returns false.
|
// It will not be possible to enable the HW AGC if this method returns false.
|
||||||
public static boolean canUseAutomaticGainControl() {
|
public static boolean canUseAutomaticGainControl() {
|
||||||
if (canUseAutomaticGainControl == null) {
|
boolean canUseAutomaticGainControl =
|
||||||
canUseAutomaticGainControl = new Boolean(
|
|
||||||
isAutomaticGainControlSupported()
|
isAutomaticGainControlSupported()
|
||||||
&& !WebRtcAudioUtils.useWebRtcBasedAutomaticGainControl()
|
&& !WebRtcAudioUtils.useWebRtcBasedAutomaticGainControl()
|
||||||
&& !isAutomaticGainControlBlacklisted()
|
&& !isAutomaticGainControlBlacklisted()
|
||||||
&& !isAutomaticGainControlExcludedByUUID());
|
&& !isAutomaticGainControlExcludedByUUID();
|
||||||
Logging.d(TAG, "canUseAutomaticGainControl: "
|
Logging.d(TAG, "canUseAutomaticGainControl: "
|
||||||
+ canUseAutomaticGainControl);
|
+ canUseAutomaticGainControl);
|
||||||
}
|
|
||||||
return canUseAutomaticGainControl;
|
return canUseAutomaticGainControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if all conditions for supporting the HW NS are fulfilled.
|
// Returns true if all conditions for supporting the HW NS are fulfilled.
|
||||||
// It will not be possible to enable the HW NS if this method returns false.
|
// It will not be possible to enable the HW NS if this method returns false.
|
||||||
public static boolean canUseNoiseSuppressor() {
|
public static boolean canUseNoiseSuppressor() {
|
||||||
if (canUseNoiseSuppressor == null) {
|
boolean canUseNoiseSuppressor =
|
||||||
canUseNoiseSuppressor = new Boolean(
|
|
||||||
isNoiseSuppressorSupported()
|
isNoiseSuppressorSupported()
|
||||||
&& !WebRtcAudioUtils.useWebRtcBasedNoiseSuppressor()
|
&& !WebRtcAudioUtils.useWebRtcBasedNoiseSuppressor()
|
||||||
&& !isNoiseSuppressorBlacklisted()
|
&& !isNoiseSuppressorBlacklisted()
|
||||||
&& !isNoiseSuppressorExcludedByUUID());
|
&& !isNoiseSuppressorExcludedByUUID();
|
||||||
Logging.d(TAG, "canUseNoiseSuppressor: " + canUseNoiseSuppressor);
|
Logging.d(TAG, "canUseNoiseSuppressor: " + canUseNoiseSuppressor);
|
||||||
}
|
|
||||||
return canUseNoiseSuppressor;
|
return canUseNoiseSuppressor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,6 +100,22 @@ public final class WebRtcAudioUtils {
|
|||||||
return useWebRtcBasedNoiseSuppressor;
|
return useWebRtcBasedNoiseSuppressor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if the device supports an audio effect (AEC, AGC or NS).
|
||||||
|
// Four conditions must be fulfilled if functions are to return true:
|
||||||
|
// 1) the platform must support the built-in (HW) effect,
|
||||||
|
// 2) explicit use (override) of a WebRTC based version must not be set,
|
||||||
|
// 3) the device must not be blacklisted for use of the effect, and
|
||||||
|
// 4) the UUID of the effect must be approved (some UUIDs can be excluded).
|
||||||
|
public static boolean isAcousticEchoCancelerSupported() {
|
||||||
|
return WebRtcAudioEffects.canUseAcousticEchoCanceler();
|
||||||
|
}
|
||||||
|
public static boolean isAutomaticGainControlSupported() {
|
||||||
|
return WebRtcAudioEffects.canUseAutomaticGainControl();
|
||||||
|
}
|
||||||
|
public static boolean isNoiseSuppressorSupported() {
|
||||||
|
return WebRtcAudioEffects.canUseNoiseSuppressor();
|
||||||
|
}
|
||||||
|
|
||||||
// Call this method if the default handling of querying the native sample
|
// Call this method if the default handling of querying the native sample
|
||||||
// rate shall be overridden. Can be useful on some devices where the
|
// rate shall be overridden. Can be useful on some devices where the
|
||||||
// available Android APIs are known to return invalid results.
|
// available Android APIs are known to return invalid results.
|
||||||
|
|||||||
Reference in New Issue
Block a user