Remove CONTROL_SCENE_MODES for HDR and Night-Mode
This commit is contained in:
parent
933e92aff5
commit
56947b07e9
@ -288,22 +288,12 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
|
||||
val isExtensionAvailable = imageExtension.isExtensionAvailable(cameraSelector) &&
|
||||
previewExtension.isExtensionAvailable(cameraSelector)
|
||||
if (isExtensionAvailable) {
|
||||
Log.d(REACT_CLASS, "Enabling native HDR extension...")
|
||||
Log.i(REACT_CLASS, "Enabling native HDR extension...")
|
||||
imageExtension.enableExtension(cameraSelector)
|
||||
previewExtension.enableExtension(cameraSelector)
|
||||
} else {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
Log.d(REACT_CLASS, "Native HDR extension not available, falling back to CONTROL_SCENE_MODE...")
|
||||
Camera2Interop.Extender(previewBuilder)
|
||||
.setCaptureRequestOption(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HDR)
|
||||
Camera2Interop.Extender(imageCaptureBuilder)
|
||||
.setCaptureRequestOption(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HDR)
|
||||
Camera2Interop.Extender(videoCaptureBuilder)
|
||||
.setCaptureRequestOption(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HDR)
|
||||
} else {
|
||||
Log.d(REACT_CLASS, "Native HDR extension and CONTROL_SCENE_MODE_HDR not available!")
|
||||
throw UnsupportedOSError("hdr", "true", "5.1 (Lollipop/22)")
|
||||
}
|
||||
Log.e(REACT_CLASS, "Native HDR vendor extension not available!")
|
||||
throw HdrNotContainedInFormatError()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,17 +304,12 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
|
||||
val isExtensionAvailable = imageExtension.isExtensionAvailable(cameraSelector) &&
|
||||
previewExtension.isExtensionAvailable(cameraSelector)
|
||||
if (isExtensionAvailable) {
|
||||
Log.d(REACT_CLASS, "Enabling native night-mode extension...")
|
||||
Log.i(REACT_CLASS, "Enabling native night-mode extension...")
|
||||
imageExtension.enableExtension(cameraSelector)
|
||||
previewExtension.enableExtension(cameraSelector)
|
||||
} else {
|
||||
Log.d(REACT_CLASS, "Native night-mode extension not available, falling back to CONTROL_SCENE_MODE...")
|
||||
Camera2Interop.Extender(previewBuilder)
|
||||
.setCaptureRequestOption(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_NIGHT)
|
||||
Camera2Interop.Extender(imageCaptureBuilder)
|
||||
.setCaptureRequestOption(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_NIGHT)
|
||||
Camera2Interop.Extender(videoCaptureBuilder)
|
||||
.setCaptureRequestOption(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_NIGHT)
|
||||
Log.e(REACT_CLASS, "Native night-mode vendor extension not available!")
|
||||
throw LowLightBoostNotContainedInFormatError()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.camera.core.CameraSelector
|
||||
import androidx.camera.core.ImageCapture
|
||||
import androidx.camera.core.MeteringPoint
|
||||
import androidx.camera.core.MeteringPointFactory
|
||||
import androidx.camera.extensions.HdrImageCaptureExtender
|
||||
import androidx.camera.extensions.NightImageCaptureExtender
|
||||
import androidx.core.content.ContextCompat
|
||||
@ -153,18 +151,15 @@ class CameraViewModule(reactContext: ReactApplicationContext) : ReactContextBase
|
||||
characteristics.get(CameraCharacteristics.INFO_VERSION)
|
||||
else null
|
||||
val fpsRanges = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)!!
|
||||
val scenes = characteristics.get(CameraCharacteristics.CONTROL_AVAILABLE_SCENE_MODES)!!
|
||||
|
||||
var supportsHdr = false
|
||||
var supportsLowLightBoost = false
|
||||
try {
|
||||
val hdrExtension = HdrImageCaptureExtender.create(imageCaptureBuilder)
|
||||
supportsHdr = hdrExtension.isExtensionAvailable(cameraSelector)
|
||||
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 && scenes.contains(CameraCharacteristics.CONTROL_SCENE_MODE_HDR))
|
||||
|
||||
val nightExtension = NightImageCaptureExtender.create(imageCaptureBuilder)
|
||||
supportsLowLightBoost = nightExtension.isExtensionAvailable(cameraSelector)
|
||||
|| scenes.contains(CameraCharacteristics.CONTROL_SCENE_MODE_NIGHT)
|
||||
} catch (e: Throwable) {
|
||||
// error on checking availability. falls back to "false"
|
||||
Log.e(REACT_CLASS, "Failed to check HDR/Night Mode extension availability.", e)
|
||||
|
@ -41,10 +41,10 @@ class NoCameraDeviceError: CameraError("device", "no-device", "No device was set
|
||||
class InvalidCameraDeviceError(cause: Throwable): CameraError("device", "invalid-device", "The given Camera device could not be found for use-case binding!", cause)
|
||||
|
||||
class FpsNotContainedInFormatError(fps: Int): CameraError("format", "invalid-fps", "The given FPS were not valid for the currently selected format. Make sure you select a format which `frameRateRanges` includes $fps FPS!")
|
||||
class HdrNotContainedInFormatError(usesFallback: Boolean): CameraError("format", "invalid-hdr", "The currently selected format does not support HDR capture! " +
|
||||
"Make sure you select a format which `frameRateRanges` includes `supportsPhotoHDR`! Using CONTROL_SCENE_MODE_HDR as fallback: $usesFallback")
|
||||
class LowLightBoostNotContainedInFormatError(usesFallback: Boolean): CameraError("format", "invalid-low-light-boost", "The currently selected format does not support low-light boost (night mode)! " +
|
||||
"Make sure you select a format which includes `supportsLowLightBoost`. Using CONTROL_SCENE_MODE_NIGHT as fallback: $usesFallback")
|
||||
class HdrNotContainedInFormatError(): CameraError("format", "invalid-hdr", "The currently selected format does not support HDR capture! " +
|
||||
"Make sure you select a format which `frameRateRanges` includes `supportsPhotoHDR`!")
|
||||
class LowLightBoostNotContainedInFormatError(): CameraError("format", "invalid-low-light-boost", "The currently selected format does not support low-light boost (night mode)! " +
|
||||
"Make sure you select a format which includes `supportsLowLightBoost`.")
|
||||
|
||||
class CameraNotReadyError: CameraError("session", "camera-not-ready", "The Camera is not ready yet! Wait for the onInitialized() callback!")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user