Add OpenSL ES enable setting to AppRTCDemo.

Disable OpenSL ES by default.
Plus remove no longer used CPU overuse detection option.

Review URL: https://codereview.webrtc.org/1449083002

Cr-Commit-Position: refs/heads/master@{#10670}
This commit is contained in:
glaznev
2015-11-17 04:05:29 -08:00
committed by Commit bot
parent 3c12f4dadb
commit e66339296b
7 changed files with 39 additions and 33 deletions

View File

@ -97,14 +97,14 @@
<string name="pref_noaudioprocessing_dlg">Disable audio processing pipeline.</string>
<string name="pref_noaudioprocessing_default">false</string>
<string name="pref_opensles_key">opensles_preference</string>
<string name="pref_opensles_title">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_miscsettings_key">misc_settings_key</string>
<string name="pref_miscsettings_title">Miscellaneous settings.</string>
<string name="pref_cpu_usage_detection_key">cpu_usage_detection</string>
<string name="pref_cpu_usage_detection_title">CPU overuse detection.</string>
<string name="pref_cpu_usage_detection_dlg">Adapt transmission to CPU status.</string>
<string name="pref_cpu_usage_detection_default" translatable="false">true</string>
<string name="pref_room_server_url_key">room_server_url_preference</string>
<string name="pref_room_server_url_title">Room server URL.</string>
<string name="pref_room_server_url_dlg">Enter a room server URL.</string>

View File

@ -94,18 +94,18 @@
android:title="@string/pref_noaudioprocessing_title"
android:dialogTitle="@string/pref_noaudioprocessing_dlg"
android:defaultValue="@string/pref_noaudioprocessing_default" />
<CheckBoxPreference
android:key="@string/pref_opensles_key"
android:title="@string/pref_opensles_title"
android:dialogTitle="@string/pref_opensles_dlg"
android:defaultValue="@string/pref_opensles_default" />
</PreferenceCategory>
<PreferenceCategory
android:key="@string/pref_miscsettings_key"
android:title="@string/pref_miscsettings_title">
<CheckBoxPreference
android:key="@string/pref_cpu_usage_detection_key"
android:title="@string/pref_cpu_usage_detection_title"
android:dialogTitle="@string/pref_cpu_usage_detection_dlg"
android:defaultValue="@string/pref_cpu_usage_detection_default" />
<EditTextPreference
android:key="@string/pref_room_server_url_key"
android:title="@string/pref_room_server_url_title"

View File

@ -72,8 +72,8 @@ public class CallActivity extends Activity
"org.appspot.apprtc.AUDIOCODEC";
public static final String EXTRA_NOAUDIOPROCESSING_ENABLED =
"org.appspot.apprtc.NOAUDIOPROCESSING";
public static final String EXTRA_CPUOVERUSE_DETECTION =
"org.appspot.apprtc.CPUOVERUSE_DETECTION";
public static final String EXTRA_OPENSLES_ENABLED =
"org.appspot.apprtc.OPENSLES";
public static final String EXTRA_DISPLAY_HUD =
"org.appspot.apprtc.DISPLAY_HUD";
public static final String EXTRA_CMDLINE =
@ -223,7 +223,7 @@ public class CallActivity extends Activity
intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0),
intent.getStringExtra(EXTRA_AUDIOCODEC),
intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false),
intent.getBooleanExtra(EXTRA_CPUOVERUSE_DETECTION, true));
intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false));
commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false);
runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0);

View File

@ -66,7 +66,7 @@ public class ConnectActivity extends Activity {
private String keyprefAudioCodec;
private String keyprefHwCodecAcceleration;
private String keyprefNoAudioProcessingPipeline;
private String keyprefCpuUsageDetection;
private String keyprefOpenSLES;
private String keyprefDisplayHud;
private String keyprefRoomServerUrl;
private String keyprefRoom;
@ -93,7 +93,7 @@ public class ConnectActivity extends Activity {
keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
keyprefAudioCodec = getString(R.string.pref_audiocodec_key);
keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
keyprefCpuUsageDetection = getString(R.string.pref_cpu_usage_detection_key);
keyprefOpenSLES = getString(R.string.pref_opensles_key);
keyprefDisplayHud = getString(R.string.pref_displayhud_key);
keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
keyprefRoom = getString(R.string.pref_room_key);
@ -258,6 +258,11 @@ public class ConnectActivity extends Activity {
keyprefNoAudioProcessingPipeline,
Boolean.valueOf(getString(R.string.pref_noaudioprocessing_default)));
// Check OpenSL ES enabled flag.
boolean useOpenSLES = sharedPref.getBoolean(
keyprefOpenSLES,
Boolean.valueOf(getString(R.string.pref_opensles_default)));
// Get video resolution from settings.
int videoWidth = 0;
int videoHeight = 0;
@ -313,12 +318,6 @@ public class ConnectActivity extends Activity {
audioStartBitrate = Integer.parseInt(bitrateValue);
}
// Test if CpuOveruseDetection should be disabled. By default is on.
boolean cpuOveruseDetection = sharedPref.getBoolean(
keyprefCpuUsageDetection,
Boolean.valueOf(
getString(R.string.pref_cpu_usage_detection_default)));
// Check statistics display option.
boolean displayHud = sharedPref.getBoolean(keyprefDisplayHud,
Boolean.valueOf(getString(R.string.pref_displayhud_default)));
@ -342,10 +341,9 @@ public class ConnectActivity extends Activity {
intent.putExtra(CallActivity.EXTRA_HWCODEC_ENABLED, hwCodec);
intent.putExtra(CallActivity.EXTRA_NOAUDIOPROCESSING_ENABLED,
noAudioProcessing);
intent.putExtra(CallActivity.EXTRA_OPENSLES_ENABLED, useOpenSLES);
intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate);
intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec);
intent.putExtra(CallActivity.EXTRA_CPUOVERUSE_DETECTION,
cpuOveruseDetection);
intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud);
intent.putExtra(CallActivity.EXTRA_CMDLINE, commandLineRun);
intent.putExtra(CallActivity.EXTRA_RUNTIME, runTimeMs);

