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

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

Issue 1992213002: Replace LooperExecutor with built-in class in Android AppRTC Demo (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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
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; 13 import java.util.LinkedList;
14 import java.util.List; 14 import java.util.List;
15 import java.util.concurrent.CountDownLatch; 15 import java.util.concurrent.CountDownLatch;
16 import java.util.concurrent.Executor;
17 import java.util.concurrent.ExecutorService;
18 import java.util.concurrent.Executors;
16 import java.util.concurrent.TimeUnit; 19 import java.util.concurrent.TimeUnit;
17 20
18 import org.appspot.apprtc.AppRTCClient.SignalingParameters; 21 import org.appspot.apprtc.AppRTCClient.SignalingParameters;
19 import org.appspot.apprtc.PeerConnectionClient; 22 import org.appspot.apprtc.PeerConnectionClient;
20 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents; 23 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents;
21 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters; 24 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters;
22 import org.appspot.apprtc.util.LooperExecutor;
23 import org.webrtc.EglBase; 25 import org.webrtc.EglBase;
24 import org.webrtc.IceCandidate; 26 import org.webrtc.IceCandidate;
25 import org.webrtc.MediaCodecVideoEncoder; 27 import org.webrtc.MediaCodecVideoEncoder;
26 import org.webrtc.PeerConnection; 28 import org.webrtc.PeerConnection;
27 import org.webrtc.PeerConnectionFactory; 29 import org.webrtc.PeerConnectionFactory;
28 import org.webrtc.SessionDescription; 30 import org.webrtc.SessionDescription;
29 import org.webrtc.StatsReport; 31 import org.webrtc.StatsReport;
30 import org.webrtc.VideoRenderer; 32 import org.webrtc.VideoRenderer;
31 33
32 import android.os.Build; 34 import android.os.Build;
(...skipping 26 matching lines...) Expand all
59 61
60 // The peer connection client is assumed to be thread safe in itself; the 62 // The peer connection client is assumed to be thread safe in itself; the
61 // reference is written by the test thread and read by worker threads. 63 // reference is written by the test thread and read by worker threads.
62 private volatile PeerConnectionClient pcClient; 64 private volatile PeerConnectionClient pcClient;
63 private volatile boolean loopback; 65 private volatile boolean loopback;
64 66
65 // EGL context that can be used by hardware video decoders to decode to a text ure. 67 // EGL context that can be used by hardware video decoders to decode to a text ure.
66 private EglBase eglBase; 68 private EglBase eglBase;
67 69
68 // These are protected by their respective event objects. 70 // These are protected by their respective event objects.
69 private LooperExecutor signalingExecutor; 71 private ExecutorService signalingExecutor;
70 private boolean isClosed; 72 private boolean isClosed;
71 private boolean isIceConnected; 73 private boolean isIceConnected;
72 private SessionDescription localSdp; 74 private SessionDescription localSdp;
73 private List<IceCandidate> iceCandidates = new LinkedList<IceCandidate>(); 75 private List<IceCandidate> iceCandidates = new LinkedList<IceCandidate>();
74 private final Object localSdpEvent = new Object(); 76 private final Object localSdpEvent = new Object();
75 private final Object iceCandidateEvent = new Object(); 77 private final Object iceCandidateEvent = new Object();
76 private final Object iceConnectedEvent = new Object(); 78 private final Object iceConnectedEvent = new Object();
77 private final Object closeEvent = new Object(); 79 private final Object closeEvent = new Object();
78 80
79 // Mock renderer implementation. 81 // Mock renderer implementation.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 PeerConnectionParameters peerConnectionParameters = 274 PeerConnectionParameters peerConnectionParameters =
273 new PeerConnectionParameters( 275 new PeerConnectionParameters(
274 true, true, false, // videoCallEnabled, loopback, tracing. 276 true, true, false, // videoCallEnabled, loopback, tracing.
275 0, 0, 0, 0, videoCodec, true, captureToTexture, // video codec param eters. 277 0, 0, 0, 0, videoCodec, true, captureToTexture, // video codec param eters.
276 0, "OPUS", false, false, false); // audio codec parameters. 278 0, "OPUS", false, false, false); // audio codec parameters.
277 return peerConnectionParameters; 279 return peerConnectionParameters;
278 } 280 }
279 281
280 @Override 282 @Override
281 public void setUp() { 283 public void setUp() {
282 signalingExecutor = new LooperExecutor(); 284 signalingExecutor = Executors.newSingleThreadExecutor();
283 signalingExecutor.requestStart();
284 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 285 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
285 eglBase = EglBase.create(); 286 eglBase = EglBase.create();
286 } 287 }
287 } 288 }
288 289
289 @Override 290 @Override
290 public void tearDown() { 291 public void tearDown() {
291 signalingExecutor.requestStop(); 292 signalingExecutor.shutdown();
292 if (eglBase != null) { 293 if (eglBase != null) {
293 eglBase.release(); 294 eglBase.release();
294 } 295 }
295 } 296 }
296 297
297 @SmallTest 298 @SmallTest
298 public void testSetLocalOfferMakesVideoFlowLocally() 299 public void testSetLocalOfferMakesVideoFlowLocally()
299 throws InterruptedException { 300 throws InterruptedException {
300 Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); 301 Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally");
301 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME); 302 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 assertTrue("Remote video frames were not rendered after capture format cha nge.", 624 assertTrue("Remote video frames were not rendered after capture format cha nge.",
624 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); 625 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT));
625 } 626 }
626 627
627 pcClient.close(); 628 pcClient.close();
628 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); 629 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT));
629 Log.d(TAG, "testCaptureFormatChange done."); 630 Log.d(TAG, "testCaptureFormatChange done.");
630 } 631 }
631 632
632 } 633 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698