diff --git a/android/src/main/java/com/mrousavy/camera/utils/CameraDevice+createCaptureSession.kt b/android/src/main/java/com/mrousavy/camera/utils/CameraDevice+createCaptureSession.kt index 2c005de06b..6dd53798f5 100644 --- a/android/src/main/java/com/mrousavy/camera/utils/CameraDevice+createCaptureSession.kt +++ b/android/src/main/java/com/mrousavy/camera/utils/CameraDevice+createCaptureSession.kt @@ -77,35 +77,6 @@ fun supportsOutputType(characteristics: CameraCharacteristics, outputType: Outpu return false } -fun getMaxRecordResolution(cameraId: String): Size { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - val profiles = CamcorderProfile.getAll(cameraId, CamcorderProfile.QUALITY_HIGH) - val highestProfile = profiles?.videoProfiles?.maxBy { it.width * it.height } - if (highestProfile != null) { - return Size(highestProfile.width, highestProfile.height) - } - } - // fallback: old API - val cameraIdInt = cameraId.toIntOrNull() - val camcorderProfile = if (cameraIdInt != null) { - CamcorderProfile.get(cameraIdInt, CamcorderProfile.QUALITY_HIGH) - } else { - CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH) - } - return Size(camcorderProfile.videoFrameWidth, camcorderProfile.videoFrameHeight) -} - -fun getMaxPreviewResolution(): Size { - val display = Resources.getSystem().displayMetrics - // According to Android documentation, "PREVIEW" size is always limited to 1920x1080 - return Size(1920.coerceAtMost(display.widthPixels), 1080.coerceAtMost(display.widthPixels)) -} - -fun getMaxMaximumResolution(format: Int, characteristics: CameraCharacteristics): Size { - val config = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)!! - return config.getOutputSizes(format).maxBy { it.width * it.height } -} - suspend fun CameraDevice.createCaptureSession(cameraManager: CameraManager, sessionType: SessionType, outputs: List, queue: CameraQueues.CameraQueue): CameraCaptureSession { return suspendCoroutine { continuation -> @@ -119,9 +90,6 @@ suspend fun CameraDevice.createCaptureSession(cameraManager: CameraManager, sess } } - val recordSize = getMaxRecordResolution(this.id) - val previewSize = getMaxPreviewResolution() - val characteristics = cameraManager.getCameraCharacteristics(this.id) val hardwareLevel = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)!! Log.i(CameraView.TAG, "Creating Capture Session on ${parseHardwareLevel(hardwareLevel)} device...") @@ -135,6 +103,7 @@ suspend fun CameraDevice.createCaptureSession(cameraManager: CameraManager, sess if (it.dynamicRangeProfile != null) result.dynamicRangeProfile = it.dynamicRangeProfile if (supportsOutputType(characteristics, it.outputType)) { result.streamUseCase = it.outputType.toOutputType() + Log.i(CameraView.TAG, "Using optimized stream use case \"${it.outputType.name}\" (${result.streamUseCase})..") } } return@map result diff --git a/example/src/CameraPage.tsx b/example/src/CameraPage.tsx index 9f76f62404..847628b7ec 100644 --- a/example/src/CameraPage.tsx +++ b/example/src/CameraPage.tsx @@ -192,7 +192,7 @@ export function CameraPage({ navigation }: Props): React.ReactElement { if (device != null && format != null) { console.log( `Re-rendering camera page with ${isActive ? 'active' : 'inactive'} camera. ` + - `Device: "${device.name}" (${format.photoWidth}x${format.photoHeight} @ ${fps}fps)`, + `Device: "${device.name}" (${format.photoWidth}x${format.photoHeight} photo / ${format.videoWidth}x${format.videoHeight} video @ ${fps}fps)`, ); } else { console.log('re-rendering camera page without active camera'); @@ -224,8 +224,6 @@ export function CameraPage({ navigation }: Props): React.ReactElement { console.log(frame.timestamp, frame.toString(), frame.pixelFormat); }, []); - console.log(JSON.stringify(device)); - return ( {device != null && (