From 796315ca870293b437dea3d6934b597f5713757e Mon Sep 17 00:00:00 2001 From: Jan Herling Date: Mon, 6 Jan 2025 11:48:33 -0800 Subject: [PATCH] Fixed focus mode in AVFLiveVideo Summary: The focus mode needs to be `AVCaptureFocusModeLocked` in case the user specifies a custom focus (`AVCaptureFocusModeContinuousAutoFocus` re-set the focus back to an auto focus immediately). Reviewed By: enpe Differential Revision: D67607868 fbshipit-source-id: 4ab3e7b9a61ec29eeb415b1f3b26d7da2b03775f --- impl/ocean/media/avfoundation/AVFLiveVideo.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/impl/ocean/media/avfoundation/AVFLiveVideo.mm b/impl/ocean/media/avfoundation/AVFLiveVideo.mm index 119d51461..8ec2d485d 100644 --- a/impl/ocean/media/avfoundation/AVFLiveVideo.mm +++ b/impl/ocean/media/avfoundation/AVFLiveVideo.mm @@ -385,11 +385,13 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM if ([captureDevice_ isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) { [captureDevice_ setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; + result = true; } else if ([captureDevice_ isFocusModeSupported:AVCaptureFocusModeAutoFocus]) { [captureDevice_ setFocusMode:AVCaptureFocusModeAutoFocus]; + result = true; } else @@ -401,8 +403,9 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM { if (captureDevice_.isLockingFocusWithCustomLensPositionSupported) { + [captureDevice_ setFocusMode:AVCaptureFocusModeLocked]; [captureDevice_ setFocusModeLockedWithLensPosition:position completionHandler:nil]; - [captureDevice_ setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; + result = true; } }