| OLD | NEW | 
|    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.TimeUnit; |   16 import java.util.concurrent.TimeUnit; | 
|   17  |   17  | 
|   18 import org.appspot.apprtc.AppRTCClient.SignalingParameters; |   18 import org.appspot.apprtc.AppRTCClient.SignalingParameters; | 
|   19 import org.appspot.apprtc.PeerConnectionClient; |   19 import org.appspot.apprtc.PeerConnectionClient; | 
|   20 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents; |   20 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents; | 
|   21 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters; |   21 import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters; | 
|   22 import org.appspot.apprtc.util.LooperExecutor; |   22 import org.appspot.apprtc.util.LooperExecutor; | 
 |   23 import org.webrtc.EglBase; | 
|   23 import org.webrtc.IceCandidate; |   24 import org.webrtc.IceCandidate; | 
|   24 import org.webrtc.MediaConstraints; |   25 import org.webrtc.MediaConstraints; | 
|   25 import org.webrtc.PeerConnection; |   26 import org.webrtc.PeerConnection; | 
|   26 import org.webrtc.PeerConnectionFactory; |   27 import org.webrtc.PeerConnectionFactory; | 
|   27 import org.webrtc.SessionDescription; |   28 import org.webrtc.SessionDescription; | 
|   28 import org.webrtc.StatsReport; |   29 import org.webrtc.StatsReport; | 
|   29 import org.webrtc.VideoRenderer; |   30 import org.webrtc.VideoRenderer; | 
|   30  |   31  | 
 |   32 import android.os.Build; | 
