Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc2e26cd authored by Shuzhen Wang's avatar Shuzhen Wang Committed by Android (Google) Code Review
Browse files

Merge "Camera: Add stream use case support"

parents b62414e6 a92e0214
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -17342,12 +17342,14 @@ package android.hardware.camera2 {
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Integer> REQUEST_RECOMMENDED_TEN_BIT_DYNAMIC_RANGE_PROFILE;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Float> SCALER_AVAILABLE_MAX_DIGITAL_ZOOM;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<int[]> SCALER_AVAILABLE_ROTATE_AND_CROP_MODES;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<int[]> SCALER_AVAILABLE_STREAM_USE_CASES;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<java.lang.Integer> SCALER_CROPPING_TYPE;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.util.Size> SCALER_DEFAULT_SECURE_IMAGE_SIZE;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.MandatoryStreamCombination[]> SCALER_MANDATORY_CONCURRENT_STREAM_COMBINATIONS;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.MandatoryStreamCombination[]> SCALER_MANDATORY_MAXIMUM_RESOLUTION_STREAM_COMBINATIONS;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.MandatoryStreamCombination[]> SCALER_MANDATORY_STREAM_COMBINATIONS;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.MandatoryStreamCombination[]> SCALER_MANDATORY_TEN_BIT_OUTPUT_STREAM_COMBINATIONS;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.MandatoryStreamCombination[]> SCALER_MANDATORY_USE_CASE_STREAM_COMBINATIONS;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.MultiResolutionStreamConfigurationMap> SCALER_MULTI_RESOLUTION_STREAM_CONFIGURATION_MAP;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.StreamConfigurationMap> SCALER_STREAM_CONFIGURATION_MAP;
    field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key<android.hardware.camera2.params.StreamConfigurationMap> SCALER_STREAM_CONFIGURATION_MAP_MAXIMUM_RESOLUTION;
@@ -17676,9 +17678,16 @@ package android.hardware.camera2 {
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS = 5; // 0x5
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_REMOSAIC_REPROCESSING = 17; // 0x11
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_SECURE_IMAGE_DATA = 13; // 0xd
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE = 19; // 0x13
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA = 14; // 0xe
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR = 16; // 0x10
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING = 7; // 0x7
    field public static final int SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT = 0; // 0x0
    field public static final int SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW = 1; // 0x1
    field public static final int SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW_VIDEO_STILL = 4; // 0x4
    field public static final int SCALER_AVAILABLE_STREAM_USE_CASES_STILL_CAPTURE = 2; // 0x2
    field public static final int SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_CALL = 5; // 0x5
    field public static final int SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_RECORD = 3; // 0x3
    field public static final int SCALER_CROPPING_TYPE_CENTER_ONLY = 0; // 0x0
    field public static final int SCALER_CROPPING_TYPE_FREEFORM = 1; // 0x1
    field public static final int SCALER_ROTATE_AND_CROP_180 = 2; // 0x2
@@ -18086,6 +18095,7 @@ package android.hardware.camera2.params {
    method public int get10BitFormat();
    method @NonNull public java.util.List<android.util.Size> getAvailableSizes();
    method public int getFormat();
    method public int getStreamUseCase();
    method public boolean is10BitCapable();
    method public boolean isInput();
    method public boolean isMaximumSize();
@@ -18142,6 +18152,7 @@ package android.hardware.camera2.params {
    method public void enableSurfaceSharing();
    method public int getDynamicRangeProfile();
    method public int getMaxSharedSurfaceCount();
    method public int getStreamUseCase();
    method @Nullable public android.view.Surface getSurface();
    method public int getSurfaceGroupId();
    method @NonNull public java.util.List<android.view.Surface> getSurfaces();
@@ -18149,6 +18160,7 @@ package android.hardware.camera2.params {
    method public void removeSurface(@NonNull android.view.Surface);
    method public void setDynamicRangeProfile(int);
    method public void setPhysicalCameraId(@Nullable String);
    method public void setStreamUseCase(int);
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.camera2.params.OutputConfiguration> CREATOR;
    field public static final int SURFACE_GROUP_ID_NONE = -1; // 0xffffffff
+12 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package android.hardware;

import android.hardware.camera2.params.DynamicRangeProfiles;
import android.hardware.camera2.CameraMetadata;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
@@ -47,6 +48,7 @@ public class CameraStreamStats implements Parcelable {
    private float[] mHistogramBins;
    private long[] mHistogramCounts;
    private int mDynamicRangeProfile;
    private int mStreamUseCase;

    private static final String TAG = "CameraStreamStats";

@@ -63,11 +65,13 @@ public class CameraStreamStats implements Parcelable {
        mMaxAppBuffers = 0;
        mHistogramType = HISTOGRAM_TYPE_UNKNOWN;
        mDynamicRangeProfile = DynamicRangeProfiles.STANDARD;
        mStreamUseCase = CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT;
    }

    public CameraStreamStats(int width, int height, int format,
            int dataSpace, long usage, long requestCount, long errorCount,
            int startLatencyMs, int maxHalBuffers, int maxAppBuffers, int dynamicRangeProfile) {
            int startLatencyMs, int maxHalBuffers, int maxAppBuffers, int dynamicRangeProfile,
            int streamUseCase) {
        mWidth = width;
        mHeight = height;
        mFormat = format;
@@ -80,6 +84,7 @@ public class CameraStreamStats implements Parcelable {
        mMaxAppBuffers = maxAppBuffers;
        mHistogramType = HISTOGRAM_TYPE_UNKNOWN;
        mDynamicRangeProfile = dynamicRangeProfile;
        mStreamUseCase = streamUseCase;
    }

    public static final @android.annotation.NonNull Parcelable.Creator<CameraStreamStats> CREATOR =
@@ -126,6 +131,7 @@ public class CameraStreamStats implements Parcelable {
        dest.writeFloatArray(mHistogramBins);
        dest.writeLongArray(mHistogramCounts);
        dest.writeInt(mDynamicRangeProfile);
        dest.writeInt(mStreamUseCase);
    }

    public void readFromParcel(Parcel in) {
@@ -143,6 +149,7 @@ public class CameraStreamStats implements Parcelable {
        mHistogramBins = in.createFloatArray();
        mHistogramCounts = in.createLongArray();
        mDynamicRangeProfile = in.readInt();
        mStreamUseCase = in.readInt();
    }

    public int getWidth() {
@@ -200,4 +207,8 @@ public class CameraStreamStats implements Parcelable {
    public int getDynamicRangeProfile() {
        return mDynamicRangeProfile;
    }

    public int getStreamUseCase() {
        return mStreamUseCase;
    }
}
+86 −0
Original line number Diff line number Diff line
@@ -2214,6 +2214,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR ULTRA_HIGH_RESOLUTION_SENSOR}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_REMOSAIC_REPROCESSING REMOSAIC_REPROCESSING}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT DYNAMIC_RANGE_TEN_BIT}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE STREAM_USE_CASE}</li>
     * </ul>
     *
     * <p>This key is available on all devices.</p>
@@ -2238,6 +2239,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     * @see #REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR
     * @see #REQUEST_AVAILABLE_CAPABILITIES_REMOSAIC_REPROCESSING
     * @see #REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT
     * @see #REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE
     */
    @PublicKey
    @NonNull
@@ -3474,6 +3476,90 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
    public static final Key<Boolean> SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED =
            new Key<Boolean>("android.scaler.multiResolutionStreamSupported", boolean.class);

    /**
     * <p>The stream use cases supported by this camera device.</p>
     * <p>The stream use case indicates the purpose of a particular camera stream from
     * the end-user perspective. Some examples of camera use cases are: preview stream for
     * live viewfinder shown to the user, still capture for generating high quality photo
     * capture, video record for encoding the camera output for the purpose of future playback,
     * and video call for live realtime video conferencing.</p>
     * <p>With this flag, the camera device can optimize the image processing pipeline
     * parameters, such as tuning, sensor mode, and ISP settings, indepedent of
     * the properties of the immediate camera output surface. For example, if the output
     * surface is a SurfaceTexture, the stream use case flag can be used to indicate whether
     * the camera frames eventually go to display, video encoder,
     * still image capture, or all of them combined.</p>
     * <p>The application sets the use case of a camera stream by calling
     * {@link android.hardware.camera2.params.OutputConfiguration#setStreamUseCase }.</p>
     * <p>A camera device with
     * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE }
     * capability must support the following stream use cases:</p>
     * <ul>
     * <li>DEFAULT</li>
     * <li>PREVIEW</li>
     * <li>STILL_CAPTURE</li>
     * <li>VIDEO_RECORD</li>
     * <li>PREVIEW_VIDEO_STILL</li>
     * <li>VIDEO_CALL</li>
     * </ul>
     * <p>The guaranteed stream combinations related to stream use case for a camera device with
     * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE }
     * capability is documented in the camera device
     * {@link android.hardware.camera2.CameraDevice#createCaptureSession guideline}. The
     * application is strongly recommended to use one of the guaranteed stream combintations.
     * If the application creates a session with a stream combination not in the guaranteed
     * list, or with mixed DEFAULT and non-DEFAULT use cases within the same session,
     * the camera device may ignore some stream use cases due to hardware constraints
     * and implementation details.</p>
     * <p>For stream combinations not covered by the stream use case mandatory lists, such as
     * reprocessable session, constrained high speed session, or RAW stream combinations, the
     * application should leave stream use cases within the session as DEFAULT.</p>
     * <p><b>Possible values:</b></p>
     * <ul>
     *   <li>{@link #SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT DEFAULT}</li>
     *   <li>{@link #SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW PREVIEW}</li>
     *   <li>{@link #SCALER_AVAILABLE_STREAM_USE_CASES_STILL_CAPTURE STILL_CAPTURE}</li>
     *   <li>{@link #SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_RECORD VIDEO_RECORD}</li>
     *   <li>{@link #SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW_VIDEO_STILL PREVIEW_VIDEO_STILL}</li>
     *   <li>{@link #SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_CALL VIDEO_CALL}</li>
     * </ul>
     *
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     * @see #SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT
     * @see #SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW
     * @see #SCALER_AVAILABLE_STREAM_USE_CASES_STILL_CAPTURE
     * @see #SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_RECORD
     * @see #SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW_VIDEO_STILL
     * @see #SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_CALL
     */
    @PublicKey
    @NonNull
    public static final Key<int[]> SCALER_AVAILABLE_STREAM_USE_CASES =
            new Key<int[]>("android.scaler.availableStreamUseCases", int[].class);

    /**
     * <p>An array of mandatory stream combinations with stream use cases.
     * This is an app-readable conversion of the mandatory stream combination
     * {@link android.hardware.camera2.CameraDevice#createCaptureSession tables} with
     * each stream's use case being set.</p>
     * <p>The array of
     * {@link android.hardware.camera2.params.MandatoryStreamCombination combinations} is
     * generated according to the documented
     * {@link android.hardware.camera2.CameraDevice#createCaptureSession guideline} for a
     * camera device with
     * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE }
     * capability.
     * The mandatory stream combination array will be {@code null} in case the device doesn't
     * have {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE }
     * capability.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     */
    @PublicKey
    @NonNull
    @SyntheticKey
    public static final Key<android.hardware.camera2.params.MandatoryStreamCombination[]> SCALER_MANDATORY_USE_CASE_STREAM_COMBINATIONS =
            new Key<android.hardware.camera2.params.MandatoryStreamCombination[]>("android.scaler.mandatoryUseCaseStreamCombinations", android.hardware.camera2.params.MandatoryStreamCombination[].class);

    /**
     * <p>The area of the image sensor which corresponds to active pixels after any geometric
     * distortion correction has been applied.</p>
+29 −1
Original line number Diff line number Diff line
@@ -404,7 +404,10 @@ public abstract class CameraDevice implements AutoCloseable {
     *                                  (output format)/(surface type), or if the extension is not
     *                                  supported, or if any of the output configurations select
     *                                  a dynamic range different from
     *                                  {@link android.hardware.camera2.params.DynamicRangeProfiles#STANDARD}
     *                                  {@link android.hardware.camera2.params.DynamicRangeProfiles#STANDARD},
     *                                  or if any of the output configurations sets a stream use
     *                                  case different from {@link
     *                                  android.hardware.camera2.CameraCharacteristics#SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT}.
     * @see CameraExtensionCharacteristics#getSupportedExtensions
     * @see CameraExtensionCharacteristics#getExtensionSupportedSizes
     */
@@ -855,6 +858,31 @@ public abstract class CameraDevice implements AutoCloseable {
     * will cause a capture session initialization failure.
     * </p>
     *
     * <p>Devices with the STREAM_USE_CASE capability ({@link
     * CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes {@link
     * CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE}) support below additional
     * stream combinations:
     *
     * <table>
     * <tr><th colspan="10">STREAM_USE_CASE capability additional guaranteed configurations</th></tr>
     * <tr><th colspan="3" id="rb">Target 1</th><th colspan="3" id="rb">Target 2</th><th colspan="3" id="rb">Target 3</th> <th rowspan="2">Sample use case(s)</th> </tr>
     * <tr><th>Type</th><th id="rb">Max size</th><th>Usecase</th><th>Type</th><th id="rb">Max size</th><th>Usecase</th><th>Type</th><th id="rb">Max size</th><th>Usecase</th> </tr>
     * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Simple preview or in-app image processing</td> </tr>
     * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code RECORD}</td><td id="rb">{@code VIDEO_RECORD}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Simple video recording or in-app video processing</td> </tr>
     * <tr> <td>{@code YUV / JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Simple JPEG or YUV still image capture</td> </tr>
     * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code s1440p}</td><td id="rb">{@code PREVIEW_VIDEO_STILL}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Multi-purpose stream for preview, video and still image capture</td> </tr>
     * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code s1440p}</td><td id="rb">{@code VIDEO_CALL}</td> <td colspan="3" id="rb"></td> <td colspan="3" id="rb"></td> <td>Simple video call</td> </tr>
     * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td colspan="3" id="rb"></td> <td>Preview with JPEG or YUV still image capture</td> </tr>
     * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / PRIV}</td><td id="rb">{@code RECORD}</td><td id="rb">{@code VIDEO_RECORD}</td> <td colspan="3" id="rb"></td> <td>Preview with video recording or in-app video processing</td> </tr>
     * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td colspan="3" id="rb"></td> <td>Preview with in-application image processing</td> </tr>
     * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / PRIV}</td><td id="rb">{@code s1440p}</td><td id="rb">{@code VIDEO_CALL}</td> <td colspan="3" id="rb"></td> <td>Preview with video call</td> </tr>
     * <tr> <td>{@code YUV / PRIV}</td><td id="rb">{@code s1440p}</td><td id="rb">{@code PREVIEW_VIDEO_STILL}</td> <td>{@code YUV / JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td colspan="3" id="rb"></td> <td>Multi-purpose stream with JPEG or YUV still capture</td> </tr>
     * <tr> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code STILL_CAPTURE}</td> <td>{@code JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td colspan="3" id="rb"></td> <td>YUV and JPEG concurrent still image capture (for testing)</td> </tr>
     * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / PRIV}</td><td id="rb">{@code RECORD}</td><td id="rb">{@code VIDEO_RECORD}</td> <td>{@code YUV / JPEG}</td><td id="rb">{@code RECORD}</td><td id="rb">{@code STILL_CAPTURE}</td> <td>Preview, video record and JPEG or YUV video snapshot</td> </tr>
     * <tr> <td>{@code PRIV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV}</td><td id="rb">{@code PREVIEW}</td><td id="rb">{@code PREVIEW}</td> <td>{@code YUV / JPEG}</td><td id="rb">{@code MAXIMUM}</td><td id="rb">{@code STILL_CAPTURE}</td> <td>Preview, in-application image processing, and JPEG or YUV still image capture</td> </tr>
     * </table><br>
     * </p>
     *
     * <p>Since the capabilities of camera devices vary greatly, a given camera device may support
     * target combinations with sizes outside of these guarantees, but this can only be tested for
     * by calling {@link #isSessionConfigurationSupported} or attempting to create a session with
+113 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading