From bcf201a9a330d268fe1bc56a8f459bd076ab490d Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Wed, 25 Oct 2023 12:56:32 +0200 Subject: [PATCH] fix: Ensure `format` is properly checked for equality (#2083) * fix: Properly check for equality in `CameraDeviceFormat` * Update CameraSession.kt * fix: Fix `autoFocusSystem` parsing * Format --- .../com/mrousavy/camera/core/CameraSession.kt | 5 -- .../camera/types/CameraDeviceFormat.kt | 54 ++----------------- package/ios/Types/AutoFocusSystem.swift | 2 +- 3 files changed, 5 insertions(+), 56 deletions(-) diff --git a/package/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt b/package/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt index 7efc1ec..712c6b6 100644 --- a/package/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt +++ b/package/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt @@ -347,11 +347,6 @@ class CameraSession(private val context: Context, private val cameraManager: Cam codeScannerOutput = output } - if (outputs.isEmpty()) { - Log.w(TAG, "Cannot create Camera Session without any outputs. Aborting...") - return - } - // Create new session captureSession = cameraDevice.createCaptureSession(cameraManager, outputs, { session -> if (this.captureSession == session) { diff --git a/package/android/src/main/java/com/mrousavy/camera/types/CameraDeviceFormat.kt b/package/android/src/main/java/com/mrousavy/camera/types/CameraDeviceFormat.kt index 23b4c6d..9ac471e 100644 --- a/package/android/src/main/java/com/mrousavy/camera/types/CameraDeviceFormat.kt +++ b/package/android/src/main/java/com/mrousavy/camera/types/CameraDeviceFormat.kt @@ -15,11 +15,11 @@ data class CameraDeviceFormat( val maxISO: Double, val fieldOfView: Double, val maxZoom: Double, - val videoStabilizationModes: Array, + val videoStabilizationModes: List, val autoFocusSystem: AutoFocusSystem, val supportsVideoHDR: Boolean, val supportsPhotoHDR: Boolean, - val pixelFormats: Array, + val pixelFormats: List, val supportsDepthCapture: Boolean ) { val photoSize: Size @@ -48,59 +48,13 @@ data class CameraDeviceFormat( value.getDouble("maxISO"), value.getDouble("fieldOfView"), value.getDouble("maxZoom"), - videoStabilizationModes.toTypedArray(), + videoStabilizationModes, autoFocusSystem, value.getBoolean("supportsVideoHDR"), value.getBoolean("supportsPhotoHDR"), - pixelFormats.toTypedArray(), + pixelFormats, value.getBoolean("supportsDepthCapture") ) } } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as CameraDeviceFormat - - if (videoWidth != other.videoWidth) return false - if (videoHeight != other.videoHeight) return false - if (photoWidth != other.photoWidth) return false - if (photoHeight != other.photoHeight) return false - if (minFps != other.minFps) return false - if (maxFps != other.maxFps) return false - if (minISO != other.minISO) return false - if (maxISO != other.maxISO) return false - if (fieldOfView != other.fieldOfView) return false - if (maxZoom != other.maxZoom) return false - if (!videoStabilizationModes.contentEquals(other.videoStabilizationModes)) return false - if (autoFocusSystem != other.autoFocusSystem) return false - if (supportsVideoHDR != other.supportsVideoHDR) return false - if (supportsPhotoHDR != other.supportsPhotoHDR) return false - if (!pixelFormats.contentEquals(other.pixelFormats)) return false - if (supportsDepthCapture != other.supportsDepthCapture) return false - - return true - } - - override fun hashCode(): Int { - var result = videoWidth - result = 31 * result + videoHeight - result = 31 * result + photoWidth - result = 31 * result + photoHeight - result = 31 * result + minFps.hashCode() - result = 31 * result + maxFps.hashCode() - result = 31 * result + minISO.hashCode() - result = 31 * result + maxISO.hashCode() - result = 31 * result + fieldOfView.hashCode() - result = 31 * result + maxZoom.hashCode() - result = 31 * result + videoStabilizationModes.contentHashCode() - result = 31 * result + autoFocusSystem.hashCode() - result = 31 * result + supportsVideoHDR.hashCode() - result = 31 * result + supportsPhotoHDR.hashCode() - result = 31 * result + pixelFormats.contentHashCode() - result = 31 * result + supportsDepthCapture.hashCode() - return result - } } diff --git a/package/ios/Types/AutoFocusSystem.swift b/package/ios/Types/AutoFocusSystem.swift index b5613a4..5743d2e 100644 --- a/package/ios/Types/AutoFocusSystem.swift +++ b/package/ios/Types/AutoFocusSystem.swift @@ -11,7 +11,7 @@ import Foundation enum AutoFocusSystem: String, JSUnionValue { case contrastDetection = "contrast-detection" - case phaseDetection + case phaseDetection = "phase-detection" case none init(jsValue: String) throws {