|   31 import android.test.InstrumentationTestCase; |   33 import android.test.InstrumentationTestCase; | 
|   32 import android.util.Log; |   34 import android.util.Log; | 
|   33  |   35  | 
|   34 public class PeerConnectionClientTest extends InstrumentationTestCase |   36 public class PeerConnectionClientTest extends InstrumentationTestCase | 
|   35     implements PeerConnectionEvents { |   37     implements PeerConnectionEvents { | 
|   36   private static final String TAG = "RTCClientTest"; |   38   private static final String TAG = "RTCClientTest"; | 
|   37   private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000; |   39   private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000; | 
|   38   private static final int WAIT_TIMEOUT = 7000; |   40   private static final int WAIT_TIMEOUT = 7000; | 
|   39   private static final int CAMERA_SWITCH_ATTEMPTS = 3; |   41   private static final int CAMERA_SWITCH_ATTEMPTS = 3; | 
|   40   private static final int VIDEO_RESTART_ATTEMPTS = 3; |   42   private static final int VIDEO_RESTART_ATTEMPTS = 3; | 
|   41   private static final int VIDEO_RESTART_TIMEOUT = 500; |   43   private static final int VIDEO_RESTART_TIMEOUT = 500; | 
|   42   private static final int EXPECTED_VIDEO_FRAMES = 10; |   44   private static final int EXPECTED_VIDEO_FRAMES = 10; | 
|   43   private static final String VIDEO_CODEC_VP8 = "VP8"; |   45   private static final String VIDEO_CODEC_VP8 = "VP8"; | 
|   44   private static final String VIDEO_CODEC_VP9 = "VP9"; |   46   private static final String VIDEO_CODEC_VP9 = "VP9"; | 
|   45   private static final String VIDEO_CODEC_H264 = "H264"; |   47   private static final String VIDEO_CODEC_H264 = "H264"; | 
|   46   private static final int AUDIO_RUN_TIMEOUT = 1000; |   48   private static final int AUDIO_RUN_TIMEOUT = 1000; | 
|   47   private static final String LOCAL_RENDERER_NAME = "Local renderer"; |   49   private static final String LOCAL_RENDERER_NAME = "Local renderer"; | 
|   48   private static final String REMOTE_RENDERER_NAME = "Remote renderer"; |   50   private static final String REMOTE_RENDERER_NAME = "Remote renderer"; | 
|   49  |   51  | 
|   50   // The peer connection client is assumed to be thread safe in itself; the |   52   // The peer connection client is assumed to be thread safe in itself; the | 
|   51   // reference is written by the test thread and read by worker threads. |   53   // reference is written by the test thread and read by worker threads. | 
|   52   private volatile PeerConnectionClient pcClient; |   54   private volatile PeerConnectionClient pcClient; | 
|   53   private volatile boolean loopback; |   55   private volatile boolean loopback; | 
|   54  |   56  | 
 |   57   // EGL context that can be used by hardware video decoders to decode to a text
     ure. | 
 |   58   private EglBase eglBase; | 
 |   59  | 
|   55   // These are protected by their respective event objects. |   60   // These are protected by their respective event objects. | 
|   56   private LooperExecutor signalingExecutor; |   61   private LooperExecutor signalingExecutor; | 
|   57   private boolean isClosed; |   62   private boolean isClosed; | 
|   58   private boolean isIceConnected; |   63   private boolean isIceConnected; | 
|   59   private SessionDescription localSdp; |   64   private SessionDescription localSdp; | 
|   60   private List<IceCandidate> iceCandidates = new LinkedList<IceCandidate>(); |   65   private List<IceCandidate> iceCandidates = new LinkedList<IceCandidate>(); | 
|   61   private final Object localSdpEvent = new Object(); |   66   private final Object localSdpEvent = new Object(); | 
|   62   private final Object iceCandidateEvent = new Object(); |   67   private final Object iceCandidateEvent = new Object(); | 
|   63   private final Object iceConnectedEvent = new Object(); |   68   private final Object iceConnectedEvent = new Object(); | 
|   64   private final Object closeEvent = new Object(); |   69   private final Object closeEvent = new Object(); | 
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  213     synchronized(closeEvent) { |  218     synchronized(closeEvent) { | 
|  214       if (!isClosed) { |  219       if (!isClosed) { | 
|  215         closeEvent.wait(timeoutMs); |  220         closeEvent.wait(timeoutMs); | 
|  216       } |  221       } | 
|  217       return isClosed; |  222       return isClosed; | 
|  218     } |  223     } | 
|  219   } |  224   } | 
|  220  |  225  | 
|  221   PeerConnectionClient createPeerConnectionClient( |  226   PeerConnectionClient createPeerConnectionClient( | 
|  222       MockRenderer localRenderer, MockRenderer remoteRenderer, |  227       MockRenderer localRenderer, MockRenderer remoteRenderer, | 
|  223       boolean enableVideo, String videoCodec) { |  228       PeerConnectionParameters peerConnectionParameters, boolean decodeToTexture
     ) { | 
|  224     List<PeerConnection.IceServer> iceServers = |  229     List<PeerConnection.IceServer> iceServers = | 
|  225         new LinkedList<PeerConnection.IceServer>(); |  230         new LinkedList<PeerConnection.IceServer>(); | 
|  226     SignalingParameters signalingParameters = new SignalingParameters( |  231     SignalingParameters signalingParameters = new SignalingParameters( | 
|  227         iceServers, true, // iceServers, initiator. |  232         iceServers, true, // iceServers, initiator. | 
|  228         null, null, null, // clientId, wssUrl, wssPostUrl. |  233         null, null, null, // clientId, wssUrl, wssPostUrl. | 
|  229         null, null); // offerSdp, iceCandidates. |  234         null, null); // offerSdp, iceCandidates. | 
|  230     PeerConnectionParameters peerConnectionParameters = |  | 
|  231         new PeerConnectionParameters( |  | 
|  232             enableVideo, true, // videoCallEnabled, loopback. |  | 
|  233             0, 0, 0, 0, videoCodec, true, // video codec parameters. |  | 
|  234             0, "OPUS", false, true); // audio codec parameters. |  | 
|  235  |  235  | 
|  236     PeerConnectionClient client = PeerConnectionClient.getInstance(); |  236     PeerConnectionClient client = PeerConnectionClient.getInstance(); | 
|  237     PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); |  237     PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); | 
|  238     options.networkIgnoreMask = 0; |  238     options.networkIgnoreMask = 0; | 
|  239     client.setPeerConnectionFactoryOptions(options); |  239     client.setPeerConnectionFactoryOptions(options); | 
|  240     client.createPeerConnectionFactory( |  240     client.createPeerConnectionFactory( | 
|  241         getInstrumentation().getContext(), peerConnectionParameters, this); |  241         getInstrumentation().getContext(), peerConnectionParameters, this); | 
|  242     client.createPeerConnection( |  242     client.createPeerConnection(decodeToTexture ? eglBase.getContext() : null, | 
|  243         null, localRenderer, remoteRenderer, signalingParameters); |  243         localRenderer, remoteRenderer, signalingParameters); | 
|  244     client.createOffer(); |  244     client.createOffer(); | 
|  245     return client; |  245     return client; | 
|  246   } |  246   } | 
|  247  |  247  | 
 |  248   private PeerConnectionParameters createParameters(boolean enableVideo, | 
 |  249       String videoCodec) { | 
 |  250     PeerConnectionParameters peerConnectionParameters = | 
 |  251         new PeerConnectionParameters( | 
 |  252             enableVideo, true, // videoCallEnabled, loopback. | 
 |  253             0, 0, 0, 0, videoCodec, true, // video codec parameters. | 
 |  254             0, "OPUS", false, true); // audio codec parameters. | 
 |  255     return peerConnectionParameters; | 
 |  256   } | 
 |  257  | 
