{"id":17853,"url":"https://patchwork.libcamera.org/api/1.1/patches/17853/?format=json","web_url":"https://patchwork.libcamera.org/patch/17853/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20221124025133.17875-3-laurent.pinchart@ideasonboard.com>","date":"2022-11-24T02:51:26","name":"[libcamera-devel,v4,2/9] libcamera: stream: Turn StreamRole into scoped enumeration","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4911f9a1d546d8c635671b95a9c8a15f58f5a841","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17853/mbox/","series":[{"id":3634,"url":"https://patchwork.libcamera.org/api/1.1/series/3634/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3634","date":"2022-11-24T02:51:24","name":"Add Bayer format support for RkISP1","version":4,"mbox":"https://patchwork.libcamera.org/series/3634/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17853/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17853/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A75E9BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 02:51:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6547A63324;\n\tThu, 24 Nov 2022 03:51:56 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C9AB63316\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 03:51:53 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 90D09496\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 03:51:52 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669258316;\n\tbh=vUHwcxJAScu2Sbdsm+MFseawJOtM3gYrdpvjCuCcBCw=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Yn0SQPhjVooukbxkRKUCLRkTyt0hGbsVoF5qodcMM6EO9KU6NxQU5MvbQree5QtjC\n\tu6zuk9f8NQmA3lYqIh8RyrmD8SIh2snfn/My7Pgd+gDRouFeMPF3n74GbxoqhS1Qmn\n\t9DuN8CfCoo1uMbz8E1D74y2yeLfP0MA3lovBvPrDR4C9+PzgZ7OELiqq6qC1YyckH7\n\tJGSxXT0y1oQXSNJ/hNg1s8dKkD19gutfwvgaMX0NQLlFmnT1zRfByyD0slBaMKb2wg\n\tLzCwPNWLu/0EKLCbNOzApiPZGBVf1GORbCojrlnaSPnU+qTU1bKbimDHVilIFiuTZX\n\tbIHMdsfqXySZQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669258312;\n\tbh=vUHwcxJAScu2Sbdsm+MFseawJOtM3gYrdpvjCuCcBCw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=heQkZ3z3V1RbKLJelwM9mH2P/Qbhhp9VJEd/IGjnouj7D3ugSdUJybxSOfRAoz5EA\n\tnq6TMXdEEzohqeRu6gO+61okhmZW1u4T3crecz1nSpRUyNZSypBl65aqmW65REasIw\n\tk6+U0OmLwE+lbY6/Fn6hEDbozBM/gYUSL56nmUCw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"heQkZ3z3\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 2/9] libcamera: stream: Turn StreamRole\n\tinto scoped enumeration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The StreamRole enum has enumerators such as 'Raw' that are too generic\nto be in the global libcamera namespace. Turn it into a scoped enum to\navoid namespace clashes, and update users accordingly.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges since v3:\n\n- Address imx8-isi pipeline handler\n---\n include/libcamera/stream.h                   |  2 +-\n src/android/camera_capabilities.cpp          |  2 +-\n src/apps/lc-compliance/capture_test.cpp      | 17 ++++++++++++-----\n src/gstreamer/gstlibcamerapad.cpp            | 20 +++++++++++++++-----\n src/libcamera/pipeline/imx8-isi/imx8-isi.cpp |  8 ++++----\n 5 files changed, 33 insertions(+), 16 deletions(-)","diff":"diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\nindex efec695ad317..29235ddf0d8a 100644\n--- a/include/libcamera/stream.h\n+++ b/include/libcamera/stream.h\n@@ -62,7 +62,7 @@ private:\n \tStreamFormats formats_;\n };\n \n-enum StreamRole {\n+enum class StreamRole {\n \tRaw,\n \tStillCapture,\n \tVideoRecording,\ndiff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp\nindex ef0d10d08fbd..1bfeaea4b121 100644\n--- a/src/android/camera_capabilities.cpp\n+++ b/src/android/camera_capabilities.cpp\n@@ -488,7 +488,7 @@ int CameraCapabilities::initializeStreamConfigurations()\n \t * \\todo Get this from the camera properties once defined\n \t */\n \tstd::unique_ptr<CameraConfiguration> cameraConfig =\n-\t\tcamera_->generateConfiguration({ StillCapture });\n+\t\tcamera_->generateConfiguration({ StreamRole::StillCapture });\n \tif (!cameraConfig) {\n \t\tLOG(HAL, Error) << \"Failed to get maximum resolution\";\n \t\treturn -EINVAL;\ndiff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp\nindex 52578207c11f..1dcfcf92fc8c 100644\n--- a/src/apps/lc-compliance/capture_test.cpp\n+++ b/src/apps/lc-compliance/capture_test.cpp\n@@ -16,7 +16,12 @@\n using namespace libcamera;\n \n const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };\n-const std::vector<StreamRole> ROLES = { Raw, StillCapture, VideoRecording, Viewfinder };\n+const std::vector<StreamRole> ROLES = {\n+\tStreamRole::Raw,\n+\tStreamRole::StillCapture,\n+\tStreamRole::VideoRecording,\n+\tStreamRole::Viewfinder\n+};\n \n class SingleStream : public testing::TestWithParam<std::tuple<StreamRole, int>>\n {\n@@ -54,10 +59,12 @@ void SingleStream::TearDown()\n \n std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)\n {\n-\tstd::map<StreamRole, std::string> rolesMap = { { Raw, \"Raw\" },\n-\t\t\t\t\t\t       { StillCapture, \"StillCapture\" },\n-\t\t\t\t\t\t       { VideoRecording, \"VideoRecording\" },\n-\t\t\t\t\t\t       { Viewfinder, \"Viewfinder\" } };\n+\tstd::map<StreamRole, std::string> rolesMap = {\n+\t\t{ StreamRole::Raw, \"Raw\" },\n+\t\t{ StreamRole::StillCapture, \"StillCapture\" },\n+\t\t{ StreamRole::VideoRecording, \"VideoRecording\" },\n+\t\t{ StreamRole::Viewfinder, \"Viewfinder\" }\n+\t};\n \n \tstd::string roleName = rolesMap[std::get<0>(info.param)];\n \tstd::string numRequestsName = std::to_string(std::get<1>(info.param));\ndiff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp\nindex 87b4057ac101..9e710a479368 100644\n--- a/src/gstreamer/gstlibcamerapad.cpp\n+++ b/src/gstreamer/gstlibcamerapad.cpp\n@@ -54,7 +54,7 @@ gst_libcamera_pad_get_property(GObject *object, guint prop_id, GValue *value,\n \n \tswitch (prop_id) {\n \tcase PROP_STREAM_ROLE:\n-\t\tg_value_set_enum(value, self->role);\n+\t\tg_value_set_enum(value, static_cast<gint>(self->role));\n \t\tbreak;\n \tdefault:\n \t\tG_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);\n@@ -87,9 +87,19 @@ gst_libcamera_stream_role_get_type()\n {\n \tstatic GType type = 0;\n \tstatic const GEnumValue values[] = {\n-\t\t{ StillCapture, \"libcamera::StillCapture\", \"still-capture\" },\n-\t\t{ VideoRecording, \"libcamera::VideoRecording\", \"video-recording\" },\n-\t\t{ Viewfinder, \"libcamera::Viewfinder\", \"view-finder\" },\n+\t\t{\n+\t\t\tstatic_cast<gint>(StreamRole::StillCapture),\n+\t\t\t\"libcamera::StillCapture\",\n+\t\t\t\"still-capture\",\n+\t\t}, {\n+\t\t\tstatic_cast<gint>(StreamRole::VideoRecording),\n+\t\t\t\"libcamera::VideoRecording\",\n+\t\t\t\"video-recording\",\n+\t\t}, {\n+\t\t\tstatic_cast<gint>(StreamRole::Viewfinder),\n+\t\t\t\"libcamera::Viewfinder\",\n+\t\t\t\"view-finder\",\n+\t\t},\n \t\t{ 0, NULL, NULL }\n \t};\n \n@@ -110,7 +120,7 @@ gst_libcamera_pad_class_init(GstLibcameraPadClass *klass)\n \tauto *spec = g_param_spec_enum(\"stream-role\", \"Stream Role\",\n \t\t\t\t       \"The selected stream role\",\n \t\t\t\t       gst_libcamera_stream_role_get_type(),\n-\t\t\t\t       VideoRecording,\n+\t\t\t\t       static_cast<gint>(StreamRole::VideoRecording),\n \t\t\t\t       (GParamFlags)(GST_PARAM_MUTABLE_READY\n \t\t\t\t\t             | G_PARAM_CONSTRUCT\n \t\t\t\t\t\t     | G_PARAM_READWRITE\ndiff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\nindex e51457ebc345..0c67e35dde73 100644\n--- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n+++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n@@ -599,7 +599,7 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,\n \t\tSize size;\n \n \t\tswitch (role) {\n-\t\tcase StillCapture:\n+\t\tcase StreamRole::StillCapture:\n \t\t\t/*\n \t\t\t * \\todo Make sure the sensor can produce non-RAW formats\n \t\t\t * compatible with the ones supported by the pipeline.\n@@ -608,8 +608,8 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,\n \t\t\tpixelFormat = formats::YUYV;\n \t\t\tbreak;\n \n-\t\tcase Viewfinder:\n-\t\tcase VideoRecording:\n+\t\tcase StreamRole::Viewfinder:\n+\t\tcase StreamRole::VideoRecording:\n \t\t\t/*\n \t\t\t * \\todo Make sure the sensor can produce non-RAW formats\n \t\t\t * compatible with the ones supported by the pipeline.\n@@ -618,7 +618,7 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,\n \t\t\tpixelFormat = formats::YUYV;\n \t\t\tbreak;\n \n-\t\tcase Raw: {\n+\t\tcase StreamRole::Raw: {\n \t\t\t/*\n \t\t\t * Make sure the sensor can generate a RAW format and\n \t\t\t * prefer the ones with a larger bitdepth.\n","prefixes":["libcamera-devel","v4","2/9"]}