diff --git a/core/api/current.txt b/core/api/current.txt index a6ba517100149..b13f312f8588d 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -18037,6 +18037,7 @@ package android.hardware.camera2 { } public final class CameraExtensionCharacteristics { + method @Nullable public android.util.Range getEstimatedCaptureLatencyRange(int, @NonNull android.util.Size, int); method @NonNull public java.util.List getExtensionSupportedSizes(int, @NonNull Class); method @NonNull public java.util.List getExtensionSupportedSizes(int, int); method @NonNull public java.util.List getSupportedExtensions(); diff --git a/core/java/android/hardware/camera2/CameraExtensionCharacteristics.java b/core/java/android/hardware/camera2/CameraExtensionCharacteristics.java index 6121cd260dc3f..fd10c57e85dcb 100644 --- a/core/java/android/hardware/camera2/CameraExtensionCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraExtensionCharacteristics.java @@ -15,6 +15,7 @@ */ package android.hardware.camera2; +import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -33,6 +34,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.util.Log; import android.util.Pair; +import android.util.Range; import android.util.Size; import java.util.HashSet; @@ -566,4 +568,47 @@ public final class CameraExtensionCharacteristics { return new ArrayList<>(); } } + + /** + * Returns the estimated capture latency range in milliseconds for the + * target capture resolution during the calls to {@link CameraExtensionSession#capture}. This + * includes the time spent processing the multi-frame capture request along with any additional + * time for encoding of the processed buffer if necessary. + * + * @param extension the extension type + * @param captureOutputSize size of the capture output surface. If it is not in the supported + * output sizes, maximum capture output size is used for the estimation + * @param format device-specific extension output format + * @return the range of estimated minimal and maximal capture latency in milliseconds + * or null if no capture latency info can be provided + * + * @throws IllegalArgumentException in case of format different from {@link ImageFormat#JPEG} / + * {@link ImageFormat#YUV_420_888}; or unsupported extension. + */ + public @Nullable Range getEstimatedCaptureLatencyRange(@Extension int extension, + @NonNull Size captureOutputSize, @ImageFormat.Format int format) { + switch (format) { + case ImageFormat.YUV_420_888: + case ImageFormat.JPEG: + //No op + break; + default: + throw new IllegalArgumentException("Unsupported format: " + format); + } + + long clientId = registerClient(mContext); + if (clientId < 0) { + throw new IllegalArgumentException("Unsupported extensions"); + } + + try { + if (!isExtensionSupported(mCameraId, extension, mChars)) { + throw new IllegalArgumentException("Unsupported extension"); + } + } finally { + unregisterClient(clientId); + } + + return null; + } }