From 86fa7300fa915060e25257b41d8ebb514dd55435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Tue, 9 May 2023 23:07:57 +0000 Subject: libcamera: camera: Take span of StreamRole instead of vector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the parameter type of `generateConfiguration()` from `const std::vector&` to `libcamera::Span`. A span is almost always preferable to a const vector ref because it does not force dynamic allocation when none are needed, and it allows any contiguous container to be used. A new overload is added that accepts an initializer list so that cam->generateConfiguration({ ... }) keeps working. There is no API break since a span can be constructed from a vector and the initializer list overload takes care of the initializer lists, but this change causes an ABI break. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart [Kieran: Apply checkstyle fixups] Signed-off-by: Kieran Bingham --- include/libcamera/camera.h | 12 +++++++++++- include/libcamera/internal/pipeline_handler.h | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 5bb06584..004bc894 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -105,7 +106,16 @@ public: const ControlList &properties() const; const std::set &streams() const; - std::unique_ptr generateConfiguration(const StreamRoles &roles = {}); + + std::unique_ptr + generateConfiguration(Span roles = {}); + + std::unique_ptr + generateConfiguration(std::initializer_list roles) + { + return generateConfiguration(Span(roles.begin(), roles.end())); + } + int configure(CameraConfiguration *config); std::unique_ptr createRequest(uint64_t cookie = 0); diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 4c4dfe62..c96944f4 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -49,7 +49,7 @@ public: void release(Camera *camera); virtual std::unique_ptr generateConfiguration(Camera *camera, - const StreamRoles &roles) = 0; + Span roles) = 0; virtual int configure(Camera *camera, CameraConfiguration *config) = 0; virtual int exportFrameBuffers(Camera *camera, Stream *stream, -- cgit v1.2.1