From d9a301100f70d1a6ec48fbcf122c70490b018e50 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 30 Jan 2024 10:52:34 +0100 Subject: [PATCH] fix: Fix `priority` being ignored in some Format filters (#2456) * fix: Expose auto-focus system for Android * Add `autoFocusSystem` to filter * Update CameraDeviceDetails.kt * Update getCameraFormat.ts * fix: Fix `priority` being ignored in some Format filters * Update getCameraFormat.ts --- package/src/devices/getCameraFormat.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/package/src/devices/getCameraFormat.ts b/package/src/devices/getCameraFormat.ts index e0f5b33199..f4a86987cd 100644 --- a/package/src/devices/getCameraFormat.ts +++ b/package/src/devices/getCameraFormat.ts @@ -218,32 +218,34 @@ export function getCameraFormat(device: CameraDevice, filters: FormatFilter[]): // Find video stabilization mode if (filter.videoStabilizationMode != null) { - if (bestFormat.videoStabilizationModes.includes(filter.videoStabilizationMode.target)) leftPoints++ - if (format.videoStabilizationModes.includes(filter.videoStabilizationMode.target)) rightPoints++ + if (bestFormat.videoStabilizationModes.includes(filter.videoStabilizationMode.target)) + leftPoints += filter.videoStabilizationMode.priority + if (format.videoStabilizationModes.includes(filter.videoStabilizationMode.target)) + rightPoints += filter.videoStabilizationMode.priority } // Find pixel format if (filter.pixelFormat != null) { - if (bestFormat.pixelFormats.includes(filter.pixelFormat.target)) leftPoints++ - if (format.pixelFormats.includes(filter.pixelFormat.target)) rightPoints++ + if (bestFormat.pixelFormats.includes(filter.pixelFormat.target)) leftPoints += filter.pixelFormat.priority + if (format.pixelFormats.includes(filter.pixelFormat.target)) rightPoints += filter.pixelFormat.priority } // Find Photo HDR formats if (filter.photoHdr != null) { - if (bestFormat.supportsPhotoHdr === filter.photoHdr.target) leftPoints++ - if (format.supportsPhotoHdr === filter.photoHdr.target) rightPoints++ + if (bestFormat.supportsPhotoHdr === filter.photoHdr.target) leftPoints += filter.photoHdr.priority + if (format.supportsPhotoHdr === filter.photoHdr.target) rightPoints += filter.photoHdr.priority } // Find Video HDR formats if (filter.videoHdr != null) { - if (bestFormat.supportsVideoHdr === filter.videoHdr.target) leftPoints++ - if (format.supportsVideoHdr === filter.videoHdr.target) rightPoints++ + if (bestFormat.supportsVideoHdr === filter.videoHdr.target) leftPoints += filter.videoHdr.priority + if (format.supportsVideoHdr === filter.videoHdr.target) rightPoints += filter.videoHdr.priority } - // phase-detection is generally the best AF system + // Find matching AF system if (filter.autoFocusSystem != null) { - if (bestFormat.autoFocusSystem === filter.autoFocusSystem.target) leftPoints++ - if (format.autoFocusSystem === filter.autoFocusSystem.target) rightPoints++ + if (bestFormat.autoFocusSystem === filter.autoFocusSystem.target) leftPoints += filter.autoFocusSystem.priority + if (format.autoFocusSystem === filter.autoFocusSystem.target) rightPoints += filter.autoFocusSystem.priority } if (rightPoints > leftPoints) bestFormat = format