Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Octo4a 2.1.0 - Camera service refactor #496

Merged
merged 14 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId = "com.octo4a"
minSdk = 17
targetSdk = 28
versionName = "2.0.0"
versionCode = 2000000
versionName = "2.1.0"
versionCode = 2001000
multiDexEnabled = true

ndk {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.octo4a.utils.isServiceRunning

data class CameraSize(val width: Int, val height: Int)

data class CameraDescription(val id: String, val megapixels: Int, val lensFacing: Int, val sizes: List<CameraSize>)
data class CameraDescription(val id: String, val megapixels: Int, val lensFacing: Int, val sizes: List<CameraSize>, val frameRates: List<Int>)

fun CameraSize.readableString(): String {
return "${width}x${height}"
Expand Down Expand Up @@ -67,9 +67,11 @@ class CameraEnumerationRepository(val context: Context) {
val configs = characteristics.get(
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP
)
val fpsRanges = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)
val frameRates = fpsRanges?.map { it.upper }?.distinct()?.sorted() ?: emptyList()
val sizes = configs?.getOutputSizes(ImageFormat.YUV_420_888)
?.map { size -> CameraSize(size.width, size.height) }
CameraDescription(it, megapixels, facing, sizes ?: emptyList())
CameraDescription(it, megapixels, facing, sizes ?: emptyList(), frameRates)
}.toMutableList()
} else {
val needToRestartService = context.isServiceRunning(LegacyCameraService::class.java)
Expand All @@ -84,7 +86,7 @@ class CameraEnumerationRepository(val context: Context) {
Camera.getCameraInfo(i, cameraInfo)

val cam = Camera.open(i)

val supportedFrameRates = cam.parameters.supportedPreviewFrameRates.sorted()
val pictureSize = cam.parameters.pictureSize
val megaPixels = (pictureSize.width * pictureSize.height) / 1000000
cams.add(CameraDescription(
Expand All @@ -93,7 +95,8 @@ class CameraEnumerationRepository(val context: Context) {
cameraInfo.facing,
cam.parameters.supportedPreviewSizes.map {
CameraSize(it.width, it.height)
}
},
supportedFrameRates
))

cam.release()
Expand Down
Loading
Loading