From d7feae01a53e35fc1eb5e2a7cf3582a5fa44efed Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Mon, 22 Jun 2020 23:13:54 -0700 Subject: camera2: Add mandatory stream combinations for depth only cameras. Bug: 159247271 Test: atest ConcurrentCameraTest.java Change-Id: I89d6209d36f76aa8ec19aaafd81abf1cfd025463 Signed-off-by: Jayant Chowdhary --- .../java/android/hardware/camera2/CameraDevice.java | 11 ++++++++--- .../camera2/params/MandatoryStreamCombination.java | 21 ++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java index 30ee32604939..15625cdeb8f4 100644 --- a/core/java/android/hardware/camera2/CameraDevice.java +++ b/core/java/android/hardware/camera2/CameraDevice.java @@ -680,7 +680,7 @@ public abstract class CameraDevice implements AutoCloseable { *
*

* - *

Devices capable of streaming concurrently with other devices as described by + *

BACKWARD_COMPATIBLE devices capable of streaming concurrently with other devices as described by * {@link android.hardware.camera2.CameraManager#getConcurrentCameraIds} have the * following guaranteed streams (when streaming concurrently with other devices)

* @@ -696,10 +696,14 @@ public abstract class CameraDevice implements AutoCloseable { *
*

* + *

Devices which are not backwards-compatible, support a mandatory single stream of size sVGA with image format {@code DEPTH16} during concurrent operation. + * *

For guaranteed concurrent stream configurations:

- *

s720p refers to the camera device's resolution for that format from {@link StreamConfigurationMap#getOutputSizes} or + *

sVGA refers to the camera device's maximum resolution for that format from {@link StreamConfigurationMap#getOutputSizes} or + * VGA resolution (640X480) whichever is lower.

+ *

s720p refers to the camera device's maximum resolution for that format from {@link StreamConfigurationMap#getOutputSizes} or * 720p(1280X720) whichever is lower.

- *

s1440p refers to the camera device's resolution for that format from {@link StreamConfigurationMap#getOutputSizes} or + *

s1440p refers to the camera device's maximum resolution for that format from {@link StreamConfigurationMap#getOutputSizes} or * 1440p(1920X1440) whichever is lower.

*

MONOCHROME-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} * includes {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME MONOCHROME}) devices @@ -707,6 +711,7 @@ public abstract class CameraDevice implements AutoCloseable { * streams with {@code Y8} in all guaranteed stream combinations for the device's hardware level * and capabilities.

* + * *

Devices capable of outputting HEIC formats ({@link StreamConfigurationMap#getOutputFormats} * contains {@link android.graphics.ImageFormat#HEIC}) will support substituting {@code JPEG} * streams with {@code HEIC} in all guaranteed stream combinations for the device's hardware diff --git a/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java b/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java index 20d9c30bb4cc..776d155e5b3e 100644 --- a/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java +++ b/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java @@ -685,6 +685,12 @@ public final class MandatoryStreamCombination { "Standard still image capture"), }; + private static StreamCombinationTemplate sConcurrentDepthOnlyStreamCombinations[] = { + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.DEPTH16, SizeThreshold.VGA) }, + "Depth capture for mesh based object rendering"), + }; + /** * Helper builder class to generate a list of available mandatory stream combinations. * @hide @@ -729,19 +735,21 @@ public final class MandatoryStreamCombination { getAvailableMandatoryConcurrentStreamCombinations() { // Since concurrent streaming support is optional, we mandate these stream // combinations regardless of camera device capabilities. + + StreamCombinationTemplate []chosenStreamCombinations = sConcurrentStreamCombinations; if (!isColorOutputSupported()) { - Log.v(TAG, "Device is not backward compatible!"); - throw new IllegalArgumentException("Camera device which is not BACKWARD_COMPATIBLE" - + " cannot have mandatory concurrent streams"); + Log.v(TAG, "Device is not backward compatible, depth streams are mandatory!"); + chosenStreamCombinations = sConcurrentDepthOnlyStreamCombinations; } + Size sizeVGAp = new Size(640, 480); Size size720p = new Size(1280, 720); Size size1440p = new Size(1920, 1440); ArrayList availableConcurrentStreamCombinations = new ArrayList(); availableConcurrentStreamCombinations.ensureCapacity( - sConcurrentStreamCombinations.length); - for (StreamCombinationTemplate combTemplate : sConcurrentStreamCombinations) { + chosenStreamCombinations.length); + for (StreamCombinationTemplate combTemplate : chosenStreamCombinations) { ArrayList streamsInfo = new ArrayList(); streamsInfo.ensureCapacity(combTemplate.mStreamTemplates.length); @@ -753,6 +761,9 @@ public final class MandatoryStreamCombination { case s1440p: formatSize = size1440p; break; + case VGA: + formatSize = sizeVGAp; + break; default: formatSize = size720p; } -- cgit v1.2.3-59-g8ed1b