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) &&
|
val isExtensionAvailable = imageExtension.isExtensionAvailable(cameraSelector) &&
|
||||||
previewExtension.isExtensionAvailable(cameraSelector)
|
previewExtension.isExtensionAvailable(cameraSelector)
|
||||||
if (isExtensionAvailable) {
|
if (isExtensionAvailable) {
|
||||||
Log.d(REACT_CLASS, "Enabling native HDR extension...")
|
Log.i(REACT_CLASS, "Enabling native HDR extension...")
|
||||||
imageExtension.enableExtension(cameraSelector)
|
imageExtension.enableExtension(cameraSelector)
|
||||||
previewExtension.enableExtension(cameraSelector)
|
previewExtension.enableExtension(cameraSelector)
|
||||||
} else {
|
} else {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
|
Log.e(REACT_CLASS, "Native HDR vendor extension not available!")
|
||||||
Log.d(REACT_CLASS, "Native HDR extension not available, falling back to CONTROL_SCENE_MODE...")
|
throw HdrNotContainedInFormatError()
|
||||||
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)")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,17 +304,12 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
|
|||||||
val isExtensionAvailable = imageExtension.isExtensionAvailable(cameraSelector) &&
|
val isExtensionAvailable = imageExtension.isExtensionAvailable(cameraSelector) &&
|
||||||
previewExtension.isExtensionAvailable(cameraSelector)
|
previewExtension.isExtensionAvailable(cameraSelector)
|
||||||
if (isExtensionAvailable) {
|
if (isExtensionAvailable) {
|
||||||
Log.d(REACT_CLASS, "Enabling native night-mode extension...")
|
Log.i(REACT_CLASS, "Enabling native night-mode extension...")
|
||||||
imageExtension.enableExtension(cameraSelector)
|
imageExtension.enableExtension(cameraSelector)
|
||||||
previewExtension.enableExtension(cameraSelector)
|
previewExtension.enableExtension(cameraSelector)
|
||||||
} else {
|
} else {
|
||||||
Log.d(REACT_CLASS, "Native night-mode extension not available, falling back to CONTROL_SCENE_MODE...")
|
Log.e(REACT_CLASS, "Native night-mode vendor extension not available!")
|
||||||
Camera2Interop.Extender(previewBuilder)
|
throw LowLightBoostNotContainedInFormatError()
|
||||||
.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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,6 @@ import android.os.Build
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.camera.core.CameraSelector
|
import androidx.camera.core.CameraSelector
|
||||||
import androidx.camera.core.ImageCapture
|
import androidx.camera.core.ImageCapture
|
||||||
import androidx.camera.core.MeteringPoint
|
|
||||||
import androidx.camera.core.MeteringPointFactory
|
|
||||||
import androidx.camera.extensions.HdrImageCaptureExtender
|
import androidx.camera.extensions.HdrImageCaptureExtender
|
||||||
import androidx.camera.extensions.NightImageCaptureExtender
|
import androidx.camera.extensions.NightImageCaptureExtender
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@ -153,18 +151,15 @@ class CameraViewModule(reactContext: ReactApplicationContext) : ReactContextBase
|
|||||||
characteristics.get(CameraCharacteristics.INFO_VERSION)
|
characteristics.get(CameraCharacteristics.INFO_VERSION)
|
||||||
else null
|
else null
|
||||||
val fpsRanges = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)!!
|
val fpsRanges = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)!!
|
||||||
val scenes = characteristics.get(CameraCharacteristics.CONTROL_AVAILABLE_SCENE_MODES)!!
|
|
||||||
|
|
||||||
var supportsHdr = false
|
var supportsHdr = false
|
||||||
var supportsLowLightBoost = false
|
var supportsLowLightBoost = false
|
||||||
try {
|
try {
|
||||||
val hdrExtension = HdrImageCaptureExtender.create(imageCaptureBuilder)
|
val hdrExtension = HdrImageCaptureExtender.create(imageCaptureBuilder)
|
||||||
supportsHdr = hdrExtension.isExtensionAvailable(cameraSelector)
|
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)
|
val nightExtension = NightImageCaptureExtender.create(imageCaptureBuilder)
|
||||||
supportsLowLightBoost = nightExtension.isExtensionAvailable(cameraSelector)
|
supportsLowLightBoost = nightExtension.isExtensionAvailable(cameraSelector)
|
||||||
|| scenes.contains(CameraCharacteristics.CONTROL_SCENE_MODE_NIGHT)
|
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
// error on checking availability. falls back to "false"
|
// error on checking availability. falls back to "false"
|
||||||
Log.e(REACT_CLASS, "Failed to check HDR/Night Mode extension availability.", e)
|
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 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 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! " +
|
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`! Using CONTROL_SCENE_MODE_HDR as fallback: $usesFallback")
|
"Make sure you select a format which `frameRateRanges` includes `supportsPhotoHDR`!")
|
||||||
class LowLightBoostNotContainedInFormatError(usesFallback: Boolean): CameraError("format", "invalid-low-light-boost", "The currently selected format does not support low-light boost (night mode)! " +
|
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`. Using CONTROL_SCENE_MODE_NIGHT as fallback: $usesFallback")
|
"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!")
|
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