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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
baf3be12ef
commit
81e7689bb1
5 changed files with 33 additions and 16 deletions
|
@ -62,7 +62,7 @@ private:
|
||||||
StreamFormats formats_;
|
StreamFormats formats_;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum StreamRole {
|
enum class StreamRole {
|
||||||
Raw,
|
Raw,
|
||||||
StillCapture,
|
StillCapture,
|
||||||
VideoRecording,
|
VideoRecording,
|
||||||
|
|
|
@ -488,7 +488,7 @@ int CameraCapabilities::initializeStreamConfigurations()
|
||||||
* \todo Get this from the camera properties once defined
|
* \todo Get this from the camera properties once defined
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<CameraConfiguration> cameraConfig =
|
std::unique_ptr<CameraConfiguration> cameraConfig =
|
||||||
camera_->generateConfiguration({ StillCapture });
|
camera_->generateConfiguration({ StreamRole::StillCapture });
|
||||||
if (!cameraConfig) {
|
if (!cameraConfig) {
|
||||||
LOG(HAL, Error) << "Failed to get maximum resolution";
|
LOG(HAL, Error) << "Failed to get maximum resolution";
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -16,7 +16,12 @@
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };
|
const std::vector<int> NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };
|
||||||
const std::vector<StreamRole> ROLES = { Raw, StillCapture, VideoRecording, Viewfinder };
|
const std::vector<StreamRole> ROLES = {
|
||||||
|
StreamRole::Raw,
|
||||||
|
StreamRole::StillCapture,
|
||||||
|
StreamRole::VideoRecording,
|
||||||
|
StreamRole::Viewfinder
|
||||||
|
};
|
||||||
|
|
||||||
class SingleStream : public testing::TestWithParam<std::tuple<StreamRole, int>>
|
class SingleStream : public testing::TestWithParam<std::tuple<StreamRole, int>>
|
||||||
{
|
{
|
||||||
|
@ -54,10 +59,12 @@ void SingleStream::TearDown()
|
||||||
|
|
||||||
std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)
|
std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)
|
||||||
{
|
{
|
||||||
std::map<StreamRole, std::string> rolesMap = { { Raw, "Raw" },
|
std::map<StreamRole, std::string> rolesMap = {
|
||||||
{ StillCapture, "StillCapture" },
|
{ StreamRole::Raw, "Raw" },
|
||||||
{ VideoRecording, "VideoRecording" },
|
{ StreamRole::StillCapture, "StillCapture" },
|
||||||
{ Viewfinder, "Viewfinder" } };
|
{ StreamRole::VideoRecording, "VideoRecording" },
|
||||||
|
{ StreamRole::Viewfinder, "Viewfinder" }
|
||||||
|
};
|
||||||
|
|
||||||
std::string roleName = rolesMap[std::get<0>(info.param)];
|
std::string roleName = rolesMap[std::get<0>(info.param)];
|
||||||
std::string numRequestsName = std::to_string(std::get<1>(info.param));
|
std::string numRequestsName = std::to_string(std::get<1>(info.param));
|
||||||
|
|
|
@ -54,7 +54,7 @@ gst_libcamera_pad_get_property(GObject *object, guint prop_id, GValue *value,
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_STREAM_ROLE:
|
case PROP_STREAM_ROLE:
|
||||||
g_value_set_enum(value, self->role);
|
g_value_set_enum(value, static_cast<gint>(self->role));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
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 GType type = 0;
|
||||||
static const GEnumValue values[] = {
|
static const GEnumValue values[] = {
|
||||||
{ StillCapture, "libcamera::StillCapture", "still-capture" },
|
{
|
||||||
{ VideoRecording, "libcamera::VideoRecording", "video-recording" },
|
static_cast<gint>(StreamRole::StillCapture),
|
||||||
{ Viewfinder, "libcamera::Viewfinder", "view-finder" },
|
"libcamera::StillCapture",
|
||||||
|
"still-capture",
|
||||||
|
}, {
|
||||||
|
static_cast<gint>(StreamRole::VideoRecording),
|
||||||
|
"libcamera::VideoRecording",
|
||||||
|
"video-recording",
|
||||||
|
}, {
|
||||||
|
static_cast<gint>(StreamRole::Viewfinder),
|
||||||
|
"libcamera::Viewfinder",
|
||||||
|
"view-finder",
|
||||||
|
},
|
||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,7 +120,7 @@ gst_libcamera_pad_class_init(GstLibcameraPadClass *klass)
|
||||||
auto *spec = g_param_spec_enum("stream-role", "Stream Role",
|
auto *spec = g_param_spec_enum("stream-role", "Stream Role",
|
||||||
"The selected stream role",
|
"The selected stream role",
|
||||||
gst_libcamera_stream_role_get_type(),
|
gst_libcamera_stream_role_get_type(),
|
||||||
VideoRecording,
|
static_cast<gint>(StreamRole::VideoRecording),
|
||||||
(GParamFlags)(GST_PARAM_MUTABLE_READY
|
(GParamFlags)(GST_PARAM_MUTABLE_READY
|
||||||
| G_PARAM_CONSTRUCT
|
| G_PARAM_CONSTRUCT
|
||||||
| G_PARAM_READWRITE
|
| G_PARAM_READWRITE
|
||||||
|
|
|
@ -599,7 +599,7 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,
|
||||||
Size size;
|
Size size;
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case StillCapture:
|
case StreamRole::StillCapture:
|
||||||
/*
|
/*
|
||||||
* \todo Make sure the sensor can produce non-RAW formats
|
* \todo Make sure the sensor can produce non-RAW formats
|
||||||
* compatible with the ones supported by the pipeline.
|
* compatible with the ones supported by the pipeline.
|
||||||
|
@ -608,8 +608,8 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,
|
||||||
pixelFormat = formats::YUYV;
|
pixelFormat = formats::YUYV;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Viewfinder:
|
case StreamRole::Viewfinder:
|
||||||
case VideoRecording:
|
case StreamRole::VideoRecording:
|
||||||
/*
|
/*
|
||||||
* \todo Make sure the sensor can produce non-RAW formats
|
* \todo Make sure the sensor can produce non-RAW formats
|
||||||
* compatible with the ones supported by the pipeline.
|
* compatible with the ones supported by the pipeline.
|
||||||
|
@ -618,7 +618,7 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,
|
||||||
pixelFormat = formats::YUYV;
|
pixelFormat = formats::YUYV;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Raw: {
|
case StreamRole::Raw: {
|
||||||
/*
|
/*
|
||||||
* Make sure the sensor can generate a RAW format and
|
* Make sure the sensor can generate a RAW format and
|
||||||
* prefer the ones with a larger bitdepth.
|
* prefer the ones with a larger bitdepth.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue