Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Aug 2, 2023
1 parent 1766ea3 commit 87ef655
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ fun supportsOutputType(characteristics: CameraCharacteristics, outputType: Outpu
fun getMaxRecordResolution(cameraId: String): Size {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val profiles = CamcorderProfile.getAll(cameraId, CamcorderProfile.QUALITY_HIGH)
if (profiles != null) {
val highestProfile = profiles.videoProfiles.maxBy { it.width * it.height }
val highestProfile = profiles?.videoProfiles?.maxBy { it.width * it.height }
if (highestProfile != null) {
return Size(highestProfile.width, highestProfile.height)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class CameraDeviceDetails(private val cameraManager: CameraManager, private val
val outputSizes = cameraConfig.getOutputSizes(outputFormat).toMutableList()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// High resolution Photo sizes that are not able to run at 20FPS+
outputSizes.addAll(cameraConfig.getHighResolutionOutputSizes(outputFormat))
val highResSizes = cameraConfig.getHighResolutionOutputSizes(outputFormat)
if (highResSizes != null) outputSizes.addAll(highResSizes)
}
outputSizes.forEach { outputSize ->
val frameDuration = cameraConfig.getOutputMinFrameDuration(outputFormat, outputSize)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.mrousavy.camera.utils

import android.util.Size
import kotlin.math.abs

fun Array<Size>.closestToOrMax(size: Size?): Size {
return if (size != null) {
this.minBy { (it.width - size.width) + (it.height - size.height) }
this.minBy { abs(it.width - size.width) + abs(it.height - size.height) }
} else {
this.maxBy { it.width * it.height }
}
Expand Down

0 comments on commit 87ef655

Please sign in to comment.