Loading camera/include/camera/camera2/CaptureRequest.h +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ struct CaptureRequest : public Parcelable { CameraMetadata mMetadata; Vector<sp<Surface> > mSurfaceList; bool mIsReprocess; void* mContext; // arbitrary user context from NDK apps, null for java apps /** * Keep impl up-to-date with CaptureRequest.java in frameworks/base Loading camera/ndk/NdkCaptureRequest.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -142,3 +142,40 @@ void ACaptureRequest_free(ACaptureRequest* request) { delete request; return; } EXPORT camera_status_t ACaptureRequest_setUserContext( ACaptureRequest* request, void* context) { if (request == nullptr) { ALOGE("%s: invalid argument! request is NULL", __FUNCTION__); return ACAMERA_ERROR_INVALID_PARAMETER; } return request->setContext(context); } EXPORT camera_status_t ACaptureRequest_getUserContext( const ACaptureRequest* request, /*out*/void** context) { if (request == nullptr || context == nullptr) { ALOGE("%s: invalid argument! request %p, context %p", __FUNCTION__, request, context); return ACAMERA_ERROR_INVALID_PARAMETER; } return request->getContext(context); } EXPORT ACaptureRequest* ACaptureRequest_copy(const ACaptureRequest* src) { ATRACE_CALL(); if (src == nullptr) { ALOGE("%s: src is null!", __FUNCTION__); return nullptr; } ACaptureRequest* pRequest = new ACaptureRequest(); pRequest->settings = new ACameraMetadata(*(src->settings)); pRequest->targets = new ACameraOutputTargets(); *(pRequest->targets) = *(src->targets); pRequest->context = src->context; return pRequest; } camera/ndk/impl/ACameraDevice.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -372,6 +372,7 @@ CameraDevice::allocateCaptureRequest( sp<CaptureRequest> req(new CaptureRequest()); req->mMetadata = request->settings->getInternalData(); req->mIsReprocess = false; // NDK does not support reprocessing yet req->mContext = request->context; for (auto outputTarget : request->targets->mOutputs) { ANativeWindow* anw = outputTarget.mWindow; Loading @@ -398,6 +399,7 @@ CameraDevice::allocateACaptureRequest(sp<CaptureRequest>& req) { ACameraOutputTarget outputTarget(anw); pRequest->targets->mOutputs.insert(outputTarget); } pRequest->context = req->mContext; return pRequest; } Loading camera/ndk/impl/ACaptureRequest.h +11 −0 Original line number Diff line number Diff line Loading @@ -45,8 +45,19 @@ struct ACameraOutputTargets { }; struct ACaptureRequest { camera_status_t setContext(void* ctx) { context = ctx; return ACAMERA_OK; } camera_status_t getContext(void** ctx) const { *ctx = context; return ACAMERA_OK; } ACameraMetadata* settings; ACameraOutputTargets* targets; void* context; }; #endif // _ACAPTURE_REQUEST_H camera/ndk/include/camera/NdkCaptureRequest.h +52 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,58 @@ void ACaptureRequest_free(ACaptureRequest* request); #endif /* __ANDROID_API__ >= 24 */ #if __ANDROID_API__ >= 28 /** * Associate an arbitrary user context pointer to the {@link ACaptureRequest} * * This method is useful for user to identify the capture request in capture session callbacks. * The context is NULL for newly created request. * {@link ACameraOutputTarget_free} will not free the context. Also calling this method twice * will not cause the previous context be freed. * Also note that calling this method after the request has been sent to capture session will not * change the context pointer in the capture callbacks. * * @param request the {@link ACaptureRequest} of interest. * @param context the user context pointer to be associated with this capture request. * * @return <ul> * <li>{@link ACAMERA_OK} if the method call succeeds.</li> * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL.</li></ul> */ camera_status_t ACaptureRequest_setUserContext( ACaptureRequest* request, void* context); /** * Get the user context pointer of the {@link ACaptureRequest} * * This method is useful for user to identify the capture request in capture session callbacks. * The context is NULL for newly created request. * * @param request the {@link ACaptureRequest} of interest. * @param context the user context pointer of this capture request. * * @return <ul> * <li>{@link ACAMERA_OK} if the method call succeeds.</li> * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL.</li></ul> */ camera_status_t ACaptureRequest_getUserContext( const ACaptureRequest* request, /*out*/void** context); /** * Create a copy of input {@link ACaptureRequest}. * * <p>The returned ACaptureRequest must be freed by the application by {@link ACaptureRequest_free} * after application is done using it.</p> * * @param src the input {@link ACaptureRequest} to be copied. * * @return a valid ACaptureRequest pointer or NULL if the input request cannot be copied. */ ACaptureRequest* ACaptureRequest_copy(const ACaptureRequest* src); #endif /* __ANDROID_API__ >= 28 */ __END_DECLS #endif /* _NDK_CAPTURE_REQUEST_H */ Loading Loading
camera/include/camera/camera2/CaptureRequest.h +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ struct CaptureRequest : public Parcelable { CameraMetadata mMetadata; Vector<sp<Surface> > mSurfaceList; bool mIsReprocess; void* mContext; // arbitrary user context from NDK apps, null for java apps /** * Keep impl up-to-date with CaptureRequest.java in frameworks/base Loading
camera/ndk/NdkCaptureRequest.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -142,3 +142,40 @@ void ACaptureRequest_free(ACaptureRequest* request) { delete request; return; } EXPORT camera_status_t ACaptureRequest_setUserContext( ACaptureRequest* request, void* context) { if (request == nullptr) { ALOGE("%s: invalid argument! request is NULL", __FUNCTION__); return ACAMERA_ERROR_INVALID_PARAMETER; } return request->setContext(context); } EXPORT camera_status_t ACaptureRequest_getUserContext( const ACaptureRequest* request, /*out*/void** context) { if (request == nullptr || context == nullptr) { ALOGE("%s: invalid argument! request %p, context %p", __FUNCTION__, request, context); return ACAMERA_ERROR_INVALID_PARAMETER; } return request->getContext(context); } EXPORT ACaptureRequest* ACaptureRequest_copy(const ACaptureRequest* src) { ATRACE_CALL(); if (src == nullptr) { ALOGE("%s: src is null!", __FUNCTION__); return nullptr; } ACaptureRequest* pRequest = new ACaptureRequest(); pRequest->settings = new ACameraMetadata(*(src->settings)); pRequest->targets = new ACameraOutputTargets(); *(pRequest->targets) = *(src->targets); pRequest->context = src->context; return pRequest; }
camera/ndk/impl/ACameraDevice.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -372,6 +372,7 @@ CameraDevice::allocateCaptureRequest( sp<CaptureRequest> req(new CaptureRequest()); req->mMetadata = request->settings->getInternalData(); req->mIsReprocess = false; // NDK does not support reprocessing yet req->mContext = request->context; for (auto outputTarget : request->targets->mOutputs) { ANativeWindow* anw = outputTarget.mWindow; Loading @@ -398,6 +399,7 @@ CameraDevice::allocateACaptureRequest(sp<CaptureRequest>& req) { ACameraOutputTarget outputTarget(anw); pRequest->targets->mOutputs.insert(outputTarget); } pRequest->context = req->mContext; return pRequest; } Loading
camera/ndk/impl/ACaptureRequest.h +11 −0 Original line number Diff line number Diff line Loading @@ -45,8 +45,19 @@ struct ACameraOutputTargets { }; struct ACaptureRequest { camera_status_t setContext(void* ctx) { context = ctx; return ACAMERA_OK; } camera_status_t getContext(void** ctx) const { *ctx = context; return ACAMERA_OK; } ACameraMetadata* settings; ACameraOutputTargets* targets; void* context; }; #endif // _ACAPTURE_REQUEST_H
camera/ndk/include/camera/NdkCaptureRequest.h +52 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,58 @@ void ACaptureRequest_free(ACaptureRequest* request); #endif /* __ANDROID_API__ >= 24 */ #if __ANDROID_API__ >= 28 /** * Associate an arbitrary user context pointer to the {@link ACaptureRequest} * * This method is useful for user to identify the capture request in capture session callbacks. * The context is NULL for newly created request. * {@link ACameraOutputTarget_free} will not free the context. Also calling this method twice * will not cause the previous context be freed. * Also note that calling this method after the request has been sent to capture session will not * change the context pointer in the capture callbacks. * * @param request the {@link ACaptureRequest} of interest. * @param context the user context pointer to be associated with this capture request. * * @return <ul> * <li>{@link ACAMERA_OK} if the method call succeeds.</li> * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL.</li></ul> */ camera_status_t ACaptureRequest_setUserContext( ACaptureRequest* request, void* context); /** * Get the user context pointer of the {@link ACaptureRequest} * * This method is useful for user to identify the capture request in capture session callbacks. * The context is NULL for newly created request. * * @param request the {@link ACaptureRequest} of interest. * @param context the user context pointer of this capture request. * * @return <ul> * <li>{@link ACAMERA_OK} if the method call succeeds.</li> * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if request is NULL.</li></ul> */ camera_status_t ACaptureRequest_getUserContext( const ACaptureRequest* request, /*out*/void** context); /** * Create a copy of input {@link ACaptureRequest}. * * <p>The returned ACaptureRequest must be freed by the application by {@link ACaptureRequest_free} * after application is done using it.</p> * * @param src the input {@link ACaptureRequest} to be copied. * * @return a valid ACaptureRequest pointer or NULL if the input request cannot be copied. */ ACaptureRequest* ACaptureRequest_copy(const ACaptureRequest* src); #endif /* __ANDROID_API__ >= 28 */ __END_DECLS #endif /* _NDK_CAPTURE_REQUEST_H */ Loading