diff options
Diffstat (limited to 'webrtc/examples/androidapp')
7 files changed, 181 insertions, 64 deletions
diff --git a/webrtc/examples/androidapp/AndroidManifest.xml b/webrtc/examples/androidapp/AndroidManifest.xml index 6a91cfdeed..bd0dee821a 100644 --- a/webrtc/examples/androidapp/AndroidManifest.xml +++ b/webrtc/examples/androidapp/AndroidManifest.xml @@ -7,7 +7,7 @@ <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> - <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" /> + <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> diff --git a/webrtc/examples/androidapp/res/values/strings.xml b/webrtc/examples/androidapp/res/values/strings.xml index b3c55b438e..a5f64bad5b 100644 --- a/webrtc/examples/androidapp/res/values/strings.xml +++ b/webrtc/examples/androidapp/res/values/strings.xml @@ -71,6 +71,11 @@ <string name="pref_hwcodec_dlg">Use hardware accelerated video codec (if available).</string> <string name="pref_hwcodec_default">true</string> + <string name="pref_capturetotexture_key">capturetotexture_preference</string> + <string name="pref_capturetotexture_title">Video capture to surface texture.</string> + <string name="pref_capturetotexture_dlg">Capture video to textures (if available).</string> + <string name="pref_capturetotexture_default">false</string> + <string name="pref_value_enabled">Enabled</string> <string name="pref_value_disabled">Disabled</string> @@ -97,14 +102,19 @@ <string name="pref_noaudioprocessing_dlg">Disable audio processing pipeline.</string> <string name="pref_noaudioprocessing_default">false</string> + <string name="pref_aecdump_key">aecdump_preference</string> + <string name="pref_aecdump_title">Create aecdump.</string> + <string name="pref_aecdump_dlg">Enable diagnostic audio recordings.</string> + <string name="pref_aecdump_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> @@ -115,4 +125,9 @@ <string name="pref_displayhud_dlg">Display call statistics.</string> <string name="pref_displayhud_default" translatable="false">false</string> + <string name="pref_tracing_key">tracing_preference</string> + <string name="pref_tracing_title">Debug performance tracing.</string> + <string name="pref_tracing_dlg">Debug performance tracing.</string> + <string name="pref_tracing_default" translatable="false">false</string> + </resources> diff --git a/webrtc/examples/androidapp/res/xml/preferences.xml b/webrtc/examples/androidapp/res/xml/preferences.xml index c580e0cb77..0c6f916a2d 100644 --- a/webrtc/examples/androidapp/res/xml/preferences.xml +++ b/webrtc/examples/androidapp/res/xml/preferences.xml @@ -60,6 +60,12 @@ android:title="@string/pref_hwcodec_title" android:dialogTitle="@string/pref_hwcodec_dlg" android:defaultValue="@string/pref_hwcodec_default" /> + + <CheckBoxPreference + android:key="@string/pref_capturetotexture_key" + android:title="@string/pref_capturetotexture_title" + android:dialogTitle="@string/pref_capturetotexture_dlg" + android:defaultValue="@string/pref_capturetotexture_default" /> </PreferenceCategory> <PreferenceCategory @@ -94,18 +100,24 @@ android:title="@string/pref_noaudioprocessing_title" android:dialogTitle="@string/pref_noaudioprocessing_dlg" android:defaultValue="@string/pref_noaudioprocessing_default" /> + + <CheckBoxPreference + android:key="@string/pref_aecdump_key" + android:title="@string/pref_aecdump_title" + android:dialogTitle="@string/pref_aecdump_dlg" + android:defaultValue="@string/pref_aecdump_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" @@ -118,6 +130,12 @@ android:title="@string/pref_displayhud_title" android:dialogTitle="@string/pref_displayhud_dlg" android:defaultValue="@string/pref_displayhud_default" /> + + <CheckBoxPreference + android:key="@string/pref_tracing_key" + android:title="@string/pref_tracing_title" + android:dialogTitle="@string/pref_tracing_dlg" + android:defaultValue="@string/pref_tracing_default" /> </PreferenceCategory> </PreferenceScreen> diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java index 8ae7981e36..b9abf11eb3 100644 --- a/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java +++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java @@ -22,7 +22,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; -import android.opengl.GLSurfaceView; import android.os.Bundle; import android.os.Handler; import android.util.Log; @@ -67,16 +66,21 @@ public class CallActivity extends Activity "org.appspot.apprtc.VIDEOCODEC"; public static final String EXTRA_HWCODEC_ENABLED = "org.appspot.apprtc.HWCODEC"; + public static final String EXTRA_CAPTURETOTEXTURE_ENABLED = + "org.appspot.apprtc.CAPTURETOTEXTURE"; public static final String EXTRA_AUDIO_BITRATE = "org.appspot.apprtc.AUDIO_BITRATE"; public static final String EXTRA_AUDIOCODEC = "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_AECDUMP_ENABLED = + "org.appspot.apprtc.AECDUMP"; + 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_TRACING = "org.appspot.apprtc.TRACING"; public static final String EXTRA_CMDLINE = "org.appspot.apprtc.CMDLINE"; public static final String EXTRA_RUNTIME = @@ -177,9 +181,9 @@ public class CallActivity extends Activity remoteRender.setOnClickListener(listener); // Create video renderers. - rootEglBase = new EglBase(); - localRender.init(rootEglBase.getContext(), null); - remoteRender.init(rootEglBase.getContext(), null); + rootEglBase = EglBase.create(); + localRender.init(rootEglBase.getEglBaseContext(), null); + remoteRender.init(rootEglBase.getEglBaseContext(), null); localRender.setZOrderMediaOverlay(true); updateVideoView(); @@ -212,19 +216,23 @@ public class CallActivity extends Activity return; } boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); + boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); peerConnectionParameters = new PeerConnectionParameters( intent.getBooleanExtra(EXTRA_VIDEO_CALL, true), loopback, + tracing, intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0), intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0), intent.getIntExtra(EXTRA_VIDEO_FPS, 0), intent.getIntExtra(EXTRA_VIDEO_BITRATE, 0), intent.getStringExtra(EXTRA_VIDEOCODEC), intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), + intent.getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false), 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_AECDUMP_ENABLED, false), + intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false)); commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false); runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0); @@ -246,6 +254,7 @@ public class CallActivity extends Activity // For command line execution run connection for <runTimeMs> and exit. if (commandLineRun && runTimeMs > 0) { (new Handler()).postDelayed(new Runnable() { + @Override public void run() { disconnect(); } @@ -480,7 +489,7 @@ public class CallActivity extends Activity signalingParameters = params; logAndToast("Creating peer connection, delay=" + delta + "ms"); - peerConnectionClient.createPeerConnection(rootEglBase.getContext(), + peerConnectionClient.createPeerConnection(rootEglBase.getEglBaseContext(), localRender, remoteRender, signalingParameters); if (signalingParameters.initiator) { diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java index 0bdaebb5b0..e55dba0cba 100644 --- a/webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java +++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java @@ -65,9 +65,12 @@ public class ConnectActivity extends Activity { private String keyprefAudioBitrateValue; private String keyprefAudioCodec; private String keyprefHwCodecAcceleration; + private String keyprefCaptureToTexture; private String keyprefNoAudioProcessingPipeline; - private String keyprefCpuUsageDetection; + private String keyprefAecDump; + private String keyprefOpenSLES; private String keyprefDisplayHud; + private String keyprefTracing; private String keyprefRoomServerUrl; private String keyprefRoom; private String keyprefRoomList; @@ -89,12 +92,15 @@ public class ConnectActivity extends Activity { keyprefVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key); keyprefVideoCodec = getString(R.string.pref_videocodec_key); keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key); + keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key); keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key); 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); + keyprefAecDump = getString(R.string.pref_aecdump_key); + keyprefOpenSLES = getString(R.string.pref_opensles_key); keyprefDisplayHud = getString(R.string.pref_displayhud_key); + keyprefTracing = getString(R.string.pref_tracing_key); keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key); keyprefRoom = getString(R.string.pref_room_key); keyprefRoomList = getString(R.string.pref_room_list_key); @@ -253,11 +259,25 @@ public class ConnectActivity extends Activity { boolean hwCodec = sharedPref.getBoolean(keyprefHwCodecAcceleration, Boolean.valueOf(getString(R.string.pref_hwcodec_default))); + // Check Capture to texture. + boolean captureToTexture = sharedPref.getBoolean(keyprefCaptureToTexture, + Boolean.valueOf(getString(R.string.pref_capturetotexture_default))); + // Check Disable Audio Processing flag. boolean noAudioProcessing = sharedPref.getBoolean( keyprefNoAudioProcessingPipeline, Boolean.valueOf(getString(R.string.pref_noaudioprocessing_default))); + // Check Disable Audio Processing flag. + boolean aecDump = sharedPref.getBoolean( + keyprefAecDump, + Boolean.valueOf(getString(R.string.pref_aecdump_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,16 +333,13 @@ 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))); + boolean tracing = sharedPref.getBoolean( + keyprefTracing, Boolean.valueOf(getString(R.string.pref_tracing_default))); + // Start AppRTCDemo activity. Log.d(TAG, "Connecting to room " + roomId + " at URL " + roomUrl); if (validateUrl(roomUrl)) { @@ -340,13 +357,15 @@ public class ConnectActivity extends Activity { intent.putExtra(CallActivity.EXTRA_VIDEO_BITRATE, videoStartBitrate); intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, videoCodec); intent.putExtra(CallActivity.EXTRA_HWCODEC_ENABLED, hwCodec); + intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, captureToTexture); intent.putExtra(CallActivity.EXTRA_NOAUDIOPROCESSING_ENABLED, noAudioProcessing); + intent.putExtra(CallActivity.EXTRA_AECDUMP_ENABLED, aecDump); + 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_TRACING, tracing); intent.putExtra(CallActivity.EXTRA_CMDLINE, commandLineRun); intent.putExtra(CallActivity.EXTRA_RUNTIME, runTimeMs); diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java index 263046b2e9..c41dd66345 100644 --- a/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java +++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java @@ -11,12 +11,15 @@ package org.appspot.apprtc; import android.content.Context; +import android.os.ParcelFileDescriptor; +import android.os.Environment; import android.util.Log; import org.appspot.apprtc.AppRTCClient.SignalingParameters; import org.appspot.apprtc.util.LooperExecutor; import org.webrtc.CameraEnumerationAndroid; import org.webrtc.DataChannel; +import org.webrtc.EglBase; import org.webrtc.IceCandidate; import org.webrtc.Logging; import org.webrtc.MediaCodecVideoEncoder; @@ -34,7 +37,10 @@ import org.webrtc.VideoCapturerAndroid; import org.webrtc.VideoRenderer; import org.webrtc.VideoSource; import org.webrtc.VideoTrack; +import org.webrtc.voiceengine.WebRtcAudioManager; +import java.io.File; +import java.io.IOException; import java.util.EnumSet; import java.util.LinkedList; import java.util.Timer; @@ -42,8 +48,6 @@ import java.util.TimerTask; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.microedition.khronos.egl.EGLContext; - /** * Peer connection client implementation. * @@ -55,7 +59,6 @@ public class PeerConnectionClient { public static final String VIDEO_TRACK_ID = "ARDAMSv0"; public static final String AUDIO_TRACK_ID = "ARDAMSa0"; private static final String TAG = "PCRTCClient"; - private static final String FIELD_TRIAL_VP9 = "WebRTC-SupportVP9/Enabled/"; private static final String FIELD_TRIAL_AUTOMATIC_RESIZE = "WebRTC-MediaCodecVideoEncoder-AutomaticResize/Enabled/"; private static final String VIDEO_CODEC_VP8 = "VP8"; @@ -94,7 +97,7 @@ public class PeerConnectionClient { private VideoSource videoSource; private boolean videoCallEnabled; private boolean preferIsac; - private boolean preferH264; + private String preferredVideoCodec; private boolean videoSourceStopped; private boolean isError; private Timer statsTimer; @@ -104,6 +107,7 @@ public class PeerConnectionClient { private MediaConstraints pcConstraints; private MediaConstraints videoConstraints; private MediaConstraints audioConstraints; + private ParcelFileDescriptor aecDumpFileDescriptor; private MediaConstraints sdpMediaConstraints; private PeerConnectionParameters peerConnectionParameters; // Queued remote ICE candidates are consumed only after both local and @@ -127,35 +131,41 @@ public class PeerConnectionClient { public static class PeerConnectionParameters { public final boolean videoCallEnabled; public final boolean loopback; + public final boolean tracing; public final int videoWidth; public final int videoHeight; public final int videoFps; public final int videoStartBitrate; public final String videoCodec; public final boolean videoCodecHwAcceleration; + public final boolean captureToTexture; public final int audioStartBitrate; public final String audioCodec; public final boolean noAudioProcessing; - public final boolean cpuOveruseDetection; + public final boolean aecDump; + public final boolean useOpenSLES; public PeerConnectionParameters( - boolean videoCallEnabled, boolean loopback, + boolean videoCallEnabled, boolean loopback, boolean tracing, int videoWidth, int videoHeight, int videoFps, int videoStartBitrate, - String videoCodec, boolean videoCodecHwAcceleration, + String videoCodec, boolean videoCodecHwAcceleration, boolean captureToTexture, int audioStartBitrate, String audioCodec, - boolean noAudioProcessing, boolean cpuOveruseDetection) { + boolean noAudioProcessing, boolean aecDump, boolean useOpenSLES) { this.videoCallEnabled = videoCallEnabled; this.loopback = loopback; + this.tracing = tracing; this.videoWidth = videoWidth; this.videoHeight = videoHeight; this.videoFps = videoFps; this.videoStartBitrate = videoStartBitrate; this.videoCodec = videoCodec; this.videoCodecHwAcceleration = videoCodecHwAcceleration; + this.captureToTexture = captureToTexture; this.audioStartBitrate = audioStartBitrate; this.audioCodec = audioCodec; this.noAudioProcessing = noAudioProcessing; - this.cpuOveruseDetection = cpuOveruseDetection; + this.aecDump = aecDump; + this.useOpenSLES = useOpenSLES; } } @@ -228,7 +238,6 @@ public class PeerConnectionClient { factory = null; peerConnection = null; preferIsac = false; - preferH264 = false; videoSourceStopped = false; isError = false; queuedRemoteCandidates = null; @@ -249,7 +258,7 @@ public class PeerConnectionClient { } public void createPeerConnection( - final EGLContext renderEGLContext, + final EglBase.Context renderEGLContext, final VideoRenderer.Callbacks localRender, final VideoRenderer.Callbacks remoteRender, final SignalingParameters signalingParameters) { @@ -283,31 +292,47 @@ public class PeerConnectionClient { } private void createPeerConnectionFactoryInternal(Context context) { + PeerConnectionFactory.initializeInternalTracer(); + if (peerConnectionParameters.tracing) { + PeerConnectionFactory.startInternalTracingCapture( + Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + + "webrtc-trace.txt"); + } Log.d(TAG, "Create peer connection factory. Use video: " + peerConnectionParameters.videoCallEnabled); isError = false; // Initialize field trials. - String field_trials = FIELD_TRIAL_AUTOMATIC_RESIZE; - // Check if VP9 is used by default. - if (videoCallEnabled && peerConnectionParameters.videoCodec != null - && peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_VP9)) { - field_trials += FIELD_TRIAL_VP9; + PeerConnectionFactory.initializeFieldTrials(FIELD_TRIAL_AUTOMATIC_RESIZE); + + // Check preferred video codec. + preferredVideoCodec = VIDEO_CODEC_VP8; + if (videoCallEnabled && peerConnectionParameters.videoCodec != null) { + if (peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_VP9)) { + preferredVideoCodec = VIDEO_CODEC_VP9; + } else if (peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_H264)) { + preferredVideoCodec = VIDEO_CODEC_H264; + } } - PeerConnectionFactory.initializeFieldTrials(field_trials); + Log.d(TAG, "Pereferred video codec: " + preferredVideoCodec); - // Check if H.264 is used by default. - preferH264 = false; - if (videoCallEnabled && peerConnectionParameters.videoCodec != null - && peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_H264)) { - preferH264 = true; - } // Check if ISAC is used by default. preferIsac = false; if (peerConnectionParameters.audioCodec != null && peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC)) { preferIsac = true; } + + // Enable/disable OpenSL ES playback. + if (!peerConnectionParameters.useOpenSLES) { + Log.d(TAG, "Disable OpenSL ES audio even if device supports it"); + WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true /* enable */); + } else { + Log.d(TAG, "Allow OpenSL ES audio if device supports it"); + WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(false); + } + + // Create peer connection factory. if (!PeerConnectionFactory.initializeAndroidGlobals(context, true, true, peerConnectionParameters.videoCodecHwAcceleration)) { events.onPeerConnectionError("Failed to initializeAndroidGlobals"); @@ -405,7 +430,7 @@ public class PeerConnectionClient { } } - private void createPeerConnectionInternal(EGLContext renderEGLContext) { + private void createPeerConnectionInternal(EglBase.Context renderEGLContext) { if (factory == null || isError) { Log.e(TAG, "Peerconnection factory is not created"); return; @@ -420,7 +445,7 @@ public class PeerConnectionClient { if (videoCallEnabled) { Log.d(TAG, "EGLContext: " + renderEGLContext); - factory.setVideoHwAccelerationOptions(renderEGLContext); + factory.setVideoHwAccelerationOptions(renderEGLContext, renderEGLContext); } PeerConnection.RTCConfiguration rtcConfig = @@ -453,7 +478,8 @@ public class PeerConnectionClient { cameraDeviceName = frontCameraDeviceName; } Log.d(TAG, "Opening camera: " + cameraDeviceName); - videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null); + videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, + peerConnectionParameters.captureToTexture ? renderEGLContext : null); if (videoCapturer == null) { reportError("Failed to open camera"); return; @@ -466,10 +492,26 @@ public class PeerConnectionClient { factory.createAudioSource(audioConstraints))); peerConnection.addStream(mediaStream); + if (peerConnectionParameters.aecDump) { + try { + aecDumpFileDescriptor = ParcelFileDescriptor.open( + new File("/sdcard/Download/audio.aecdump"), + ParcelFileDescriptor.MODE_READ_WRITE | + ParcelFileDescriptor.MODE_CREATE | + ParcelFileDescriptor.MODE_TRUNCATE); + factory.startAecDump(aecDumpFileDescriptor.getFd()); + } catch(IOException e) { + Log.e(TAG, "Can not open aecdump file", e); + } + } + Log.d(TAG, "Peer connection created."); } private void closeInternal() { + if (factory != null && peerConnectionParameters.aecDump) { + factory.stopAecDump(); + } Log.d(TAG, "Closing peer connection."); statsTimer.cancel(); if (peerConnection != null) { @@ -489,6 +531,8 @@ public class PeerConnectionClient { options = null; Log.d(TAG, "Closing peer connection done."); events.onPeerConnectionClosed(); + PeerConnectionFactory.stopInternalTracingCapture(); + PeerConnectionFactory.shutdownInternalTracer(); } public boolean isHDVideo() { @@ -623,8 +667,8 @@ public class PeerConnectionClient { if (preferIsac) { sdpDescription = preferCodec(sdpDescription, AUDIO_CODEC_ISAC, true); } - if (videoCallEnabled && preferH264) { - sdpDescription = preferCodec(sdpDescription, VIDEO_CODEC_H264, false); + if (videoCallEnabled) { + sdpDescription = preferCodec(sdpDescription, preferredVideoCodec, false); } if (videoCallEnabled && peerConnectionParameters.videoStartBitrate > 0) { sdpDescription = setStartBitrate(VIDEO_CODEC_VP8, true, @@ -972,8 +1016,8 @@ public class PeerConnectionClient { if (preferIsac) { sdpDescription = preferCodec(sdpDescription, AUDIO_CODEC_ISAC, true); } - if (videoCallEnabled && preferH264) { - sdpDescription = preferCodec(sdpDescription, VIDEO_CODEC_H264, false); + if (videoCallEnabled) { + sdpDescription = preferCodec(sdpDescription, preferredVideoCodec, false); } final SessionDescription sdp = new SessionDescription( origSdp.type, sdpDescription); diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java index 9ad6e4d8e4..06a2d06802 100644 --- a/webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java +++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java @@ -30,15 +30,18 @@ public class SettingsActivity extends Activity private String keyprefStartVideoBitrateValue; private String keyPrefVideoCodec; private String keyprefHwCodec; + private String keyprefCaptureToTexture; private String keyprefStartAudioBitrateType; private String keyprefStartAudioBitrateValue; private String keyPrefAudioCodec; private String keyprefNoAudioProcessing; + private String keyprefAecDump; + private String keyprefOpenSLES; - private String keyprefCpuUsageDetection; private String keyPrefRoomServerUrl; private String keyPrefDisplayHud; + private String keyPrefTracing; @Override protected void onCreate(Bundle savedInstanceState) { @@ -51,15 +54,18 @@ public class SettingsActivity extends Activity keyprefStartVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key); keyPrefVideoCodec = getString(R.string.pref_videocodec_key); keyprefHwCodec = getString(R.string.pref_hwcodec_key); + keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key); keyprefStartAudioBitrateType = getString(R.string.pref_startaudiobitrate_key); keyprefStartAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key); keyPrefAudioCodec = getString(R.string.pref_audiocodec_key); keyprefNoAudioProcessing = getString(R.string.pref_noaudioprocessing_key); + keyprefAecDump = getString(R.string.pref_aecdump_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); + keyPrefTracing = getString(R.string.pref_tracing_key); // Display the fragment as the main content. settingsFragment = new SettingsFragment(); @@ -84,16 +90,19 @@ public class SettingsActivity extends Activity setVideoBitrateEnable(sharedPreferences); updateSummary(sharedPreferences, keyPrefVideoCodec); updateSummaryB(sharedPreferences, keyprefHwCodec); + updateSummaryB(sharedPreferences, keyprefCaptureToTexture); updateSummary(sharedPreferences, keyprefStartAudioBitrateType); updateSummaryBitrate(sharedPreferences, keyprefStartAudioBitrateValue); setAudioBitrateEnable(sharedPreferences); updateSummary(sharedPreferences, keyPrefAudioCodec); updateSummaryB(sharedPreferences, keyprefNoAudioProcessing); + updateSummaryB(sharedPreferences, keyprefAecDump); + updateSummaryB(sharedPreferences, keyprefOpenSLES); - updateSummaryB(sharedPreferences, keyprefCpuUsageDetection); updateSummary(sharedPreferences, keyPrefRoomServerUrl); updateSummaryB(sharedPreferences, keyPrefDisplayHud); + updateSummaryB(sharedPreferences, keyPrefTracing); } @Override @@ -119,10 +128,13 @@ public class SettingsActivity extends Activity || key.equals(keyprefStartAudioBitrateValue)) { updateSummaryBitrate(sharedPreferences, key); } else if (key.equals(keyprefVideoCall) + || key.equals(keyPrefTracing) || key.equals(keyprefCaptureQualitySlider) || key.equals(keyprefHwCodec) + || key.equals(keyprefCaptureToTexture) || key.equals(keyprefNoAudioProcessing) - || key.equals(keyprefCpuUsageDetection) + || key.equals(keyprefAecDump) + || key.equals(keyprefOpenSLES) || key.equals(keyPrefDisplayHud)) { updateSummaryB(sharedPreferences, key); } |