diff --git a/core/java/android/hardware/camera2/CameraCaptureSession.java b/core/java/android/hardware/camera2/CameraCaptureSession.java index 691690c09e0e0..5dbe9bff328e1 100644 --- a/core/java/android/hardware/camera2/CameraCaptureSession.java +++ b/core/java/android/hardware/camera2/CameraCaptureSession.java @@ -1233,6 +1233,41 @@ public abstract class CameraCaptureSession implements AutoCloseable { // default empty implementation } + /** + * This method is called when the camera device has started reading out the output + * image for the request, at the beginning of the sensor image readout. + * + *
For a capture request, this callback is invoked right after + * {@link #onCaptureStarted}. Unlike {@link #onCaptureStarted}, instead of passing + * a timestamp of start of exposure, this callback passes a timestamp of start of + * camera data readout. This is useful because for a camera running at fixed frame + * rate, the start of readout is at fixed interval, but not necessary for the start + * of exposure.
+ * + *This timestamp may not match {@link CaptureResult#SENSOR_TIMESTAMP the result + * timestamp field}. It will, however, match the timestamp of buffers sent to the + * output surfaces with {@link OutputConfiguration#TIMESTAMP_BASE_READOUT_SENSOR} + * timestamp base.
+ * + *This callback will be called only if {@link + * CameraCharacteristics#SENSOR_READOUT_TIMESTAMP} is + * {@link CameraMetadata#SENSOR_READOUT_TIMESTAMP_HARDWARE}, and it's called + * right after {@link #onCaptureStarted}.
+ * + * @param session the session returned by {@link CameraDevice#createCaptureSession} + * @param request the request for the readout that just began + * @param timestamp the timestamp at start of readout for a regular request, or + * the timestamp at the input image's start of readout for a + * reprocess request, in nanoseconds. + * @param frameNumber the frame number for this capture + * + * @hide + */ + public void onReadoutStarted(@NonNull CameraCaptureSession session, + @NonNull CaptureRequest request, long timestamp, long frameNumber) { + // default empty implementation + } + /** * This method is called when some results from an image capture are * available. diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index b05e6d1319577..fe4e69e6067fa 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -4381,6 +4381,40 @@ public final class CameraCharacteristics extends CameraMetadataWhether or not the camera device supports readout timestamp and + * onReadoutStarted callback.
+ *If this tag is HARDWARE, the camera device calls onReadoutStarted in addition to the + * onCaptureStarted callback for each capture. The timestamp passed into the callback + * is the start of camera image readout rather than the start of the exposure. In + * addition, the application can configure an + * {@link android.hardware.camera2.params.OutputConfiguration } with + * TIMESTAMP_BASE_READOUT_SENSOR timestamp base, in which case, the timestamp of the + * output surface matches the timestamp from the corresponding onReadoutStarted callback.
+ *The readout timestamp is beneficial for video recording, because the encoder favors + * uniform timestamps, and the readout timestamps better reflect the cadence camera sensors + * output data.
+ *If this tag is HARDWARE, the camera device produces the start-of-exposure and + * start-of-readout together. As a result, the onReadoutStarted is called right after + * onCaptureStarted. The difference in start-of-readout and start-of-exposure is the sensor + * exposure time, plus certain constant offset. The offset is usually due to camera sensor + * level crop, and it remains constant for a given camera sensor mode.
+ *Possible values:
+ *This key is available on all devices.
+ * @see #SENSOR_READOUT_TIMESTAMP_NOT_SUPPORTED + * @see #SENSOR_READOUT_TIMESTAMP_HARDWARE + * @hide + */ + @PublicKey + @NonNull + public static final KeyList of lens shading modes for {@link CaptureRequest#SHADING_MODE android.shading.mode} that are supported by this camera device.
*This list contains lens shading modes that can be set for the camera device.
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 40565b06a8f2c..5c272660b9626 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -1649,6 +1649,28 @@ public abstract class CameraMetadata This camera device doesn't support readout timestamp and onReadoutStarted
+ * callback. This camera device supports the onReadoutStarted callback as well as outputting
+ * readout timestamp for streams with TIMESTAMP_BASE_READOUT_SENSOR timestamp base. The
+ * readout timestamp is generated by the camera hardware and it has the same accuracy
+ * and timing characteristics of the start-of-exposure time. The start of the camera sensor readout after exposure. For a rolling shutter camera
+ * sensor, the timestamp is typically equal to the start of exposure time +
+ * exposure time + certain fixed offset. The fixed offset could be due to camera sensor
+ * level crop. The benefit of using readout time is that when camera runs in a fixed
+ * frame rate, the timestamp intervals between frames are constant. This timestamp is in the same time domain as in TIMESTAMP_BASE_SENSOR, with the exception
+ * that one is start of exposure, and the other is start of readout. This timestamp base is supported only if {@link
+ * CameraCharacteristics#SENSOR_READOUT_TIMESTAMP} is
+ * {@link CameraMetadata#SENSOR_READOUT_TIMESTAMP_HARDWARE}.