@@ -16,7 +16,7 @@ import com.octo4a.utils.isServiceRunning
1616
1717data class CameraSize (val width : Int , val height : Int )
1818
19- data class CameraDescription (val id : String , val megapixels : Int , val lensFacing : Int , val sizes : List <CameraSize >)
19+ data class CameraDescription (val id : String , val megapixels : Int , val lensFacing : Int , val sizes : List <CameraSize >, val frameRates : List < Int > )
2020
2121fun CameraSize.readableString (): String {
2222 return " ${width} x${height} "
@@ -67,9 +67,11 @@ class CameraEnumerationRepository(val context: Context) {
6767 val configs = characteristics.get(
6868 CameraCharacteristics .SCALER_STREAM_CONFIGURATION_MAP
6969 )
70+ val fpsRanges = characteristics.get(CameraCharacteristics .CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES )
71+ val frameRates = fpsRanges?.map { it.upper }?.distinct()?.sorted() ? : emptyList()
7072 val sizes = configs?.getOutputSizes(ImageFormat .YUV_420_888 )
7173 ?.map { size -> CameraSize (size.width, size.height) }
72- CameraDescription (it, megapixels, facing, sizes ? : emptyList())
74+ CameraDescription (it, megapixels, facing, sizes ? : emptyList(), frameRates )
7375 }.toMutableList()
7476 } else {
7577 val needToRestartService = context.isServiceRunning(LegacyCameraService ::class .java)
@@ -84,7 +86,7 @@ class CameraEnumerationRepository(val context: Context) {
8486 Camera .getCameraInfo(i, cameraInfo)
8587
8688 val cam = Camera .open(i)
87-
89+ val supportedFrameRates = cam.parameters.supportedPreviewFrameRates.sorted()
8890 val pictureSize = cam.parameters.pictureSize
8991 val megaPixels = (pictureSize.width * pictureSize.height) / 1000000
9092 cams.add(CameraDescription (
@@ -93,7 +95,8 @@ class CameraEnumerationRepository(val context: Context) {
9395 cameraInfo.facing,
9496 cam.parameters.supportedPreviewSizes.map {
9597 CameraSize (it.width, it.height)
96- }
98+ },
99+ supportedFrameRates
97100 ))
98101
99102 cam.release()
0 commit comments