From cd6d9f6ed0be142a4a866561b5ec5e894760b7c6 Mon Sep 17 00:00:00 2001 From: Andrew Gunnerson Date: Sun, 5 Nov 2023 16:55:48 -0500 Subject: [PATCH] List camera sizes by physical camera Not every physical camera represented by the same logical camera support the same set of resolutions. Signed-off-by: Andrew Gunnerson --- .../java/com/genymobile/scrcpy/LogUtils.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/LogUtils.java b/server/src/main/java/com/genymobile/scrcpy/LogUtils.java index cdda83626f..ca97731424 100644 --- a/server/src/main/java/com/genymobile/scrcpy/LogUtils.java +++ b/server/src/main/java/com/genymobile/scrcpy/LogUtils.java @@ -117,27 +117,12 @@ public static String buildCameraListMessage(boolean includeSizes) { for (String phyId : characteristics.getPhysicalCameraIds()) { CameraCharacteristics phyCharacteristics = cameraManager.getCameraCharacteristics(phyId); appendPhysicalCamera(builder, phyId, phyCharacteristics); - } - } - - if (includeSizes) { - StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); - - android.util.Size[] sizes = configs.getOutputSizes(MediaCodec.class); - for (android.util.Size size : sizes) { - builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight()); - } - - android.util.Size[] highSpeedSizes = configs.getHighSpeedVideoSizes(); - if (highSpeedSizes.length > 0) { - builder.append("\n High speed capture (--camera-high-speed):"); - for (android.util.Size size : highSpeedSizes) { - Range[] highFpsRanges = configs.getHighSpeedVideoFpsRanges(); - SortedSet uniqueHighFps = getUniqueSet(highFpsRanges); - builder.append("\n - ").append(size.getWidth()).append("x").append(size.getHeight()); - builder.append(" (fps=").append(uniqueHighFps).append(')'); + if (includeSizes) { + appendSizes(builder, phyCharacteristics); } } + } else if (includeSizes) { + appendSizes(builder, characteristics); } } } @@ -164,6 +149,26 @@ private static void appendPhysicalCamera(StringBuilder builder, String id, Camer builder.append(activeSize.width()).append("x").append(activeSize.height()).append(")"); } + private static void appendSizes(StringBuilder builder, CameraCharacteristics characteristics) { + StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); + + android.util.Size[] sizes = configs.getOutputSizes(MediaCodec.class); + for (android.util.Size size : sizes) { + builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight()); + } + + android.util.Size[] highSpeedSizes = configs.getHighSpeedVideoSizes(); + if (highSpeedSizes.length > 0) { + builder.append("\n High speed capture (--camera-high-speed):"); + for (android.util.Size size : highSpeedSizes) { + Range[] highFpsRanges = configs.getHighSpeedVideoFpsRanges(); + SortedSet uniqueHighFps = getUniqueSet(highFpsRanges); + builder.append("\n - ").append(size.getWidth()).append("x").append(size.getHeight()); + builder.append(" (fps=").append(uniqueHighFps).append(')'); + } + } + } + private static SortedSet getUniqueSet(Range[] ranges) { SortedSet set = new TreeSet<>(); for (Range range : ranges) {