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

Side by Side Diff: talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTest.java

Issue 1363303002: VideoCapturerAndroidTest: Dispose PeerConnectionFactory with pending frames (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | 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 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 final PeerConnectionFactory factory = new PeerConnectionFactory(); 398 final PeerConnectionFactory factory = new PeerConnectionFactory();
399 final VideoSource source = factory.createVideoSource(capturer, new MediaCons traints()); 399 final VideoSource source = factory.createVideoSource(capturer, new MediaCons traints());
400 final VideoTrack track = factory.createVideoTrack("dummy", source); 400 final VideoTrack track = factory.createVideoTrack("dummy", source);
401 final FakeAsyncRenderer renderer = new FakeAsyncRenderer(); 401 final FakeAsyncRenderer renderer = new FakeAsyncRenderer();
402 track.addRenderer(new VideoRenderer(renderer)); 402 track.addRenderer(new VideoRenderer(renderer));
403 // Wait for at least one frame that has not been returned. 403 // Wait for at least one frame that has not been returned.
404 assertFalse(renderer.waitForPendingFrames().isEmpty()); 404 assertFalse(renderer.waitForPendingFrames().isEmpty());
405 405
406 capturer.stopCapture(); 406 capturer.stopCapture();
407 407
408 // Dispose source and |capturer|. 408 // Dispose everything.
409 track.dispose(); 409 track.dispose();
410 source.dispose(); 410 source.dispose();
411 factory.dispose();
412
411 // The pending frames should keep the JNI parts and |capturer| alive. 413 // The pending frames should keep the JNI parts and |capturer| alive.
412 assertFalse(capturer.isReleased()); 414 assertFalse(capturer.isReleased());
413 415
414 // Return the frame(s), on a different thread out of spite. 416 // Return the frame(s), on a different thread out of spite.
415 final List<I420Frame> pendingFrames = renderer.waitForPendingFrames(); 417 final List<I420Frame> pendingFrames = renderer.waitForPendingFrames();
416 final Thread returnThread = new Thread(new Runnable() { 418 final Thread returnThread = new Thread(new Runnable() {
417 @Override 419 @Override
418 public void run() { 420 public void run() {
419 for (I420Frame frame : pendingFrames) { 421 for (I420Frame frame : pendingFrames) {
420 VideoRenderer.renderFrameDone(frame); 422 VideoRenderer.renderFrameDone(frame);
421 } 423 }
422 } 424 }
423 }); 425 });
424 returnThread.start(); 426 returnThread.start();
425 returnThread.join(); 427 returnThread.join();
426 428
427 // Check that frames have successfully returned. This will cause |capturer| to be released. 429 // Check that frames have successfully returned. This will cause |capturer| to be released.
428 assertTrue(capturer.isReleased()); 430 assertTrue(capturer.isReleased());
429
430 factory.dispose();
431 } 431 }
432 } 432 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698