[libcamera-devel] [PATCH 1/2] libcamera: request: Declare a using directive for map of buffers
Kieran Bingham
kieran.bingham at ideasonboard.com
Tue Aug 11 14:58:34 CEST 2020
Hi Niklas,
On 11/08/2020 00:45, Niklas Söderlund wrote:
> Declare a using directive for the map of Stream to FrameBuffer. Update
> all users of Request::buffers() to use the new usage directive.
I like this because it gives a 'named purpose' to the extended template
types that we use, but I know Laurent sometimes prefers to see the
underlying types.
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> include/libcamera/request.h | 6 ++++--
> src/android/camera_device.cpp | 2 +-
> src/cam/capture.cpp | 2 +-
> src/libcamera/request.cpp | 5 +++++
> src/qcam/main_window.h | 4 ++--
> test/camera/buffer_import.cpp | 2 +-
> test/camera/capture.cpp | 2 +-
> 7 files changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/include/libcamera/request.h b/include/libcamera/request.h
> index eded68318b7dbb3c..e74f56a7d6415315 100644
> --- a/include/libcamera/request.h
> +++ b/include/libcamera/request.h
> @@ -31,6 +31,8 @@ public:
> RequestCancelled,
> };
>
> + using BufferMap = std::map<Stream *, FrameBuffer *>;
> +
> Request(Camera *camera, uint64_t cookie = 0);
> Request(const Request &) = delete;
> Request &operator=(const Request &) = delete;
> @@ -38,7 +40,7 @@ public:
>
> ControlList &controls() { return *controls_; }
> ControlList &metadata() { return *metadata_; }
> - const std::map<Stream *, FrameBuffer *> &buffers() const { return bufferMap_; }
> + const BufferMap &buffers() const { return bufferMap_; }
> int addBuffer(Stream *stream, FrameBuffer *buffer);
> FrameBuffer *findBuffer(Stream *stream) const;
>
> @@ -58,7 +60,7 @@ private:
> CameraControlValidator *validator_;
> ControlList *controls_;
> ControlList *metadata_;
> - std::map<Stream *, FrameBuffer *> bufferMap_;
> + BufferMap bufferMap_;
> std::unordered_set<FrameBuffer *> pending_;
>
> const uint64_t cookie_;
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index d9183501228f4642..3419236a061cba57 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1371,7 +1371,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
>
> void CameraDevice::requestComplete(Request *request)
> {
> - const std::map<Stream *, FrameBuffer *> &buffers = request->buffers();
> + const Request::BufferMap &buffers = request->buffers();
> camera3_buffer_status status = CAMERA3_BUFFER_STATUS_OK;
> std::unique_ptr<CameraMetadata> resultMetadata;
> Camera3RequestDescriptor *descriptor =
> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
> index 3d8e89d52c7ab68d..0720376983470f2f 100644
> --- a/src/cam/capture.cpp
> +++ b/src/cam/capture.cpp
> @@ -157,7 +157,7 @@ void Capture::requestComplete(Request *request)
> if (request->status() == Request::RequestCancelled)
> return;
>
> - const std::map<Stream *, FrameBuffer *> &buffers = request->buffers();
> + const Request::BufferMap &buffers = request->buffers();
>
> std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
> double fps = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_).count();
> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
> index f3753514131ae394..d5f11e8c43c32766 100644
> --- a/src/libcamera/request.cpp
> +++ b/src/libcamera/request.cpp
> @@ -37,6 +37,11 @@ LOG_DEFINE_CATEGORY(Request)
> * The request has been cancelled due to capture stop
> */
>
> +/**
> + * \typedef Request::BufferMap
> + * \brief A map of Stream to FrameBuffer pointers
> + */
> +
> /**
> * \class Request
> * \brief A frame capture request
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index 4606fe487ad49777..6e1bcd76a2438b4c 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -47,13 +47,13 @@ public:
> {
> }
>
> - CaptureRequest(const std::map<Stream *, FrameBuffer *> &buffers,
> + CaptureRequest(const Request::BufferMap &buffers,
> const ControlList &metadata)
> : buffers_(buffers), metadata_(metadata)
> {
> }
>
> - std::map<Stream *, FrameBuffer *> buffers_;
> + Request::BufferMap buffers_;
> ControlList metadata_;
> };
>
> diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp
> index 46e03746213912aa..726d2cb2fe757066 100644
> --- a/test/camera/buffer_import.cpp
> +++ b/test/camera/buffer_import.cpp
> @@ -46,7 +46,7 @@ protected:
> if (request->status() != Request::RequestComplete)
> return;
>
> - const std::map<Stream *, FrameBuffer *> &buffers = request->buffers();
> + const Request::BufferMap &buffers = request->buffers();
>
> completeRequestsCount_++;
>
> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp
> index ea84daeef196e349..ae572eb955753151 100644
> --- a/test/camera/capture.cpp
> +++ b/test/camera/capture.cpp
> @@ -39,7 +39,7 @@ protected:
> if (request->status() != Request::RequestComplete)
> return;
>
> - const std::map<Stream *, FrameBuffer *> &buffers = request->buffers();
> + const Request::BufferMap &buffers = request->buffers();
>
> completeRequestsCount_++;
>
>
--
Regards
--
Kieran
More information about the libcamera-devel
mailing list