| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 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 package org.webrtc; | 10 package org.webrtc; |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 assertFalse(observer.WaitForCapturerToStart()); | 419 assertFalse(observer.WaitForCapturerToStart()); |
| 420 } | 420 } |
| 421 | 421 |
| 422 release(capturer); | 422 release(capturer); |
| 423 camera.release(); | 423 camera.release(); |
| 424 surfaceTextureHelper.dispose(); | 424 surfaceTextureHelper.dispose(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 static public void startWhileCameraIsAlreadyOpenAndCloseCamera( | 427 static public void startWhileCameraIsAlreadyOpenAndCloseCamera( |
| 428 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep
tion { | 428 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep
tion { |
| 429 final PeerConnectionFactory factory = new PeerConnectionFactory(null /* opti
ons */); |
| 429 final List<CaptureFormat> formats = capturer.getSupportedFormats(); | 430 final List<CaptureFormat> formats = capturer.getSupportedFormats(); |
| 430 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); | 431 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); |
| 431 android.hardware.Camera camera = android.hardware.Camera.open(capturer.getCu
rrentCameraId()); | 432 android.hardware.Camera camera = android.hardware.Camera.open(capturer.getCu
rrentCameraId()); |
| 432 | 433 |
| 433 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat
e( | 434 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat
e( |
| 434 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); | 435 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); |
| 435 final FakeCapturerObserver observer = new FakeCapturerObserver(); | 436 final VideoSource source = factory.createVideoSource(capturer, new MediaCons
traints()); |
| 436 capturer.startCapture(format.width, format.height, format.framerate.max, | 437 final VideoTrack track = factory.createVideoTrack("dummy", source); |
| 437 surfaceTextureHelper, appContext, observer); | 438 final RendererCallbacks callbacks = new RendererCallbacks(); |
| 439 track.addRenderer(new VideoRenderer(callbacks)); |
| 438 waitUntilIdle(capturer); | 440 waitUntilIdle(capturer); |
| 439 | 441 |
| 440 camera.release(); | 442 camera.release(); |
| 441 | 443 |
| 442 // Make sure camera is started and first frame is received and then stop it. | 444 // Make sure camera is started and first frame is received and then stop it. |
| 443 assertTrue(observer.WaitForCapturerToStart()); | 445 callbacks.WaitForNextFrameToRender(); |
| 444 observer.WaitForNextCapturedFrame(); | |
| 445 capturer.stopCapture(); | 446 capturer.stopCapture(); |
| 446 if (capturer.isCapturingToTexture()) { | |
| 447 surfaceTextureHelper.returnTextureFrame(); | |
| 448 } | |
| 449 release(capturer); | 447 release(capturer); |
| 450 surfaceTextureHelper.dispose(); | 448 surfaceTextureHelper.dispose(); |
| 451 } | 449 } |
| 452 | 450 |
| 453 static public void startWhileCameraIsAlreadyOpenAndStop( | 451 static public void startWhileCameraIsAlreadyOpenAndStop( |
| 454 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep
tion { | 452 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep
tion { |
| 455 final List<CaptureFormat> formats = capturer.getSupportedFormats(); | 453 final List<CaptureFormat> formats = capturer.getSupportedFormats(); |
| 456 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); | 454 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); |
| 457 android.hardware.Camera camera = android.hardware.Camera.open(capturer.getCu
rrentCameraId()); | 455 android.hardware.Camera camera = android.hardware.Camera.open(capturer.getCu
rrentCameraId()); |
| 458 | 456 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 595 |
| 598 source.stop(); | 596 source.stop(); |
| 599 track.dispose(); | 597 track.dispose(); |
| 600 source.dispose(); | 598 source.dispose(); |
| 601 factory.dispose(); | 599 factory.dispose(); |
| 602 | 600 |
| 603 assertTrue(gotExpectedResolution); | 601 assertTrue(gotExpectedResolution); |
| 604 } | 602 } |
| 605 | 603 |
| 606 } | 604 } |
| OLD | NEW |