Loading camera/ndk/NdkCameraCaptureSession.cpp +3 −8 Original line number Diff line number Diff line Loading @@ -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; } Loading camera/ndk/impl/ACameraCaptureSession.h +15 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); Loading camera/ndk/include/camera/NdkCameraCaptureSession.h +21 −30 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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 { /** Loading Loading @@ -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 Loading @@ -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); /** * Loading Loading @@ -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} Loading camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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. Loading Loading
camera/ndk/NdkCameraCaptureSession.cpp +3 −8 Original line number Diff line number Diff line Loading @@ -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; } Loading
camera/ndk/impl/ACameraCaptureSession.h +15 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); Loading
camera/ndk/include/camera/NdkCameraCaptureSession.h +21 −30 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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 { /** Loading Loading @@ -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 Loading @@ -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); /** * Loading Loading @@ -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} Loading
camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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. Loading