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

Commit 022d0a37 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Address EFV latency API feedback

Update javadocs and interface signatures of
getRealtimeStillCaptureLatency(),
getSupportedPostviewOutputResolutions() and
startMultiFrameCapture() according to the
API council feedback.

Flag: com.android.internal.camera.flags.efv_capture_latency
Bug: 427953808
Bug: 297083874
API-Coverage-Bug: 433563889
Test: Successful build
Change-Id: I657eb60617350061155f056c25113e561fc12f5e
parent f223c0f6
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -5339,7 +5339,7 @@ package android.hardware.camera2.extension {
  public abstract class SessionProcessor {
  public abstract class SessionProcessor {
    ctor public SessionProcessor();
    ctor public SessionProcessor();
    method public abstract void deInitSession(@NonNull android.os.IBinder);
    method public abstract void deInitSession(@NonNull android.os.IBinder);
    method @FlaggedApi("com.android.internal.camera.flags.efv_capture_latency") @Nullable public android.util.Pair<java.lang.Long,java.lang.Long> getRealtimeStillCaptureLatency();
    method @FlaggedApi("com.android.internal.camera.flags.efv_capture_latency") @Nullable public android.hardware.camera2.extension.SessionProcessor.CaptureLatencyInfo getRealtimeStillCaptureLatency();
    method @NonNull public abstract android.hardware.camera2.extension.ExtensionConfiguration initSession(@NonNull android.os.IBinder, @NonNull String, @NonNull android.hardware.camera2.extension.CharacteristicsMap, @NonNull android.hardware.camera2.extension.CameraOutputSurface, @NonNull android.hardware.camera2.extension.CameraOutputSurface);
    method @NonNull public abstract android.hardware.camera2.extension.ExtensionConfiguration initSession(@NonNull android.os.IBinder, @NonNull String, @NonNull android.hardware.camera2.extension.CharacteristicsMap, @NonNull android.hardware.camera2.extension.CameraOutputSurface, @NonNull android.hardware.camera2.extension.CameraOutputSurface);
    method @FlaggedApi("com.android.internal.camera.flags.efv_capture_latency") @NonNull public android.hardware.camera2.extension.ExtensionConfiguration initSession(@NonNull android.os.IBinder, @NonNull String, @NonNull android.hardware.camera2.extension.CharacteristicsMap, @NonNull android.hardware.camera2.extension.CameraConfiguration);
    method @FlaggedApi("com.android.internal.camera.flags.efv_capture_latency") @NonNull public android.hardware.camera2.extension.ExtensionConfiguration initSession(@NonNull android.os.IBinder, @NonNull String, @NonNull android.hardware.camera2.extension.CharacteristicsMap, @NonNull android.hardware.camera2.extension.CameraConfiguration);
    method public abstract void onCaptureSessionEnd();
    method public abstract void onCaptureSessionEnd();
@@ -5362,6 +5362,12 @@ package android.hardware.camera2.extension {
    method public void onCaptureStarted(int, long);
    method public void onCaptureStarted(int, long);
  }
  }
  @FlaggedApi("com.android.internal.camera.flags.efv_capture_latency") public static final class SessionProcessor.CaptureLatencyInfo {
    ctor public SessionProcessor.CaptureLatencyInfo(long, long);
    field public final long captureLatency;
    field public final long processingLatency;
  }
}
}
package android.hardware.camera2.params {
package android.hardware.camera2.params {
+2 −1
Original line number Original line Diff line number Diff line
@@ -293,10 +293,11 @@ public abstract class AdvancedExtender {
     *   resolution exists for the provided capture size then an empty map is returned.
     *   resolution exists for the provided capture size then an empty map is returned.
     *   An example of how the map is parsed can be found in {@link #initializeParcelable(Map)}.</p>
     *   An example of how the map is parsed can be found in {@link #initializeParcelable(Map)}.</p>
     * @param captureSize The still capture resolution
     * @param captureSize The still capture resolution
     * @see ImageFormat
     */
     */
    @FlaggedApi(Flags.FLAG_EFV_CAPTURE_LATENCY)
    @FlaggedApi(Flags.FLAG_EFV_CAPTURE_LATENCY)
    @NonNull
    @NonNull
    public Map<Integer, List<Size>> getSupportedPostviewOutputResolutions(
    public Map<@ImageFormat.Format Integer, List<Size>> getSupportedPostviewOutputResolutions(
            @NonNull Size captureSize) {
            @NonNull Size captureSize) {
        throw new UnsupportedOperationException("Subclasses must override this method");
        throw new UnsupportedOperationException("Subclasses must override this method");
    }
    }
+68 −14
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.hardware.camera2.extension;
package android.hardware.camera2.extension;


import android.annotation.DurationMillisLong;
import android.annotation.FlaggedApi;
import android.annotation.FlaggedApi;
import android.annotation.IntRange;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.NonNull;
@@ -27,12 +28,12 @@ import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.impl.CameraExtensionUtils.HandlerExecutor;
import android.hardware.camera2.impl.CameraExtensionUtils.HandlerExecutor;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.camera2.utils.HashCodeHelpers;
import android.os.Handler;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Looper;
import android.os.Looper;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Log;
import android.util.Log;
import android.util.Pair;


import com.android.internal.camera.flags.Flags;
import com.android.internal.camera.flags.Flags;


@@ -196,6 +197,62 @@ public abstract class SessionProcessor {
        }
        }
    }
    }


    /**
     * Realtime calculated still capture {@link #startMultiFrameCapture} latency.
     *
     * @see #getRealtimeStillCaptureLatency()
     */
    @FlaggedApi(Flags.FLAG_EFV_CAPTURE_LATENCY)
    public final static class CaptureLatencyInfo {

        /**
         * The estimated still capture latency in milliseconds
         * from {@link CaptureCallback#onCaptureStarted} until
         * {@link CaptureCallback#onCaptureProcessStarted}.
         */
        @DurationMillisLong
        public final long captureLatency;

        /**
         * The estimated post-processing latency in milliseconds from
         * {@link CaptureCallback#onCaptureProcessStarted} until the processed frame
         * returns to the client.
         */
        @DurationMillisLong
        public final long processingLatency;

        public CaptureLatencyInfo(@DurationMillisLong long captureLatency,
                @DurationMillisLong long processingLatency) {
            this.captureLatency = captureLatency;
            this.processingLatency = processingLatency;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            CaptureLatencyInfo latency = (CaptureLatencyInfo) o;

            if (captureLatency != latency.captureLatency) return false;
            if (processingLatency != latency.processingLatency) return false;

            return true;
        }

        @Override
        public int hashCode() {
            return HashCodeHelpers.hashCode((float) captureLatency, (float) processingLatency);
        }

        @Override
        public String toString() {
            return "CaptureLatencyInfo(processingLatency:" + processingLatency +
                    ", captureLatency: " + captureLatency + ")";
        }
    }


    /**
    /**
     * Initializes the session for the extension. This is where the
     * Initializes the session for the extension. This is where the
     * extension implementations allocate resources for
     * extension implementations allocate resources for
@@ -354,6 +411,10 @@ public abstract class SessionProcessor {
     * another capture is running  will cause onCaptureFailed to be called
     * another capture is running  will cause onCaptureFailed to be called
     * immediately.</p>
     * immediately.</p>
     *
     *
     * <p>This method will not generate postview images and it behaves essentially
     * the same as calling {@link #startMultiFrameCapture(boolean, Executor, CaptureCallback)}
     * with the postview argument set to false.</p>
     *
     * @param executor the executor which will be used for
     * @param executor the executor which will be used for
     *                 invoking the callbacks
     *                 invoking the callbacks
     * @param callback a callback to report the status.
     * @param callback a callback to report the status.
@@ -396,18 +457,11 @@ public abstract class SessionProcessor {
     * state and will include the time spent processing the multi-frame capture request along with
     * state and will include the time spent processing the multi-frame capture request along with
     * any additional time for encoding of the processed buffer if necessary.</p>
     * any additional time for encoding of the processed buffer if necessary.</p>
     *
     *
     * @return {@code null} if the estimation is not supported or a pair that includes the estimated
     * @return {@link CaptureLatencyInfo} or {@code null} if the estimation is not supported.
     * input frame/frames camera capture latency as the * first field. This is the time between
     * {@link CaptureCallback#onCaptureStarted} and
     * {@link CaptureCallback#onCaptureProcessStarted}. The second field value includes the
     * estimated post-processing latency. This is the time between
     * {@link CaptureCallback#onCaptureProcessStarted} until * the processed frame returns back to
     * the client registered surface. Both first and second values will be in milliseconds. The
     * total still capture latency will be the sum of both the first and second values of the pair.
     */
     */
    @FlaggedApi(Flags.FLAG_EFV_CAPTURE_LATENCY)
    @FlaggedApi(Flags.FLAG_EFV_CAPTURE_LATENCY)
    @Nullable
    @Nullable
    public Pair<Long, Long> getRealtimeStillCaptureLatency() {
    public CaptureLatencyInfo getRealtimeStillCaptureLatency() {
        throw new UnsupportedOperationException("Subclasses must override this method");
        throw new UnsupportedOperationException("Subclasses must override this method");
    }
    }


@@ -558,13 +612,13 @@ public abstract class SessionProcessor {
        @Override
        @Override
        public LatencyPair getRealtimeCaptureLatency() throws RemoteException {
        public LatencyPair getRealtimeCaptureLatency() throws RemoteException {
            if (Flags.efvCaptureLatency()) {
            if (Flags.efvCaptureLatency()) {
                Pair<Long, Long> pair = SessionProcessor.this.getRealtimeStillCaptureLatency();
                CaptureLatencyInfo info = SessionProcessor.this.getRealtimeStillCaptureLatency();
                if (pair == null) {
                if (info == null) {
                    return null;
                    return null;
                }
                }
                LatencyPair ret = new LatencyPair();
                LatencyPair ret = new LatencyPair();
                ret.first = pair.first;
                ret.first = info.captureLatency;
                ret.second = pair.second;
                ret.second = info.processingLatency;
                return ret;
                return ret;
            }
            }
            return null;
            return null;
+3 −0
Original line number Original line Diff line number Diff line
@@ -21,12 +21,15 @@ import android.annotation.IntDef;


import com.android.internal.camera.flags.Flags;
import com.android.internal.camera.flags.Flags;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


@android.ravenwood.annotation.RavenwoodKeepWholeClass
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class ImageFormat {
public class ImageFormat {
     /** @hide */
     /** @hide */
     @Target(ElementType.TYPE_USE)
     @Retention(RetentionPolicy.SOURCE)
     @Retention(RetentionPolicy.SOURCE)
     @IntDef(value = {
     @IntDef(value = {
             UNKNOWN,
             UNKNOWN,