From patchwork Wed May 3 12:47:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 18599 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 06EDEC0DA4 for ; Wed, 3 May 2023 12:47:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 78257633B4; Wed, 3 May 2023 14:47:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1683118059; bh=TrO8b7WRJpEl8ppiKwLjbH/+KXdK6DYFLIJKEZeJbL8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HyXP8gvQ0Bk80M1M8mmFgKW8Ea+qPTPbEPD3xYxTGqbymqKwvv1EGIF8cJq5kQ7sD zCrMytJWX5G3ZOhosmy45gSc1sPXPOIolrbTk+e/cU5SbN+7bUpSK+ufW0wokxCXyc RB7aKhqkPtHfavj5FV56gg4cd9j1x3uYiHWbqhPpn/33fA7EXXLr1LY11pQ5zthWpz wuor86UXSyFu4YjhYg871IXd9DmusT9cnlG9gx0IkmnddpUUK9URmmBCzRyhgS9I54 yWTehenEvWA17fg843v6aHCJzSlTLsIzYne9FfmJQpNq4wXVwZ0lHCGZ4rvOAoI1KG xmR6CjdZ55V1g== Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 34EC061EAF for ; Wed, 3 May 2023 14:47:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="sotGU6ct"; dkim-atps=neutral Date: Wed, 03 May 2023 12:47:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1683118057; x=1683377257; bh=4AEY4bqh5go4zKoZrbaxXR4nvb2n56GWpUfEisgRh80=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=sotGU6ctzT/aZVEDAadpF+2DTbdqxWkuHzmlAbBxOM0jKnf3xMZ5iLszeAwfhSsrd ZGQkqkEjrthGjxHVdR3+qaJJf7ThGoBpi6oeir+lPg71wxN1DaS9TX7joWuvQTvyPG 6UKT5l9aj4tyi4NyJ3UzCs6rpqYEDVZlenpSuBT3Gsc1Wv5MPwaq1RcB3A1JT04tIp YzhAjQKyvMOw5qCtwNpaiMsZbGh+M5G5lZvu7OWUe1umqsbXnKeGO6QBpk3uugFIbc v3HW6y9+TtYBG334b0V2QeoCDPdHp/l9g0MfNQe3dTo3QKk+MDN2IYEgz+K9xQOKAW FOBIkDs1wNuWg== To: libcamera-devel@lists.libcamera.org Message-ID: <20230503124725.200550-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/2] libcamera: camera: Take span of StreamRole instead of vector X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze_via_libcamera-devel?= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- Documentation/guides/pipeline-handler.rst | 4 ++-- include/libcamera/camera.h | 12 +++++++++++- include/libcamera/internal/pipeline_handler.h | 2 +- src/libcamera/camera.cpp | 2 +- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 4 ++-- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++-- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 ++-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++-- src/libcamera/pipeline/simple/simple.cpp | 4 ++-- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 4 ++-- src/libcamera/pipeline/vimc/vimc.cpp | 4 ++-- src/py/libcamera/py_main.cpp | 5 ++++- 12 files changed, 33 insertions(+), 20 deletions(-) -- 2.40.1 diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index 1acd1812..e08bb72f 100644 --- a/Documentation/guides/pipeline-handler.rst +++ b/Documentation/guides/pipeline-handler.rst @@ -203,7 +203,7 @@ implementations for the overridden class members. PipelineHandlerVivid(CameraManager *manager); CameraConfiguration *generateConfiguration(Camera *camera, - const StreamRoles &roles) override; + Span roles) override; int configure(Camera *camera, CameraConfiguration *config) override; int exportFrameBuffers(Camera *camera, Stream *stream, @@ -223,7 +223,7 @@ implementations for the overridden class members. } CameraConfiguration *PipelineHandlerVivid::generateConfiguration(Camera *camera, - const StreamRoles &roles) + Span roles) { return nullptr; } diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 5bb06584..425fe51b 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 = {}); + + /** + * \overload + */ + 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..aaeb3a9e 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, diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 99683e49..f53fcdfd 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -938,7 +938,7 @@ const std::set &Camera::streams() const * \return A CameraConfiguration if the requested roles can be satisfied, or a * null pointer otherwise. */ -std::unique_ptr Camera::generateConfiguration(const StreamRoles &roles) +std::unique_ptr Camera::generateConfiguration(Span roles) { Private *const d = _d(); diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 449d9012..9bdfff0b 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -104,7 +104,7 @@ public: bool match(DeviceEnumerator *enumerator) override; std::unique_ptr - generateConfiguration(Camera *camera, const StreamRoles &roles) override; + generateConfiguration(Camera *camera, Span roles) override; int configure(Camera *camera, CameraConfiguration *config) override; int exportFrameBuffers(Camera *camera, Stream *stream, @@ -739,7 +739,7 @@ StreamConfiguration PipelineHandlerISI::generateRawConfiguration(Camera *camera) std::unique_ptr PipelineHandlerISI::generateConfiguration(Camera *camera, - const StreamRoles &roles) + Span roles) { ISICameraData *data = cameraData(camera); std::unique_ptr config = diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 355cb0cb..ada8c272 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -135,7 +135,7 @@ public: PipelineHandlerIPU3(CameraManager *manager); std::unique_ptr generateConfiguration(Camera *camera, - const StreamRoles &roles) override; + Span roles) override; int configure(Camera *camera, CameraConfiguration *config) override; int exportFrameBuffers(Camera *camera, Stream *stream, @@ -390,7 +390,7 @@ PipelineHandlerIPU3::PipelineHandlerIPU3(CameraManager *manager) } std::unique_ptr -PipelineHandlerIPU3::generateConfiguration(Camera *camera, const StreamRoles &roles) +PipelineHandlerIPU3::generateConfiguration(Camera *camera, Span roles) { IPU3CameraData *data = cameraData(camera); std::unique_ptr config = diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 00600441..6421eda5 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -367,7 +367,7 @@ public: PipelineHandlerRPi(CameraManager *manager); std::unique_ptr generateConfiguration(Camera *camera, - const StreamRoles &roles) override; + Span roles) override; int configure(Camera *camera, CameraConfiguration *config) override; int exportFrameBuffers(Camera *camera, Stream *stream, @@ -667,7 +667,7 @@ PipelineHandlerRPi::PipelineHandlerRPi(CameraManager *manager) } std::unique_ptr -PipelineHandlerRPi::generateConfiguration(Camera *camera, const StreamRoles &roles) +PipelineHandlerRPi::generateConfiguration(Camera *camera, Span roles) { RPiCameraData *data = cameraData(camera); std::unique_ptr config = diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 8a30fe06..1fdfde7b 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -148,7 +148,7 @@ public: PipelineHandlerRkISP1(CameraManager *manager); std::unique_ptr generateConfiguration(Camera *camera, - const StreamRoles &roles) override; + Span roles) override; int configure(Camera *camera, CameraConfiguration *config) override; int exportFrameBuffers(Camera *camera, Stream *stream, @@ -609,7 +609,7 @@ PipelineHandlerRkISP1::PipelineHandlerRkISP1(CameraManager *manager) std::unique_ptr PipelineHandlerRkISP1::generateConfiguration(Camera *camera, - const StreamRoles &roles) + Span roles) { RkISP1CameraData *data = cameraData(camera); diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index e1f8b989..d6e0758e 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -315,7 +315,7 @@ public: SimplePipelineHandler(CameraManager *manager); std::unique_ptr generateConfiguration(Camera *camera, - const StreamRoles &roles) override; + Span roles) override; int configure(Camera *camera, CameraConfiguration *config) override; int exportFrameBuffers(Camera *camera, Stream *stream, @@ -1043,7 +1043,7 @@ SimplePipelineHandler::SimplePipelineHandler(CameraManager *manager) } std::unique_ptr -SimplePipelineHandler::generateConfiguration(Camera *camera, const StreamRoles &roles) +SimplePipelineHandler::generateConfiguration(Camera *camera, Span roles) { SimpleCameraData *data = cameraData(camera); std::unique_ptr config = diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 277465b7..03935876 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -75,7 +75,7 @@ public: PipelineHandlerUVC(CameraManager *manager); std::unique_ptr generateConfiguration(Camera *camera, - const StreamRoles &roles) override; + Span roles) override; int configure(Camera *camera, CameraConfiguration *config) override; int exportFrameBuffers(Camera *camera, Stream *stream, @@ -180,7 +180,7 @@ PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager) std::unique_ptr PipelineHandlerUVC::generateConfiguration(Camera *camera, - const StreamRoles &roles) + Span roles) { UVCCameraData *data = cameraData(camera); std::unique_ptr config = diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 204f5ad7..49ee949f 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -85,7 +85,7 @@ public: PipelineHandlerVimc(CameraManager *manager); std::unique_ptr generateConfiguration(Camera *camera, - const StreamRoles &roles) override; + Span roles) override; int configure(Camera *camera, CameraConfiguration *config) override; int exportFrameBuffers(Camera *camera, Stream *stream, @@ -191,7 +191,7 @@ PipelineHandlerVimc::PipelineHandlerVimc(CameraManager *manager) std::unique_ptr PipelineHandlerVimc::generateConfiguration(Camera *camera, - const StreamRoles &roles) + Span roles) { VimcCameraData *data = cameraData(camera); std::unique_ptr config = diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index d14e18e2..3f04871f 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -156,7 +156,10 @@ PYBIND11_MODULE(_libcamera, m) }) /* Keep the camera alive, as StreamConfiguration contains a Stream* */ - .def("generate_configuration", &Camera::generateConfiguration, py::keep_alive<0, 1>()) + .def("generate_configuration", [](Camera &self, const std::vector &roles) { + return self.generateConfiguration(roles); + }, py::keep_alive<0, 1>()) + .def("configure", &Camera::configure) .def("create_request", &Camera::createRequest, py::arg("cookie") = 0) From patchwork Wed May 3 12:47:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 18600 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 39DBAC0DA4 for ; Wed, 3 May 2023 12:47:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E9965633A8; Wed, 3 May 2023 14:47:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1683118069; bh=muMmIr3pG6Bpf1aB1ZYXkNTCMMxDFYKnSZlVQaVwvR0=; h=Date:To:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=gceUnlNkoJdsPYP3GG4id4A7fooyfFBV09W8OoEef9jZNzwVrSj3fjYXORLqBMcyT 1deQ5HLbgcJt32MlmDQHLVcWN3LHR9H5xBG6f233nSkMPK2kB6/klk2GiIkcX20/pS dkE2d2SzEYu1nkjtAXLCuzzpmhOKkVH5YRWWSk6JqeU3xamz2m6tFTAUnRFqnUpBl7 YqWSrAMNcICNLMfvYqBvdDHQAh97jKWGOJkRNwdRQCcyTwQsMLr+fTpQqBS4e5ChGP Zfj6gI4dgV5UhrQ9fIeVSReT+82yn1/73E4wPglpiLgycDcQ4p30J7s94MLFo0t7b7 /6uuWgvatl42w== Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E69E2627DE for ; Wed, 3 May 2023 14:47:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="nRj7g2Q2"; dkim-atps=neutral Date: Wed, 03 May 2023 12:47:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1683118066; x=1683377266; bh=QvnxbmHOT4DMMa5+YSlhrUKT9DyTFBq4cP41MvtJMMU=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=nRj7g2Q2JsKqdvSuG7jRbMnP0sVXcMkkUtIcF5zPEnh7tRmY2A/CgQ+FZnT403+hY x+Ej2b8OobVsBpiClGlKiefiSPTGPZMMozwHnFJhNJ2t1/7++Y+EyHWeu/UTZYGktV QC+s8vBLETVWPmflXuxFaHvOE1rQ+MxX8Q7EPMrWsbEY24ya1O7lfJGrU2tonWFqd0 pM5EHkFew60ttPYGza/vIT4uSdLxynEfuTY6yddfZ5x+GkHCOskdj+zVynbzcQvEp7 vA0s3g9+2gbS2pnoWBKbf5WB7yVkFfSfjgXJyegCWFDXnRmh+3R753Csy+Hakmra2U DQDz86Cot2aBQ== To: libcamera-devel@lists.libcamera.org Message-ID: <20230503124725.200550-2-pobrn@protonmail.com> In-Reply-To: <20230503124725.200550-1-pobrn@protonmail.com> References: <20230503124725.200550-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 2/2] libcamera: Remove `StreamRoles` alias X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze_via_libcamera-devel?= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Now that `Camera::generateConfiguration()` takes a `libcamera::Span` of `StreamRole`, remove the `StreamRoles` type, which was an alias to `std::vector`. The removal has two reasons: - it is no longer strictly necessary, - its presence may suggest that that is the preferred (or correct) way to build/pass a list of `StreamRole`. Signed-off-by: Barnabás Pőcze --- include/libcamera/stream.h | 2 -- src/apps/cam/camera_session.cpp | 2 +- src/apps/common/stream_options.cpp | 4 ++-- src/apps/common/stream_options.h | 2 +- src/apps/qcam/main_window.cpp | 2 +- src/gstreamer/gstlibcameraprovider.cpp | 5 ++--- src/gstreamer/gstlibcamerasrc.cpp | 2 +- src/libcamera/stream.cpp | 5 ----- 8 files changed, 8 insertions(+), 16 deletions(-) -- 2.40.1 diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 29235ddf..4e94187d 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -69,8 +69,6 @@ enum class StreamRole { Viewfinder, }; -using StreamRoles = std::vector; - std::ostream &operator<<(std::ostream &out, StreamRole role); class Stream diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index 8fcec630..ecca2a97 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -55,7 +55,7 @@ CameraSession::CameraSession(CameraManager *cm, return; } - StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]); + auto roles = StreamKeyValueParser::roles(options_[OptStream]); std::unique_ptr config = camera_->generateConfiguration(roles); diff --git a/src/apps/common/stream_options.cpp b/src/apps/common/stream_options.cpp index 19dfe051..663b979a 100644 --- a/src/apps/common/stream_options.cpp +++ b/src/apps/common/stream_options.cpp @@ -40,7 +40,7 @@ KeyValueParser::Options StreamKeyValueParser::parse(const char *arguments) return options; } -StreamRoles StreamKeyValueParser::roles(const OptionValue &values) +std::vector StreamKeyValueParser::roles(const OptionValue &values) { /* If no configuration values to examine default to viewfinder. */ if (values.empty()) @@ -48,7 +48,7 @@ StreamRoles StreamKeyValueParser::roles(const OptionValue &values) const std::vector &streamParameters = values.toArray(); - StreamRoles roles; + std::vector roles; for (auto const &value : streamParameters) { /* If a role is invalid default it to viewfinder. */ roles.push_back(parseRole(value.toKeyValues()).value_or(StreamRole::Viewfinder)); diff --git a/src/apps/common/stream_options.h b/src/apps/common/stream_options.h index fe298c84..a5f3bde0 100644 --- a/src/apps/common/stream_options.h +++ b/src/apps/common/stream_options.h @@ -20,7 +20,7 @@ public: KeyValueParser::Options parse(const char *arguments) override; - static libcamera::StreamRoles roles(const OptionValue &values); + static std::vector roles(const OptionValue &values); static int updateConfiguration(libcamera::CameraConfiguration *config, const OptionValue &values); diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp index 680668df..0b123d40 100644 --- a/src/apps/qcam/main_window.cpp +++ b/src/apps/qcam/main_window.cpp @@ -362,7 +362,7 @@ void MainWindow::toggleCapture(bool start) */ int MainWindow::startCapture() { - StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]); + auto roles = StreamKeyValueParser::roles(options_[OptStream]); int ret; /* Verify roles are supported. */ diff --git a/src/gstreamer/gstlibcameraprovider.cpp b/src/gstreamer/gstlibcameraprovider.cpp index 6eb0a0eb..332837e4 100644 --- a/src/gstreamer/gstlibcameraprovider.cpp +++ b/src/gstreamer/gstlibcameraprovider.cpp @@ -126,13 +126,12 @@ gst_libcamera_device_class_init(GstLibcameraDeviceClass *klass) static GstDevice * gst_libcamera_device_new(const std::shared_ptr &camera) { + static const StreamRole roles[] = { StreamRole::VideoRecording }; g_autoptr(GstCaps) caps = gst_caps_new_empty(); const gchar *name = camera->id().c_str(); - StreamRoles roles; - roles.push_back(StreamRole::VideoRecording); std::unique_ptr config = camera->generateConfiguration(roles); - if (!config || config->size() != roles.size()) { + if (!config || config->size() != std::size(roles)) { GST_ERROR("Failed to generate a default configuration for %s", name); return nullptr; } diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index a10cbd4f..46a5400e 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -468,7 +468,7 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, GST_DEBUG_OBJECT(self, "Streaming thread has started"); gint stream_id_num = 0; - StreamRoles roles; + std::vector roles; for (GstPad *srcpad : state->srcpads_) { /* Create stream-id and push stream-start. */ g_autofree gchar *stream_id_intermediate = g_strdup_printf("%i%i", state->group_id_, stream_id_num++); diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 67f30815..272222b7 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -436,11 +436,6 @@ std::ostream &operator<<(std::ostream &out, StreamRole role) return out; } -/** - * \typedef StreamRoles - * \brief A vector of StreamRole - */ - /** * \class Stream * \brief Video stream for a camera