diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java index 462742a4..add6698f 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java @@ -216,7 +216,6 @@ public class CameraViewCallbacksTest extends BaseTest { verify(listener, times(1)).onCameraError(error); } - @Test public void testProcessFrame() { Frame mock = mock(Frame.class); completeTask().when(processor).process(mock); diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index 6d0c9e13..1d7251c6 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -616,6 +616,15 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera // ----------------- // Video recording stuff. + @Override + public void onVideoResult(@Nullable VideoResult result) { + if (result != null) { + mCameraCallbacks.dispatchOnVideoTaken(result); + } else { + // Something went wrong, lock the camera again. + mCamera.lock(); + } + } @Override void takeVideo(@NonNull final File videoFile) { @@ -672,10 +681,6 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera // Something went wrong, lock the camera again. mCamera.lock(); } - if (mCamera != null) { - // This is needed to restore FrameProcessor. No re-allocation needed though. - mCamera.setPreviewCallbackWithBuffer(this); - } } @WorkerThread diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java index 6149bda7..bfa1f4e4 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java @@ -57,8 +57,6 @@ abstract class CameraController implements protected FrameManager mFrameManager; protected SizeSelector mPictureSizeSelector; protected SizeSelector mVideoSizeSelector; - // protected MediaRecorder mMediaRecorder; - // protected VideoResult mVideoResult; protected VideoRecorder mVideoRecorder; protected long mVideoMaxSize; protected int mVideoMaxDuration; diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/MediaRecorderVideoRecorder.java b/cameraview/src/main/java/com/otaliastudios/cameraview/MediaRecorderVideoRecorder.java index dc3ba767..e6f1539b 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/MediaRecorderVideoRecorder.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/MediaRecorderVideoRecorder.java @@ -35,7 +35,11 @@ class MediaRecorderVideoRecorder extends VideoRecorder { mMediaRecorder.setOutputFormat(mProfile.fileFormat); mMediaRecorder.setVideoFrameRate(mProfile.videoFrameRate); mMediaRecorder.setVideoSize(size.getWidth(), size.getHeight()); - mMediaRecorder.setVideoEncoder(new Mapper1().map(mResult.getCodec())); + if (mResult.getCodec() == VideoCodec.DEFAULT) { + mMediaRecorder.setVideoEncoder(mProfile.videoCodec); + } else { + mMediaRecorder.setVideoEncoder(new Mapper1().map(mResult.getCodec())); + } mMediaRecorder.setVideoEncodingBitRate(mProfile.videoBitRate); if (mResult.getAudio() == Audio.ON) { mMediaRecorder.setAudioChannels(mProfile.audioChannels);