Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java

Issue 2077663003: Camera2 in AppRTC Android Demo. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@camera2_only
Patch Set: Create peer connection factory with the target context in the test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 package org.appspot.apprtc.test; 11 package org.appspot.apprtc.test;
12 12
13 import java.util.LinkedList;
14 import java.util.List;
15 import java.util.concurrent.CountDownLatch;
16 import java.util.concurrent.Executor;
17 import java.util.concurrent.ExecutorService;
18 import java.util.concurrent.Executors;
19 import java.util.concurrent.TimeUnit;
20
21 import org.appspot.apprtc.AppRTCClient.SignalingParameters; 13 import org.appspot.apprtc.AppRTCClient.SignalingParameters;
22 import org.appspot.apprtc.PeerConnectionClient; 14 import org.appspot.apprtc.PeerConnectionClient;
23 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents; 15 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents;
24 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters; 16 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters;
17
18 import android.os.Build;
19 import android.test.InstrumentationTestCase;
20 import android.test.suitebuilder.annotation.SmallTest;
21 import android.util.Log;
22
23 import org.webrtc.Camera2Enumerator;
25 import org.webrtc.EglBase; 24 import org.webrtc.EglBase;
26 import org.webrtc.IceCandidate; 25 import org.webrtc.IceCandidate;
27 import org.webrtc.MediaCodecVideoEncoder; 26 import org.webrtc.MediaCodecVideoEncoder;
28 import org.webrtc.PeerConnection; 27 import org.webrtc.PeerConnection;
29 import org.webrtc.PeerConnectionFactory; 28 import org.webrtc.PeerConnectionFactory;
30 import org.webrtc.SessionDescription; 29 import org.webrtc.SessionDescription;
31 import org.webrtc.StatsReport; 30 import org.webrtc.StatsReport;
32 import org.webrtc.VideoRenderer; 31 import org.webrtc.VideoRenderer;
33 32
34 import android.os.Build; 33 import java.util.LinkedList;
35 import android.test.InstrumentationTestCase; 34 import java.util.List;
36 import android.test.suitebuilder.annotation.SmallTest; 35 import java.util.concurrent.CountDownLatch;
37 import android.util.Log; 36 import java.util.concurrent.Executor;
37 import java.util.concurrent.ExecutorService;
38 import java.util.concurrent.Executors;
39 import java.util.concurrent.TimeUnit;
38 40
39 public class PeerConnectionClientTest extends InstrumentationTestCase 41 public class PeerConnectionClientTest extends InstrumentationTestCase
40 implements PeerConnectionEvents { 42 implements PeerConnectionEvents {
41 private static final String TAG = "RTCClientTest"; 43 private static final String TAG = "RTCClientTest";
42 private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000; 44 private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000;
43 private static final int WAIT_TIMEOUT = 7000; 45 private static final int WAIT_TIMEOUT = 7000;
44 private static final int CAMERA_SWITCH_ATTEMPTS = 3; 46 private static final int CAMERA_SWITCH_ATTEMPTS = 3;
45 private static final int VIDEO_RESTART_ATTEMPTS = 3; 47 private static final int VIDEO_RESTART_ATTEMPTS = 3;
46 private static final int CAPTURE_FORMAT_CHANGE_ATTEMPTS = 3; 48 private static final int CAPTURE_FORMAT_CHANGE_ATTEMPTS = 3;
47 private static final int VIDEO_RESTART_TIMEOUT = 500; 49 private static final int VIDEO_RESTART_TIMEOUT = 500;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 iceServers, true, // iceServers, initiator. 249 iceServers, true, // iceServers, initiator.
248 null, null, null, // clientId, wssUrl, wssPostUrl. 250 null, null, null, // clientId, wssUrl, wssPostUrl.
249 null, null); // offerSdp, iceCandidates. 251 null, null); // offerSdp, iceCandidates.
250 252
251 PeerConnectionClient client = PeerConnectionClient.getInstance(); 253 PeerConnectionClient client = PeerConnectionClient.getInstance();
252 PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); 254 PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
253 options.networkIgnoreMask = 0; 255 options.networkIgnoreMask = 0;
254 options.disableNetworkMonitor = true; 256 options.disableNetworkMonitor = true;
255 client.setPeerConnectionFactoryOptions(options); 257 client.setPeerConnectionFactoryOptions(options);
256 client.createPeerConnectionFactory( 258 client.createPeerConnectionFactory(
257 getInstrumentation().getContext(), peerConnectionParameters, this); 259 getInstrumentation().getTargetContext(), peerConnectionParameters, this) ;
258 client.createPeerConnection(eglContext, localRenderer, remoteRenderer, signa lingParameters); 260 client.createPeerConnection(eglContext, localRenderer, remoteRenderer, signa lingParameters);
259 client.createOffer(); 261 client.createOffer();
260 return client; 262 return client;
261 } 263 }
262 264
263 private PeerConnectionParameters createParametersForAudioCall() { 265 private PeerConnectionParameters createParametersForAudioCall() {
264 PeerConnectionParameters peerConnectionParameters = 266 PeerConnectionParameters peerConnectionParameters =
265 new PeerConnectionParameters( 267 new PeerConnectionParameters(
266 false, /* videoCallEnabled */ 268 false, /* videoCallEnabled */
267 true, /* loopback */ 269 true, /* loopback */
268 false, /* tracing */ 270 false, /* tracing */
269 // Video codec parameters. 271 // Video codec parameters.
272 true, /* useCamera2 */
270 0, /* videoWidth */ 273 0, /* videoWidth */
271 0, /* videoHeight */ 274 0, /* videoHeight */
272 0, /* videoFps */ 275 0, /* videoFps */
273 0, /* videoStartBitrate */ 276 0, /* videoStartBitrate */
274 "", /* videoCodec */ 277 "", /* videoCodec */
275 true, /* videoCodecHwAcceleration */ 278 true, /* videoCodecHwAcceleration */
276 false, /* captureToToTexture */ 279 false, /* captureToToTexture */
277 // Audio codec parameters. 280 // Audio codec parameters.
278 0, /* audioStartBitrate */ 281 0, /* audioStartBitrate */
279 "OPUS", /* audioCodec */ 282 "OPUS", /* audioCodec */
280 false, /* noAudioProcessing */ 283 false, /* noAudioProcessing */
281 false, /* aecDump */ 284 false, /* aecDump */
282 false /* useOpenSLES */, 285 false /* useOpenSLES */,
283 false /* disableBuiltInAEC */); 286 false /* disableBuiltInAEC */);
284 return peerConnectionParameters; 287 return peerConnectionParameters;
285 } 288 }
286 289
287 private PeerConnectionParameters createParametersForVideoCall( 290 private PeerConnectionParameters createParametersForVideoCall(
288 String videoCodec, boolean captureToTexture) { 291 String videoCodec, boolean captureToTexture) {
292 final boolean useCamera2 = captureToTexture && Camera2Enumerator.isSupported ();
293
289 PeerConnectionParameters peerConnectionParameters = 294 PeerConnectionParameters peerConnectionParameters =
290 new PeerConnectionParameters( 295 new PeerConnectionParameters(
291 true, /* videoCallEnabled */ 296 true, /* videoCallEnabled */
292 true, /* loopback */ 297 true, /* loopback */
293 false, /* tracing */ 298 false, /* tracing */
294 // Video codec parameters. 299 // Video codec parameters.
300 useCamera2, /* useCamera2 */
295 0, /* videoWidth */ 301 0, /* videoWidth */
296 0, /* videoHeight */ 302 0, /* videoHeight */
297 0, /* videoFps */ 303 0, /* videoFps */
298 0, /* videoStartBitrate */ 304 0, /* videoStartBitrate */
299 videoCodec, /* videoCodec */ 305 videoCodec, /* videoCodec */
300 true, /* videoCodecHwAcceleration */ 306 true, /* videoCodecHwAcceleration */
301 captureToTexture, /* captureToToTexture */ 307 captureToTexture, /* captureToToTexture */
302 // Audio codec parameters. 308 // Audio codec parameters.
303 0, /* audioStartBitrate */ 309 0, /* audioStartBitrate */
304 "OPUS", /* audioCodec */ 310 "OPUS", /* audioCodec */
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 assertTrue("Remote video frames were not rendered after capture format cha nge.", 660 assertTrue("Remote video frames were not rendered after capture format cha nge.",
655 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); 661 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT));
656 } 662 }
657 663
658 pcClient.close(); 664 pcClient.close();
659 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); 665 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT));
660 Log.d(TAG, "testCaptureFormatChange done."); 666 Log.d(TAG, "testCaptureFormatChange done.");
661 } 667 }
662 668
663 } 669 }
OLDNEW
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698