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

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

Issue 1615153002: Change PeerConnectionFactory.setVideoHwAccelerationOptions to create shared Egl context for harware… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added eglbase_jni to avoid code duplication. Created 4 years, 11 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 | « talk/libjingle.gyp ('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
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 synchronized(closeEvent) { 218 synchronized(closeEvent) {
219 if (!isClosed) { 219 if (!isClosed) {
220 closeEvent.wait(timeoutMs); 220 closeEvent.wait(timeoutMs);
221 } 221 }
222 return isClosed; 222 return isClosed;
223 } 223 }
224 } 224 }
225 225
226 PeerConnectionClient createPeerConnectionClient( 226 PeerConnectionClient createPeerConnectionClient(
227 MockRenderer localRenderer, MockRenderer remoteRenderer, 227 MockRenderer localRenderer, MockRenderer remoteRenderer,
228 PeerConnectionParameters peerConnectionParameters, boolean useTexures) { 228 PeerConnectionParameters peerConnectionParameters, EglBase.Context eglCont ext) {
229 List<PeerConnection.IceServer> iceServers = 229 List<PeerConnection.IceServer> iceServers =
230 new LinkedList<PeerConnection.IceServer>(); 230 new LinkedList<PeerConnection.IceServer>();
231 SignalingParameters signalingParameters = new SignalingParameters( 231 SignalingParameters signalingParameters = new SignalingParameters(
232 iceServers, true, // iceServers, initiator. 232 iceServers, true, // iceServers, initiator.
233 null, null, null, // clientId, wssUrl, wssPostUrl. 233 null, null, null, // clientId, wssUrl, wssPostUrl.
234 null, null); // offerSdp, iceCandidates. 234 null, null); // offerSdp, iceCandidates.
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 options.disableNetworkMonitor = true; 239 options.disableNetworkMonitor = true;
240 client.setPeerConnectionFactoryOptions(options); 240 client.setPeerConnectionFactoryOptions(options);
241 client.createPeerConnectionFactory( 241 client.createPeerConnectionFactory(
242 getInstrumentation().getContext(), peerConnectionParameters, this); 242 getInstrumentation().getContext(), peerConnectionParameters, this);
243 client.createPeerConnection(useTexures ? eglBase.getEglBaseContext() : null, 243 client.createPeerConnection(eglContext, localRenderer, remoteRenderer, signa lingParameters);
244 localRenderer, remoteRenderer, signalingParameters);
245 client.createOffer(); 244 client.createOffer();
246 return client; 245 return client;
247 } 246 }
248 247
249 private PeerConnectionParameters createParametersForAudioCall() { 248 private PeerConnectionParameters createParametersForAudioCall() {
250 PeerConnectionParameters peerConnectionParameters = 249 PeerConnectionParameters peerConnectionParameters =
251 new PeerConnectionParameters( 250 new PeerConnectionParameters(
252 false, true, false, // videoCallEnabled, loopback, tracing. 251 false, true, false, // videoCallEnabled, loopback, tracing.
253 0, 0, 0, 0, "", true, false, // video codec parameters. 252 0, 0, 0, 0, "", true, false, // video codec parameters.
254 0, "OPUS", false, false, false); // audio codec parameters. 253 0, "OPUS", false, false, false); // audio codec parameters.
(...skipping 26 matching lines...) Expand all
281 eglBase.release(); 280 eglBase.release();
282 } 281 }
283 } 282 }
284 283
285 public void testSetLocalOfferMakesVideoFlowLocally() 284 public void testSetLocalOfferMakesVideoFlowLocally()
286 throws InterruptedException { 285 throws InterruptedException {
287 Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); 286 Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally");
288 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME); 287 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME);
289 pcClient = createPeerConnectionClient( 288 pcClient = createPeerConnectionClient(
290 localRenderer, new MockRenderer(0, null), 289 localRenderer, new MockRenderer(0, null),
291 createParametersForVideoCall(VIDEO_CODEC_VP8, false), false); 290 createParametersForVideoCall(VIDEO_CODEC_VP8, false), null);
292 291
293 // Wait for local SDP and ice candidates set events. 292 // Wait for local SDP and ice candidates set events.
294 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); 293 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT));
295 assertTrue("ICE candidates were not generated.", 294 assertTrue("ICE candidates were not generated.",
296 waitForIceCandidates(WAIT_TIMEOUT)); 295 waitForIceCandidates(WAIT_TIMEOUT));
297 296
298 // Check that local video frames were rendered. 297 // Check that local video frames were rendered.
299 assertTrue("Local video frames were not rendered.", 298 assertTrue("Local video frames were not rendered.",
300 localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); 299 localRenderer.waitForFramesRendered(WAIT_TIMEOUT));
301 300
302 pcClient.close(); 301 pcClient.close();
303 assertTrue("PeerConnection close event was not received.", 302 assertTrue("PeerConnection close event was not received.",
304 waitForPeerConnectionClosed(WAIT_TIMEOUT)); 303 waitForPeerConnectionClosed(WAIT_TIMEOUT));
305 Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally Done."); 304 Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally Done.");
306 } 305 }
307 306
308 private void doLoopbackTest(PeerConnectionParameters parameters, boolean decod eToTexure) 307 private void doLoopbackTest(PeerConnectionParameters parameters, boolean decod eToTexure)
309 throws InterruptedException { 308 throws InterruptedException {
310 loopback = true; 309 loopback = true;
311 MockRenderer localRenderer = null; 310 MockRenderer localRenderer = null;
312 MockRenderer remoteRenderer = null; 311 MockRenderer remoteRenderer = null;
313 if (parameters.videoCallEnabled) { 312 if (parameters.videoCallEnabled) {
314 Log.d(TAG, "testLoopback for video " + parameters.videoCodec); 313 Log.d(TAG, "testLoopback for video " + parameters.videoCodec);
315 localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_RENDERER_NAM E); 314 localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_RENDERER_NAM E);
316 remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE_RENDERER_N AME); 315 remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE_RENDERER_N AME);
317 } else { 316 } else {
318 Log.d(TAG, "testLoopback for audio."); 317 Log.d(TAG, "testLoopback for audio.");
319 } 318 }
320 pcClient = createPeerConnectionClient( 319 pcClient = createPeerConnectionClient(localRenderer, remoteRenderer, paramet ers,
321 localRenderer, remoteRenderer, parameters, decodeToTexure); 320 decodeToTexure ? eglBase.getEglBaseContext() : null);
322 321
323 // Wait for local SDP, rename it to answer and set as remote SDP. 322 // Wait for local SDP, rename it to answer and set as remote SDP.
324 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); 323 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT));
325 SessionDescription remoteSdp = new SessionDescription( 324 SessionDescription remoteSdp = new SessionDescription(
326 SessionDescription.Type.fromCanonicalForm("answer"), 325 SessionDescription.Type.fromCanonicalForm("answer"),
327 localSdp.description); 326 localSdp.description);
328 pcClient.setRemoteDescription(remoteSdp); 327 pcClient.setRemoteDescription(remoteSdp);
329 328
330 // Wait for ICE connection. 329 // Wait for ICE connection.
331 assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI T_TIMEOUT)); 330 assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI T_TIMEOUT));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 393 }
395 // TODO(perkj): If we can always capture to textures, there is no need to ch eck if the 394 // TODO(perkj): If we can always capture to textures, there is no need to ch eck if the
396 // hardware encoder supports to encode from a texture. 395 // hardware encoder supports to encode from a texture.
397 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) { 396 if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) {
398 Log.i(TAG, "VP8 encode to textures is not supported."); 397 Log.i(TAG, "VP8 encode to textures is not supported.");
399 return; 398 return;
400 } 399 }
401 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, true), true); 400 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, true), true);
402 } 401 }
403 402
403
404 // Test that a call can be setup even if a released EGL context is used during setup.
405 // The HW encoder and decoder will fallback to encode and decode from byte buf fers.
406 public void testLoopbackEglContextReleasedBeforeSetup() throws InterruptedExce ption {
407 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
408 Log.i(TAG, "Decode to textures is not supported, requires SDK version 19." );
409 return;
410 }
411 eglBase.release();
412 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8, false), true);
413 eglBase = null;
414 }
415
416 // Test that a call can be setup even if the EGL context used during initializ ation is
417 // released before the Video codecs are created. The HW encoder and decoder is setup to use
418 // textures.
419 public void testLoopbackEglContextReleasedAfterCreatingPc() throws Interrupted Exception {
420 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
421 Log.i(TAG, "Decode to textures is not supported. Requires SDK version 19") ;
422 return;
423 }
424
425 loopback = true;
426 PeerConnectionParameters parameters = createParametersForVideoCall(VIDEO_COD EC_VP8, false);
427 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME);
428 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE _RENDERER_NAME);
429 pcClient = createPeerConnectionClient(
430 localRenderer, remoteRenderer, parameters, eglBase.getEglBaseContext());
431
432 // Wait for local SDP, rename it to answer and set as remote SDP.
433 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT));
434
435 // Release the EGL context used for creating the PeerConnectionClient.
436 // Since createPeerConnectionClient is asynchronous, we must wait for the lo cal
437 // SessionDescription.
438 eglBase.release();
439 eglBase = null;
440
441 SessionDescription remoteSdp = new SessionDescription(
442 SessionDescription.Type.fromCanonicalForm("answer"),
443 localSdp.description);
444 pcClient.setRemoteDescription(remoteSdp);
445
446 // Wait for ICE connection.
447 assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI T_TIMEOUT));
448 // Check that local and remote video frames were rendered.
449 assertTrue("Local video frames were not rendered.",
450 localRenderer.waitForFramesRendered(WAIT_TIMEOUT));
451 assertTrue("Remote video frames were not rendered.",
452 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT));
453
454 pcClient.close();
455 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT));
456 Log.d(TAG, "testLoopback done.");
457 }
458
404 public void testLoopbackH264CaptureToTexture() throws InterruptedException { 459 public void testLoopbackH264CaptureToTexture() throws InterruptedException {
405 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { 460 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
406 Log.i(TAG, "Encode to textures is not supported. Requires KITKAT"); 461 Log.i(TAG, "Encode to textures is not supported. Requires KITKAT");
407 return; 462 return;
408 } 463 }
409 // TODO(perkj): If we can always capture to textures, there is no need to ch eck if the 464 // TODO(perkj): If we can always capture to textures, there is no need to ch eck if the
410 // hardware encoder supports to encode from a texture. 465 // hardware encoder supports to encode from a texture.
411 if (!MediaCodecVideoEncoder.isH264HwSupportedUsingTextures()) { 466 if (!MediaCodecVideoEncoder.isH264HwSupportedUsingTextures()) {
412 Log.i(TAG, "H264 encode to textures is not supported."); 467 Log.i(TAG, "H264 encode to textures is not supported.");
413 return; 468 return;
414 } 469 }
415 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, true), true); 470 doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, true), true);
416 } 471 }
417 472
418 473
419 // Checks if default front camera can be switched to back camera and then 474 // Checks if default front camera can be switched to back camera and then
420 // again to front camera. 475 // again to front camera.
421 public void testCameraSwitch() throws InterruptedException { 476 public void testCameraSwitch() throws InterruptedException {
422 Log.d(TAG, "testCameraSwitch"); 477 Log.d(TAG, "testCameraSwitch");
423 loopback = true; 478 loopback = true;
424 479
425 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME); 480 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME);
426 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE _RENDERER_NAME); 481 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE _RENDERER_NAME);
427 482
428 pcClient = createPeerConnectionClient( 483 pcClient = createPeerConnectionClient(
429 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_ VP8, false), false); 484 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_ VP8, false), null);
430 485
431 // Wait for local SDP, rename it to answer and set as remote SDP. 486 // Wait for local SDP, rename it to answer and set as remote SDP.
432 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); 487 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT));
433 SessionDescription remoteSdp = new SessionDescription( 488 SessionDescription remoteSdp = new SessionDescription(
434 SessionDescription.Type.fromCanonicalForm("answer"), 489 SessionDescription.Type.fromCanonicalForm("answer"),
435 localSdp.description); 490 localSdp.description);
436 pcClient.setRemoteDescription(remoteSdp); 491 pcClient.setRemoteDescription(remoteSdp);
437 492
438 // Wait for ICE connection. 493 // Wait for ICE connection.
439 assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI T_TIMEOUT)); 494 assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI T_TIMEOUT));
(...skipping 25 matching lines...) Expand all
465 // Checks if video source can be restarted - simulate app goes to 520 // Checks if video source can be restarted - simulate app goes to
466 // background and back to foreground. 521 // background and back to foreground.
467 public void testVideoSourceRestart() throws InterruptedException { 522 public void testVideoSourceRestart() throws InterruptedException {
468 Log.d(TAG, "testVideoSourceRestart"); 523 Log.d(TAG, "testVideoSourceRestart");
469 loopback = true; 524 loopback = true;
470 525
471 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME); 526 MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_R ENDERER_NAME);
472 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE _RENDERER_NAME); 527 MockRenderer remoteRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, REMOTE _RENDERER_NAME);
473 528
474 pcClient = createPeerConnectionClient( 529 pcClient = createPeerConnectionClient(
475 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_ VP8, false), false); 530 localRenderer, remoteRenderer, createParametersForVideoCall(VIDEO_CODEC_ VP8, false), null);
476 531
477 // Wait for local SDP, rename it to answer and set as remote SDP. 532 // Wait for local SDP, rename it to answer and set as remote SDP.
478 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); 533 assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT));
479 SessionDescription remoteSdp = new SessionDescription( 534 SessionDescription remoteSdp = new SessionDescription(
480 SessionDescription.Type.fromCanonicalForm("answer"), 535 SessionDescription.Type.fromCanonicalForm("answer"),
481 localSdp.description); 536 localSdp.description);
482 pcClient.setRemoteDescription(remoteSdp); 537 pcClient.setRemoteDescription(remoteSdp);
483 538
484 // Wait for ICE connection. 539 // Wait for ICE connection.
485 assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI T_TIMEOUT)); 540 assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAI T_TIMEOUT));
(...skipping 16 matching lines...) Expand all
502 remoteRenderer.reset(EXPECTED_VIDEO_FRAMES); 557 remoteRenderer.reset(EXPECTED_VIDEO_FRAMES);
503 assertTrue("Local video frames were not rendered after video restart.", 558 assertTrue("Local video frames were not rendered after video restart.",
504 localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); 559 localRenderer.waitForFramesRendered(WAIT_TIMEOUT));
505 assertTrue("Remote video frames were not rendered after video restart.", 560 assertTrue("Remote video frames were not rendered after video restart.",
506 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); 561 remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT));
507 } 562 }
508 pcClient.close(); 563 pcClient.close();
509 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); 564 assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT));
510 Log.d(TAG, "testVideoSourceRestart done."); 565 Log.d(TAG, "testVideoSourceRestart done.");
511 } 566 }
512
513 } 567 }
OLDNEW
« no previous file with comments | « talk/libjingle.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698