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

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

Issue 1732533002: Add an option to soft reset HW decoder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address comments Created 4 years, 9 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
(...skipping 22 matching lines...) Expand all
33 import android.test.InstrumentationTestCase; 33 import android.test.InstrumentationTestCase;
34 import android.util.Log; 34 import android.util.Log;
35 35
36 public class PeerConnectionClientTest extends InstrumentationTestCase 36 public class PeerConnectionClientTest extends InstrumentationTestCase
37 implements PeerConnectionEvents { 37 implements PeerConnectionEvents {
38 private static final String TAG = "RTCClientTest"; 38 private static final String TAG = "RTCClientTest";
39 private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000; 39 private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000;
40 private static final int WAIT_TIMEOUT = 7000; 40 private static final int WAIT_TIMEOUT = 7000;
41 private static final int CAMERA_SWITCH_ATTEMPTS = 3; 41 private static final int CAMERA_SWITCH_ATTEMPTS = 3;
42 private static final int VIDEO_RESTART_ATTEMPTS = 3; 42 private static final int VIDEO_RESTART_ATTEMPTS = 3;
43 private static final int CAPTURE_FORMAT_CHANGE_ATTEMPTS = 3;
43 private static final int VIDEO_RESTART_TIMEOUT = 500; 44 private static final int VIDEO_RESTART_TIMEOUT = 500;
44 private static final int EXPECTED_VIDEO_FRAMES = 10; 45 private static final int EXPECTED_VIDEO_FRAMES = 10;
45 private static final String VIDEO_CODEC_VP8 = "VP8"; 46 private static final String VIDEO_CODEC_VP8 = "VP8";
46 private static final String VIDEO_CODEC_VP9 = "VP9"; 47 private static final String VIDEO_CODEC_VP9 = "VP9";
47 private static final String VIDEO_CODEC_H264 = "H264"; 48 private static final String VIDEO_CODEC_H264 = "H264";
48 private static final int AUDIO_RUN_TIMEOUT = 1000; 49 private static final int AUDIO_RUN_TIMEOUT = 1000;
49 private static final String LOCAL_RENDERER_NAME = "Local renderer"; 50 private static final String LOCAL_RENDERER_NAME = "Local renderer";
50 private static final String REMOTE_RENDERER_NAME = "Remote renderer"; 51 private static final String REMOTE_RENDERER_NAME = "Remote renderer";
51 52
53 private static final int MAX_VIDEO_FPS = 30;
54 private static final int WIDTH_VGA = 640;
55 private static final int HEIGHT_VGA = 480;
56 private static final int WIDTH_QVGA = 320;
57 private static final int HEIGHT_QVGA = 240;
58
52 // The peer connection client is assumed to be thread safe in itself; the 59 // The peer connection client is assumed to be thread safe in itself; the
53 // reference is written by the test thread and read by worker threads. 60 // reference is written by the test thread and read by worker threads.
54 private volatile PeerConnectionClient pcClient; 61 private volatile PeerConnectionClient pcClient;
55 private volatile boolean loopback; 62 private volatile boolean loopback;
56 63
57 // EGL context that can be used by hardware video decoders to decode to a text ure. 64 // EGL context that can be used by hardware video decoders to decode to a text ure.
58 private EglBase eglBase; 65 private EglBase eglBase;
59 66
60 // These are protected by their respective event objects. 67 // These are protected by their respective event objects.
61 private LooperExecutor signalingExecutor; 68 private LooperExecutor signalingExecutor;
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 remoteRenderer.reset(EXPECTED_VIDEO_FRAMES); 551 remoteRenderer.reset(EXPECTED_VIDEO_FRAMES);
545 assertTrue("Local video frames were not rendered after video restart.", 552 assertTrue("Local video frames were not rendered after video restart.",
546 localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); 553 localRenderer.waitForFramesRendered(WAIT_TIMEOUT));
547 assertTrue("Remote video frames were not rendered after video restart.", 554 assertTrue("Remote video frames were not rendered after video restart.",
548 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); 555 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT));
549 } 556 }
550 pcClient.close(); 557 pcClient.close();
551 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); 558 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT));
552 Log.d(TAG, "testVideoSourceRestart done."); 559 Log.d(TAG, "testVideoSourceRestart done.");
553 } 560 }
561
562 // Checks if capture format can be changed on fly and decoder can be reset pro perly.
563 public void testCaptureFormatChange() throws InterruptedException {
564 Log.d(TAG, "testCaptureFormatChange");
565 loopback = true;
566
567 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME);
568 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE _RENDERER_NAME);
569
570 pcClient = createPeerConnectionClient(
571 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_ VP8, false), null);
572
573 // Wait for local SDP, rename it to answer and set as remote SDP.
574 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT));
575 SessionDescription remoteSdp = new SessionDescription(
576 SessionDescription.Type.fromCanonicalForm("answer"),
577 localSdp.description);
578 pcClient.setRemoteDescription(remoteSdp);
579
580 // Wait for ICE connection.
581 assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI T_TIMEOUT));
582
583 // Check that local and remote video frames were rendered.
584 assertTrue("Local video frames were not rendered before camera resolution ch ange.",
585 localRenderer.waitForFramesRendered(WAIT_TIMEOUT));
586 assertTrue("Remote video frames were not rendered before camera resolution c hange.",
587 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT));
588
589 // Change capture output format a few times.
590 for (int i = 0; i < 2 * CAPTURE_FORMAT_CHANGE_ATTEMPTS; i++) {
591 if (i % 2 == 0) {
592 pcClient.changeCaptureFormat(WIDTH_VGA, HEIGHT_VGA, MAX_VIDEO_FPS);
593 } else {
594 pcClient.changeCaptureFormat(WIDTH_QVGA, HEIGHT_QVGA, MAX_VIDEO_FPS);
595 }
596
597 // Reset video renders and check that local and remote video frames
598 // were rendered after capture format change.
599 localRenderer.reset(EXPECTED_VIDEO_FRAMES);
600 remoteRenderer.reset(EXPECTED_VIDEO_FRAMES);
601 assertTrue("Local video frames were not rendered after capture format chan ge.",
602 localRenderer.waitForFramesRendered(WAIT_TIMEOUT));
603 assertTrue("Remote video frames were not rendered after capture format cha nge.",
604 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT));
605 }
606
607 pcClient.close();
608 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT));
609 Log.d(TAG, "testCaptureFormatChange done.");
610 }
611
554 } 612 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698