From patchwork Tue May 9 23:15:43 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: 18612 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 50B7EBE08B for ; Tue, 9 May 2023 23:15:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AC348627DE; Wed, 10 May 2023 01:15:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1683674157; bh=Q5SGRgEPhtMWN2SPPbGsIJpzESVn0Ubfddl+zGF/19Y=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OrFdIu416QWvrW+6/Fz7cIPTf2nBKx0wTQirItudeuWgS0CygcpbinM+Gk+zngfUQ /MAD7G/wyIzLtCj2QXorKxZyI/BEey14uOvblmReg2EJgKChZKxslthxr67uEN6L9v u8CzNwc1c7umXSefnsKq4BN2CCcQNv0FvA8W145FJAAxPzOxoDFnpLLvQrfmbqZeqV EqsYYcpdQnLiaVLdijs3YhovaDpB1CUqmkCTxE134fn98Pls+m/eug78QCx2YRAbYb MbethrufyXkjESLpYQVr4XAp7xDbGmEz+UhSTRlaVGk45vWSp5EQluZtx2GtF/2wMr o6EUc6uIj3UTw== Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F0CF6053A for ; Wed, 10 May 2023 01:15:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="kVgWAThe"; dkim-atps=neutral Date: Tue, 09 May 2023 23:15:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1683674155; x=1683933355; bh=Q8buc6jb6m4PUQwor+bshXFw8BGEUrrnlQorTFHThwg=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=kVgWAThewkxe+tTMOKzQqN4pMskxi6c8Be2beoR17nTaDKG6FnoalKdxbS0uhjGPv nKfv71x9+TnVGA+svxrA9kAa1pxIY9B5m4b7HMiDqbUQApuePMyGcKDIn6mNxhsJMt XJRQHSnpm1k3J+qfftbE0vw8ClYn3wO0h1zysnBQXpFrrJyKnkj7N5tWRMjp+s8U7r CUIf7kqZR+cohWhcfB8zKvuvgpnpH2gPPBNenzek1yYtCpnmuY7WW/yRH+keo5yWfv puB9KzQj6Y3SK0zQDawjAjpGOaB/K1AoL5XBXI6dCUdQBYWnwMJFMT54cB08XqYzwv +X7Z/Xe4NK9aw== To: libcamera-devel@lists.libcamera.org Message-ID: <20230509231542.1123025-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 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 Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- 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, 9 insertions(+), 15 deletions(-) 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..066e397b 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]); + std::vector 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..0f16c038 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]); + std::vector 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..494f778b 100644 --- a/src/gstreamer/gstlibcameraprovider.cpp +++ b/src/gstreamer/gstlibcameraprovider.cpp @@ -6,6 +6,8 @@ * gstlibcameraprovider.c - GStreamer Device Provider */ +#include + #include "gstlibcameraprovider.h" #include @@ -126,11 +128,10 @@ gst_libcamera_device_class_init(GstLibcameraDeviceClass *klass) static GstDevice * gst_libcamera_device_new(const std::shared_ptr &camera) { + static const std::array 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()) { GST_ERROR("Failed to generate a default configuration for %s", name); 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