am cbd88b6c: am 97698b18: am 58cfc43f: am 5b672fcd: am a1976879: Merge "Camera: change supported preview/video size logic" into lollipop-cts-dev automerge: 6a44e14
* commit 'cbd88b6c1ff748bd72422e22c3e9bffecd602e25':
Camera: change supported preview/video size logic
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
index 872f951..be43d2f 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
@@ -570,7 +570,27 @@
*/
static public List<Size> getSupportedPreviewSizes(String cameraId,
CameraManager cameraManager, Size bound) throws CameraAccessException {
- return getSortedSizesForFormat(cameraId, cameraManager, ImageFormat.YUV_420_888, bound);
+ CameraCharacteristics props = cameraManager.getCameraCharacteristics(cameraId);
+ StreamConfigurationMap config =
+ props.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+ Size[] rawSizes = config.getOutputSizes(android.view.SurfaceHolder.class);
+ assertArrayNotEmpty(rawSizes,
+ "Available sizes for SurfaceHolder class should not be empty");
+ if (VERBOSE) {
+ Log.v(TAG, "Supported sizes are: " + Arrays.deepToString(rawSizes));
+ }
+
+ if (bound == null) {
+ return getAscendingOrderSizes(Arrays.asList(rawSizes), /*ascending*/false);
+ }
+
+ List<Size> sizes = new ArrayList<Size>();
+ for (Size sz: rawSizes) {
+ if (sz.getWidth() <= bound.getWidth() && sz.getHeight() <= bound.getHeight()) {
+ sizes.add(sz);
+ }
+ }
+ return getAscendingOrderSizes(sizes, /*ascending*/false);
}
/**
@@ -605,7 +625,7 @@
* Get sorted (descending order) size list for given format. Remove the sizes larger than
* the bound. If the bound is null, don't do the size bound filtering.
*/
- static private List<Size> getSortedSizesForFormat(String cameraId,
+ static public List<Size> getSortedSizesForFormat(String cameraId,
CameraManager cameraManager, int format, Size bound) throws CameraAccessException {
Comparator<Size> comparator = new SizeComparator();
Size[] sizes = getSupportedSizeForFormat(format, cameraId, cameraManager);
@@ -639,7 +659,27 @@
*/
static public List<Size> getSupportedVideoSizes(String cameraId,
CameraManager cameraManager, Size bound) throws CameraAccessException {
- return getSortedSizesForFormat(cameraId, cameraManager, ImageFormat.YUV_420_888, bound);
+ CameraCharacteristics props = cameraManager.getCameraCharacteristics(cameraId);
+ StreamConfigurationMap config =
+ props.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+ Size[] rawSizes = config.getOutputSizes(android.media.MediaRecorder.class);
+ assertArrayNotEmpty(rawSizes,
+ "Available sizes for MediaRecorder class should not be empty");
+ if (VERBOSE) {
+ Log.v(TAG, "Supported sizes are: " + Arrays.deepToString(rawSizes));
+ }
+
+ if (bound == null) {
+ return getAscendingOrderSizes(Arrays.asList(rawSizes), /*ascending*/false);
+ }
+
+ List<Size> sizes = new ArrayList<Size>();
+ for (Size sz: rawSizes) {
+ if (sz.getWidth() <= bound.getWidth() && sz.getHeight() <= bound.getHeight()) {
+ sizes.add(sz);
+ }
+ }
+ return getAscendingOrderSizes(sizes, /*ascending*/false);
}
/**
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
index 124c5b0..bb73629 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
@@ -211,8 +211,8 @@
new SimpleTimingResultListener();
SimpleImageListener imageListener = new SimpleImageListener();
- Size maxYuvSize = CameraTestUtils.getSupportedPreviewSizes(id, mCameraManager,
- /*bound*/null).get(0);
+ Size maxYuvSize = CameraTestUtils.getSortedSizesForFormat(
+ id, mCameraManager, ImageFormat.YUV_420_888, /*bound*/null).get(0);
prepareCaptureAndStartPreview(previewBuilder, captureBuilder,
mOrderedPreviewSizes.get(0), maxYuvSize,