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

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

Merge "Camera2: Add secondary surface to OutputConfiguration"

parents d1c3379a 9c663d44
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -48,8 +48,6 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession

    /** Input surface configured by native camera framework based on user-specified configuration */
    private final Surface mInput;
    /** User-specified set of surfaces used as the configuration outputs */
    private final List<Surface> mOutputs;
    /**
     * User-specified state callback, used for outgoing events; calls to this object will be
     * automatically {@link Handler#post(Runnable) posted} to {@code mStateHandler}.
@@ -87,21 +85,17 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
     * There must be no pending actions
     * (e.g. no pending captures, no repeating requests, no flush).</p>
     */
    CameraCaptureSessionImpl(int id, Surface input, List<Surface> outputs,
    CameraCaptureSessionImpl(int id, Surface input,
            CameraCaptureSession.StateCallback callback, Handler stateHandler,
            android.hardware.camera2.impl.CameraDeviceImpl deviceImpl,
            Handler deviceStateHandler, boolean configureSuccess) {
        if (outputs == null || outputs.isEmpty()) {
            throw new IllegalArgumentException("outputs must be a non-null, non-empty list");
        } else if (callback == null) {
        if (callback == null) {
            throw new IllegalArgumentException("callback must not be null");
        }

        mId = id;
        mIdString = String.format("Session %d: ", mId);

        // TODO: extra verification of outputs
        mOutputs = outputs;
        mInput = input;
        mStateHandler = checkHandler(stateHandler);
        mStateCallback = createUserStateCallbackProxy(mStateHandler, callback);
+2 −2
Original line number Diff line number Diff line
@@ -58,14 +58,14 @@ public class CameraConstrainedHighSpeedCaptureSessionImpl
     * There must be no pending actions
     * (e.g. no pending captures, no repeating requests, no flush).</p>
     */
    CameraConstrainedHighSpeedCaptureSessionImpl(int id, List<Surface> outputs,
    CameraConstrainedHighSpeedCaptureSessionImpl(int id,
            CameraCaptureSession.StateCallback callback, Handler stateHandler,
            android.hardware.camera2.impl.CameraDeviceImpl deviceImpl,
            Handler deviceStateHandler, boolean configureSuccess,
            CameraCharacteristics characteristics) {
        mCharacteristics = characteristics;
        CameraCaptureSession.StateCallback wrapperCallback = new WrapperCallback(callback);
        mSessionImpl = new CameraCaptureSessionImpl(id, /*input*/null, outputs, wrapperCallback,
        mSessionImpl = new CameraCaptureSessionImpl(id, /*input*/null, wrapperCallback,
                stateHandler, deviceImpl, deviceStateHandler, configureSuccess);
    }

+32 −26
Original line number Diff line number Diff line
@@ -501,7 +501,7 @@ public class CameraDeviceImpl extends CameraDevice
            CameraCaptureSession.StateCallback callback, Handler handler)
            throws CameraAccessException {
        if (DEBUG) {
            Log.d(TAG, "createCaptureSessionByOutputConfiguration");
            Log.d(TAG, "createCaptureSessionByOutputConfigurations");
        }

        // OutputConfiguration objects are immutable, but need to have our own array
@@ -621,19 +621,15 @@ public class CameraDeviceImpl extends CameraDevice
                }
            }

            List<Surface> outSurfaces = new ArrayList<>(outputConfigurations.size());
            for (OutputConfiguration config : outputConfigurations) {
                outSurfaces.add(config.getSurface());
            }
            // Fire onConfigured if configureOutputs succeeded, fire onConfigureFailed otherwise.
            CameraCaptureSessionCore newSession = null;
            if (isConstrainedHighSpeed) {
                newSession = new CameraConstrainedHighSpeedCaptureSessionImpl(mNextSessionId++,
                        outSurfaces, callback, handler, this, mDeviceHandler, configureSuccess,
                        callback, handler, this, mDeviceHandler, configureSuccess,
                        mCharacteristics);
            } else {
                newSession = new CameraCaptureSessionImpl(mNextSessionId++, input,
                        outSurfaces, callback, handler, this, mDeviceHandler,
                        callback, handler, this, mDeviceHandler,
                        configureSuccess);
            }

@@ -1946,11 +1942,17 @@ public class CameraDeviceImpl extends CameraDevice

            Runnable failureDispatch = null;
            if (errorCode == ERROR_CAMERA_BUFFER) {
                final Surface outputSurface =
                        mConfiguredOutputs.get(resultExtras.getErrorStreamId()).getSurface();
                // Because 1 stream id could map to multiple surfaces, we need to specify both
                // streamId and surfaceId.
                List<Surface> surfaces =
                        mConfiguredOutputs.get(resultExtras.getErrorStreamId()).getSurfaces();
                for (Surface surface : surfaces) {
                    if (!request.containsTarget(surface)) {
                        continue;
                    }
                    if (DEBUG) {
                        Log.v(TAG, String.format("Lost output buffer reported for frame %d, target %s",
                            frameNumber, outputSurface));
                                frameNumber, surface));
                    }
                    failureDispatch = new Runnable() {
                        @Override
@@ -1959,11 +1961,14 @@ public class CameraDeviceImpl extends CameraDevice
                                holder.getCallback().onCaptureBufferLost(
                                    CameraDeviceImpl.this,
                                    request,
                                outputSurface,
                                    surface,
                                    frameNumber);
                            }
                        }
                    };
                    // Dispatch the failure callback
                    holder.getHandler().post(failureDispatch);
                }
            } else {
                boolean mayHaveBuffers = (errorCode == ERROR_CAMERA_RESULT);

@@ -2000,12 +2005,13 @@ public class CameraDeviceImpl extends CameraDevice
                }
                mFrameNumberTracker.updateTracker(frameNumber, /*error*/true, request.isReprocess());
                checkAndFireSequenceComplete();
            }

                // Dispatch the failure callback
                holder.getHandler().post(failureDispatch);
            }

        }

    } // public class CameraDeviceCallbacks

    /**
+264 −61

File changed.

Preview size limit exceeded, changes collapsed.