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

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

Merge "Camera: Add support for extension progress callbacks"

parents 35504745 f2c8dff0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -17770,6 +17770,7 @@ package android.hardware.camera2 {
    method @NonNull public <T> java.util.List<android.util.Size> getExtensionSupportedSizes(int, @NonNull Class<T>);
    method @NonNull public java.util.List<android.util.Size> getExtensionSupportedSizes(int, int);
    method @NonNull public java.util.List<java.lang.Integer> getSupportedExtensions();
    method public boolean isCaptureProcessProgressAvailable(int);
    field public static final int EXTENSION_AUTOMATIC = 0; // 0x0
    field @Deprecated public static final int EXTENSION_BEAUTY = 1; // 0x1
    field public static final int EXTENSION_BOKEH = 2; // 0x2
@@ -17789,6 +17790,7 @@ package android.hardware.camera2 {
  public abstract static class CameraExtensionSession.ExtensionCaptureCallback {
    ctor public CameraExtensionSession.ExtensionCaptureCallback();
    method public void onCaptureFailed(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest);
    method public void onCaptureProcessProgressed(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest, @IntRange(from=0, to=100) int);
    method public void onCaptureProcessStarted(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest);
    method public void onCaptureResultAvailable(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest, @NonNull android.hardware.camera2.TotalCaptureResult);
    method public void onCaptureSequenceAborted(@NonNull android.hardware.camera2.CameraExtensionSession, int);
+40 −0
Original line number Diff line number Diff line
@@ -801,6 +801,46 @@ public final class CameraExtensionCharacteristics {
        return null;
    }

    /**
     * Retrieve support for capture progress callbacks via
     *  {@link CameraExtensionSession.ExtensionCaptureCallback#onCaptureProcessProgressed}.
     *
     * @param extension         the extension type
     * @return {@code true} in case progress callbacks are supported, {@code false} otherwise
     *
     * @throws IllegalArgumentException in case of an unsupported extension.
     */
    public boolean isCaptureProcessProgressAvailable(@Extension int extension) {
        long clientId = registerClient(mContext);
        if (clientId < 0) {
            throw new IllegalArgumentException("Unsupported extensions");
        }

        try {
            if (!isExtensionSupported(mCameraId, extension, mChars)) {
                throw new IllegalArgumentException("Unsupported extension");
            }

            if (areAdvancedExtensionsSupported()) {
                IAdvancedExtenderImpl extender = initializeAdvancedExtension(extension);
                extender.init(mCameraId);
                return extender.isCaptureProcessProgressAvailable();
            } else {
                Pair<IPreviewExtenderImpl, IImageCaptureExtenderImpl> extenders =
                        initializeExtension(extension);
                extenders.second.init(mCameraId, mChars.getNativeMetadata());
                return extenders.second.isCaptureProcessProgressAvailable();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to query the extension progress callbacks! Extension service does"
                    + " not respond!");
        } finally {
            unregisterClient(clientId);
        }

        return false;
    }

    /**
     * Returns the set of keys supported by a {@link CaptureRequest} submitted in a
     * {@link CameraExtensionSession} with a given extension type.
+36 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.hardware.camera2;

import android.annotation.IntRange;
import android.annotation.NonNull;

import java.util.concurrent.Executor;
@@ -198,6 +199,41 @@ public abstract class CameraExtensionSession implements AutoCloseable {
                @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
            // default empty implementation
        }

        /**
         * This method is called when image capture processing is ongoing between
         * {@link #onCaptureProcessStarted} and the processed still capture frame returning
         * to the client surface.
         *
         * <p>The value included in the arguments provides clients with an estimate
         * of the post-processing progress which could take significantly more time
         * relative to the rest of the {@link #capture} sequence.</p>
         *
         * <p>The callback will be triggered only by extensions that return {@code true}
         * from calls
         * {@link CameraExtensionCharacteristics#isCaptureProcessProgressAvailable}.</p>
         *
         * <p>If support for this callback is present, then clients will be notified at least once
         * with progress value 100.</p>
         *
         * <p>The callback will be triggered only for still capture requests {@link #capture} and
         * is not supported for repeating requests {@link #setRepeatingRequest}.</p>
         *
         * <p>The default implementation of this method does nothing.</p>
         *
         * @param session The session received during
         *                {@link StateCallback#onConfigured(CameraExtensionSession)}
         * @param request The request that was given to the CameraDevice
         * @param progress Value between 0 and 100 (inclusive) indicating the current
         *                post-processing progress
         *
         * @see CameraExtensionCharacteristics#isCaptureProcessProgressAvailable
         *
         */
        public void onCaptureProcessProgressed(@NonNull CameraExtensionSession session,
                @NonNull CaptureRequest request, @IntRange(from = 0, to = 100) int progress) {
            // default empty implementation
        }
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -33,4 +33,5 @@ interface IAdvancedExtenderImpl
    ISessionProcessorImpl getSessionProcessor();
    CameraMetadataNative getAvailableCaptureRequestKeys(in String cameraId);
    CameraMetadataNative getAvailableCaptureResultKeys(in String cameraId);
    boolean isCaptureProcessProgressAvailable();
}
+1 −0
Original line number Diff line number Diff line
@@ -27,4 +27,5 @@ interface ICaptureCallback
    void onCaptureSequenceCompleted(int captureSequenceId);
    void onCaptureSequenceAborted(int captureSequenceId);
    void onCaptureCompleted(long shutterTimestamp, int requestId, in CameraMetadataNative results);
    void onCaptureProcessProgressed(int progress);
}
Loading