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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 import org.webrtc.IceCandidate; | 24 import org.webrtc.IceCandidate; |
25 import org.webrtc.MediaCodecVideoEncoder; | 25 import org.webrtc.MediaCodecVideoEncoder; |
26 import org.webrtc.PeerConnection; | 26 import org.webrtc.PeerConnection; |
27 import org.webrtc.PeerConnectionFactory; | 27 import org.webrtc.PeerConnectionFactory; |
28 import org.webrtc.SessionDescription; | 28 import org.webrtc.SessionDescription; |
29 import org.webrtc.StatsReport; | 29 import org.webrtc.StatsReport; |
30 import org.webrtc.VideoRenderer; | 30 import org.webrtc.VideoRenderer; |
31 | 31 |
32 import android.os.Build; | 32 import android.os.Build; |
33 import android.test.InstrumentationTestCase; | 33 import android.test.InstrumentationTestCase; |
| 34 import android.test.suitebuilder.annotation.SmallTest; |
34 import android.util.Log; | 35 import android.util.Log; |
35 | 36 |
36 public class PeerConnectionClientTest extends InstrumentationTestCase | 37 public class PeerConnectionClientTest extends InstrumentationTestCase |
37 implements PeerConnectionEvents { | 38 implements PeerConnectionEvents { |
38 private static final String TAG = "RTCClientTest"; | 39 private static final String TAG = "RTCClientTest"; |
39 private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000; | 40 private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000; |
40 private static final int WAIT_TIMEOUT = 7000; | 41 private static final int WAIT_TIMEOUT = 7000; |
41 private static final int CAMERA_SWITCH_ATTEMPTS = 3; | 42 private static final int CAMERA_SWITCH_ATTEMPTS = 3; |
42 private static final int VIDEO_RESTART_ATTEMPTS = 3; | 43 private static final int VIDEO_RESTART_ATTEMPTS = 3; |
43 private static final int CAPTURE_FORMAT_CHANGE_ATTEMPTS = 3; | 44 private static final int CAPTURE_FORMAT_CHANGE_ATTEMPTS = 3; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 287 } |
287 | 288 |
288 @Override | 289 @Override |
289 public void tearDown() { | 290 public void tearDown() { |
290 signalingExecutor.requestStop(); | 291 signalingExecutor.requestStop(); |
291 if (eglBase != null) { | 292 if (eglBase != null) { |
292 eglBase.release(); | 293 eglBase.release(); |
293 } | 294 } |
294 } | 295 } |
295 | 296 |
| 297 @SmallTest |
296 public void testSetLocalOfferMakesVideoFlowLocally() | 298 public void testSetLocalOfferMakesVideoFlowLocally() |
297 throws InterruptedException { | 299 throws InterruptedException { |
298 Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); | 300 Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); |
299 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); | 301 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); |
300 pcClient = createPeerConnectionClient( | 302 pcClient = createPeerConnectionClient( |
301 localRenderer, new MockRenderer(0, null), | 303 localRenderer, new MockRenderer(0, null), |
302 createParametersForVideoCall(VIDEO_CODEC_VP8, false), null); | 304 createParametersForVideoCall(VIDEO_CODEC_VP8, false), null); |
303 | 305 |
304 // Wait for local SDP and ice candidates set events. | 306 // Wait for local SDP and ice candidates set events. |
305 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); | 307 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 // For audio just sleep for 1 sec. | 353 // For audio just sleep for 1 sec. |
352 // TODO(glaznev): check how we can detect that remote audio was rendered. | 354 // TODO(glaznev): check how we can detect that remote audio was rendered. |
353 Thread.sleep(AUDIO_RUN_TIMEOUT); | 355 Thread.sleep(AUDIO_RUN_TIMEOUT); |
354 } | 356 } |
355 | 357 |
356 pcClient.close(); | 358 pcClient.close(); |
357 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); | 359 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); |
358 Log.d(TAG, "testLoopback done."); | 360 Log.d(TAG, "testLoopback done."); |
359 } | 361 } |
360 | 362 |
| 363 @SmallTest |
361 public void testLoopbackAudio() throws InterruptedException { | 364 public void testLoopbackAudio() throws InterruptedException { |
362 doLoopbackTest(createParametersForAudioCall(), false); | 365 doLoopbackTest(createParametersForAudioCall(), false); |
363 } | 366 } |
364 | 367 |
| 368 @SmallTest |
365 public void testLoopbackVp8() throws InterruptedException { | 369 public void testLoopbackVp8() throws InterruptedException { |
366 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, false), false); | 370 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, false), false); |
367 } | 371 } |
368 | 372 |
369 public void DISABLED_testLoopbackVp9() throws InterruptedException { | 373 //@SmallTest |
| 374 public void testLoopbackVp9() throws InterruptedException { |
370 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP9, false), false); | 375 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP9, false), false); |
371 } | 376 } |
372 | 377 |
| 378 @SmallTest |
373 public void testLoopbackH264() throws InterruptedException { | 379 public void testLoopbackH264() throws InterruptedException { |
374 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, false), false)
; | 380 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, false), false)
; |
375 } | 381 } |
376 | 382 |
| 383 @SmallTest |
377 public void testLoopbackVp8DecodeToTexture() throws InterruptedException { | 384 public void testLoopbackVp8DecodeToTexture() throws InterruptedException { |
378 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { | 385 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { |
379 Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."
); | 386 Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."
); |
380 return; | 387 return; |
381 } | 388 } |
382 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, false), true); | 389 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, false), true); |
383 } | 390 } |
384 | 391 |
385 public void DISABLED_testLoopbackVp9DecodeToTexture() throws InterruptedExcept
ion { | 392 //@SmallTest |
| 393 public void testLoopbackVp9DecodeToTexture() throws InterruptedException { |
386 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { | 394 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { |
387 Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."
); | 395 Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."
); |
388 return; | 396 return; |
389 } | 397 } |
390 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP9, false), true); | 398 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP9, false), true); |
391 } | 399 } |
392 | 400 |
| 401 @SmallTest |
393 public void testLoopbackH264DecodeToTexture() throws InterruptedException { | 402 public void testLoopbackH264DecodeToTexture() throws InterruptedException { |
394 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { | 403 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { |
395 Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."
); | 404 Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."
); |
396 return; | 405 return; |
397 } | 406 } |
398 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, false), true); | 407 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, false), true); |
399 } | 408 } |
400 | 409 |
| 410 @SmallTest |
401 public void testLoopbackVp8CaptureToTexture() throws InterruptedException { | 411 public void testLoopbackVp8CaptureToTexture() throws InterruptedException { |
402 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { | 412 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { |
403 Log.i(TAG, "Encode to textures is not supported. Requires SDK version 19")
; | 413 Log.i(TAG, "Encode to textures is not supported. Requires SDK version 19")
; |
404 return; | 414 return; |
405 } | 415 } |
406 // TODO(perkj): If we can always capture to textures, there is no need to ch
eck if the | 416 // TODO(perkj): If we can always capture to textures, there is no need to ch
eck if the |
407 // hardware encoder supports to encode from a texture. | 417 // hardware encoder supports to encode from a texture. |
408 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) { | 418 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) { |
409 Log.i(TAG, "VP8 encode to textures is not supported."); | 419 Log.i(TAG, "VP8 encode to textures is not supported."); |
410 return; | 420 return; |
411 } | 421 } |
412 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, true), true); | 422 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, true), true); |
413 } | 423 } |
414 | 424 |
415 // Test that a call can be setup even if the EGL context used during initializ
ation is | 425 // Test that a call can be setup even if the EGL context used during initializ
ation is |
416 // released before the Video codecs are created. The HW encoder and decoder is
setup to use | 426 // released before the Video codecs are created. The HW encoder and decoder is
setup to use |
417 // textures. | 427 // textures. |
| 428 @SmallTest |
418 public void testLoopbackEglContextReleasedAfterCreatingPc() throws Interrupted
Exception { | 429 public void testLoopbackEglContextReleasedAfterCreatingPc() throws Interrupted
Exception { |
419 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { | 430 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { |
420 Log.i(TAG, "Decode to textures is not supported. Requires SDK version 19")
; | 431 Log.i(TAG, "Decode to textures is not supported. Requires SDK version 19")
; |
421 return; | 432 return; |
422 } | 433 } |
423 | 434 |
424 loopback = true; | 435 loopback = true; |
425 PeerConnectionParameters parameters = createParametersForVideoCall(VIDEO_COD
EC_VP8, true); | 436 PeerConnectionParameters parameters = createParametersForVideoCall(VIDEO_COD
EC_VP8, true); |
426 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); | 437 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); |
427 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
_RENDERER_NAME); | 438 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
_RENDERER_NAME); |
(...skipping 20 matching lines...) Expand all Loading... |
448 assertTrue("Local video frames were not rendered.", | 459 assertTrue("Local video frames were not rendered.", |
449 localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 460 localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
450 assertTrue("Remote video frames were not rendered.", | 461 assertTrue("Remote video frames were not rendered.", |
451 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 462 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
452 | 463 |
453 pcClient.close(); | 464 pcClient.close(); |
454 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); | 465 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); |
455 Log.d(TAG, "testLoopback done."); | 466 Log.d(TAG, "testLoopback done."); |
456 } | 467 } |
457 | 468 |
| 469 @SmallTest |
458 public void testLoopbackH264CaptureToTexture() throws InterruptedException { | 470 public void testLoopbackH264CaptureToTexture() throws InterruptedException { |
459 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { | 471 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { |
460 Log.i(TAG, "Encode to textures is not supported. Requires KITKAT"); | 472 Log.i(TAG, "Encode to textures is not supported. Requires KITKAT"); |
461 return; | 473 return; |
462 } | 474 } |
463 // TODO(perkj): If we can always capture to textures, there is no need to ch
eck if the | 475 // TODO(perkj): If we can always capture to textures, there is no need to ch
eck if the |
464 // hardware encoder supports to encode from a texture. | 476 // hardware encoder supports to encode from a texture. |
465 if (!MediaCodecVideoEncoder.isH264HwSupportedUsingTextures()) { | 477 if (!MediaCodecVideoEncoder.isH264HwSupportedUsingTextures()) { |
466 Log.i(TAG, "H264 encode to textures is not supported."); | 478 Log.i(TAG, "H264 encode to textures is not supported."); |
467 return; | 479 return; |
468 } | 480 } |
469 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, true), true); | 481 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, true), true); |
470 } | 482 } |
471 | 483 |
472 | 484 |
473 // Checks if default front camera can be switched to back camera and then | 485 // Checks if default front camera can be switched to back camera and then |
474 // again to front camera. | 486 // again to front camera. |
| 487 @SmallTest |
475 public void testCameraSwitch() throws InterruptedException { | 488 public void testCameraSwitch() throws InterruptedException { |
476 Log.d(TAG, "testCameraSwitch"); | 489 Log.d(TAG, "testCameraSwitch"); |
477 loopback = true; | 490 loopback = true; |
478 | 491 |
479 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); | 492 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); |
480 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
_RENDERER_NAME); | 493 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
_RENDERER_NAME); |
481 | 494 |
482 pcClient = createPeerConnectionClient( | 495 pcClient = createPeerConnectionClient( |
483 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_
VP8, false), null); | 496 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_
VP8, false), null); |
484 | 497 |
(...skipping 26 matching lines...) Expand all Loading... |
511 assertTrue("Remote video frames were not rendered after camera switch.", | 524 assertTrue("Remote video frames were not rendered after camera switch.", |
512 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 525 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
513 } | 526 } |
514 pcClient.close(); | 527 pcClient.close(); |
515 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); | 528 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); |
516 Log.d(TAG, "testCameraSwitch done."); | 529 Log.d(TAG, "testCameraSwitch done."); |
517 } | 530 } |
518 | 531 |
519 // Checks if video source can be restarted - simulate app goes to | 532 // Checks if video source can be restarted - simulate app goes to |
520 // background and back to foreground. | 533 // background and back to foreground. |
| 534 @SmallTest |
521 public void testVideoSourceRestart() throws InterruptedException { | 535 public void testVideoSourceRestart() throws InterruptedException { |
522 Log.d(TAG, "testVideoSourceRestart"); | 536 Log.d(TAG, "testVideoSourceRestart"); |
523 loopback = true; | 537 loopback = true; |
524 | 538 |
525 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); | 539 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); |
526 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
_RENDERER_NAME); | 540 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
_RENDERER_NAME); |
527 | 541 |
528 pcClient = createPeerConnectionClient( | 542 pcClient = createPeerConnectionClient( |
529 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_
VP8, false), null); | 543 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_
VP8, false), null); |
530 | 544 |
(...skipping 27 matching lines...) Expand all Loading... |
558 localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 572 localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
559 assertTrue("Remote video frames were not rendered after video restart.", | 573 assertTrue("Remote video frames were not rendered after video restart.", |
560 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 574 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
561 } | 575 } |
562 pcClient.close(); | 576 pcClient.close(); |
563 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); | 577 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); |
564 Log.d(TAG, "testVideoSourceRestart done."); | 578 Log.d(TAG, "testVideoSourceRestart done."); |
565 } | 579 } |
566 | 580 |
567 // Checks if capture format can be changed on fly and decoder can be reset pro
perly. | 581 // Checks if capture format can be changed on fly and decoder can be reset pro
perly. |
| 582 @SmallTest |
568 public void testCaptureFormatChange() throws InterruptedException { | 583 public void testCaptureFormatChange() throws InterruptedException { |
569 Log.d(TAG, "testCaptureFormatChange"); | 584 Log.d(TAG, "testCaptureFormatChange"); |
570 loopback = true; | 585 loopback = true; |
571 | 586 |
572 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); | 587 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R
ENDERER_NAME); |
573 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
_RENDERER_NAME); | 588 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE
_RENDERER_NAME); |
574 | 589 |
575 pcClient = createPeerConnectionClient( | 590 pcClient = createPeerConnectionClient( |
576 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_
VP8, false), null); | 591 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_
VP8, false), null); |
577 | 592 |
(...skipping 30 matching lines...) Expand all Loading... |
608 assertTrue("Remote video frames were not rendered after capture format cha
nge.", | 623 assertTrue("Remote video frames were not rendered after capture format cha
nge.", |
609 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); | 624 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
610 } | 625 } |
611 | 626 |
612 pcClient.close(); | 627 pcClient.close(); |
613 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); | 628 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); |
614 Log.d(TAG, "testCaptureFormatChange done."); | 629 Log.d(TAG, "testCaptureFormatChange done."); |
615 } | 630 } |
616 | 631 |
617 } | 632 } |
OLD | NEW |