From 68e7631d17c79970cd0a83d18ee372d0008610da Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Thu, 3 Jan 2019 17:23:06 +0100 Subject: [PATCH] Restore frame processor after videos (#344) --- .../otaliastudios/cameraview/IntegrationTest.java | 14 ++++++++++++++ .../java/com/otaliastudios/cameraview/Camera1.java | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/IntegrationTest.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/IntegrationTest.java index 4e42ce62..887bc85d 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/IntegrationTest.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/IntegrationTest.java @@ -626,5 +626,19 @@ public class IntegrationTest extends BaseTest { assert30Frames(processor); } + + @Test + public void testFrameProcessing_afterVideo() throws Exception { + FrameProcessor processor = mock(FrameProcessor.class); + camera.addFrameProcessor(processor); + camera.setSessionType(SessionType.VIDEO); + waitForOpen(true); + + camera.startCapturingVideo(null, 2000); + waitForVideoEnd(true); + + assert30Frames(processor); + } + //endregion } diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index a814e7a8..b8af16b2 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -684,6 +684,10 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera mCameraCallbacks.dispatchOnVideoTaken(mVideoFile); mVideoFile = null; } + if (mCamera != null) { + // This is needed to restore FrameProcessor. No re-allocation needed though. + mCamera.setPreviewCallbackWithBuffer(this); + } } @WorkerThread