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

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

Issue 1350663002: VideoCapturerAndroid: Add test for making calls on stopped camera (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase and also test onOutputFormatRequest() and changeCaptureFormat() Created 5 years, 3 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Ensure that frames are received. 285 // Ensure that frames are received.
286 RendererCallbacks callbacks = new RendererCallbacks(); 286 RendererCallbacks callbacks = new RendererCallbacks();
287 track.addRenderer(new VideoRenderer(callbacks)); 287 track.addRenderer(new VideoRenderer(callbacks));
288 assertTrue(callbacks.WaitForNextFrameToRender() > 0); 288 assertTrue(callbacks.WaitForNextFrameToRender() > 0);
289 track.dispose(); 289 track.dispose();
290 source.dispose(); 290 source.dispose();
291 factory.dispose(); 291 factory.dispose();
292 assertTrue(capturer.isReleased()); 292 assertTrue(capturer.isReleased());
293 } 293 }
294 294
295 @MediumTest
296 // Test what happens when attempting to call e.g. switchCamera() after camera has been stopped.
297 public void testCameraCallsAfterStop() throws InterruptedException {
298 final String deviceName = CameraEnumerationAndroid.getDeviceName(0);
299 final VideoCapturerAndroid capturer = VideoCapturerAndroid.create(deviceName , null);
300 final List<CaptureFormat> formats = CameraEnumerationAndroid.getSupportedFor mats(0);
301 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0);
302
303 final FakeCapturerObserver observer = new FakeCapturerObserver();
304 capturer.startCapture(format.width, format.height, format.maxFramerate,
305 getInstrumentation().getContext(), observer);
306 // Make sure camera is started and then stop it.
307 assertTrue(observer.WaitForCapturerToStart());
308 capturer.stopCapture();
309 for (long timeStamp : observer.getCopyAndResetListOftimeStamps()) {
310 capturer.returnBuffer(timeStamp);
311 }
312 // We can't change |capturer| at this point, but we should not crash.
313 capturer.switchCamera(null);
314 capturer.onOutputFormatRequest(640, 480, 15);
315 capturer.changeCaptureFormat(640, 480, 15);
316
317 capturer.dispose();
318 assertTrue(capturer.isReleased());
319 }
320
295 @SmallTest 321 @SmallTest
296 // This test that the VideoSource that the VideoCapturer is connected to can 322 // This test that the VideoSource that the VideoCapturer is connected to can
297 // be stopped and restarted. It tests both the Java and the C++ layer. 323 // be stopped and restarted. It tests both the Java and the C++ layer.
298 public void testStopRestartVideoSource() throws Exception { 324 public void testStopRestartVideoSource() throws Exception {
299 PeerConnectionFactory factory = new PeerConnectionFactory(); 325 PeerConnectionFactory factory = new PeerConnectionFactory();
300 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null); 326 VideoCapturerAndroid capturer = VideoCapturerAndroid.create("", null);
301 VideoSource source = 327 VideoSource source =
302 factory.createVideoSource(capturer, new MediaConstraints()); 328 factory.createVideoSource(capturer, new MediaConstraints());
303 VideoTrack track = factory.createVideoTrack("dummy", source); 329 VideoTrack track = factory.createVideoTrack("dummy", source);
304 RendererCallbacks callbacks = new RendererCallbacks(); 330 RendererCallbacks callbacks = new RendererCallbacks();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 449 }
424 } 450 }
425 }); 451 });
426 returnThread.start(); 452 returnThread.start();
427 returnThread.join(); 453 returnThread.join();
428 454
429 // Check that frames have successfully returned. This will cause |capturer| to be released. 455 // Check that frames have successfully returned. This will cause |capturer| to be released.
430 assertTrue(capturer.isReleased()); 456 assertTrue(capturer.isReleased());
431 } 457 }
432 } 458 }
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