summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt11
-rw-r--r--core/java/android/hardware/camera2/CameraCharacteristics.java31
-rw-r--r--core/java/android/hardware/camera2/CameraMetadata.java28
-rw-r--r--core/java/android/hardware/camera2/CaptureRequest.java48
-rw-r--r--core/java/android/hardware/camera2/CaptureResult.java48
-rw-r--r--core/java/android/hardware/camera2/impl/CameraMetadataNative.java31
-rw-r--r--core/java/android/hardware/camera2/marshal/impl/MarshalQueryableCapabilityAndMaxSize.java77
-rw-r--r--core/java/android/hardware/camera2/params/CapabilityAndMaxSize.java126
8 files changed, 398 insertions, 2 deletions
diff --git a/api/current.txt b/api/current.txt
index fb65243b8e97..87337eb7a1ac 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -16856,6 +16856,7 @@ package android.hardware.camera2 {
field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.util.Rational> CONTROL_AE_COMPENSATION_STEP;
field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Boolean> CONTROL_AE_LOCK_AVAILABLE;
field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<int[]> CONTROL_AF_AVAILABLE_MODES;
+ field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.CapabilityAndMaxSize[]> CONTROL_AVAILABLE_BOKEH_CAPABILITIES;
field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<int[]> CONTROL_AVAILABLE_EFFECTS;
field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<int[]> CONTROL_AVAILABLE_MODES;
field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<int[]> CONTROL_AVAILABLE_SCENE_MODES;
@@ -17071,6 +17072,9 @@ package android.hardware.camera2 {
field public static final int CONTROL_AWB_STATE_INACTIVE = 0; // 0x0
field public static final int CONTROL_AWB_STATE_LOCKED = 3; // 0x3
field public static final int CONTROL_AWB_STATE_SEARCHING = 1; // 0x1
+ field public static final int CONTROL_BOKEH_MODE_CONTINUOUS = 2; // 0x2
+ field public static final int CONTROL_BOKEH_MODE_OFF = 0; // 0x0
+ field public static final int CONTROL_BOKEH_MODE_STILL_CAPTURE = 1; // 0x1
field public static final int CONTROL_CAPTURE_INTENT_CUSTOM = 0; // 0x0
field public static final int CONTROL_CAPTURE_INTENT_MANUAL = 6; // 0x6
field public static final int CONTROL_CAPTURE_INTENT_MOTION_TRACKING = 7; // 0x7
@@ -17266,6 +17270,7 @@ package android.hardware.camera2 {
field @NonNull public static final android.hardware.camera2.CaptureRequest.Key<java.lang.Boolean> CONTROL_AWB_LOCK;
field @NonNull public static final android.hardware.camera2.CaptureRequest.Key<java.lang.Integer> CONTROL_AWB_MODE;
field @NonNull public static final android.hardware.camera2.CaptureRequest.Key<android.hardware.camera2.params.MeteringRectangle[]> CONTROL_AWB_REGIONS;
+ field @NonNull public static final android.hardware.camera2.CaptureRequest.Key<java.lang.Integer> CONTROL_BOKEH_MODE;
field @NonNull public static final android.hardware.camera2.CaptureRequest.Key<java.lang.Integer> CONTROL_CAPTURE_INTENT;
field @NonNull public static final android.hardware.camera2.CaptureRequest.Key<java.lang.Integer> CONTROL_EFFECT_MODE;
field @NonNull public static final android.hardware.camera2.CaptureRequest.Key<java.lang.Boolean> CONTROL_ENABLE_ZSL;
@@ -17351,6 +17356,7 @@ package android.hardware.camera2 {
field @NonNull public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> CONTROL_AWB_MODE;
field @NonNull public static final android.hardware.camera2.CaptureResult.Key<android.hardware.camera2.params.MeteringRectangle[]> CONTROL_AWB_REGIONS;
field @NonNull public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> CONTROL_AWB_STATE;
+ field @NonNull public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> CONTROL_BOKEH_MODE;
field @NonNull public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> CONTROL_CAPTURE_INTENT;
field @NonNull public static final android.hardware.camera2.CaptureResult.Key<java.lang.Integer> CONTROL_EFFECT_MODE;
field @NonNull public static final android.hardware.camera2.CaptureResult.Key<java.lang.Boolean> CONTROL_ENABLE_ZSL;
@@ -17447,6 +17453,11 @@ package android.hardware.camera2.params {
field public static final int COUNT = 4; // 0x4
}
+ public final class CapabilityAndMaxSize {
+ method @NonNull public android.util.Size getMaxStreamingSize();
+ method public int getMode();
+ }
+
public final class ColorSpaceTransform {
ctor public ColorSpaceTransform(android.util.Rational[]);
ctor public ColorSpaceTransform(int[]);
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index fbcc78593aa6..1f29d1a22325 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -1125,6 +1125,37 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
new Key<android.util.Range<Integer>>("android.control.postRawSensitivityBoostRange", new TypeReference<android.util.Range<Integer>>() {{ }});
/**
+ * <p>The list of bokeh modes that are supported by this camera device, and each bokeh mode's
+ * maximum streaming (non-stall) size with bokeh effect.</p>
+ * <p>For OFF mode, the camera behaves normally with no bokeh effect.</p>
+ * <p>For STILL_CAPTURE mode, the maximum streaming dimension specifies the limit under which
+ * bokeh is effective when capture intent is PREVIEW. Note that when capture intent is
+ * PREVIEW, the bokeh effect may not be as high quality compared to STILL_CAPTURE intent
+ * in order to maintain reasonable frame rate. The maximum streaming dimension must be one
+ * of the YUV_420_888 or PRIVATE resolutions in availableStreamConfigurations, or (0, 0)
+ * if preview bokeh is not supported. If the application configures a stream larger than
+ * the maximum streaming dimension, bokeh effect may not be applied for this stream for
+ * PREVIEW intent.</p>
+ * <p>For CONTINUOUS mode, the maximum streaming dimension specifies the limit under which
+ * bokeh is effective. This dimension must be one of the YUV_420_888 or PRIVATE resolutions
+ * in availableStreamConfigurations, and if the sensor maximum resolution is larger than or
+ * equal to 1080p, the maximum streaming dimension must be at least 1080p. If the
+ * application configures a stream with larger dimension, the stream may not have bokeh
+ * effect applied.</p>
+ * <p><b>Units</b>: (mode, width, height)</p>
+ * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
+ * <p><b>Limited capability</b> -
+ * Present on all camera devices that report being at least {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED HARDWARE_LEVEL_LIMITED} devices in the
+ * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel} key</p>
+ *
+ * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL
+ */
+ @PublicKey
+ @NonNull
+ public static final Key<android.hardware.camera2.params.CapabilityAndMaxSize[]> CONTROL_AVAILABLE_BOKEH_CAPABILITIES =
+ new Key<android.hardware.camera2.params.CapabilityAndMaxSize[]>("android.control.availableBokehCapabilities", android.hardware.camera2.params.CapabilityAndMaxSize[].class);
+
+ /**
* <p>List of edge enhancement modes for {@link CaptureRequest#EDGE_MODE android.edge.mode} that are supported by this camera
* device.</p>
* <p>Full-capability camera devices must always support OFF; camera devices that support
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 2fa612574810..799c71683d8a 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -2444,6 +2444,34 @@ public abstract class CameraMetadata<TKey> {
public static final int CONTROL_VIDEO_STABILIZATION_MODE_ON = 1;
//
+ // Enumeration values for CaptureRequest#CONTROL_BOKEH_MODE
+ //
+
+ /**
+ * <p>Bokeh mode is disabled.</p>
+ * @see CaptureRequest#CONTROL_BOKEH_MODE
+ */
+ public static final int CONTROL_BOKEH_MODE_OFF = 0;
+
+ /**
+ * <p>High quality bokeh mode is enabled for all non-raw streams (including YUV,
+ * JPEG, and IMPLEMENTATION_DEFINED) when capture intent is STILL_CAPTURE. Due to the
+ * extra image processing, this mode may introduce additional stall to non-raw streams.
+ * This mode should be used in high quality still capture use case.</p>
+ * @see CaptureRequest#CONTROL_BOKEH_MODE
+ */
+ public static final int CONTROL_BOKEH_MODE_STILL_CAPTURE = 1;
+
+ /**
+ * <p>Bokeh effect must not slow down capture rate relative to sensor raw output,
+ * and the effect is applied to all processed streams no larger than the maximum
+ * streaming dimension. This mode should be used if performance and power are a
+ * priority, such as video recording.</p>
+ * @see CaptureRequest#CONTROL_BOKEH_MODE
+ */
+ public static final int CONTROL_BOKEH_MODE_CONTINUOUS = 2;
+
+ //
// Enumeration values for CaptureRequest#EDGE_MODE
//
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index 43c197aa737d..5c76dff85a84 100644
--- a/core/java/android/hardware/camera2/CaptureRequest.java
+++ b/core/java/android/hardware/camera2/CaptureRequest.java
@@ -994,7 +994,7 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>>
* application controls how the color mapping is performed.</p>
* <p>We define the expected processing pipeline below. For consistency
* across devices, this is always the case with TRANSFORM_MATRIX.</p>
- * <p>When either FULL or HIGH_QUALITY is used, the camera device may
+ * <p>When either FAST or HIGH_QUALITY is used, the camera device may
* do additional processing but {@link CaptureRequest#COLOR_CORRECTION_GAINS android.colorCorrection.gains} and
* {@link CaptureRequest#COLOR_CORRECTION_TRANSFORM android.colorCorrection.transform} will still be provided by the
* camera device (in the results) and be roughly correct.</p>
@@ -2094,6 +2094,52 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>>
new Key<Boolean>("android.control.enableZsl", boolean.class);
/**
+ * <p>Whether bokeh mode is enabled for a particular capture request.</p>
+ * <p>With bokeh mode, the camera device may blur out the parts of scene that are not in
+ * focus, creating a bokeh (or shallow depth of field) effect for people or objects.</p>
+ * <p>When set to STILL_CAPTURE bokeh mode with STILL_CAPTURE capture intent, due to the extra
+ * processing needed for high quality bokeh effect, the stall may be longer than when
+ * capture intent is not STILL_CAPTURE.</p>
+ * <p>When set to STILL_CAPTURE bokeh mode with PREVIEW capture intent,</p>
+ * <ul>
+ * <li>If the camera device has BURST_CAPTURE capability, the frame rate requirement of
+ * BURST_CAPTURE must still be met.</li>
+ * <li>All streams not larger than the maximum streaming dimension for STILL_CAPTURE mode
+ * (queried via {@link android.hardware.camera2.CameraCharacteristics#CONTROL_AVAILABLE_BOKEH_CAPABILITIES })
+ * will have preview bokeh effect applied.</li>
+ * </ul>
+ * <p>When set to CONTINUOUS mode, configured streams dimension should not exceed this mode's
+ * maximum streaming dimension in order to have bokeh effect applied. Bokeh effect may not
+ * be available for streams larger than the maximum streaming dimension.</p>
+ * <p>Switching between different bokeh modes may involve reconfiguration of the camera
+ * pipeline, resulting in long latency. The application should check this key against the
+ * available session keys queried via
+ * {@link android.hardware.camera2.CameraCharacteristics#getAvailableSessionKeys }.</p>
+ * <p>When bokeh mode is on, the camera device may override certain control parameters, such as
+ * reduce frame rate or use face priority scene mode, to achieve best power and quality
+ * tradeoffs. When turned on, AE, AWB, and AF run in auto modes, and only the mandatory
+ * stream combinations of LIMITED hardware level are guaranteed.</p>
+ * <p>For a logical multi-camera, bokeh may be implemented by stereo vision from sub-cameras
+ * with different field of view. As a result, when bokeh mode is enabled, the camera device
+ * may override android.scaler.CropRegion, and the field of view will be smaller than when
+ * bokeh mode is off.</p>
+ * <p><b>Possible values:</b>
+ * <ul>
+ * <li>{@link #CONTROL_BOKEH_MODE_OFF OFF}</li>
+ * <li>{@link #CONTROL_BOKEH_MODE_STILL_CAPTURE STILL_CAPTURE}</li>
+ * <li>{@link #CONTROL_BOKEH_MODE_CONTINUOUS CONTINUOUS}</li>
+ * </ul></p>
+ * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
+ * @see #CONTROL_BOKEH_MODE_OFF
+ * @see #CONTROL_BOKEH_MODE_STILL_CAPTURE
+ * @see #CONTROL_BOKEH_MODE_CONTINUOUS
+ */
+ @PublicKey
+ @NonNull
+ public static final Key<Integer> CONTROL_BOKEH_MODE =
+ new Key<Integer>("android.control.bokehMode", int.class);
+
+ /**
* <p>Operation mode for edge
* enhancement.</p>
* <p>Edge enhancement improves sharpness and details in the captured image. OFF means
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index 1007fd96a0c7..2d0ec6d19286 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -398,7 +398,7 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> {
* application controls how the color mapping is performed.</p>
* <p>We define the expected processing pipeline below. For consistency
* across devices, this is always the case with TRANSFORM_MATRIX.</p>
- * <p>When either FULL or HIGH_QUALITY is used, the camera device may
+ * <p>When either FAST or HIGH_QUALITY is used, the camera device may
* do additional processing but {@link CaptureRequest#COLOR_CORRECTION_GAINS android.colorCorrection.gains} and
* {@link CaptureRequest#COLOR_CORRECTION_TRANSFORM android.colorCorrection.transform} will still be provided by the
* camera device (in the results) and be roughly correct.</p>
@@ -2324,6 +2324,52 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> {
new Key<Integer>("android.control.afSceneChange", int.class);
/**
+ * <p>Whether bokeh mode is enabled for a particular capture request.</p>
+ * <p>With bokeh mode, the camera device may blur out the parts of scene that are not in
+ * focus, creating a bokeh (or shallow depth of field) effect for people or objects.</p>
+ * <p>When set to STILL_CAPTURE bokeh mode with STILL_CAPTURE capture intent, due to the extra
+ * processing needed for high quality bokeh effect, the stall may be longer than when
+ * capture intent is not STILL_CAPTURE.</p>
+ * <p>When set to STILL_CAPTURE bokeh mode with PREVIEW capture intent,</p>
+ * <ul>
+ * <li>If the camera device has BURST_CAPTURE capability, the frame rate requirement of
+ * BURST_CAPTURE must still be met.</li>
+ * <li>All streams not larger than the maximum streaming dimension for STILL_CAPTURE mode
+ * (queried via {@link android.hardware.camera2.CameraCharacteristics#CONTROL_AVAILABLE_BOKEH_CAPABILITIES })
+ * will have preview bokeh effect applied.</li>
+ * </ul>
+ * <p>When set to CONTINUOUS mode, configured streams dimension should not exceed this mode's
+ * maximum streaming dimension in order to have bokeh effect applied. Bokeh effect may not
+ * be available for streams larger than the maximum streaming dimension.</p>
+ * <p>Switching between different bokeh modes may involve reconfiguration of the camera
+ * pipeline, resulting in long latency. The application should check this key against the
+ * available session keys queried via
+ * {@link android.hardware.camera2.CameraCharacteristics#getAvailableSessionKeys }.</p>
+ * <p>When bokeh mode is on, the camera device may override certain control parameters, such as
+ * reduce frame rate or use face priority scene mode, to achieve best power and quality
+ * tradeoffs. When turned on, AE, AWB, and AF run in auto modes, and only the mandatory
+ * stream combinations of LIMITED hardware level are guaranteed.</p>
+ * <p>For a logical multi-camera, bokeh may be implemented by stereo vision from sub-cameras
+ * with different field of view. As a result, when bokeh mode is enabled, the camera device
+ * may override android.scaler.CropRegion, and the field of view will be smaller than when
+ * bokeh mode is off.</p>
+ * <p><b>Possible values:</b>
+ * <ul>
+ * <li>{@link #CONTROL_BOKEH_MODE_OFF OFF}</li>
+ * <li>{@link #CONTROL_BOKEH_MODE_STILL_CAPTURE STILL_CAPTURE}</li>
+ * <li>{@link #CONTROL_BOKEH_MODE_CONTINUOUS CONTINUOUS}</li>
+ * </ul></p>
+ * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
+ * @see #CONTROL_BOKEH_MODE_OFF
+ * @see #CONTROL_BOKEH_MODE_STILL_CAPTURE
+ * @see #CONTROL_BOKEH_MODE_CONTINUOUS
+ */
+ @PublicKey
+ @NonNull
+ public static final Key<Integer> CONTROL_BOKEH_MODE =
+ new Key<Integer>("android.control.bokehMode", int.class);
+
+ /**
* <p>Operation mode for edge
* enhancement.</p>
* <p>Edge enhancement improves sharpness and details in the captured image. OFF means
diff --git a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
index e909c0075f38..7c1ddad5fe12 100644
--- a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
+++ b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
@@ -21,6 +21,7 @@ import android.graphics.ImageFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
@@ -29,6 +30,7 @@ import android.hardware.camera2.marshal.MarshalRegistry;
import android.hardware.camera2.marshal.Marshaler;
import android.hardware.camera2.marshal.impl.MarshalQueryableArray;
import android.hardware.camera2.marshal.impl.MarshalQueryableBlackLevelPattern;
+import android.hardware.camera2.marshal.impl.MarshalQueryableCapabilityAndMaxSize;
import android.hardware.camera2.marshal.impl.MarshalQueryableBoolean;
import android.hardware.camera2.marshal.impl.MarshalQueryableColorSpaceTransform;
import android.hardware.camera2.marshal.impl.MarshalQueryableEnum;
@@ -48,6 +50,7 @@ import android.hardware.camera2.marshal.impl.MarshalQueryableSizeF;
import android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfiguration;
import android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfigurationDuration;
import android.hardware.camera2.marshal.impl.MarshalQueryableString;
+import android.hardware.camera2.params.CapabilityAndMaxSize;
import android.hardware.camera2.params.Face;
import android.hardware.camera2.params.HighSpeedVideoConfiguration;
import android.hardware.camera2.params.LensShadingMap;
@@ -671,6 +674,15 @@ public class CameraMetadataNative implements Parcelable {
return (T) metadata.getOisSamples();
}
});
+ sGetCommandMap.put(
+ CameraCharacteristics.CONTROL_AVAILABLE_BOKEH_CAPABILITIES.getNativeKey(),
+ new GetCommand() {
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
+ return (T) metadata.getBokehCapabilities();
+ }
+ });
}
private int[] getAvailableFormats() {
@@ -1373,6 +1385,24 @@ public class CameraMetadataNative implements Parcelable {
return samples;
}
+ private CapabilityAndMaxSize[] getBokehCapabilities() {
+ CapabilityAndMaxSize[] bcs = getBase(
+ CameraCharacteristics.CONTROL_AVAILABLE_BOKEH_CAPABILITIES);
+
+ if (bcs != null) {
+ for (CapabilityAndMaxSize bc : bcs) {
+ if (bc.getMode() < CameraMetadata.CONTROL_BOKEH_MODE_OFF ||
+ bc.getMode() > CameraMetadata.CONTROL_BOKEH_MODE_CONTINUOUS) {
+ throw new AssertionError(String.format(
+ "bokehMode %d is out of valid range [%d, %d]", bc.getMode(),
+ CameraMetadata.CONTROL_BOKEH_MODE_OFF,
+ CameraMetadata.CONTROL_BOKEH_MODE_CONTINUOUS));
+ }
+ }
+ }
+ return bcs;
+ }
+
private <T> void setBase(CameraCharacteristics.Key<T> key, T value) {
setBase(key.getNativeKey(), value);
}
@@ -1750,6 +1780,7 @@ public class CameraMetadataNative implements Parcelable {
new MarshalQueryableBlackLevelPattern(),
new MarshalQueryableHighSpeedVideoConfiguration(),
new MarshalQueryableRecommendedStreamConfiguration(),
+ new MarshalQueryableCapabilityAndMaxSize(),
// generic parcelable marshaler (MUST BE LAST since it has lowest priority)
new MarshalQueryableParcelable(),
diff --git a/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableCapabilityAndMaxSize.java b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableCapabilityAndMaxSize.java
new file mode 100644
index 000000000000..5c1f301369e1
--- /dev/null
+++ b/core/java/android/hardware/camera2/marshal/impl/MarshalQueryableCapabilityAndMaxSize.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.camera2.marshal.impl;
+
+import android.hardware.camera2.marshal.MarshalQueryable;
+import android.hardware.camera2.marshal.Marshaler;
+import android.hardware.camera2.params.CapabilityAndMaxSize;
+import android.hardware.camera2.utils.TypeReference;
+import android.util.Size;
+
+import java.nio.ByteBuffer;
+
+import static android.hardware.camera2.impl.CameraMetadataNative.TYPE_INT32;
+import static android.hardware.camera2.marshal.MarshalHelpers.SIZEOF_INT32;
+
+/**
+ * Marshal {@link CapabilityAndMaxSize} to/from {@link #TYPE_INT32} {@code x CapabilityAndMaxSize.COUNT}
+ */
+public class MarshalQueryableCapabilityAndMaxSize implements MarshalQueryable<CapabilityAndMaxSize> {
+ private static final int SIZE = SIZEOF_INT32 * CapabilityAndMaxSize.COUNT;
+
+ private class MarshalerCapabilityAndMaxSize extends Marshaler<CapabilityAndMaxSize> {
+ protected MarshalerCapabilityAndMaxSize(TypeReference<CapabilityAndMaxSize> typeReference,
+ int nativeType) {
+ super(MarshalQueryableCapabilityAndMaxSize.this, typeReference, nativeType);
+ }
+
+ @Override
+ public void marshal(CapabilityAndMaxSize value, ByteBuffer buffer) {
+ Size maxStreamingSize = value.getMaxStreamingSize();
+
+ buffer.putInt(value.getMode());
+ buffer.putInt(maxStreamingSize.getWidth());
+ buffer.putInt(maxStreamingSize.getHeight());
+ }
+
+ @Override
+ public CapabilityAndMaxSize unmarshal(ByteBuffer buffer) {
+ int mode = buffer.getInt();
+ int maxWidth = buffer.getInt();
+ int maxHeight = buffer.getInt();
+
+ return new CapabilityAndMaxSize(mode, maxWidth, maxHeight);
+ }
+
+ @Override
+ public int getNativeSize() {
+ return SIZE;
+ }
+ }
+
+ @Override
+ public Marshaler<CapabilityAndMaxSize> createMarshaler(
+ TypeReference<CapabilityAndMaxSize> managedType, int nativeType) {
+ return new MarshalerCapabilityAndMaxSize(managedType, nativeType);
+ }
+
+ @Override
+ public boolean isTypeMappingSupported(
+ TypeReference<CapabilityAndMaxSize> managedType, int nativeType) {
+ return nativeType == TYPE_INT32 &&
+ (CapabilityAndMaxSize.class.equals(managedType.getType()));
+ }
+}
diff --git a/core/java/android/hardware/camera2/params/CapabilityAndMaxSize.java b/core/java/android/hardware/camera2/params/CapabilityAndMaxSize.java
new file mode 100644
index 000000000000..be0829934a4b
--- /dev/null
+++ b/core/java/android/hardware/camera2/params/CapabilityAndMaxSize.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.camera2.params;
+
+import static com.android.internal.util.Preconditions.checkArgumentInRange;
+import static com.android.internal.util.Preconditions.checkArgumentNonnegative;
+
+import android.annotation.NonNull;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraMetadata;
+import android.hardware.camera2.utils.HashCodeHelpers;
+import android.util.Size;
+
+/**
+ * Immutable class to store the available camera capability and its
+ * corresponding maximum streaming dimensions.
+ *
+ * @see CameraCharacteristics#CONTROL_AVAILABLE_BOKEH_CAPABILITIES
+ */
+
+public final class CapabilityAndMaxSize {
+ /**
+ * @hide
+ */
+ public static final int COUNT = 3;
+
+ private final int mMode;
+ private final int mMaxStreamingWidth;
+ private final int mMaxStreamingHeight;
+
+ /**
+ * Create a new CapabilityAndMaxSize object.
+ *
+ * @param mode supported mode for a camera capability.
+ * @param maxStreamingWidth width >= 0
+ * @param maxStreamingHeight height >= 0
+ *
+ * @hide
+ */
+ public CapabilityAndMaxSize(int mode, int maxStreamingWidth, int maxStreamingHeight) {
+ mMode = mode;
+ mMaxStreamingWidth = checkArgumentNonnegative(maxStreamingWidth,
+ "maxStreamingWidth must be nonnegative");
+ mMaxStreamingHeight = checkArgumentNonnegative(maxStreamingHeight,
+ "maxStreamingHeight must be nonnegative");
+ }
+
+ /**
+ * Return the supported mode for this capability.
+ *
+ * @return One of supported modes for the capability. For example, for available bokeh modes,
+ * this will be one of {@link CameraMetadata#CONTROL_BOKEH_MODE_OFF},
+ * {@link CameraMetadata#CONTROL_BOKEH_MODE_STILL_CAPTURE}, and
+ * {@link CameraMetadata#CONTROL_BOKEH_MODE_CONTINUOUS}.
+ */
+ public int getMode() {
+ return mMode;
+ }
+
+ /**
+ * Return the maximum streaming dimension of this capability.
+ *
+ * @return a new {@link Size} with non-negative width and height
+ */
+ public @NonNull Size getMaxStreamingSize() {
+ return new Size(mMaxStreamingWidth, mMaxStreamingHeight);
+ }
+
+ /**
+ * Compare two CapabilityAndMaxSize objects to see if they are equal.
+ *
+ * @param obj Another CapabilityAndMaxSize object
+ *
+ * @return {@code true} if the mode and max size are equal, {@code false} otherwise
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof CapabilityAndMaxSize) {
+ final CapabilityAndMaxSize other = (CapabilityAndMaxSize) obj;
+ return (mMode == other.mMode
+ && mMaxStreamingWidth == other.mMaxStreamingWidth
+ && mMaxStreamingHeight == other.mMaxStreamingHeight);
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return HashCodeHelpers.hashCode(mMode, mMaxStreamingWidth, mMaxStreamingHeight);
+ }
+
+ /**
+ * Return the CapabilityAndMaxSize as a string representation
+ * {@code "(mode:%d, maxStreamingSize:%d x %d)"}.
+ *
+ * @return string representation of the capability and max streaming size.
+ */
+ @Override
+ public String toString() {
+ return String.format("(mode:%d, maxStreamingSize:%d x %d)",
+ mMode, mMaxStreamingWidth, mMaxStreamingHeight);
+ }
+}