fix: Ensure format is properly checked for equality (#2083)

* fix: Properly check for equality in `CameraDeviceFormat`

* Update CameraSession.kt

* fix: Fix `autoFocusSystem` parsing

* Format
This commit is contained in:
Marc Rousavy 2023-10-25 12:56:32 +02:00 committed by GitHub
parent d675b6a9da
commit bcf201a9a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 56 deletions

View File

@ -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) {

View File

@ -15,11 +15,11 @@ data class CameraDeviceFormat(
val maxISO: Double,
val fieldOfView: Double,
val maxZoom: Double,
val videoStabilizationModes: Array<VideoStabilizationMode>,
val videoStabilizationModes: List<VideoStabilizationMode>,
val autoFocusSystem: AutoFocusSystem,
val supportsVideoHDR: Boolean,
val supportsPhotoHDR: Boolean,
val pixelFormats: Array<PixelFormat>,
val pixelFormats: List<PixelFormat>,
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
}
}

View File

@ -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 {