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

Commit eef77e39 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'b/34853980'

* changes:
  Camera: Add createCustomCameraSession to system API.
  CameraDevice: Add hidden createCustomCaptureSession
parents 1c83656e 49c62f51
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -15613,10 +15613,14 @@ package android.hardware.camera2 {
    method public abstract void createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createCaptureSessionByOutputConfigurations(java.util.List<android.hardware.camera2.params.OutputConfiguration>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createConstrainedHighSpeedCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createCustomCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List<android.hardware.camera2.params.OutputConfiguration>, int, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract android.hardware.camera2.CaptureRequest.Builder createReprocessCaptureRequest(android.hardware.camera2.TotalCaptureResult) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createReprocessableCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createReprocessableCaptureSessionByConfigurations(android.hardware.camera2.params.InputConfiguration, java.util.List<android.hardware.camera2.params.OutputConfiguration>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract java.lang.String getId();
    field public static final int SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED = 1; // 0x1
    field public static final int SESSION_OPERATION_MODE_NORMAL = 0; // 0x0
    field public static final int SESSION_OPERATION_MODE_VENDOR_START = 32768; // 0x8000
    field public static final int TEMPLATE_MANUAL = 6; // 0x6
    field public static final int TEMPLATE_PREVIEW = 1; // 0x1
    field public static final int TEMPLATE_RECORD = 3; // 0x3
+4 −0
Original line number Diff line number Diff line
@@ -14927,10 +14927,14 @@ package android.hardware.camera2 {
    method public abstract void createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createCaptureSessionByOutputConfigurations(java.util.List<android.hardware.camera2.params.OutputConfiguration>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createConstrainedHighSpeedCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createCustomCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List<android.hardware.camera2.params.OutputConfiguration>, int, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract android.hardware.camera2.CaptureRequest.Builder createReprocessCaptureRequest(android.hardware.camera2.TotalCaptureResult) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createReprocessableCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract void createReprocessableCaptureSessionByConfigurations(android.hardware.camera2.params.InputConfiguration, java.util.List<android.hardware.camera2.params.OutputConfiguration>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method public abstract java.lang.String getId();
    field public static final int SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED = 1; // 0x1
    field public static final int SESSION_OPERATION_MODE_NORMAL = 0; // 0x0
    field public static final int SESSION_OPERATION_MODE_VENDOR_START = 32768; // 0x8000
    field public static final int TEMPLATE_MANUAL = 6; // 0x6
    field public static final int TEMPLATE_PREVIEW = 1; // 0x1
    field public static final int TEMPLATE_RECORD = 3; // 0x3
+82 −0
Original line number Diff line number Diff line
@@ -19,6 +19,10 @@ package android.hardware.camera2;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.IntDef;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import static android.hardware.camera2.ICameraDeviceUser.NORMAL_MODE;
import static android.hardware.camera2.ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE;
import android.hardware.camera2.params.InputConfiguration;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.hardware.camera2.params.OutputConfiguration;
@@ -718,6 +722,84 @@ public abstract class CameraDevice implements AutoCloseable {
            @Nullable Handler handler)
            throws CameraAccessException;

    /**
     * Standard camera operation mode.
     *
     * @see #createCustomCaptureSession
     * @hide
     */
    @SystemApi
    @TestApi
    public static final int SESSION_OPERATION_MODE_NORMAL =
            ICameraDeviceUser.NORMAL_MODE;

    /**
     * Constrained high-speed operation mode.
     *
     * @see #createCustomCaptureSession
     * @hide
     */
    @SystemApi
    @TestApi
    public static final int SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED =
            ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE;

    /**
     * First vendor-specific operating mode
     *
     * @see #createCustomCaptureSession
     * @hide
     */
    @SystemApi
    @TestApi
    public static final int SESSION_OPERATION_MODE_VENDOR_START =
            ICameraDeviceUser.VENDOR_MODE_START;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(
            {SESSION_OPERATION_MODE_NORMAL,
             SESSION_OPERATION_MODE_CONSTRAINED_HIGH_SPEED,
             SESSION_OPERATION_MODE_VENDOR_START})
    public @interface SessionOperatingMode {};

    /**
     * Create a new camera capture session with a custom operating mode.
     *
     * @param inputConfig The configuration for the input {@link Surface} if a reprocessing session
     *                is desired, or {@code null} otherwise.
     * @param outputs The new set of {@link OutputConfiguration OutputConfigurations} that should be
     *                made available as targets for captured image data.
     * @param operatingMode The custom operating mode to use; a nonnegative value, either a custom
     *                vendor value or one of the SESSION_OPERATION_MODE_* values.
     * @param callback The callback to notify about the status of the new capture session.
     * @param handler The handler on which the callback should be invoked, or {@code null} to use
     *                the current thread's {@link android.os.Looper looper}.
     *
     * @throws IllegalArgumentException if the input configuration is null or not supported, the set
     *                                  of output Surfaces do not meet the requirements, the
     *                                  callback is null, or the handler is null but the current
     *                                  thread has no looper.
     * @throws CameraAccessException if the camera device is no longer connected or has
     *                               encountered a fatal error
     * @throws IllegalStateException if the camera device has been closed
     *
     * @see #createCaptureSession
     * @see #createReprocessableCaptureSession
     * @see CameraCaptureSession
     * @see OutputConfiguration
     * @hide
     */
    @SystemApi
    @TestApi
    public abstract void createCustomCaptureSession(
            InputConfiguration inputConfig,
            @NonNull List<OutputConfiguration> outputs,
            @SessionOperatingMode int operatingMode,
            @NonNull CameraCaptureSession.StateCallback callback,
            @Nullable Handler handler)
            throws CameraAccessException;

    /**
     * <p>Create a {@link CaptureRequest.Builder} for new capture requests,
     * initialized with template for a target use case. The settings are chosen
+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.ICameraDeviceUser;
import android.hardware.camera2.dispatch.ArgumentReplacingDispatcher;
import android.hardware.camera2.dispatch.BroadcastDispatcher;
import android.hardware.camera2.dispatch.DuckTypingDispatcher;
@@ -742,7 +743,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
                    try {
                        // begin transition to unconfigured
                        mDeviceImpl.configureStreamsChecked(/*inputConfig*/null, /*outputs*/null,
                                /*isConstrainedHighSpeed*/false);
                                /*operatingMode*/ ICameraDeviceUser.NORMAL_MODE);
                    } catch (CameraAccessException e) {
                        // OK: do not throw checked exceptions.
                        Log.e(TAG, mIdString + "Exception while unconfiguring outputs: ", e);
+27 −11
Original line number Diff line number Diff line
@@ -356,7 +356,7 @@ public class CameraDeviceImpl extends CameraDevice
            outputConfigs.add(new OutputConfiguration(s));
        }
        configureStreamsChecked(/*inputConfig*/null, outputConfigs,
                /*isConstrainedHighSpeed*/false);
                /*operatingMode*/ICameraDeviceUser.NORMAL_MODE);

    }

@@ -374,13 +374,14 @@ public class CameraDeviceImpl extends CameraDevice
     *
     * @param inputConfig input configuration or {@code null} for no input
     * @param outputs a list of one or more surfaces, or {@code null} to unconfigure
     * @param isConstrainedHighSpeed If the streams configuration is for constrained high speed output.
     * @param operatingMode If the stream configuration is for a normal session,
     *     a constrained high speed session, or something else.
     * @return whether or not the configuration was successful
     *
     * @throws CameraAccessException if there were any unexpected problems during configuration
     */
    public boolean configureStreamsChecked(InputConfiguration inputConfig,
            List<OutputConfiguration> outputs, boolean isConstrainedHighSpeed)
            List<OutputConfiguration> outputs, int operatingMode)
                    throws CameraAccessException {
        // Treat a null input the same an empty list
        if (outputs == null) {
@@ -456,7 +457,7 @@ public class CameraDeviceImpl extends CameraDevice
                    }
                }

                mRemoteDevice.endConfigure(isConstrainedHighSpeed);
                mRemoteDevice.endConfigure(operatingMode);

                success = true;
            } catch (IllegalArgumentException e) {
@@ -492,7 +493,7 @@ public class CameraDeviceImpl extends CameraDevice
            outConfigurations.add(new OutputConfiguration(surface));
        }
        createCaptureSessionInternal(null, outConfigurations, callback, handler,
                /*isConstrainedHighSpeed*/false);
                /*operatingMode*/ICameraDeviceUser.NORMAL_MODE);
    }

    @Override