|  248   @Override |  258   @Override | 
|  249   public void setUp() { |  259   public void setUp() { | 
|  250     signalingExecutor = new LooperExecutor(); |  260     signalingExecutor = new LooperExecutor(); | 
|  251     signalingExecutor.requestStart(); |  261     signalingExecutor.requestStart(); | 
 |  262     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { | 
 |  263       eglBase = new EglBase(); | 
 |  264     } | 
|  252   } |  265   } | 
|  253  |  266  | 
|  254   @Override |  267   @Override | 
|  255   public void tearDown() { |  268   public void tearDown() { | 
|  256     signalingExecutor.requestStop(); |  269     signalingExecutor.requestStop(); | 
 |  270     if (eglBase != null) { | 
 |  271       eglBase.release(); | 
 |  272     } | 
|  257   } |  273   } | 
|  258  |  274  | 
|  259   public void testSetLocalOfferMakesVideoFlowLocally() |  275   public void testSetLocalOfferMakesVideoFlowLocally() | 
|  260       throws InterruptedException { |  276       throws InterruptedException { | 
|  261     Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); |  277     Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); | 
|  262     MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
     ENDERER_NAME); |  278     MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
     ENDERER_NAME); | 
|  263     pcClient = createPeerConnectionClient( |  279     pcClient = createPeerConnectionClient( | 
|  264         localRenderer, new MockRenderer(0, null), true, VIDEO_CODEC_VP8); |  280         localRenderer, new MockRenderer(0, null), createParameters(true, VIDEO_C
     ODEC_VP8), false); | 
