diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 1196f3c298f60f9fc232621fca33cda0f87045c6..6dfafcb2ac61cff5f74ecb09993f7c7350718433 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -286,6 +286,8 @@ public class CaptureModule implements CameraModule, PhotoController, new CameraCharacteristics.Key<>("org.quic.camera2.customhfrfps.info.CustomHFRFpsTable", int[].class); public static final CameraCharacteristics.Key<int[]> sensorModeTable = new CameraCharacteristics.Key<>("org.quic.camera2.sensormode.info.SensorModeTable", int[].class); + public static final CameraCharacteristics.Key<int[]> highSpeedVideoConfigs = + new CameraCharacteristics.Key<>("android.control.availableHighSpeedVideoConfigurations", int[].class); public static final CaptureRequest.Key<Integer> sharpness_control = new CaptureRequest.Key<>( "org.codeaurora.qcamera3.sharpness.strength", Integer.class); diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java index b9aca66fdda2ee3fc44aaf471e2cd2b46e63546d..afb02eb895fc7ce6666ff43f529bee8ea7325b83 100755 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -504,6 +504,17 @@ public class SettingsManager implements ListMenu.SettingsListener { return sensorModeTable; } + public int[] getHighSpeedVideoConfigs(final int cameraId) { + int[] highSpeedVideoConfigs = null; + try { + highSpeedVideoConfigs = mCharacteristics.get(cameraId).get( + CaptureModule.highSpeedVideoConfigs); + } catch (IllegalArgumentException exception) { + exception.printStackTrace(); + } + return highSpeedVideoConfigs; + } + public void registerListener(Listener listener) { mListeners.add(listener); } diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index 378d6633f7b277bc4d724751eb74a272b04c9d4b..0704a90f9b2d0609cfd684cc6be7147ca794378d 100755 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -1403,7 +1403,10 @@ public class CameraUtil { // Request list size: to limit the preview to 30fps, need use maxFps/30; to maximize // the preview frame rate, should use maxBatch size for that high speed stream // configuration. We choose the former for now. - int requestListSize = fpsRange.getUpper() / 30; + int requestListSize = getHighSpeedVideoConfigsLists((int)request.getTag()); + if (requestListSize == -1) { + requestListSize = fpsRange.getUpper() / 30; + } List<CaptureRequest> requestList = new ArrayList<CaptureRequest>(); // Prepare the Request builders: need carry over the request controls. @@ -1471,6 +1474,47 @@ public class CameraUtil { return Collections.unmodifiableList(requestList); } + private static int getHighSpeedVideoConfigsLists(int cameraId) { + int optimalSizeIndex = -1; + SettingsManager settingsManager = SettingsManager.getInstance(); + int[] table = settingsManager.getHighSpeedVideoConfigs(cameraId); + if (table == null) { + Log.w(TAG, " getHighSpeedVideoConfigsLists is null"); + return optimalSizeIndex; + } + String videoSizeString = settingsManager.getValue(SettingsManager.KEY_VIDEO_QUALITY); + if (videoSizeString == null) { + Log.w(TAG, " KEY_VIDEO_QUALITY is null"); + return optimalSizeIndex; + } + android.util.Size videoSize = parsePictureSize(videoSizeString); + String rateValue = settingsManager.getValue(SettingsManager.KEY_VIDEO_HIGH_FRAME_RATE); + if (rateValue == null || rateValue.substring(0, 3).equals("off")) { + Log.w(TAG, " KEY_VIDEO_HIGH_FRAME_RATE is null"); + return optimalSizeIndex; + } + int frameRate = Integer.parseInt(rateValue.substring(3)); + for (int i = 0; i < table.length; i += 5) { + if (table[i] == videoSize.getWidth() + && table[i + 1] == videoSize.getHeight() + && (table[i + 2] == frameRate + || table[i + 3] == frameRate)) { + if (i != table.length) { + optimalSizeIndex = table[i + 4]; + return optimalSizeIndex; + } + } + } + return optimalSizeIndex; + } + + private static android.util.Size parsePictureSize(String value) { + int indexX = value.indexOf('x'); + int width = Integer.parseInt(value.substring(0, indexX)); + int height = Integer.parseInt(value.substring(indexX + 1)); + return new android.util.Size(width, height); + } + private static CaptureRequest.Builder constructorCaptureRequestBuilder ( CameraMetadataNative requestMetadata, boolean reprocess, int SESSION_ID_NONE, CaptureRequest request, Set<String> physicalCameraIdSet) {