View File

@ -34,6 +34,7 @@ import org.webrtc.VideoCapturerAndroid;
import org.webrtc.VideoRenderer;
import org.webrtc.VideoSource;
import org.webrtc.VideoTrack;
import org.webrtc.voiceengine.WebRtcAudioManager;
import java.util.EnumSet;
import java.util.LinkedList;
@ -135,14 +136,14 @@ public class PeerConnectionClient {
public final int audioStartBitrate;
public final String audioCodec;
public final boolean noAudioProcessing;
public final boolean cpuOveruseDetection;
public final boolean useOpenSLES;
public PeerConnectionParameters(
boolean videoCallEnabled, boolean loopback,
int videoWidth, int videoHeight, int videoFps, int videoStartBitrate,
String videoCodec, boolean videoCodecHwAcceleration,
int audioStartBitrate, String audioCodec,
boolean noAudioProcessing, boolean cpuOveruseDetection) {
boolean noAudioProcessing, boolean useOpenSLES) {
this.videoCallEnabled = videoCallEnabled;
this.loopback = loopback;
this.videoWidth = videoWidth;
@ -154,7 +155,7 @@ public class PeerConnectionClient {
this.audioStartBitrate = audioStartBitrate;
this.audioCodec = audioCodec;
this.noAudioProcessing = noAudioProcessing;
this.cpuOveruseDetection = cpuOveruseDetection;
this.useOpenSLES = useOpenSLES;
}
}
@ -305,6 +306,14 @@ public class PeerConnectionClient {
&& peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC)) {
preferIsac = true;
}
// Enable/disable OpenSL ES playback.
if (!peerConnectionParameters.useOpenSLES) {
Log.d(TAG, "Disable OpenSL ES audio");
WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true /* enable */);
}
// Create peer connection factory.
if (!PeerConnectionFactory.initializeAndroidGlobals(context, true, true,
peerConnectionParameters.videoCodecHwAcceleration)) {
events.onPeerConnectionError("Failed to initializeAndroidGlobals");

View File

@ -35,8 +35,8 @@ public class SettingsActivity extends Activity
private String keyprefStartAudioBitrateValue;
private String keyPrefAudioCodec;
private String keyprefNoAudioProcessing;
private String keyprefOpenSLES;
private String keyprefCpuUsageDetection;
private String keyPrefRoomServerUrl;
private String keyPrefDisplayHud;
@ -56,8 +56,8 @@ public class SettingsActivity extends Activity
keyprefStartAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
keyPrefAudioCodec = getString(R.string.pref_audiocodec_key);
keyprefNoAudioProcessing = getString(R.string.pref_noaudioprocessing_key);
keyprefOpenSLES = getString(R.string.pref_opensles_key);
keyprefCpuUsageDetection = getString(R.string.pref_cpu_usage_detection_key);
keyPrefRoomServerUrl = getString(R.string.pref_room_server_url_key);
keyPrefDisplayHud = getString(R.string.pref_displayhud_key);
@ -90,8 +90,8 @@ public class SettingsActivity extends Activity
setAudioBitrateEnable(sharedPreferences);
updateSummary(sharedPreferences, keyPrefAudioCodec);
updateSummaryB(sharedPreferences, keyprefNoAudioProcessing);
updateSummaryB(sharedPreferences, keyprefOpenSLES);
updateSummaryB(sharedPreferences, keyprefCpuUsageDetection);
updateSummary(sharedPreferences, keyPrefRoomServerUrl);
updateSummaryB(sharedPreferences, keyPrefDisplayHud);
}
@ -122,7 +122,7 @@ public class SettingsActivity extends Activity
|| key.equals(keyprefCaptureQualitySlider)
|| key.equals(keyprefHwCodec)
|| key.equals(keyprefNoAudioProcessing)
|| key.equals(keyprefCpuUsageDetection)
|| key.equals(keyprefOpenSLES)
|| key.equals(keyPrefDisplayHud)) {
updateSummaryB(sharedPreferences, key);
}

View File

@ -22,7 +22,6 @@ import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters;
import org.appspot.apprtc.util.LooperExecutor;
import org.webrtc.EglBase;
import org.webrtc.IceCandidate;
import org.webrtc.MediaConstraints;
import org.webrtc.PeerConnection;
import org.webrtc.PeerConnectionFactory;
import org.webrtc.SessionDescription;
@ -252,7 +251,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
new PeerConnectionParameters(
enableVideo, true, // videoCallEnabled, loopback.
0, 0, 0, 0, videoCodec, true, // video codec parameters.
0, "OPUS", false, true); // audio codec parameters.
0, "OPUS", false, false); // audio codec parameters.
return peerConnectionParameters;
}