@@ -508,7 +509,7 @@ public class CameraDeviceImpl extends CameraDevice
        List<OutputConfiguration> currentOutputs = new ArrayList<>(outputConfigurations);

        createCaptureSessionInternal(null, currentOutputs, callback, handler,
                /*isConstrainedHighSpeed*/false);
                /*operatingMode*/ICameraDeviceUser.NORMAL_MODE);
    }

    @Override
@@ -528,7 +529,7 @@ public class CameraDeviceImpl extends CameraDevice
            outConfigurations.add(new OutputConfiguration(surface));
        }
        createCaptureSessionInternal(inputConfig, outConfigurations, callback, handler,
                /*isConstrainedHighSpeed*/false);
                /*operatingMode*/ICameraDeviceUser.NORMAL_MODE);
    }

    @Override
@@ -556,7 +557,7 @@ public class CameraDeviceImpl extends CameraDevice
            currentOutputs.add(new OutputConfiguration(output));
        }
        createCaptureSessionInternal(inputConfig, currentOutputs,
                callback, handler, /*isConstrainedHighSpeed*/false);
                callback, handler, /*operatingMode*/ICameraDeviceUser.NORMAL_MODE);
    }

    @Override
@@ -576,13 +577,26 @@ public class CameraDeviceImpl extends CameraDevice
            outConfigurations.add(new OutputConfiguration(surface));
        }
        createCaptureSessionInternal(null, outConfigurations, callback, handler,
                /*isConstrainedHighSpeed*/true);
                /*operatingMode*/ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE);
    }

    @Override
    public void createCustomCaptureSession(InputConfiguration inputConfig,
            List<OutputConfiguration> outputs,
            int operatingMode,
            android.hardware.camera2.CameraCaptureSession.StateCallback callback,
            Handler handler) throws CameraAccessException {
        List<OutputConfiguration> currentOutputs = new ArrayList<OutputConfiguration>();
        for (OutputConfiguration output : outputs) {
            currentOutputs.add(new OutputConfiguration(output));
        }
        createCaptureSessionInternal(inputConfig, currentOutputs, callback, handler, operatingMode);
    }

    private void createCaptureSessionInternal(InputConfiguration inputConfig,
            List<OutputConfiguration> outputConfigurations,
            CameraCaptureSession.StateCallback callback, Handler handler,
            boolean isConstrainedHighSpeed) throws CameraAccessException {
            int operatingMode) throws CameraAccessException {
        synchronized(mInterfaceLock) {
            if (DEBUG) {
                Log.d(TAG, "createCaptureSessionInternal");
@@ -590,6 +604,8 @@ public class CameraDeviceImpl extends CameraDevice

            checkIfCameraClosedOrInError();

            boolean isConstrainedHighSpeed =
                    (operatingMode == ICameraDeviceUser.CONSTRAINED_HIGH_SPEED_MODE);
            if (isConstrainedHighSpeed && inputConfig != null) {
                throw new IllegalArgumentException("Constrained high speed session doesn't support"
                        + " input configuration yet.");
@@ -608,7 +624,7 @@ public class CameraDeviceImpl extends CameraDevice
            try {
                // configure streams and then block until IDLE
                configureSuccess = configureStreamsChecked(inputConfig, outputConfigurations,
                        isConstrainedHighSpeed);
                        operatingMode);
                if (configureSuccess == true && inputConfig != null) {
                    input = mRemoteDevice.getInputSurface();
                }
Loading