Camera2 in AppRTC Android Demo.

Add an option to use Camera2 implemantion of CameraVideoCapturer in
AppRTC Android Demo. It is enabled by default.

BUG=webrtc:5519

Review-Url: https://codereview.webrtc.org/2077663003
Cr-Commit-Position: refs/heads/master@{#13391}
This commit is contained in:
sakal
2016-07-06 00:58:29 -07:00
committed by Commit bot
parent 9c0b551425
commit b224d80166
7 changed files with 124 additions and 39 deletions

View File

@ -9,16 +9,14 @@
</string> </string>
<string name="favorites">Favorites</string> <string name="favorites">Favorites</string>
<string name="no_favorites">No favorites</string> <string name="no_favorites">No favorites</string>
<string name="add_favorite_title">Add favorite</string>
<string name="invalid_url_title">Invalid URL</string> <string name="invalid_url_title">Invalid URL</string>
<string name="invalid_url_text">The URL or room name you entered resulted in an invalid URL: %1$s <string name="invalid_url_text">The URL or room name you entered resulted in an invalid URL: %1$s
</string> </string>
<string name="channel_error_title">Connection error</string> <string name="channel_error_title">Connection error</string>
<string name="connecting_to">Connecting to: %1$s</string> <string name="connecting_to">Connecting to: %1$s</string>
<string name="missing_url">FATAL ERROR: Missing URL to connect to.</string> <string name="missing_url">FATAL ERROR: Missing URL to connect to.</string>
<string name="camera2_texture_only_error">Camera2 only supports capturing to texture. Either disable Camera2 or enable capturing to texture in the options.</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="add">Add</string>
<string name="cancel">Cancel</string>
<string name="switch_camera">Switch front/back camera</string> <string name="switch_camera">Switch front/back camera</string>
<string name="capture_format_change_text">Slide to change capture format</string> <string name="capture_format_change_text">Slide to change capture format</string>
<string name="muted">Muted</string> <string name="muted">Muted</string>
@ -41,6 +39,11 @@
<string name="pref_videocall_dlg">Enable video in a call.</string> <string name="pref_videocall_dlg">Enable video in a call.</string>
<string name="pref_videocall_default">true</string> <string name="pref_videocall_default">true</string>
<string name="pref_camera2_key">camera2_preference</string>
<string name="pref_camera2_title">Use Camera2.</string>
<string name="pref_camera2_default">true</string>
<string name="pref_camera2_not_supported">Only supported on Android Lollipop and forward.</string>
<string name="pref_resolution_key">resolution_preference</string> <string name="pref_resolution_key">resolution_preference</string>
<string name="pref_resolution_title">Video resolution.</string> <string name="pref_resolution_title">Video resolution.</string>
<string name="pref_resolution_dlg">Enter AppRTC local video resolution.</string> <string name="pref_resolution_dlg">Enter AppRTC local video resolution.</string>
@ -79,7 +82,7 @@
<string name="pref_capturetotexture_key">capturetotexture_preference</string> <string name="pref_capturetotexture_key">capturetotexture_preference</string>
<string name="pref_capturetotexture_title">Video capture to surface texture.</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_dlg">Capture video to textures (if available).</string>
<string name="pref_capturetotexture_default">false</string> <string name="pref_capturetotexture_default">true</string>
<string name="pref_value_enabled">Enabled</string> <string name="pref_value_enabled">Enabled</string>
<string name="pref_value_disabled">Disabled</string> <string name="pref_value_disabled">Disabled</string>
@ -140,5 +143,4 @@
<string name="pref_tracing_title">Debug performance tracing.</string> <string name="pref_tracing_title">Debug performance tracing.</string>
<string name="pref_tracing_dlg">Debug performance tracing.</string> <string name="pref_tracing_dlg">Debug performance tracing.</string>
<string name="pref_tracing_default" translatable="false">false</string> <string name="pref_tracing_default" translatable="false">false</string>
</resources> </resources>

View File

@ -10,6 +10,11 @@
android:dialogTitle="@string/pref_videocall_dlg" android:dialogTitle="@string/pref_videocall_dlg"
android:defaultValue="@string/pref_videocall_default" /> android:defaultValue="@string/pref_videocall_default" />
<CheckBoxPreference
android:key="@string/pref_camera2_key"
android:title="@string/pref_camera2_title"
android:defaultValue="@string/pref_camera2_default" />
<ListPreference <ListPreference
android:key="@string/pref_resolution_key" android:key="@string/pref_resolution_key"
android:title="@string/pref_resolution_title" android:title="@string/pref_resolution_title"

View File

@ -10,6 +10,11 @@
package org.appspot.apprtc; package org.appspot.apprtc;
import org.appspot.apprtc.AppRTCClient.RoomConnectionParameters;
import org.appspot.apprtc.AppRTCClient.SignalingParameters;
import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters;
import org.appspot.apprtc.util.LooperExecutor;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
@ -25,10 +30,7 @@ import android.view.Window;
import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams;
import android.widget.Toast; import android.widget.Toast;
import org.appspot.apprtc.AppRTCClient.RoomConnectionParameters; import org.webrtc.Camera2Enumerator;
import org.appspot.apprtc.AppRTCClient.SignalingParameters;
import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters;
import org.appspot.apprtc.util.LooperExecutor;
import org.webrtc.EglBase; import org.webrtc.EglBase;
import org.webrtc.IceCandidate; import org.webrtc.IceCandidate;
import org.webrtc.PeerConnectionFactory; import org.webrtc.PeerConnectionFactory;
@ -52,6 +54,8 @@ public class CallActivity extends Activity
"org.appspot.apprtc.LOOPBACK"; "org.appspot.apprtc.LOOPBACK";
public static final String EXTRA_VIDEO_CALL = public static final String EXTRA_VIDEO_CALL =
"org.appspot.apprtc.VIDEO_CALL"; "org.appspot.apprtc.VIDEO_CALL";
public static final String EXTRA_CAMERA2 =
"org.appspot.apprtc.CAMERA2";
public static final String EXTRA_VIDEO_WIDTH = public static final String EXTRA_VIDEO_WIDTH =
"org.appspot.apprtc.VIDEO_WIDTH"; "org.appspot.apprtc.VIDEO_WIDTH";
public static final String EXTRA_VIDEO_HEIGHT = public static final String EXTRA_VIDEO_HEIGHT =
@ -219,12 +223,18 @@ public class CallActivity extends Activity
finish(); finish();
return; return;
} }
boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false);
boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false);
boolean useCamera2 = Camera2Enumerator.isSupported()
&& intent.getBooleanExtra(EXTRA_CAMERA2, true);
peerConnectionParameters = new PeerConnectionParameters( peerConnectionParameters = new PeerConnectionParameters(
intent.getBooleanExtra(EXTRA_VIDEO_CALL, true), intent.getBooleanExtra(EXTRA_VIDEO_CALL, true),
loopback, loopback,
tracing, tracing,
useCamera2,
intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0), intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0),
intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0), intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0),
intent.getIntExtra(EXTRA_VIDEO_FPS, 0), intent.getIntExtra(EXTRA_VIDEO_FPS, 0),

