From 81e7689bb168a74c0822846729d992128da97322 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 23 Oct 2022 02:51:10 +0300 Subject: libcamera: stream: Turn StreamRole into scoped enumeration 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/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 efec695a..29235ddf 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 ef0d10d0..1bfeaea4 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 52578207..1dcfcf92 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 87b4057a..9e710a47 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 e51457eb..0c67e35d 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. -- cgit v1.2.1