summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cam/main.cpp3
-rw-r--r--src/libcamera/camera.cpp30
-rw-r--r--src/libcamera/include/pipeline_handler.h2
-rw-r--r--src/libcamera/pipeline/ipu3/ipu3.cpp4
-rw-r--r--src/libcamera/pipeline/uvcvideo.cpp6
-rw-r--r--src/libcamera/pipeline/vimc.cpp6
-rw-r--r--src/libcamera/pipeline_handler.cpp10
-rw-r--r--src/qcam/main_window.cpp5
8 files changed, 25 insertions, 41 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index b5895fae..d45ffd37 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -80,8 +80,7 @@ static int parseOptions(int argc, char *argv[])
static int prepareCameraConfig(std::map<Stream *, StreamConfiguration> *config)
{
- std::set<Stream *> streams = camera->streams();
- *config = camera->streamConfiguration(streams);
+ *config = camera->streamConfiguration({ Stream::VideoRecording() });
Stream *stream = config->begin()->first;
if (options.isSet(OptFormat)) {
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 8ee9cc08..63fde0ff 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -345,33 +345,23 @@ const std::set<Stream *> &Camera::streams() const
}
/**
- * \brief Retrieve a group of stream configurations
- * \param[in] streams A map of stream IDs and configurations to setup
+ * \brief Retrieve a group of stream configurations according to stream usages
+ * \param[in] usages A list of stream usages
*
- * Retrieve the camera's configuration for a specified group of streams. The
- * caller can specifies which of the camera's streams to retrieve configuration
- * from by populating \a streams.
+ * Retrieve configuration for a set of desired usages. The caller specifies a
+ * list of stream usages and the camera returns a map of suitable streams and
+ * their suggested default configurations.
*
- * The easiest way to populate the array of streams to fetch configuration from
- * is to first retrieve the camera's full array of stream with streams() and
- * then potentially trim it down to only contain the streams the caller
- * are interested in.
- *
- * \return A map of successfully retrieved stream IDs and configurations or an
- * empty list on error.
+ * \return A map of streams to configurations if the requested usages can be
+ * satisfied, or an empty map otherwise
*/
std::map<Stream *, StreamConfiguration>
-Camera::streamConfiguration(std::set<Stream *> &streams)
+Camera::streamConfiguration(const std::vector<StreamUsage> &usages)
{
- if (disconnected_ || !streams.size())
+ if (disconnected_ || !usages.size() || usages.size() > streams_.size())
return std::map<Stream *, StreamConfiguration>{};
- for (Stream *stream : streams) {
- if (streams_.find(stream) == streams_.end())
- return std::map<Stream *, StreamConfiguration>{};
- }
-
- return pipe_->streamConfiguration(this, streams);
+ return pipe_->streamConfiguration(this, usages);
}
/**
diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
index acb376e0..8a1706fa 100644
--- a/src/libcamera/include/pipeline_handler.h
+++ b/src/libcamera/include/pipeline_handler.h
@@ -53,7 +53,7 @@ public:
virtual bool match(DeviceEnumerator *enumerator) = 0;
virtual std::map<Stream *, StreamConfiguration>
- streamConfiguration(Camera *camera, std::set<Stream *> &streams) = 0;
+ streamConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0;
virtual int configureStreams(Camera *camera,
std::map<Stream *, StreamConfiguration> &config) = 0;
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index fed04ce5..5d01504e 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -141,7 +141,7 @@ public:
std::map<Stream *, StreamConfiguration>
streamConfiguration(Camera *camera,
- std::set<Stream *> &streams) override;
+ const std::vector<StreamUsage> &usages) override;
int configureStreams(Camera *camera,
std::map<Stream *, StreamConfiguration> &config) override;
@@ -206,7 +206,7 @@ PipelineHandlerIPU3::~PipelineHandlerIPU3()
std::map<Stream *, StreamConfiguration>
PipelineHandlerIPU3::streamConfiguration(Camera *camera,
- std::set<Stream *> &streams)
+ const std::vector<StreamUsage> &usages)
{
std::map<Stream *, StreamConfiguration> configs;
IPU3CameraData *data = cameraData(camera);
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index cc3e0cd9..dfff7116 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -28,7 +28,7 @@ public:
std::map<Stream *, StreamConfiguration>
streamConfiguration(Camera *camera,
- std::set<Stream *> &streams) override;
+ const std::vector<StreamUsage> &usages) override;
int configureStreams(Camera *camera,
std::map<Stream *, StreamConfiguration> &config) override;
@@ -84,14 +84,12 @@ PipelineHandlerUVC::~PipelineHandlerUVC()
std::map<Stream *, StreamConfiguration>
PipelineHandlerUVC::streamConfiguration(Camera *camera,
- std::set<Stream *> &streams)
+ const std::vector<StreamUsage> &usages)
{
UVCCameraData *data = cameraData(camera);
-
std::map<Stream *, StreamConfiguration> configs;
StreamConfiguration config{};
- LOG(UVC, Debug) << "Retrieving default format";
config.width = 640;
config.height = 480;
config.pixelFormat = V4L2_PIX_FMT_YUYV;
diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
index 2e8c26fb..4da4ca01 100644
--- a/src/libcamera/pipeline/vimc.cpp
+++ b/src/libcamera/pipeline/vimc.cpp
@@ -28,7 +28,7 @@ public:
std::map<Stream *, StreamConfiguration>
streamConfiguration(Camera *camera,
- std::set<Stream *> &streams) override;
+ const std::vector<StreamUsage> &usages) override;
int configureStreams(Camera *camera,
std::map<Stream *, StreamConfiguration> &config) override;
@@ -84,14 +84,12 @@ PipelineHandlerVimc::~PipelineHandlerVimc()
std::map<Stream *, StreamConfiguration>
PipelineHandlerVimc::streamConfiguration(Camera *camera,
- std::set<Stream *> &streams)
+ const std::vector<StreamUsage> &usages)
{
VimcCameraData *data = cameraData(camera);
std::map<Stream *, StreamConfiguration> configs;
-
StreamConfiguration config{};
- LOG(VIMC, Debug) << "Retrieving default format";
config.width = 640;
config.height = 480;
config.pixelFormat = V4L2_PIX_FMT_RGB24;
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 1a858f26..0574f990 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -152,13 +152,13 @@ PipelineHandler::~PipelineHandler()
* \fn PipelineHandler::streamConfiguration()
* \brief Retrieve a group of stream configurations for a specified camera
* \param[in] camera The camera to fetch default configuration from
- * \param[in] streams An array of streams to fetch information about
+ * \param[in] usages A list of stream usages
*
* Retrieve the species camera's default configuration for a specified group of
- * streams. The caller shall populate the \a streams array with the streams it
- * wish to fetch the configuration from. The map of streams and configuration
- * returned can then be examined by the caller to learn about the defualt
- * parameters for the specified streams.
+ * use-cases. The caller shall populate the \a usages array with the use-cases it
+ * wishes to fetch the default configuration for. The map of streams and
+ * configurations returned can then be examined by the caller to learn about
+ * the default parameters for the specified streams.
*
* The intended companion to this is \a configureStreams() which can be used to
* change the group of streams parameters.
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index fea70142..faa3bc57 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -97,9 +97,8 @@ int MainWindow::startCapture()
{
int ret;
- Stream *stream = *camera_->streams().begin();
- std::set<Stream *> streams{ stream };
- config_ = camera_->streamConfiguration(streams);
+ config_ = camera_->streamConfiguration({ Stream::VideoRecording() });
+ Stream *stream = config_.begin()->first;
ret = camera_->configureStreams(config_);
if (ret < 0) {
std::cout << "Failed to configure camera" << std::endl;