From 2473ec098c6fe283207fea323eaff894d7d82b2b Mon Sep 17 00:00:00 2001 From: colorgold <45986859+colorgold@users.noreply.github.com> Date: Tue, 17 Jan 2023 17:00:17 -0600 Subject: [PATCH] Update CameraBaseEngine.java FileDescriptor parameter for API 29+ --- .../cameraview/engine/CameraBaseEngine.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java index b96a8aec..6e73a27f 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java @@ -610,16 +610,24 @@ public abstract class CameraBaseEngine extends CameraEngine { /** * @param stub a video stub * @param file the output file + * @param fileDescriptor a file descriptor where the video will be saved */ @Override - public final void takeVideoSnapshot(@NonNull final VideoResult.Stub stub, - @NonNull final File file) { + public final void takeVideoSnapshot(final @NonNull VideoResult.Stub stub, + final @Nullable File file, + final @Nullable FileDescriptor fileDescriptor) { getOrchestrator().scheduleStateful("take video snapshot", CameraState.BIND, new Runnable() { @Override public void run() { LOG.i("takeVideoSnapshot:", "running. isTakingVideo:", isTakingVideo()); - stub.file = file; + if (file != null) { + stub.file = file; + } else if (fileDescriptor != null) { + stub.fileDescriptor = fileDescriptor; + } else { + throw new IllegalStateException("file and fileDescriptor are both null."); + } stub.isSnapshot = true; stub.videoCodec = mVideoCodec; stub.audioCodec = mAudioCodec;