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

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

Merge "Camera: Use dedicated class for realtime latency queries"

parents 59bce679 1e42a0a4
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -18229,7 +18229,7 @@ package android.hardware.camera2 {
    method public int capture(@NonNull android.hardware.camera2.CaptureRequest, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.camera2.CameraExtensionSession.ExtensionCaptureCallback) throws android.hardware.camera2.CameraAccessException;
    method public void close() throws android.hardware.camera2.CameraAccessException;
    method @NonNull public android.hardware.camera2.CameraDevice getDevice();
    method @Nullable public android.util.Pair<java.lang.Long,java.lang.Long> getRealtimeStillCaptureLatency() throws android.hardware.camera2.CameraAccessException;
    method @Nullable public android.hardware.camera2.CameraExtensionSession.StillCaptureLatency getRealtimeStillCaptureLatency() throws android.hardware.camera2.CameraAccessException;
    method public int setRepeatingRequest(@NonNull android.hardware.camera2.CaptureRequest, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.camera2.CameraExtensionSession.ExtensionCaptureCallback) throws android.hardware.camera2.CameraAccessException;
    method public void stopRepeating() throws android.hardware.camera2.CameraAccessException;
  }
@@ -18252,6 +18252,12 @@ package android.hardware.camera2 {
    method public abstract void onConfigured(@NonNull android.hardware.camera2.CameraExtensionSession);
  }
  public static final class CameraExtensionSession.StillCaptureLatency {
    ctor public CameraExtensionSession.StillCaptureLatency(long, long);
    method public long getCaptureLatency();
    method public long getProcessingLatency();
  }
  public final class CameraManager {
    method @NonNull public android.hardware.camera2.CameraCharacteristics getCameraCharacteristics(@NonNull String) throws android.hardware.camera2.CameraAccessException;
    method @NonNull public android.hardware.camera2.CameraExtensionCharacteristics getCameraExtensionCharacteristics(@NonNull String) throws android.hardware.camera2.CameraAccessException;
+61 −12
Original line number Diff line number Diff line
@@ -19,10 +19,7 @@ package android.hardware.camera2;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.hardware.camera2.impl.PublicKey;
import android.hardware.camera2.utils.TypeReference;
import android.util.Pair;
import android.util.Range;
import android.hardware.camera2.utils.HashCodeHelpers;

import java.util.concurrent.Executor;

@@ -434,14 +431,66 @@ public abstract class CameraExtensionSession implements AutoCloseable {
    }

    /**
     * Return the realtime still {@link #capture} latency.
     * Realtime calculated still {@link #capture} latency.
     *
     * <p>The pair will be in milliseconds with the first value indicating the capture latency from
     * the {@link ExtensionCaptureCallback#onCaptureStarted} until
     * {@link ExtensionCaptureCallback#onCaptureProcessStarted}
     * and the second value containing the estimated post-processing latency from
     * {@link ExtensionCaptureCallback#onCaptureProcessStarted} until the processed frame returns
     * to the client.</p>
     * @see #getRealtimeStillCaptureLatency()
     */
    public final static class StillCaptureLatency {
        private final long mCaptureLatency, mProcessingLatency;

        public StillCaptureLatency(long captureLatency, long processingLatency) {
            mCaptureLatency = captureLatency;
            mProcessingLatency = processingLatency;
        }
        /**
         * Return the capture latency from
         * {@link ExtensionCaptureCallback#onCaptureStarted} until
         * {@link ExtensionCaptureCallback#onCaptureProcessStarted}.
         *
         * @return The realtime capture latency in milliseconds.
         */
        public long getCaptureLatency() {
            return mCaptureLatency;
        }

        /**
         * Return the estimated post-processing latency from
         * {@link ExtensionCaptureCallback#onCaptureProcessStarted} until the processed frame
         * returns to the client.
         *
         * @return returns post-processing latency in milliseconds
         */
        public long getProcessingLatency() {
            return mProcessingLatency;
        }

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

            StillCaptureLatency latency = (StillCaptureLatency) o;

            if (mCaptureLatency != latency.mCaptureLatency) return false;
            if (mProcessingLatency != latency.mProcessingLatency) return false;

            return true;
        }

        @Override
        public int hashCode() {
            return HashCodeHelpers.hashCode(mCaptureLatency, mProcessingLatency);
        }

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

    /**
     * Return the realtime still {@link #capture} latency.
     *
     * <p>The estimations will take into account the current environment conditions, the camera
     * state and will include the time spent processing the multi-frame capture request along with
@@ -451,7 +500,7 @@ public abstract class CameraExtensionSession implements AutoCloseable {
     * or {@code null} if the estimation is not supported.
     */
    @Nullable
    public Pair<Long, Long> getRealtimeStillCaptureLatency() throws CameraAccessException {
    public StillCaptureLatency getRealtimeStillCaptureLatency() throws CameraAccessException {
        throw new UnsupportedOperationException("Subclasses must override this method");
    }

+2 −2
Original line number Diff line number Diff line
@@ -361,7 +361,7 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
    }

    @Override
    public Pair<Long, Long> getRealtimeStillCaptureLatency() throws CameraAccessException {
    public StillCaptureLatency getRealtimeStillCaptureLatency() throws CameraAccessException {
        synchronized (mInterfaceLock) {
            if (!mInitialized) {
                throw new IllegalStateException("Uninitialized component");
@@ -370,7 +370,7 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
            try {
                LatencyPair latency = mSessionProcessor.getRealtimeCaptureLatency();
                if (latency != null) {
                    return new Pair<>(latency.first, latency.second);
                    return new StillCaptureLatency(latency.first, latency.second);
                }

                return null;
+2 −2
Original line number Diff line number Diff line
@@ -513,7 +513,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
    }

    @Override
    public Pair<Long, Long> getRealtimeStillCaptureLatency() throws CameraAccessException {
    public StillCaptureLatency getRealtimeStillCaptureLatency() throws CameraAccessException {
        synchronized (mInterfaceLock) {
            if (!mInitialized) {
                throw new IllegalStateException("Uninitialized component");
@@ -522,7 +522,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
            try {
                LatencyPair latency = mImageExtender.getRealtimeCaptureLatency();
                if (latency != null) {
                    return new Pair<>(latency.first, latency.second);
                    return new StillCaptureLatency(latency.first, latency.second);
                }

                return null;