Skip to content

Commit

Permalink
fix: Properly check SDR
Browse files Browse the repository at this point in the history
mrousavy committed Mar 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 5fe7608 commit 211783a
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ import com.mrousavy.camera.extensions.byId
import com.mrousavy.camera.extensions.forSize
import com.mrousavy.camera.extensions.getCameraError
import com.mrousavy.camera.extensions.id
import com.mrousavy.camera.extensions.isSDR
import com.mrousavy.camera.extensions.takePicture
import com.mrousavy.camera.extensions.toCameraError
import com.mrousavy.camera.extensions.withExtension
@@ -368,7 +369,7 @@ class CameraSession(private val context: Context, private val callback: Callback
var cameraSelector = CameraSelector.Builder().byId(cameraId).build()

// Wrap input with a vendor extension if needed (see https://developer.android.com/media/camera/camera-extensions)
val isStreamingHDR = useCases.any { it.currentConfig.dynamicRange != DynamicRange.SDR }
val isStreamingHDR = useCases.any { !it.currentConfig.dynamicRange.isSDR }
val needsImageAnalysis = codeScannerOutput != null
val photoOptions = configuration.photo as? CameraConfiguration.Output.Enabled<CameraConfiguration.Photo>
if (photoOptions != null && photoOptions.config.enableHdr) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mrousavy.camera.extensions

import androidx.camera.core.DynamicRange

val DynamicRange.isSDR: Boolean
get() = encoding == DynamicRange.ENCODING_SDR || encoding == DynamicRange.ENCODING_UNSPECIFIED
7 changes: 5 additions & 2 deletions package/example/src/CameraPage.tsx
Original file line number Diff line number Diff line change
@@ -179,6 +179,9 @@ export function CameraPage({ navigation }: Props): React.ReactElement {
exampleKotlinSwiftPlugin(frame)
}, [])

const videoHdr = format?.supportsVideoHdr && enableHdr
const photoHdr = format?.supportsPhotoHdr && enableHdr && !videoHdr

return (
<View style={styles.container}>
{device != null && (
@@ -196,8 +199,8 @@ export function CameraPage({ navigation }: Props): React.ReactElement {
onStopped={() => 'Camera stopped!'}
format={format}
fps={fps}
// photoHdr={format?.supportsPhotoHdr && enableHdr}
videoHdr={format?.supportsVideoHdr && enableHdr}
photoHdr={photoHdr}
videoHdr={videoHdr}
photoQualityBalance="quality"
lowLightBoost={device.supportsLowLightBoost && enableNightMode}
enableZoomGesture={false}

0 comments on commit 211783a

Please sign in to comment.