|  265  |  281  | 
|  266     // Wait for local SDP and ice candidates set events. |  282     // Wait for local SDP and ice candidates set events. | 
|  267     assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |  283     assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); | 
|  268     assertTrue("ICE candidates were not generated.", |  284     assertTrue("ICE candidates were not generated.", | 
|  269         waitForIceCandidates(WAIT_TIMEOUT)); |  285         waitForIceCandidates(WAIT_TIMEOUT)); | 
|  270  |  286  | 
|  271     // Check that local video frames were rendered. |  287     // Check that local video frames were rendered. | 
|  272     assertTrue("Local video frames were not rendered.", |  288     assertTrue("Local video frames were not rendered.", | 
|  273         localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |  289         localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 
|  274  |  290  | 
|  275     pcClient.close(); |  291     pcClient.close(); | 
|  276     assertTrue("PeerConnection close event was not received.", |  292     assertTrue("PeerConnection close event was not received.", | 
|  277         waitForPeerConnectionClosed(WAIT_TIMEOUT)); |  293         waitForPeerConnectionClosed(WAIT_TIMEOUT)); | 
|  278     Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally Done."); |  294     Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally Done."); | 
|  279   } |  295   } | 
|  280  |  296  | 
|  281   private void doLoopbackTest(boolean enableVideo, String videoCodec) |  297   private void doLoopbackTest(PeerConnectionParameters parameters, boolean decod
     eToTexure) | 
|  282       throws InterruptedException { |  298       throws InterruptedException { | 
|  283     loopback = true; |  299     loopback = true; | 
|  284     MockRenderer localRenderer = null; |  300     MockRenderer localRenderer = null; | 
|  285     MockRenderer remoteRenderer = null; |  301     MockRenderer remoteRenderer = null; | 
|  286     if (enableVideo) { |  302     if (parameters.videoCallEnabled) { | 
|  287       Log.d(TAG, "testLoopback for video " + videoCodec); |  303       Log.d(TAG, "testLoopback for video " + parameters.videoCodec); | 
|  288       localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_RENDERER_NAM
     E); |  304       localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_RENDERER_NAM
     E); | 
|  289       remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE_RENDERER_N
     AME); |  305       remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE_RENDERER_N
     AME); | 
|  290     } else { |  306     } else { | 
|  291       Log.d(TAG, "testLoopback for audio."); |  307       Log.d(TAG, "testLoopback for audio."); | 
|  292     } |  308     } | 
|  293     pcClient = createPeerConnectionClient( |  309     pcClient = createPeerConnectionClient( | 
|  294         localRenderer, remoteRenderer, enableVideo, videoCodec); |  310         localRenderer, remoteRenderer, parameters, decodeToTexure); | 
|  295  |  311  | 
|  296     // Wait for local SDP, rename it to answer and set as remote SDP. |  312     // Wait for local SDP, rename it to answer and set as remote SDP. | 
|  297     assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |  313     assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); | 
|  298     SessionDescription remoteSdp = new SessionDescription( |  314     SessionDescription remoteSdp = new SessionDescription( | 
|  299         SessionDescription.Type.fromCanonicalForm("answer"), |  315         SessionDescription.Type.fromCanonicalForm("answer"), | 
|  300         localSdp.description); |  316         localSdp.description); | 
|  301     pcClient.setRemoteDescription(remoteSdp); |  317     pcClient.setRemoteDescription(remoteSdp); | 
|  302  |  318  | 
|  303     // Wait for ICE connection. |  319     // Wait for ICE connection. | 
|  304     assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI
     T_TIMEOUT)); |  320     assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI
     T_TIMEOUT)); | 
