libcamera: Remove StreamRoles alias

Now that `Camera::generateConfiguration()` takes a `libcamera::Span`
of `StreamRole`, remove the `StreamRoles` type, which was an alias
to `std::vector<libcamera::StreamRole>`.

The removal has two reasons:
 - it is no longer strictly necessary,
 - its presence may suggest that that is the preferred (or correct)
   way to build/pass a list of `StreamRole`.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
[Kieran: Fix small checkstyle report on roles initialiser]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze 2023-05-09 23:15:43 +00:00 committed by Kieran Bingham
parent 86fa7300fa
commit 26a4b83d1b
8 changed files with 9 additions and 15 deletions

View file

@ -69,8 +69,6 @@ enum class StreamRole {
Viewfinder,
};
using StreamRoles = std::vector<StreamRole>;
std::ostream &operator<<(std::ostream &out, StreamRole role);
class Stream

View file

@ -55,7 +55,7 @@ CameraSession::CameraSession(CameraManager *cm,
return;
}
StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]);
std::vector<StreamRole> roles = StreamKeyValueParser::roles(options_[OptStream]);
std::unique_ptr<CameraConfiguration> config =
camera_->generateConfiguration(roles);

View file

@ -40,7 +40,7 @@ KeyValueParser::Options StreamKeyValueParser::parse(const char *arguments)
return options;
}
StreamRoles StreamKeyValueParser::roles(const OptionValue &values)
std::vector<StreamRole> StreamKeyValueParser::roles(const OptionValue &values)
{
/* If no configuration values to examine default to viewfinder. */
if (values.empty())
@ -48,7 +48,7 @@ StreamRoles StreamKeyValueParser::roles(const OptionValue &values)
const std::vector<OptionValue> &streamParameters = values.toArray();
StreamRoles roles;
std::vector<StreamRole> roles;
for (auto const &value : streamParameters) {
/* If a role is invalid default it to viewfinder. */
roles.push_back(parseRole(value.toKeyValues()).value_or(StreamRole::Viewfinder));

View file

@ -20,7 +20,7 @@ public:
KeyValueParser::Options parse(const char *arguments) override;
static libcamera::StreamRoles roles(const OptionValue &values);
static std::vector<libcamera::StreamRole> roles(const OptionValue &values);
static int updateConfiguration(libcamera::CameraConfiguration *config,
const OptionValue &values);

View file

@ -362,7 +362,7 @@ void MainWindow::toggleCapture(bool start)
*/
int MainWindow::startCapture()
{
StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]);
std::vector<StreamRole> roles = StreamKeyValueParser::roles(options_[OptStream]);
int ret;
/* Verify roles are supported. */

View file

@ -6,6 +6,8 @@
* gstlibcameraprovider.c - GStreamer Device Provider
*/
#include <array>
#include "gstlibcameraprovider.h"
#include <libcamera/camera.h>
@ -141,11 +143,10 @@ gst_libcamera_device_class_init(GstLibcameraDeviceClass *klass)
static GstDevice *
gst_libcamera_device_new(const std::shared_ptr<Camera> &camera)
{
static const std::array roles{ StreamRole::VideoRecording };
g_autoptr(GstCaps) caps = gst_caps_new_empty();
const gchar *name = camera->id().c_str();
StreamRoles roles;
roles.push_back(StreamRole::VideoRecording);
std::unique_ptr<CameraConfiguration> config = camera->generateConfiguration(roles);
if (!config || config->size() != roles.size()) {
GST_ERROR("Failed to generate a default configuration for %s", name);

View file

@ -466,7 +466,7 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,
GST_DEBUG_OBJECT(self, "Streaming thread has started");
gint stream_id_num = 0;
StreamRoles roles;
std::vector<StreamRole> roles;
for (GstPad *srcpad : state->srcpads_) {
/* Create stream-id and push stream-start. */
g_autofree gchar *stream_id_intermediate = g_strdup_printf("%i%i", state->group_id_, stream_id_num++);

View file

@ -436,11 +436,6 @@ std::ostream &operator<<(std::ostream &out, StreamRole role)
return out;
}
/**
* \typedef StreamRoles
* \brief A vector of StreamRole
*/
/**
* \class Stream
* \brief Video stream for a camera