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

Commit e8df3093 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

Camera2: Add frameNumber to CaptureCallback#onCaptureStarted

Otherwise, cannot reliably match up capture progressed and failure callbacks
with the start callback.

Bug: 17421092
Change-Id: I91d92be70a15536b215bac330370ce37e426ec26
parent 5f5df97d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12691,7 +12691,7 @@ package android.hardware.camera2 {
    method public void onCaptureProgressed(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, android.hardware.camera2.CaptureResult);
    method public void onCaptureSequenceAborted(android.hardware.camera2.CameraCaptureSession, int);
    method public void onCaptureSequenceCompleted(android.hardware.camera2.CameraCaptureSession, int, long);
    method public void onCaptureStarted(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, long);
    method public void onCaptureStarted(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, long, long);
  }
  public static abstract class CameraCaptureSession.StateCallback {
+14 −1
Original line number Diff line number Diff line
@@ -483,7 +483,9 @@ public abstract class CameraCaptureSession implements AutoCloseable {
         * and in the buffers sent to each output Surface. These buffer
         * timestamps are accessible through, for example,
         * {@link android.media.Image#getTimestamp() Image.getTimestamp()} or
         * {@link android.graphics.SurfaceTexture#getTimestamp()}.</p>
         * {@link android.graphics.SurfaceTexture#getTimestamp()}.
         * The frame number included is equal to the frame number that will be included in
         * {@link CaptureResult#getFrameNumber}.</p>
         *
         * <p>For the simplest way to play a shutter sound camera shutter or a
         * video recording start/stop sound, see the
@@ -494,9 +496,20 @@ public abstract class CameraCaptureSession implements AutoCloseable {
         * @param session the session returned by {@link CameraDevice#createCaptureSession}
         * @param request the request for the capture that just begun
         * @param timestamp the timestamp at start of capture, in nanoseconds.
         * @param frameNumber the frame number for this capture
         *
         * @see android.media.MediaActionSound
         */
        public void onCaptureStarted(CameraCaptureSession session,
                CaptureRequest request, long timestamp, long frameNumber) {
            // Temporary trampoline for API change transition
            onCaptureStarted(session, request, timestamp);
        }

        /**
         * Temporary for API change transition
         * @hide
         */
        public void onCaptureStarted(CameraCaptureSession session,
                CaptureRequest request, long timestamp) {
            // default empty implementation
+5 −3
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ public class MethodNameInvoker<T> {
    /**
     * Invoke a method by its name.
     *
     * <p>If more than one method exists in {@code targetClass}, the first method will be used.</p>
     * <p>If more than one method exists in {@code targetClass}, the first method with the right
     * number of arguments will be used, and later calls will all use that method.</p>
     *
     * @param methodName
     *          The name of the method, which will be matched 1:1 to the destination method
@@ -68,8 +69,9 @@ public class MethodNameInvoker<T> {
        Method targetMethod = mMethods.get(methodName);
        if (targetMethod == null) {
            for (Method method : mTargetClass.getMethods()) {
                // TODO future: match by # of params and types of params if possible
                if (method.getName().equals(methodName)) {
                // TODO future: match types of params if possible
                if (method.getName().equals(methodName) &&
                        (params.length == method.getParameterTypes().length) ) {
                    targetMethod = method;
                    mMethods.put(methodName, targetMethod);
                    break;
+2 −2
Original line number Diff line number Diff line
@@ -98,8 +98,8 @@ public class CallbackProxies {

        @Override
        public void onCaptureStarted(CameraDevice camera,
                CaptureRequest request, long timestamp) {
            mProxy.invoke("onCaptureStarted", camera, request, timestamp);
                CaptureRequest request, long timestamp, long frameNumber) {
            mProxy.invoke("onCaptureStarted", camera, request, timestamp, frameNumber);
        }

        @Override
+5 −3
Original line number Diff line number Diff line
@@ -803,7 +803,7 @@ public class CameraDeviceImpl extends CameraDevice {
         * @see android.media.MediaActionSound
         */
        public void onCaptureStarted(CameraDevice camera,
                CaptureRequest request, long timestamp) {
                CaptureRequest request, long timestamp, long frameNumber) {
            // default empty implementation
        }

@@ -1237,8 +1237,10 @@ public class CameraDeviceImpl extends CameraDevice {
        @Override
        public void onCaptureStarted(final CaptureResultExtras resultExtras, final long timestamp) {
            int requestId = resultExtras.getRequestId();
            final long frameNumber = resultExtras.getFrameNumber();

            if (DEBUG) {
                Log.d(TAG, "Capture started for id " + requestId);
                Log.d(TAG, "Capture started for id " + requestId + " frame number " + frameNumber);
            }
            final CaptureCallbackHolder holder;

@@ -1263,7 +1265,7 @@ public class CameraDeviceImpl extends CameraDevice {
                                holder.getCallback().onCaptureStarted(
                                    CameraDeviceImpl.this,
                                    holder.getRequest(resultExtras.getSubsequenceId()),
                                    timestamp);
                                    timestamp, frameNumber);
                            }
                        }
                    });