From patchwork Thu Nov 24 02:51:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17853 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 A75E9BDE6B for ; Thu, 24 Nov 2022 02:51:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6547A63324; Thu, 24 Nov 2022 03:51:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669258316; bh=vUHwcxJAScu2Sbdsm+MFseawJOtM3gYrdpvjCuCcBCw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Yn0SQPhjVooukbxkRKUCLRkTyt0hGbsVoF5qodcMM6EO9KU6NxQU5MvbQree5QtjC u6zuk9f8NQmA3lYqIh8RyrmD8SIh2snfn/My7Pgd+gDRouFeMPF3n74GbxoqhS1Qmn 9DuN8CfCoo1uMbz8E1D74y2yeLfP0MA3lovBvPrDR4C9+PzgZ7OELiqq6qC1YyckH7 JGSxXT0y1oQXSNJ/hNg1s8dKkD19gutfwvgaMX0NQLlFmnT1zRfByyD0slBaMKb2wg LzCwPNWLu/0EKLCbNOzApiPZGBVf1GORbCojrlnaSPnU+qTU1bKbimDHVilIFiuTZX bIHMdsfqXySZQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C9AB63316 for ; Thu, 24 Nov 2022 03:51:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="heQkZ3z3"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 90D09496 for ; Thu, 24 Nov 2022 03:51:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669258312; bh=vUHwcxJAScu2Sbdsm+MFseawJOtM3gYrdpvjCuCcBCw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=heQkZ3z3V1RbKLJelwM9mH2P/Qbhhp9VJEd/IGjnouj7D3ugSdUJybxSOfRAoz5EA nq6TMXdEEzohqeRu6gO+61okhmZW1u4T3crecz1nSpRUyNZSypBl65aqmW65REasIw k6+U0OmLwE+lbY6/Fn6hEDbozBM/gYUSL56nmUCw= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 04:51:26 +0200 Message-Id: <20221124025133.17875-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221124025133.17875-1-laurent.pinchart@ideasonboard.com> References: <20221124025133.17875-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/9] libcamera: stream: Turn StreamRole into scoped enumeration 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The StreamRole enum has enumerators such as 'Raw' that are too generic to be in the global libcamera namespace. Turn it into a scoped enum to avoid namespace clashes, and update users accordingly. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Jacopo Mondi --- Changes since v3: - Address imx8-isi pipeline handler --- include/libcamera/stream.h | 2 +- src/android/camera_capabilities.cpp | 2 +- src/apps/lc-compliance/capture_test.cpp | 17 ++++++++++++----- src/gstreamer/gstlibcamerapad.cpp | 20 +++++++++++++++----- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 8 ++++---- 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index efec695ad317..29235ddf0d8a 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -62,7 +62,7 @@ private: StreamFormats formats_; }; -enum StreamRole { +enum class StreamRole { Raw, StillCapture, VideoRecording, diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index ef0d10d08fbd..1bfeaea4b121 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -488,7 +488,7 @@ int CameraCapabilities::initializeStreamConfigurations() * \todo Get this from the camera properties once defined */ std::unique_ptr cameraConfig = - camera_->generateConfiguration({ StillCapture }); + camera_->generateConfiguration({ StreamRole::StillCapture }); if (!cameraConfig) { LOG(HAL, Error) << "Failed to get maximum resolution"; return -EINVAL; diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index 52578207c11f..1dcfcf92fc8c 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -16,7 +16,12 @@ using namespace libcamera; const std::vector NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; -const std::vector ROLES = { Raw, StillCapture, VideoRecording, Viewfinder }; +const std::vector ROLES = { + StreamRole::Raw, + StreamRole::StillCapture, + StreamRole::VideoRecording, + StreamRole::Viewfinder +}; class SingleStream : public testing::TestWithParam> { @@ -54,10 +59,12 @@ void SingleStream::TearDown() std::string SingleStream::nameParameters(const testing::TestParamInfo &info) { - std::map rolesMap = { { Raw, "Raw" }, - { StillCapture, "StillCapture" }, - { VideoRecording, "VideoRecording" }, - { Viewfinder, "Viewfinder" } }; + std::map rolesMap = { + { StreamRole::Raw, "Raw" }, + { StreamRole::StillCapture, "StillCapture" }, + { StreamRole::VideoRecording, "VideoRecording" }, + { StreamRole::Viewfinder, "Viewfinder" } + }; std::string roleName = rolesMap[std::get<0>(info.param)]; std::string numRequestsName = std::to_string(std::get<1>(info.param)); diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp index 87b4057ac101..9e710a479368 100644 --- a/src/gstreamer/gstlibcamerapad.cpp +++ b/src/gstreamer/gstlibcamerapad.cpp @@ -54,7 +54,7 @@ gst_libcamera_pad_get_property(GObject *object, guint prop_id, GValue *value, switch (prop_id) { case PROP_STREAM_ROLE: - g_value_set_enum(value, self->role); + g_value_set_enum(value, static_cast(self->role)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -87,9 +87,19 @@ gst_libcamera_stream_role_get_type() { static GType type = 0; static const GEnumValue values[] = { - { StillCapture, "libcamera::StillCapture", "still-capture" }, - { VideoRecording, "libcamera::VideoRecording", "video-recording" }, - { Viewfinder, "libcamera::Viewfinder", "view-finder" }, + { + static_cast(StreamRole::StillCapture), + "libcamera::StillCapture", + "still-capture", + }, { + static_cast(StreamRole::VideoRecording), + "libcamera::VideoRecording", + "video-recording", + }, { + static_cast(StreamRole::Viewfinder), + "libcamera::Viewfinder", + "view-finder", + }, { 0, NULL, NULL } }; @@ -110,7 +120,7 @@ gst_libcamera_pad_class_init(GstLibcameraPadClass *klass) auto *spec = g_param_spec_enum("stream-role", "Stream Role", "The selected stream role", gst_libcamera_stream_role_get_type(), - VideoRecording, + static_cast(StreamRole::VideoRecording), (GParamFlags)(GST_PARAM_MUTABLE_READY | G_PARAM_CONSTRUCT | G_PARAM_READWRITE diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index e51457ebc345..0c67e35dde73 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -599,7 +599,7 @@ PipelineHandlerISI::generateConfiguration(Camera *camera, Size size; switch (role) { - case StillCapture: + case StreamRole::StillCapture: /* * \todo Make sure the sensor can produce non-RAW formats * compatible with the ones supported by the pipeline. @@ -608,8 +608,8 @@ PipelineHandlerISI::generateConfiguration(Camera *camera, pixelFormat = formats::YUYV; break; - case Viewfinder: - case VideoRecording: + case StreamRole::Viewfinder: + case StreamRole::VideoRecording: /* * \todo Make sure the sensor can produce non-RAW formats * compatible with the ones supported by the pipeline. @@ -618,7 +618,7 @@ PipelineHandlerISI::generateConfiguration(Camera *camera, pixelFormat = formats::YUYV; break; - case Raw: { + case StreamRole::Raw: { /* * Make sure the sensor can generate a RAW format and * prefer the ones with a larger bitdepth.