|  305  |  321  | 
|  306     if (enableVideo) { |  322     if (parameters.videoCallEnabled) { | 
|  307       // Check that local and remote video frames were rendered. |  323       // Check that local and remote video frames were rendered. | 
|  308       assertTrue("Local video frames were not rendered.", |  324       assertTrue("Local video frames were not rendered.", | 
|  309           localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |  325           localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 
|  310       assertTrue("Remote video frames were not rendered.", |  326       assertTrue("Remote video frames were not rendered.", | 
|  311           remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |  327           remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 
|  312     } else { |  328     } else { | 
|  313       // For audio just sleep for 1 sec. |  329       // For audio just sleep for 1 sec. | 
|  314       // TODO(glaznev): check how we can detect that remote audio was rendered. |  330       // TODO(glaznev): check how we can detect that remote audio was rendered. | 
|  315       Thread.sleep(AUDIO_RUN_TIMEOUT); |  331       Thread.sleep(AUDIO_RUN_TIMEOUT); | 
|  316     } |  332     } | 
|  317  |  333  | 
|  318     pcClient.close(); |  334     pcClient.close(); | 
|  319     assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); |  335     assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); | 
|  320     Log.d(TAG, "testLoopback done."); |  336     Log.d(TAG, "testLoopback done."); | 
|  321   } |  337   } | 
|  322  |  338  | 
|  323   public void testLoopbackAudio() throws InterruptedException { |  339   public void testLoopbackAudio() throws InterruptedException { | 
|  324     doLoopbackTest(false, VIDEO_CODEC_VP8); |  340     doLoopbackTest(createParameters(false, VIDEO_CODEC_VP8), false); | 
|  325   } |  341   } | 
|  326  |  342  | 
|  327   public void testLoopbackVp8() throws InterruptedException { |  343   public void testLoopbackVp8() throws InterruptedException { | 
|  328     doLoopbackTest(true, VIDEO_CODEC_VP8); |  344     doLoopbackTest(createParameters(true, VIDEO_CODEC_VP8), false); | 
|  329   } |  345   } | 
|  330  |  346  | 
|  331   public void DISABLED_testLoopbackVp9() throws InterruptedException { |  347   public void DISABLED_testLoopbackVp9() throws InterruptedException { | 
|  332     doLoopbackTest(true, VIDEO_CODEC_VP9); |  348     doLoopbackTest(createParameters(true, VIDEO_CODEC_VP9), false); | 
|  333   } |  349   } | 
|  334  |  350  | 
|  335   public void testLoopbackH264() throws InterruptedException { |  351   public void testLoopbackH264() throws InterruptedException { | 
|  336     doLoopbackTest(true, VIDEO_CODEC_H264); |  352     doLoopbackTest(createParameters(true, VIDEO_CODEC_H264), false); | 
 |  353   } | 
 |  354  | 
 |  355   public void testLoopbackVp8DecodeToTexture() throws InterruptedException { | 
 |  356     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | 
 |  357       Log.i(TAG, "Decode to textures is not supported, requires EGL14."); | 
 |  358       return; | 
 |  359     } | 
 |  360  | 
 |  361     doLoopbackTest(createParameters(true, VIDEO_CODEC_VP8), true); | 
 |  362   } | 
 |  363  | 
 |  364   public void DISABLED_testLoopbackVp9DecodeToTexture() throws InterruptedExcept
     ion { | 
 |  365     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | 
 |  366       Log.i(TAG, "Decode to textures is not supported, requires EGL14."); | 
 |  367       return; | 
 |  368     } | 
 |  369     doLoopbackTest(createParameters(true, VIDEO_CODEC_VP9), true); | 
 |  370   } | 
 |  371  | 
 |  372   public void testLoopbackH264DecodeToTexture() throws InterruptedException { | 
 |  373     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { | 
 |  374       Log.i(TAG, "Decode to textures is not supported, requires EGL14."); | 
 |  375       return; | 
 |  376     } | 
 |  377     doLoopbackTest(createParameters(true, VIDEO_CODEC_H264), true); | 
|  337   } |  378   } | 
|  338  |  379  | 
|  339   // Checks if default front camera can be switched to back camera and then |  380   // Checks if default front camera can be switched to back camera and then | 
|  340   // again to front camera. |  381   // again to front camera. | 
|  341   public void testCameraSwitch() throws InterruptedException { |  382   public void testCameraSwitch() throws InterruptedException { | 
|  342     Log.d(TAG, "testCameraSwitch"); |  383     Log.d(TAG, "testCameraSwitch"); | 
|  343     loopback = true; |  384     loopback = true; | 
|  344  |  385  | 
|  345     MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
     ENDERER_NAME); |  386     MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
     ENDERER_NAME); | 
|  346     MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
     _RENDERER_NAME); |  387     MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
     _RENDERER_NAME); | 
|  347  |  388  | 
|  348     pcClient = createPeerConnectionClient( |  389     pcClient = createPeerConnectionClient( | 
|  349         localRenderer, remoteRenderer, true, VIDEO_CODEC_VP8); |  390         localRenderer, remoteRenderer, createParameters(true, VIDEO_CODEC_VP8), 
     false); | 
|  350  |  391  | 
|  351     // Wait for local SDP, rename it to answer and set as remote SDP. |  392     // Wait for local SDP, rename it to answer and set as remote SDP. | 
|  352     assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |  393     assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); | 
|  353     SessionDescription remoteSdp = new SessionDescription( |  394     SessionDescription remoteSdp = new SessionDescription( | 
|  354         SessionDescription.Type.fromCanonicalForm("answer"), |  395         SessionDescription.Type.fromCanonicalForm("answer"), | 
|  355         localSdp.description); |  396         localSdp.description); | 
|  356     pcClient.setRemoteDescription(remoteSdp); |  397     pcClient.setRemoteDescription(remoteSdp); | 
|  357  |  398  | 
|  358     // Wait for ICE connection. |  399     // Wait for ICE connection. | 
|  359     assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI
     T_TIMEOUT)); |  400     assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI
     T_TIMEOUT)); | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|  385   // Checks if video source can be restarted - simulate app goes to |  426   // Checks if video source can be restarted - simulate app goes to | 
|  386   // background and back to foreground. |  427   // background and back to foreground. | 
|  387   public void testVideoSourceRestart() throws InterruptedException { |  428   public void testVideoSourceRestart() throws InterruptedException { | 
|  388     Log.d(TAG, "testVideoSourceRestart"); |  429     Log.d(TAG, "testVideoSourceRestart"); | 
|  389     loopback = true; |  430     loopback = true; | 
|  390  |  431  | 
|  391     MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
     ENDERER_NAME); |  432     MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
     ENDERER_NAME); | 
|  392     MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
     _RENDERER_NAME); |  433     MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
     _RENDERER_NAME); | 
|  393  |  434  | 
|  394     pcClient = createPeerConnectionClient( |  435     pcClient = createPeerConnectionClient( | 
|  395         localRenderer, remoteRenderer, true, VIDEO_CODEC_VP8); |  436         localRenderer, remoteRenderer, createParameters(true, VIDEO_CODEC_VP8), 
     false); | 
|  396  |  437  | 
|  397     // Wait for local SDP, rename it to answer and set as remote SDP. |  438     // Wait for local SDP, rename it to answer and set as remote SDP. | 
|  398     assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |  439     assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); | 
|  399     SessionDescription remoteSdp = new SessionDescription( |  440     SessionDescription remoteSdp = new SessionDescription( | 
|  400         SessionDescription.Type.fromCanonicalForm("answer"), |  441         SessionDescription.Type.fromCanonicalForm("answer"), | 
|  401         localSdp.description); |  442         localSdp.description); | 
|  402     pcClient.setRemoteDescription(remoteSdp); |  443     pcClient.setRemoteDescription(remoteSdp); | 
|  403  |  444  | 
|  404     // Wait for ICE connection. |  445     // Wait for ICE connection. | 
|  405     assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI
     T_TIMEOUT)); |  446     assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI
     T_TIMEOUT)); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  424           localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |  465           localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 
|  425       assertTrue("Remote video frames were not rendered after video restart.", |  466       assertTrue("Remote video frames were not rendered after video restart.", | 
|  426           remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |  467           remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 
|  427     } |  468     } | 
|  428     pcClient.close(); |  469     pcClient.close(); | 
|  429     assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); |  470     assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); | 
|  430     Log.d(TAG, "testVideoSourceRestart done."); |  471     Log.d(TAG, "testVideoSourceRestart done."); | 
|  431   } |  472   } | 
|  432  |  473  | 
|  433 } |  474 } | 
| OLD | NEW |