fix: Fix blackscreen issues and lifecycle when closing Camera (#2339)

* fix: Fix Blackscreen by deterministically destroying session if `isActive=false`

* Re-open Camera if session died

* Simplify Camera

* Disconnect is optional, block when resetting state

* fix: Log in `configure { ... }`

* fix: Make concurrent configure safe

* fix: Don't resize preview

* fix: Use current `CameraConfiguration`

* Don't start if no outputs are available

* Only mount with preview outputs

* Update CameraSession.kt

* Update PreviewView.kt

* Better logging

* Update CameraSession.kt

* Extract

* fix: Rebuild entire session if `isActive` changed

* isActive safe

* Start session at 1

* Create ActiveCameraDevice.kt

* interrupts

* chore: Freeze `frame` in `useFrameProcessor`

* Revert "chore: Freeze `frame` in `useFrameProcessor`"

This reverts commit dff93d506e29a791d8dea8842b880ab5c892211e.

* chore: Better logging

* fix: Move HDR to `video`/`photo` config

* fix: Fix hdr usage

* fix: Ignore any updates after destroying Camera

* fix: Fix video HDR

* chore: Format code

* fix: Check Camera permission

* Remove unneeded error

* Update CameraSession.kt

* Update CameraPage.tsx

* Delete OutputConfiguration.toDebugString.kt

* Update CameraSession.kt
This commit is contained in:
Marc Rousavy
2024-01-08 11:41:57 +01:00
committed by GitHub
parent 2cd22ad236
commit 0d21bc3a57
16 changed files with 297 additions and 239 deletions

View File

@@ -0,0 +1,28 @@
package com.mrousavy.camera.utils
import android.graphics.ImageFormat
import android.graphics.PixelFormat
class ImageFormatUtils {
companion object {
fun imageFormatToString(format: Int): String =
when (format) {
ImageFormat.YUV_420_888 -> "YUV_420_888"
ImageFormat.NV21 -> "NV21"
ImageFormat.NV16 -> "NV16"
ImageFormat.YV12 -> "YV12"
ImageFormat.YUV_422_888 -> "YUV_422_888"
ImageFormat.YCBCR_P010 -> "YCBCR_P010"
ImageFormat.YUV_444_888 -> "YUV_444_888"
ImageFormat.YUY2 -> "YUY2"
ImageFormat.Y8 -> "Y8"
ImageFormat.JPEG -> "JPEG"
ImageFormat.RGB_565 -> "RGB_565"
ImageFormat.FLEX_RGB_888 -> "FLEX_RGB_888"
ImageFormat.FLEX_RGBA_8888 -> "FLEX_RGBA_8888"
PixelFormat.RGB_888 -> "RGB_888"
ImageFormat.PRIVATE -> "PRIVATE"
else -> "UNKNOWN ($format)"
}
}
}