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

Commit 4bd7abe7 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera2: Combine API for deferred surface and shared surface

- Unhide API to enable sharing surfaces via OutputConfiguration.
- Combine the APIs for deferred surface and shared surfaces so that
  same functions can be used for both use cases.
  1. setDeferredSurface becomes addSurface.
  2. finishDeferredConfiguration becomes finalizeOutputConfiguration.
- Better documentation on shared surface use cases.

Test: Camera CTS, and preview/video/capture with GCA
Bug: 33777818
Change-Id: I528b221492e07888a2da96658aaf8e7b9c4d1640
parent 3b8eaf3f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -14332,7 +14332,7 @@ package android.hardware.camera2 {
    method public abstract int capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract int captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void close();
    method public abstract void finishDeferredConfiguration(java.util.List<android.hardware.camera2.params.OutputConfiguration>) throws android.hardware.camera2.CameraAccessException;
    method public abstract void finalizeOutputConfigurations(java.util.List<android.hardware.camera2.params.OutputConfiguration>) throws android.hardware.camera2.CameraAccessException;
    method public abstract android.hardware.camera2.CameraDevice getDevice();
    method public abstract android.view.Surface getInputSurface();
    method public abstract boolean isReprocessable();
@@ -14973,10 +14973,12 @@ package android.hardware.camera2.params {
    ctor public OutputConfiguration(android.view.Surface);
    ctor public OutputConfiguration(int, android.view.Surface);
    ctor public OutputConfiguration(android.util.Size, java.lang.Class<T>);
    method public void addSurface(android.view.Surface);
    method public int describeContents();
    method public void enableSurfaceSharing();
    method public android.view.Surface getSurface();
    method public int getSurfaceGroupId();
    method public void setDeferredSurface(android.view.Surface);
    method public java.util.List<android.view.Surface> getSurfaces();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.camera2.params.OutputConfiguration> CREATOR;
    field public static final int SURFACE_GROUP_ID_NONE = -1; // 0xffffffff
+4 −2
Original line number Diff line number Diff line
@@ -14862,7 +14862,7 @@ package android.hardware.camera2 {
    method public abstract int capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract int captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void close();
    method public abstract void finishDeferredConfiguration(java.util.List<android.hardware.camera2.params.OutputConfiguration>) throws android.hardware.camera2.CameraAccessException;
    method public abstract void finalizeOutputConfigurations(java.util.List<android.hardware.camera2.params.OutputConfiguration>) throws android.hardware.camera2.CameraAccessException;
    method public abstract android.hardware.camera2.CameraDevice getDevice();
    method public abstract android.view.Surface getInputSurface();
    method public abstract boolean isReprocessable();
@@ -15505,11 +15505,13 @@ package android.hardware.camera2.params {
    ctor public OutputConfiguration(android.view.Surface, int);
    ctor public OutputConfiguration(int, android.view.Surface, int);
    ctor public OutputConfiguration(android.util.Size, java.lang.Class<T>);
    method public void addSurface(android.view.Surface);
    method public int describeContents();
    method public void enableSurfaceSharing();
    method public int getRotation();
    method public android.view.Surface getSurface();
    method public int getSurfaceGroupId();
    method public void setDeferredSurface(android.view.Surface);
    method public java.util.List<android.view.Surface> getSurfaces();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.camera2.params.OutputConfiguration> CREATOR;
    field public static final int ROTATION_0 = 0; // 0x0
+4 −2
Original line number Diff line number Diff line
@@ -14364,7 +14364,7 @@ package android.hardware.camera2 {
    method public abstract int capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract int captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void close();
    method public abstract void finishDeferredConfiguration(java.util.List<android.hardware.camera2.params.OutputConfiguration>) throws android.hardware.camera2.CameraAccessException;
    method public abstract void finalizeOutputConfigurations(java.util.List<android.hardware.camera2.params.OutputConfiguration>) throws android.hardware.camera2.CameraAccessException;
    method public abstract android.hardware.camera2.CameraDevice getDevice();
    method public abstract android.view.Surface getInputSurface();
    method public abstract boolean isReprocessable();
@@ -15005,10 +15005,12 @@ package android.hardware.camera2.params {
    ctor public OutputConfiguration(android.view.Surface);
    ctor public OutputConfiguration(int, android.view.Surface);
    ctor public OutputConfiguration(android.util.Size, java.lang.Class<T>);
    method public void addSurface(android.view.Surface);
    method public int describeContents();
    method public void enableSurfaceSharing();
    method public android.view.Surface getSurface();
    method public int getSurfaceGroupId();
    method public void setDeferredSurface(android.view.Surface);
    method public java.util.List<android.view.Surface> getSurfaces();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.camera2.params.OutputConfiguration> CREATOR;
    field public static final int SURFACE_GROUP_ID_NONE = -1; // 0xffffffff
+20 −11
Original line number Diff line number Diff line
@@ -221,8 +221,8 @@ public abstract class CameraCaptureSession implements AutoCloseable {
    public abstract void tearDown(@NonNull Surface surface) throws CameraAccessException;

    /**
     * <p>Finish the deferred output configurations where the output Surface was not configured
     * before.</p>
     * <p>Finalize the output configurations that now have their deferred and/or extra Surfaces
     * included.</p>
     *
     * <p>For camera use cases where a preview and other output configurations need to be
     * configured, it can take some time for the preview Surface to be ready. For example, if the
@@ -235,22 +235,31 @@ public abstract class CameraCaptureSession implements AutoCloseable {
     * and defer the preview output configuration until the Surface is ready. After the
     * {@link CameraCaptureSession} is created successfully with this deferred output and other
     * normal outputs, the application can start submitting requests as long as they do not include
     * deferred output Surfaces. Once a deferred Surface is ready, the application can set the
     * Surface on the deferred output configuration with the
     * {@link OutputConfiguration#setDeferredSurface} method, and then finish the deferred output
     * deferred output Surfaces. Once a deferred Surface is ready, the application can add the
     * Surface to the deferred output configuration with the
     * {@link OutputConfiguration#addSurface} method, and then update the deferred output
     * configuration via this method, before it can submit capture requests with this output
     * target.</p>
     *
     * <p>The output Surfaces included by this list of deferred
     * <p>This function can also be called in case where multiple surfaces share the same
     * OutputConfiguration, and one of the surfaces becomes available after the {@link
     * CameraCaptureSession} is created. In that case, the application must first create the
     * OutputConfiguration with the available Surface, then enable furture surface sharing via
     * {@link OutputConfiguration#enableSurfaceSharing}, before creating the CameraCaptureSession.
     * After the CameraCaptureSession is created, and once the extra Surface becomes available, the
     * application must then call {@link OutputConfiguration#addSurface} before finalizing the
     * configuration with this method.</p>
     *
     * <p>The output Surfaces included by this list of
     * {@link OutputConfiguration OutputConfigurations} can be used as {@link CaptureRequest}
     * targets as soon as this call returns.</p>
     *
     * <p>This method is not supported by
     * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}-level devices.</p>
     *
     * @param deferredOutputConfigs a list of {@link OutputConfiguration OutputConfigurations} that
     *            have had {@link OutputConfiguration#setDeferredSurface setDeferredSurface} invoked
     *            with a valid output Surface.
     * @param outputConfigs a list of {@link OutputConfiguration OutputConfigurations} that
     *            have had {@link OutputConfiguration#addSurface addSurface} invoked with a valid
     *            output Surface after {@link CameraDevice#createCaptureSessionByOutputConfigurations}.
     * @throws CameraAccessException if the camera device is no longer connected or has encountered
     *             a fatal error.
     * @throws IllegalStateException if this session is no longer active, either because the session
@@ -261,8 +270,8 @@ public abstract class CameraCaptureSession implements AutoCloseable {
     *             source. Or if one of the output configuration was already finished with an
     *             included surface in a prior call.
     */
    public abstract void finishDeferredConfiguration(
            List<OutputConfiguration> deferredOutputConfigs) throws CameraAccessException;
    public abstract void finalizeOutputConfigurations(
            List<OutputConfiguration> outputConfigs) throws CameraAccessException;

    /**
     * <p>Submit a request for an image to be captured by the camera device.</p>
+3 −3
Original line number Diff line number Diff line
@@ -151,9 +151,9 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
    }

    @Override
    public void finishDeferredConfiguration(
            List<OutputConfiguration> deferredOutputConfigs) throws CameraAccessException {
        mDeviceImpl.finishDeferredConfig(deferredOutputConfigs);
    public void finalizeOutputConfigurations(
            List<OutputConfiguration> outputConfigs) throws CameraAccessException {
        mDeviceImpl.finalizeOutputConfigs(outputConfigs);
    }

    @Override
Loading