From patchwork Mon Oct 24 00:03:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17670 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 E51F1C3288 for ; Mon, 24 Oct 2022 00:04:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 428DF62EFB; Mon, 24 Oct 2022 02:04:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666569876; bh=k92pDEMlNvueNxJ8zWmi/V9ZAkb7fwWyqiJALyBlU/A=; 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=P1GF471sa4HehrPlYudma2RPzxh11tSDZZKBOnjaPazFN7q6Qlm7T6lcii8odDe9L w3a8d4jKZIuR+F0eJqaDq3q4mfvQ5MUoQBONZbvJLMEZ+TR/sWDazKGFAgojp4GRTq Q8arz7lfTLAB1jI8NcVu2IGLJoN0oSXlsC2vHQUI11KDVDWpJPe6Hsn0pF83nZWYLa VAQRILkv0IhmQOvZBSgrUi2BHfFrb/r6KAwpyNhnCkLWOMWIh7Mru0xkNwwnbRSpGe jQhilTXRpxgXM6xoX6cQbmt83eXcPPqXArjL1rsNSoicSp8ZRItU9ySbzocpGgSRCn QDjCLi5fdc3TA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2486862ED2 for ; Mon, 24 Oct 2022 02:04:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fiFW0fhN"; 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 AD78688F; Mon, 24 Oct 2022 02:04:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1666569870; bh=k92pDEMlNvueNxJ8zWmi/V9ZAkb7fwWyqiJALyBlU/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fiFW0fhNZEW+GFkfCITCNr/kiKOrAFin6i/h2mLJ1NfKnFnIhL3bE5byEyooWKGAE zlWh8Ya8v+F4QUGBDNRhUmZ8psmIOLZL4zuV8thQreMgWO4T8JPhx6UFTIxJlr67sl vp9/fgLQFhn1FJPJM03CiJyt1d82FIesJ7FNfg2k= To: libcamera-devel@lists.libcamera.org Date: Mon, 24 Oct 2022 03:03:50 +0300 Message-Id: <20221024000356.29521-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221024000356.29521-1-laurent.pinchart@ideasonboard.com> References: <20221024000356.29521-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 07/13] 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 --- include/libcamera/stream.h | 2 +- src/apps/lc-compliance/capture_test.cpp | 17 ++++++++++++----- src/gstreamer/gstlibcamerapad.cpp | 20 +++++++++++++++----- 3 files changed, 28 insertions(+), 11 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/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