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

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

Merge "Camera: add OFFLINE_PROCESSING capability"

parents 132a186b 440ee260
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -17246,6 +17246,7 @@ package android.hardware.camera2 {
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR = 1; // 0x1
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR = 1; // 0x1
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME = 12; // 0xc
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME = 12; // 0xc
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING = 10; // 0xa
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING = 10; // 0xa
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING = 15; // 0xf
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING = 4; // 0x4
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING = 4; // 0x4
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_RAW = 3; // 0x3
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_RAW = 3; // 0x3
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS = 5; // 0x5
    field public static final int REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS = 5; // 0x5
+6 −4
Original line number Original line Diff line number Diff line
@@ -935,7 +935,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
    /**
    /**
     * <p>List of the maximum number of regions that can be used for metering in
     * <p>List of the maximum number of regions that can be used for metering in
     * auto-exposure (AE), auto-white balance (AWB), and auto-focus (AF);
     * auto-exposure (AE), auto-white balance (AWB), and auto-focus (AF);
     * this corresponds to the the maximum number of elements in
     * this corresponds to the maximum number of elements in
     * {@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}, {@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions},
     * {@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}, {@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions},
     * and {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}.</p>
     * and {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}.</p>
     * <p><b>Range of valid values:</b><br></p>
     * <p><b>Range of valid values:</b><br></p>
@@ -955,7 +955,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
    /**
    /**
     * <p>The maximum number of metering regions that can be used by the auto-exposure (AE)
     * <p>The maximum number of metering regions that can be used by the auto-exposure (AE)
     * routine.</p>
     * routine.</p>
     * <p>This corresponds to the the maximum allowed number of elements in
     * <p>This corresponds to the maximum allowed number of elements in
     * {@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}.</p>
     * {@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}.</p>
     * <p><b>Range of valid values:</b><br>
     * <p><b>Range of valid values:</b><br>
     * Value will be &gt;= 0. For FULL-capability devices, this
     * Value will be &gt;= 0. For FULL-capability devices, this
@@ -973,7 +973,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
    /**
    /**
     * <p>The maximum number of metering regions that can be used by the auto-white balance (AWB)
     * <p>The maximum number of metering regions that can be used by the auto-white balance (AWB)
     * routine.</p>
     * routine.</p>
     * <p>This corresponds to the the maximum allowed number of elements in
     * <p>This corresponds to the maximum allowed number of elements in
     * {@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions}.</p>
     * {@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions}.</p>
     * <p><b>Range of valid values:</b><br>
     * <p><b>Range of valid values:</b><br>
     * Value will be &gt;= 0.</p>
     * Value will be &gt;= 0.</p>
@@ -989,7 +989,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri


    /**
    /**
     * <p>The maximum number of metering regions that can be used by the auto-focus (AF) routine.</p>
     * <p>The maximum number of metering regions that can be used by the auto-focus (AF) routine.</p>
     * <p>This corresponds to the the maximum allowed number of elements in
     * <p>This corresponds to the maximum allowed number of elements in
     * {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}.</p>
     * {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}.</p>
     * <p><b>Range of valid values:</b><br>
     * <p><b>Range of valid values:</b><br>
     * Value will be &gt;= 0. For FULL-capability devices, this
     * Value will be &gt;= 0. For FULL-capability devices, this
@@ -1987,6 +1987,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME MONOCHROME}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME MONOCHROME}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_SECURE_IMAGE_DATA SECURE_IMAGE_DATA}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_SECURE_IMAGE_DATA SECURE_IMAGE_DATA}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA SYSTEM_CAMERA}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA SYSTEM_CAMERA}</li>
     *   <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING OFFLINE_PROCESSING}</li>
     * </ul></p>
     * </ul></p>
     * <p>This key is available on all devices.</p>
     * <p>This key is available on all devices.</p>
     *
     *
@@ -2006,6 +2007,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     * @see #REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME
     * @see #REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME
     * @see #REQUEST_AVAILABLE_CAPABILITIES_SECURE_IMAGE_DATA
     * @see #REQUEST_AVAILABLE_CAPABILITIES_SECURE_IMAGE_DATA
     * @see #REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA
     * @see #REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA
     * @see #REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING
     */
     */
    @PublicKey
    @PublicKey
    @NonNull
    @NonNull
+45 −0
Original line number Original line Diff line number Diff line
@@ -1004,6 +1004,51 @@ public abstract class CameraMetadata<TKey> {
     */
     */
    public static final int REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA = 14;
    public static final int REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA = 14;


    /**
     * <p>The camera device supports the OFFLINE_PROCESSING use case.</p>
     * <p>With OFFLINE_PROCESSING capability, the application can switch an ongoing
     * capture session to offline mode by calling the
     * CameraCaptureSession#switchToOffline method and specify streams to be kept in offline
     * mode. The camera will then stop currently active repeating requests, prepare for
     * some requests to go into offline mode, and return an offline session object. After
     * the switchToOffline call returns, the original capture session is in closed state as
     * if the CameraCaptureSession#close method has been called.
     * In the offline mode, all inflight requests will continue to be processed in the
     * background, and the application can immediately close the camera or create a new
     * capture session without losing those requests' output images and capture results.</p>
     * <p>While the camera device is processing offline requests, it
     * might not be able to support all stream configurations it can support
     * without offline requests. When that happens, the createCaptureSession
     * method call will fail. The following stream configurations are guaranteed to work
     * without hitting the resource busy exception:</p>
     * <ul>
     * <li>One ongoing offline session: target one output surface of YUV or
     * JPEG format, any resolution.</li>
     * <li>The active camera capture session:<ol>
     * <li>One preview surface (SurfaceView or SurfaceTexture) up to 1920 width</li>
     * <li>One YUV ImageReader surface up to 1920 width</li>
     * <li>One Jpeg ImageReader, any resolution: the camera device is
     *    allowed to slow down JPEG output speed by 50% if there is any ongoing offline
     *    session.</li>
     * <li>One ImageWriter surface of private format, any resolution if the device supports
     *    PRIVATE_REPROCESSING capability</li>
     * </ol>
     * </li>
     * <li>Alternatively, the active camera session above can be replaced by an legacy
     * {@link android.hardware.Camera Camera} with the following parameter settings:<ol>
     * <li>Preview size up to 1920 width</li>
     * <li>Preview callback size up to 1920 width</li>
     * <li>Video size up to 1920 width</li>
     * <li>Picture size, any resolution: the camera device is
     *     allowed to slow down JPEG output speed by 50% if there is any ongoing offline
     *     session.</li>
     * </ol>
     * </li>
     * </ul>
     * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
     */
    public static final int REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING = 15;

    //
    //
    // Enumeration values for CameraCharacteristics#SCALER_CROPPING_TYPE
    // Enumeration values for CameraCharacteristics#SCALER_CROPPING_TYPE
    //
    //
+33 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.ICameraDeviceCallbacks;
import android.hardware.camera2.ICameraDeviceCallbacks;
import android.hardware.camera2.ICameraDeviceUser;
import android.hardware.camera2.ICameraDeviceUser;
import android.hardware.camera2.ICameraOfflineSession;
import android.hardware.camera2.TotalCaptureResult;
import android.hardware.camera2.TotalCaptureResult;
import android.hardware.camera2.params.InputConfiguration;
import android.hardware.camera2.params.InputConfiguration;
import android.hardware.camera2.params.OutputConfiguration;
import android.hardware.camera2.params.OutputConfiguration;
@@ -866,6 +867,38 @@ public class CameraDeviceImpl extends CameraDevice
        }
        }
    }
    }


    public void switchToOffline(ICameraDeviceCallbacks cbs, Surface[] offlineOutputs)
            throws CameraAccessException {
        if ((offlineOutputs == null) || (offlineOutputs.length == 0)) {
            throw new IllegalArgumentException("Invalid offline outputs!");
        }
        if (cbs == null) {
            throw new IllegalArgumentException("Invalid device callbacks!");
        }

        ICameraOfflineSession offlineSession = null;
        synchronized(mInterfaceLock) {
            int streamId = -1;
            for (Surface surface : offlineOutputs) {
                for (int i = 0; i < mConfiguredOutputs.size(); i++) {
                    if (surface == mConfiguredOutputs.valueAt(i).getSurface()) {
                        streamId = mConfiguredOutputs.keyAt(i);
                        break;
                    }
                }
                if (streamId == -1) {
                    throw new IllegalArgumentException("Offline surface is not part of this" +
                            " session");
                }
            }

            offlineSession = mRemoteDevice.switchToOffline(cbs,
                    offlineOutputs);
            // TODO: Initialize CameraOfflineSession wrapper, clear 'mConfiguredOutputs',
            // and update request tracking
        }
    }

    public void tearDown(Surface surface) throws CameraAccessException {
    public void tearDown(Surface surface) throws CameraAccessException {
        if (surface == null) throw new IllegalArgumentException("Surface is null");
        if (surface == null) throw new IllegalArgumentException("Surface is null");


+13 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,8 @@ import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.ICameraDeviceUser;
import android.hardware.camera2.ICameraDeviceUser;
import android.hardware.camera2.ICameraDeviceCallbacks;
import android.hardware.camera2.ICameraOfflineSession;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.camera2.params.OutputConfiguration;
import android.hardware.camera2.params.OutputConfiguration;
import android.hardware.camera2.params.SessionConfiguration;
import android.hardware.camera2.params.SessionConfiguration;
@@ -248,6 +250,17 @@ public class ICameraDeviceUserWrapper {
        }
        }
    }
    }


    public ICameraOfflineSession switchToOffline(ICameraDeviceCallbacks cbs,
            Surface[] offlineOutputs)
            throws CameraAccessException {
        try {
            return mRemoteDevice.switchToOffline(cbs, offlineOutputs);
        } catch (Throwable t) {
            CameraManager.throwAsPublicException(t);
            throw new UnsupportedOperationException("Unexpected exception", t);
        }
    }

    public void finalizeOutputConfigurations(int streamId, OutputConfiguration deferredConfig)
    public void finalizeOutputConfigurations(int streamId, OutputConfiguration deferredConfig)
            throws CameraAccessException {
            throws CameraAccessException {
        try {
        try {
Loading