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

Commit 77ad3092 authored by Jayant Chowdhary's avatar Jayant Chowdhary Committed by Android (Google) Code Review
Browse files

Merge "ACameraCaptureSession_setWindowPreparedCallback API council feedback" into udc-dev

parents 47dce1a1 719b4668
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -194,24 +194,19 @@ camera_status_t ACameraCaptureSession_updateSharedOutput(ACameraCaptureSession*

EXPORT
camera_status_t ACameraCaptureSession_setWindowPreparedCallback(
        ACameraCaptureSession* session, ACameraCaptureSession_prepareCallbacks *cb) {
        ACameraCaptureSession* session, void *context,
        ACameraCaptureSession_prepareCallback cb) {
    ATRACE_CALL();
    if (session == nullptr || cb == nullptr) {
        ALOGE("%s: Error: session %p / callback %p is null", __FUNCTION__, session, cb);
        return ACAMERA_ERROR_INVALID_PARAMETER;
    }

    if (cb->reserved0 != nullptr || cb->reserved1 != nullptr) {
         ALOGE("%s: Setting reserved 0 and reserved 1 fields of "
               "ACameraCaptureSession_prepareCallbacks is currently not supported "
               " .They must be set to  null", __FUNCTION__);
        return ACAMERA_ERROR_INVALID_PARAMETER;
    }
    if (session->isClosed()) {
        ALOGE("%s: session %p is already closed", __FUNCTION__, session);
        return ACAMERA_ERROR_SESSION_CLOSED;
    }
    session->setWindowPreparedCallback(cb);
    session->setWindowPreparedCallback(context, cb);
    return ACAMERA_OK;
}

+15 −2
Original line number Diff line number Diff line
@@ -74,6 +74,17 @@ struct ACaptureSessionOutputContainer {
    std::set<ACaptureSessionOutput> mOutputs;
};

/**
 * Capture session state callbacks used in {@link ACameraDevice_setPrepareCallbacks}
 */
typedef struct ACameraCaptureSession_prepareCallbacks {
    /// optional application context. This will be passed in the context
    /// parameter of the {@link onWindowPrepared} callback.
    void*                               context;

    ACameraCaptureSession_prepareCallback onWindowPrepared;
} ACameraCaptureSession_prepareCallbacks;

/**
 * ACameraCaptureSession opaque struct definition
 * Leave outside of android namespace because it's NDK struct
@@ -130,9 +141,11 @@ struct ACameraCaptureSession : public RefBase {

    camera_status_t updateOutputConfiguration(ACaptureSessionOutput *output);

    void setWindowPreparedCallback(ACameraCaptureSession_prepareCallbacks *cb) {
    void setWindowPreparedCallback(void *context,
            ACameraCaptureSession_prepareCallback cb) {
        Mutex::Autolock _l(mSessionLock);
        mPreparedCb = *cb;
        mPreparedCb.context = context;
        mPreparedCb.onWindowPrepared = cb;
    }
    camera_status_t prepare(ACameraWindowType *window);

+21 −30
Original line number Diff line number Diff line
@@ -101,6 +101,20 @@ typedef struct ACameraCaptureSession_stateCallbacks {

/**
 * The definition of camera capture session onWindowPrepared callback.
 *
 * <p>This callback is called when the buffer pre-allocation for an output window Surface is
 * complete. </p>
 *
 * <p>Buffer pre-allocation for an output window is started by
 * {@link ACameraCaptureSession_prepare}
 * call. While allocation is underway, the output must not be used in a capture request.
 * Once this callback is called, the output provided can be used as a target for a
 * capture request. In case of an error during pre-allocation (such as running out of
 * suitable-memory), this callback is still invoked after the error is encountered, though some
 * buffers may not have been successfully pre-allocated.</p>
 *
 * Introduced in API 34.
 *
 * @param context The optional app-provided context pointer that was included in
 *        the {@link ACameraCaptureSession_prepareCallbacks} struct.
 * @param window The window that {@link ACameraCaptureSession_prepare} was called on.
@@ -112,32 +126,6 @@ typedef void (*ACameraCaptureSession_prepareCallback)(
        ACameraWindowType *window,
        ACameraCaptureSession *session);

/**
 * Capture session state callbacks used in {@link ACameraDevice_setPrepareCallbacks}
 */
typedef struct ACameraCaptureSession_prepareCallbacks {
    /// optional application context. This will be passed in the context
    /// parameter of the {@link onWindowPrepared} callback.
    void*                               context;

    /**
     * This callback is called when the buffer pre-allocation for an output window Surface is
     * complete.
     * <p>Buffer pre-allocation for an output window is started by
     * {@link ACameraCaptureSession_prepare}
     * call. While allocation is underway, the output must not be used in a capture request.
     * Once this callback is called, the output provided can be used as a target for a
     * capture request. In case of an error during pre-allocation (such as running out of
     * suitable-memory), this callback is still invoked after the error is encountered, though some
     * buffers may not have been successfully pre-allocated </p>
     */
    ACameraCaptureSession_prepareCallback onWindowPrepared;

    // Reserved for future callback additions, these must be set to nullptr by the client.
    ACameraCaptureSession_prepareCallback reserved0;
    ACameraCaptureSession_prepareCallback reserved1;
} ACameraCaptureSession_prepareCallbacks;

/// Enum for describing error reason in {@link ACameraCaptureFailure}
enum {
    /**
@@ -1033,7 +1021,9 @@ camera_status_t ACameraCaptureSession_logicalCamera_setRepeatingRequestV2(
 * pre-allocation of buffers through the {@link ACameraCaptureSession_prepareWindow} call has
 * completed the pre-allocation of buffers.
 * @param session the ACameraCaptureSession on which ACameraCaptureSession_prepareWindow was called.
 * @param callbacks the callback to be called when the output window's buffer pre-allocation is
 * @param context optional application provided context. This will be passed into the context
 *        parameter of the {@link onWindowPrepared} callback.
 * @param callback the callback to be called when the output window's buffer pre-allocation is
 *        complete.
 * @return <ul><li> {@link ACAMERA_OK} if the method succeeds</li>
 *         <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if session or callbacks is
@@ -1046,7 +1036,8 @@ camera_status_t ACameraCaptureSession_logicalCamera_setRepeatingRequestV2(
 */
camera_status_t ACameraCaptureSession_setWindowPreparedCallback(
    ACameraCaptureSession* session,
    ACameraCaptureSession_prepareCallbacks* callbacks) __INTRODUCED_IN(34);
    void *context,
    ACameraCaptureSession_prepareCallback callback) __INTRODUCED_IN(34);

/**
 *
@@ -1087,7 +1078,7 @@ camera_status_t ACameraCaptureSession_setWindowPreparedCallback(
 * <p>Once allocation is complete, {@link ACameraCaptureSession_prepareCallback#onWindowPrepared}
 * will be invoked with the output provided to this method. Between the prepare call and the
 * {@link ACameraCaptureSession_prepareCallback#onWindowPrepared} call,
 * the output provided to prepare must not be used as a target of a capture qequest submitted
 * the output provided to prepare must not be used as a target of a capture request submitted
 * to this session.</p>
 *
 * <p>{@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY LEGACY}
+3 −3
Original line number Diff line number Diff line
@@ -144,7 +144,8 @@ class CameraHelper {
        }
        if (prepareWindows) {
            // Set window prepared callback
            ACameraCaptureSession_setWindowPreparedCallback(mSession, &mPreparedCb);
            ACameraCaptureSession_setWindowPreparedCallback(mSession, /*context*/this,
                    mPreparedCb);
            // Prepare windows
            for (auto &window : configuredWindows) {
                ret = ACameraCaptureSession_prepareWindow(mSession, window);
@@ -342,8 +343,7 @@ class CameraHelper {
    ACameraDevice_StateCallbacks mDeviceCb{this, nullptr, nullptr};
    ACameraCaptureSession_stateCallbacks mSessionCb{ this, nullptr, nullptr, nullptr};

    ACameraCaptureSession_prepareCallbacks mPreparedCb{
            this, onPreparedCb, /*reserved0*/nullptr, /*reserved1*/nullptr};
    ACameraCaptureSession_prepareCallback mPreparedCb = &onPreparedCb;

    const native_handle_t* mImgReaderAnw = nullptr;  // not owned by us.