Skip to content

Commit

Permalink
fix: Also dont enable if other extension is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Mar 18, 2024
1 parent 27a4f85 commit 5525f2b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ class PhotoHdrAndVideoHdrNotSupportedSimultaneously :
"photo-hdr-and-video-hdr-not-suppoted-simultaneously",
"Photo HDR and Video HDR are not supported simultaneously! Disable either `videoHdr` or `photoHdr`."
)
class LowLightBoostNotSupportedWithVideoHdr :
class LowLightBoostNotSupportedWithHdr :
CameraError(
"format",
"low-light-boost-not-supported-with-video-hdr",
"The low light boost extension does not work when video HDR is enabled! Disable either `lowLightBoost` or `videoHdr`."
"low-light-boost-not-supported-with-hdr",
"The low light boost extension does not work when HDR is enabled! Disable either `lowLightBoost` or `videoHdr`/`photoHdr`."
)

class VideoNotEnabledError :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ class CameraSession(private val context: Context, private val callback: Callback
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) {
val enableHdrExtension = photoOptions != null && photoOptions.config.enableHdr
if (enableHdrExtension) {
if (isStreamingHDR) {
// extensions don't work if a camera stream is running at 10-bit HDR.
throw PhotoHdrAndVideoHdrNotSupportedSimultaneously()
Expand All @@ -383,7 +384,11 @@ class CameraSession(private val context: Context, private val callback: Callback
if (configuration.enableLowLightBoost) {
if (isStreamingHDR) {
// extensions don't work if a camera stream is running at 10-bit HDR.
throw LowLightBoostNotSupportedWithVideoHdr()
throw LowLightBoostNotSupportedWithHdr()
}
if (enableHdrExtension) {
// low-light boost does not work when another HDR extension is already applied
throw LowLightBoostNotSupportedWithHdr()
}
// Load night mode Vendor extension (only applies to image capture)
cameraSelector = cameraSelector.withExtension(context, provider, needsImageAnalysis, ExtensionMode.NIGHT, "NIGHT")
Expand Down
2 changes: 1 addition & 1 deletion package/src/CameraError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type FormatError =
| 'format/invalid-fps'
| 'format/invalid-video-hdr'
| 'format/photo-hdr-and-video-hdr-not-suppoted-simultaneously'
| 'format/low-light-boost-not-supported-with-video-hdr'
| 'format/low-light-boost-not-supported-with-hdr'
| 'format/invalid-video-stabilization-mode'
| 'format/incompatible-pixel-format-with-hdr-setting'
| 'format/invalid-format'
Expand Down

0 comments on commit 5525f2b

Please sign in to comment.