Skip to content

Commit

Permalink
fix: Fix priority being ignored in some Format filters (#2456)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mrousavy authored Jan 30, 2024
1 parent b5eb01b commit d9a3011
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions package/src/devices/getCameraFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d9a3011

Please sign in to comment.