View File

@ -55,6 +55,7 @@ public class ConnectActivity extends Activity {
private ListView roomListView; private ListView roomListView;
private SharedPreferences sharedPref; private SharedPreferences sharedPref;
private String keyprefVideoCallEnabled; private String keyprefVideoCallEnabled;
private String keyprefCamera2;
private String keyprefResolution; private String keyprefResolution;
private String keyprefFps; private String keyprefFps;
private String keyprefCaptureQualitySlider; private String keyprefCaptureQualitySlider;
@ -86,6 +87,7 @@ public class ConnectActivity extends Activity {
PreferenceManager.setDefaultValues(this, R.xml.preferences, false); PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
sharedPref = PreferenceManager.getDefaultSharedPreferences(this); sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
keyprefVideoCallEnabled = getString(R.string.pref_videocall_key); keyprefVideoCallEnabled = getString(R.string.pref_videocall_key);
keyprefCamera2 = getString(R.string.pref_camera2_key);
keyprefResolution = getString(R.string.pref_resolution_key); keyprefResolution = getString(R.string.pref_resolution_key);
keyprefFps = getString(R.string.pref_fps_key); keyprefFps = getString(R.string.pref_fps_key);
keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key); keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key);
@ -259,6 +261,10 @@ public class ConnectActivity extends Activity {
boolean videoCallEnabled = sharedPref.getBoolean(keyprefVideoCallEnabled, boolean videoCallEnabled = sharedPref.getBoolean(keyprefVideoCallEnabled,
Boolean.valueOf(getString(R.string.pref_videocall_default))); Boolean.valueOf(getString(R.string.pref_videocall_default)));
// Use Camera2 option.
boolean useCamera2 = sharedPref.getBoolean(keyprefCamera2,
Boolean.valueOf(getString(R.string.pref_camera2_default)));
// Get default codecs. // Get default codecs.
String videoCodec = sharedPref.getString(keyprefVideoCodec, String videoCodec = sharedPref.getString(keyprefVideoCodec,
getString(R.string.pref_videocodec_default)); getString(R.string.pref_videocodec_default));
@ -364,6 +370,7 @@ public class ConnectActivity extends Activity {
intent.putExtra(CallActivity.EXTRA_ROOMID, roomId); intent.putExtra(CallActivity.EXTRA_ROOMID, roomId);
intent.putExtra(CallActivity.EXTRA_LOOPBACK, loopback); intent.putExtra(CallActivity.EXTRA_LOOPBACK, loopback);
intent.putExtra(CallActivity.EXTRA_VIDEO_CALL, videoCallEnabled); intent.putExtra(CallActivity.EXTRA_VIDEO_CALL, videoCallEnabled);
intent.putExtra(CallActivity.EXTRA_CAMERA2, useCamera2);
intent.putExtra(CallActivity.EXTRA_VIDEO_WIDTH, videoWidth); intent.putExtra(CallActivity.EXTRA_VIDEO_WIDTH, videoWidth);
intent.putExtra(CallActivity.EXTRA_VIDEO_HEIGHT, videoHeight); intent.putExtra(CallActivity.EXTRA_VIDEO_HEIGHT, videoHeight);
intent.putExtra(CallActivity.EXTRA_VIDEO_FPS, cameraFps); intent.putExtra(CallActivity.EXTRA_VIDEO_FPS, cameraFps);

View File

@ -19,7 +19,11 @@ import android.util.Log;
import org.webrtc.AudioSource; import org.webrtc.AudioSource;
import org.webrtc.AudioTrack; import org.webrtc.AudioTrack;
import org.webrtc.Camera1Enumerator;
import org.webrtc.Camera2Enumerator;
import org.webrtc.CameraEnumerationAndroid; import org.webrtc.CameraEnumerationAndroid;
import org.webrtc.CameraEnumerator;
import org.webrtc.CameraVideoCapturer;
import org.webrtc.DataChannel; import org.webrtc.DataChannel;
import org.webrtc.EglBase; import org.webrtc.EglBase;
import org.webrtc.IceCandidate; import org.webrtc.IceCandidate;
@ -35,7 +39,7 @@ import org.webrtc.SdpObserver;
import org.webrtc.SessionDescription; import org.webrtc.SessionDescription;
import org.webrtc.StatsObserver; import org.webrtc.StatsObserver;
import org.webrtc.StatsReport; import org.webrtc.StatsReport;
import org.webrtc.VideoCapturerAndroid; import org.webrtc.VideoCapturer;
import org.webrtc.VideoRenderer; import org.webrtc.VideoRenderer;
import org.webrtc.VideoSource; import org.webrtc.VideoSource;
import org.webrtc.VideoTrack; import org.webrtc.VideoTrack;
@ -48,7 +52,6 @@ import java.util.EnumSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -95,6 +98,7 @@ public class PeerConnectionClient {
private final SDPObserver sdpObserver = new SDPObserver(); private final SDPObserver sdpObserver = new SDPObserver();
private final ScheduledExecutorService executor; private final ScheduledExecutorService executor;
private Context context;
private PeerConnectionFactory factory; private PeerConnectionFactory factory;
private PeerConnection peerConnection; private PeerConnection peerConnection;
PeerConnectionFactory.Options options = null; PeerConnectionFactory.Options options = null;
@ -124,7 +128,7 @@ public class PeerConnectionClient {
private SessionDescription localSdp; // either offer or answer SDP private SessionDescription localSdp; // either offer or answer SDP
private MediaStream mediaStream; private MediaStream mediaStream;
private int numberOfCameras; private int numberOfCameras;
private VideoCapturerAndroid videoCapturer; private CameraVideoCapturer videoCapturer;
// enableVideo is set to true if video should be rendered and sent. // enableVideo is set to true if video should be rendered and sent.
private boolean renderVideo; private boolean renderVideo;
private VideoTrack localVideoTrack; private VideoTrack localVideoTrack;
@ -140,6 +144,7 @@ public class PeerConnectionClient {
public final boolean videoCallEnabled; public final boolean videoCallEnabled;
public final boolean loopback; public final boolean loopback;
public final boolean tracing; public final boolean tracing;
public final boolean useCamera2;
public final int videoWidth; public final int videoWidth;
public final int videoHeight; public final int videoHeight;
public final int videoFps; public final int videoFps;
@ -155,13 +160,14 @@ public class PeerConnectionClient {
public final boolean disableBuiltInAEC; public final boolean disableBuiltInAEC;
public PeerConnectionParameters( public PeerConnectionParameters(
boolean videoCallEnabled, boolean loopback, boolean tracing, boolean videoCallEnabled, boolean loopback, boolean tracing, boolean useCamera2,
int videoWidth, int videoHeight, int videoFps, int videoStartBitrate, int videoWidth, int videoHeight, int videoFps,
String videoCodec, boolean videoCodecHwAcceleration, boolean captureToTexture, int videoStartBitrate, String videoCodec, boolean videoCodecHwAcceleration,
int audioStartBitrate, String audioCodec, boolean captureToTexture, int audioStartBitrate, String audioCodec,
boolean noAudioProcessing, boolean aecDump, boolean useOpenSLES, boolean noAudioProcessing, boolean aecDump, boolean useOpenSLES,
boolean disableBuiltInAEC) { boolean disableBuiltInAEC) {
this.videoCallEnabled = videoCallEnabled; this.videoCallEnabled = videoCallEnabled;
this.useCamera2 = useCamera2;
this.loopback = loopback; this.loopback = loopback;
this.tracing = tracing; this.tracing = tracing;
this.videoWidth = videoWidth; this.videoWidth = videoWidth;
@ -250,6 +256,7 @@ public class PeerConnectionClient {
this.events = events; this.events = events;
videoCallEnabled = peerConnectionParameters.videoCallEnabled; videoCallEnabled = peerConnectionParameters.videoCallEnabled;
// Reset variables to initial states. // Reset variables to initial states.
this.context = null;
factory = null; factory = null;
peerConnection = null; peerConnection = null;
preferIsac = false; preferIsac = false;
@ -367,6 +374,7 @@ public class PeerConnectionClient {
if (options != null) { if (options != null) {
Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMask); Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMask);
} }
this.context = context;
factory = new PeerConnectionFactory(options); factory = new PeerConnectionFactory(options);
Log.d(TAG, "Peer connection factory created."); Log.d(TAG, "Peer connection factory created.");
} }
@ -456,6 +464,36 @@ public class PeerConnectionClient {
} }
} }
private void createCapturer(CameraEnumerator enumerator) {
final String[] deviceNames = enumerator.getDeviceNames();
// First, try to find front facing camera
Logging.d(TAG, "Looking for front facing cameras.");
for (String deviceName : deviceNames) {
if (enumerator.isFrontFacing(deviceName)) {
Logging.d(TAG, "Creating front facing camera capturer.");
videoCapturer = enumerator.createCapturer(deviceName, null);
if (videoCapturer != null) {
return;
}
}
}
// Front facing camera not found, try something else
Logging.d(TAG, "Looking for other cameras.");
for (String deviceName : deviceNames) {
if (!enumerator.isFrontFacing(deviceName)) {
Logging.d(TAG, "Creating other camera capturer.");
videoCapturer = enumerator.createCapturer(deviceName, null);
if (videoCapturer != null) {
return;
}
}
}
}
private void createPeerConnectionInternal(EglBase.Context renderEGLContext) { private void createPeerConnectionInternal(EglBase.Context renderEGLContext) {
if (factory == null || isError) { if (factory == null || isError) {
Log.e(TAG, "Peerconnection factory is not created"); Log.e(TAG, "Peerconnection factory is not created");
@ -498,15 +536,19 @@ public class PeerConnectionClient {
mediaStream = factory.createLocalMediaStream("ARDAMS"); mediaStream = factory.createLocalMediaStream("ARDAMS");
if (videoCallEnabled) { if (videoCallEnabled) {
String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0); if (peerConnectionParameters.useCamera2) {
String frontCameraDeviceName = if (!peerConnectionParameters.captureToTexture) {
CameraEnumerationAndroid.getNameOfFrontFacingDevice(); reportError(context.getString(R.string.camera2_texture_only_error));
if (numberOfCameras > 1 && frontCameraDeviceName != null) { return;
cameraDeviceName = frontCameraDeviceName; }
Logging.d(TAG, "Creating capturer using camera2 API.");
createCapturer(new Camera2Enumerator(context));
} else {
Logging.d(TAG, "Creating capturer using camera1 API.");
createCapturer(new Camera1Enumerator(peerConnectionParameters.captureToTexture));
} }
Log.d(TAG, "Opening camera: " + cameraDeviceName);
videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null,
peerConnectionParameters.captureToTexture);
if (videoCapturer == null) { if (videoCapturer == null) {
reportError("Failed to open camera"); reportError("Failed to open camera");
return; return;
@ -791,7 +833,7 @@ public class PeerConnectionClient {
return localAudioTrack; return localAudioTrack;
} }
private VideoTrack createVideoTrack(VideoCapturerAndroid capturer) { private VideoTrack createVideoTrack(VideoCapturer capturer) {
videoSource = factory.createVideoSource(capturer, videoConstraints); videoSource = factory.createVideoSource(capturer, videoConstraints);
localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource); localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource);

View File

@ -14,8 +14,10 @@ import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import org.webrtc.Camera2Enumerator;
import org.webrtc.voiceengine.WebRtcAudioUtils; import org.webrtc.voiceengine.WebRtcAudioUtils;
/** /**
@ -25,6 +27,7 @@ public class SettingsActivity extends Activity
implements OnSharedPreferenceChangeListener{ implements OnSharedPreferenceChangeListener{
private SettingsFragment settingsFragment; private SettingsFragment settingsFragment;
private String keyprefVideoCall; private String keyprefVideoCall;
private String keyprefCamera2;
private String keyprefResolution; private String keyprefResolution;
private String keyprefFps; private String keyprefFps;
private String keyprefCaptureQualitySlider; private String keyprefCaptureQualitySlider;
@ -50,6 +53,7 @@ public class SettingsActivity extends Activity
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
keyprefVideoCall = getString(R.string.pref_videocall_key); keyprefVideoCall = getString(R.string.pref_videocall_key);
keyprefCamera2 = getString(R.string.pref_camera2_key);
keyprefResolution = getString(R.string.pref_resolution_key); keyprefResolution = getString(R.string.pref_resolution_key);
keyprefFps = getString(R.string.pref_fps_key); keyprefFps = getString(R.string.pref_fps_key);
keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key); keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key);
@ -86,6 +90,7 @@ public class SettingsActivity extends Activity
settingsFragment.getPreferenceScreen().getSharedPreferences(); settingsFragment.getPreferenceScreen().getSharedPreferences();
sharedPreferences.registerOnSharedPreferenceChangeListener(this); sharedPreferences.registerOnSharedPreferenceChangeListener(this);
updateSummaryB(sharedPreferences, keyprefVideoCall); updateSummaryB(sharedPreferences, keyprefVideoCall);
updateSummaryB(sharedPreferences, keyprefCamera2);
updateSummary(sharedPreferences, keyprefResolution); updateSummary(sharedPreferences, keyprefResolution);
updateSummary(sharedPreferences, keyprefFps); updateSummary(sharedPreferences, keyprefFps);
updateSummaryB(sharedPreferences, keyprefCaptureQualitySlider); updateSummaryB(sharedPreferences, keyprefCaptureQualitySlider);
@ -109,6 +114,14 @@ public class SettingsActivity extends Activity
updateSummaryB(sharedPreferences, keyPrefDisplayHud); updateSummaryB(sharedPreferences, keyPrefDisplayHud);
updateSummaryB(sharedPreferences, keyPrefTracing); updateSummaryB(sharedPreferences, keyPrefTracing);
if (!Camera2Enumerator.isSupported()) {
Preference camera2Preference =
settingsFragment.findPreference(keyprefCamera2);
camera2Preference.setSummary(getString(R.string.pref_camera2_not_supported));
camera2Preference.setEnabled(false);
}
// Disable forcing WebRTC based AEC so it won't affect our value. // Disable forcing WebRTC based AEC so it won't affect our value.
// Otherwise, if it was enabled, isAcousticEchoCancelerSupported would always return false. // Otherwise, if it was enabled, isAcousticEchoCancelerSupported would always return false.
WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(false); WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(false);
@ -116,7 +129,6 @@ public class SettingsActivity extends Activity
Preference disableBuiltInAECPreference = Preference disableBuiltInAECPreference =
settingsFragment.findPreference(keyprefDisableBuiltInAEC); settingsFragment.findPreference(keyprefDisableBuiltInAEC);
disableBuiltInAECPreference.setSummary(getString(R.string.pref_built_in_aec_not_available)); disableBuiltInAECPreference.setSummary(getString(R.string.pref_built_in_aec_not_available));
disableBuiltInAECPreference.setEnabled(false); disableBuiltInAECPreference.setEnabled(false);
} }
@ -145,6 +157,7 @@ public class SettingsActivity extends Activity
|| key.equals(keyprefStartAudioBitrateValue)) { || key.equals(keyprefStartAudioBitrateValue)) {
updateSummaryBitrate(sharedPreferences, key); updateSummaryBitrate(sharedPreferences, key);
} else if (key.equals(keyprefVideoCall) } else if (key.equals(keyprefVideoCall)
|| key.equals(keyprefCamera2)
|| key.equals(keyPrefTracing) || key.equals(keyPrefTracing)
|| key.equals(keyprefCaptureQualitySlider) || key.equals(keyprefCaptureQualitySlider)
|| key.equals(keyprefHwCodec) || key.equals(keyprefHwCodec)

View File

@ -10,18 +10,17 @@
package org.appspot.apprtc.test; package org.appspot.apprtc.test;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.appspot.apprtc.AppRTCClient.SignalingParameters; import org.appspot.apprtc.AppRTCClient.SignalingParameters;
import org.appspot.apprtc.PeerConnectionClient; import org.appspot.apprtc.PeerConnectionClient;
import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents; import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents;
import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters; import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters;
import android.os.Build;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
import org.webrtc.Camera2Enumerator;
import org.webrtc.EglBase; import org.webrtc.EglBase;
import org.webrtc.IceCandidate; import org.webrtc.IceCandidate;
import org.webrtc.MediaCodecVideoEncoder; import org.webrtc.MediaCodecVideoEncoder;
@ -31,10 +30,13 @@ import org.webrtc.SessionDescription;
import org.webrtc.StatsReport; import org.webrtc.StatsReport;
import org.webrtc.VideoRenderer; import org.webrtc.VideoRenderer;
import android.os.Build; import java.util.LinkedList;
import android.test.InstrumentationTestCase; import java.util.List;
import android.test.suitebuilder.annotation.SmallTest; import java.util.concurrent.CountDownLatch;
import android.util.Log; import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class PeerConnectionClientTest extends InstrumentationTestCase public class PeerConnectionClientTest extends InstrumentationTestCase
implements PeerConnectionEvents { implements PeerConnectionEvents {
@ -254,7 +256,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
options.disableNetworkMonitor = true; options.disableNetworkMonitor = true;
client.setPeerConnectionFactoryOptions(options); client.setPeerConnectionFactoryOptions(options);
client.createPeerConnectionFactory( client.createPeerConnectionFactory(
getInstrumentation().getContext(), peerConnectionParameters, this); getInstrumentation().getTargetContext(), peerConnectionParameters, this);
client.createPeerConnection(eglContext, localRenderer, remoteRenderer, signalingParameters); client.createPeerConnection(eglContext, localRenderer, remoteRenderer, signalingParameters);
client.createOffer(); client.createOffer();
return client; return client;
@ -267,6 +269,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
true, /* loopback */ true, /* loopback */
false, /* tracing */ false, /* tracing */
// Video codec parameters. // Video codec parameters.
true, /* useCamera2 */
0, /* videoWidth */ 0, /* videoWidth */
0, /* videoHeight */ 0, /* videoHeight */
0, /* videoFps */ 0, /* videoFps */
@ -286,12 +289,15 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
private PeerConnectionParameters createParametersForVideoCall( private PeerConnectionParameters createParametersForVideoCall(
String videoCodec, boolean captureToTexture) { String videoCodec, boolean captureToTexture) {
final boolean useCamera2 = captureToTexture && Camera2Enumerator.isSupported();
PeerConnectionParameters peerConnectionParameters = PeerConnectionParameters peerConnectionParameters =
new PeerConnectionParameters( new PeerConnectionParameters(
true, /* videoCallEnabled */ true, /* videoCallEnabled */
true, /* loopback */ true, /* loopback */
false, /* tracing */ false, /* tracing */
// Video codec parameters. // Video codec parameters.
useCamera2, /* useCamera2 */
0, /* videoWidth */ 0, /* videoWidth */
0, /* videoHeight */ 0, /* videoHeight */
0, /* videoFps */ 0, /* videoFps */