[{"id":25529,"web_url":"https://patchwork.libcamera.org/comment/25529/","msgid":"<20221024074150.GA3874866@pyrite.rasen.tech>","date":"2022-10-24T07:41:50","subject":"Re: [libcamera-devel] [PATCH v3 07/13] libcamera: stream: Turn\n\tStreamRole into scoped enumeration","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"On Mon, Oct 24, 2022 at 03:03:50AM +0300, Laurent Pinchart wrote:\n> The StreamRole enum has enumerators such as 'Raw' that are too generic\n> to be in the global libcamera namespace. Turn it into a scoped enum to\n> avoid namespace clashes, and update users accordingly.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  include/libcamera/stream.h              |  2 +-\n>  src/apps/lc-compliance/capture_test.cpp | 17 ++++++++++++-----\n>  src/gstreamer/gstlibcamerapad.cpp       | 20 +++++++++++++++-----\n>  3 files changed, 28 insertions(+), 11 deletions(-)\n> \n> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> index 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,\n> diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp\n> index 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));\n> diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp\n> index 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\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 7316FBDB16\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Oct 2022 07:42:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1CFF062EED;\n\tMon, 24 Oct 2022 09:42:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E4CA662EBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Oct 2022 09:41:58 +0200 (CEST)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 227EB471;\n\tMon, 24 Oct 2022 09:41:56 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666597320;\n\tbh=SxdsqlcrdjTTRCpfcWwvy73Qd9CAB8nwpvX2GYHgSTc=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Zd28X5NCRQLfwKoe9Lb70EgwtIrwq9wc2Q02m9Jl3559isiKHnB2+tWhNwU7ELjGi\n\txM59044dLiq+0BdAeCCbYA2wH7Lb5w0zYsLjFDERhz3Egjy3faxzhhp9OYQJAIJsqF\n\t/jNKdSOCjyDU/w0gDV3xu1OTK9InOi9DQO5oGWG7ixKMGBVns6eznWvyq9iMBaw0ga\n\tqfH2ZaK3X5HWjDtm2IDtNYm1Jw92REB6Z0vyu2vJ/5x6fnl0j1kp3VpSP6G9KDjUYV\n\tFQrGFqGYNcq9W3Y/2lam+PnSyxyuA514dxtdfA3+b/Eb2HM3VoMk2T1u5tAxfvAcqu\n\trEnyWQt6NKvPg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666597318;\n\tbh=SxdsqlcrdjTTRCpfcWwvy73Qd9CAB8nwpvX2GYHgSTc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Tw6d+JxCJcZ99P8UX7dXY480CpyQRRm2hrmOv1QG55XTYwMGYVg65nqd82UUOqGYn\n\tfNBPBTtJONYTe+6yiPMtbhn+RyAjkpyHLQaBPKcIVe0DH4Vig9X8PUg0AwKQA7SfiV\n\tzsb3xP9UVk7LC+aU9OH262lhdAff1KxgONJS5+z0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Tw6d+JxC\"; dkim-atps=neutral","Date":"Mon, 24 Oct 2022 16:41:50 +0900","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20221024074150.GA3874866@pyrite.rasen.tech>","References":"<20221024000356.29521-1-laurent.pinchart@ideasonboard.com>\n\t<20221024000356.29521-8-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20221024000356.29521-8-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 07/13] libcamera: stream: Turn\n\tStreamRole into 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":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":25603,"web_url":"https://patchwork.libcamera.org/comment/25603/","msgid":"<20221026150939.rovf73z27k2vh2u5@uno.localdomain>","date":"2022-10-26T15:09:39","subject":"Re: [libcamera-devel] [PATCH v3 07/13] libcamera: stream: Turn\n\tStreamRole into scoped enumeration","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent\n\nOn Mon, Oct 24, 2022 at 03:03:50AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> The StreamRole enum has enumerators such as 'Raw' that are too generic\n> to be in the global libcamera namespace. Turn it into a scoped enum to\n> avoid namespace clashes, and update users accordingly.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n> ---\n>  include/libcamera/stream.h              |  2 +-\n>  src/apps/lc-compliance/capture_test.cpp | 17 ++++++++++++-----\n>  src/gstreamer/gstlibcamerapad.cpp       | 20 +++++++++++++++-----\n>  3 files changed, 28 insertions(+), 11 deletions(-)\n>\n> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> index 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,\n> diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp\n> index 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));\n> diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp\n> index 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\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","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 D0DC8BDB16\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Oct 2022 15:09:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3412462F59;\n\tWed, 26 Oct 2022 17:09:44 +0200 (CEST)","from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::226])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6548B61F4B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Oct 2022 17:09:42 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id D760EC0004;\n\tWed, 26 Oct 2022 15:09:41 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666796984;\n\tbh=4FDJeENn9tQlS2q2DEEoxG9zstXtbt7quvXBdI4ZQkU=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Ifb2Rn7KPNEQ/4RVBSVALBG/lmBR4qL8IjfR9PX1SfMkNdEnpDuDLUMix3ajQDD7t\n\tOwlV0HEx16dOsuRj7nl707JYs/V3GUspOVo4UewnxOrGEoi8oqMba+yEXLPkRMJuEZ\n\tflNELsv5K+i+HfnYhiix4C/LfrHfmtr50WASEPEfDXpvnBbxtuhu3uyGRk8rU1ZXGA\n\tec3To6624ArIhYyhSOACfxyy80KbIGX/Jor+S1Z8VBtRtg5sSXGAdfcWNvFJsuEevU\n\tCBQGcZLw6vBEOSOjKHXSTM4d6PY1EbfS47mXMe6Qp7CYptSOJ5rnjG1rD57j7rZIZr\n\thWdv7bsn/G+TA==","Date":"Wed, 26 Oct 2022 17:09:39 +0200","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20221026150939.rovf73z27k2vh2u5@uno.localdomain>","References":"<20221024000356.29521-1-laurent.pinchart@ideasonboard.com>\n\t<20221024000356.29521-8-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20221024000356.29521-8-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 07/13] libcamera: stream: Turn\n\tStreamRole into 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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]