[libcamera-devel,18/27] libcamera: camera: Cache the stream configuration in the stream object

Message ID 20190206060818.13907-19-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Capture frames throught requests
Related show

Commit Message

Laurent Pinchart Feb. 6, 2019, 6:08 a.m. UTC
From: Niklas Söderlund <niklas.soderlund@ragnatech.se>

The API towards the application and pipeline handler can be simplified
if the camera caches which streams have been selected and their
respective configuration.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/camera.h |  1 +
 src/libcamera/camera.cpp   | 15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

Patch

diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h
index 36bf1cbb215b..1c0ee07c2a22 100644
--- a/include/libcamera/camera.h
+++ b/include/libcamera/camera.h
@@ -55,6 +55,7 @@  private:
 	std::shared_ptr<PipelineHandler> pipe_;
 	std::string name_;
 	std::vector<Stream *> streams_;
+	std::vector<Stream *> activeStreams_;
 
 	bool acquired_;
 	bool disconnected_;
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 62291d2c9e6c..3f7b805b09a2 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -253,7 +253,20 @@  int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &config)
 		return -EINVAL;
 	}
 
-	return pipe_->configureStreams(this, config);
+	ret = pipe_->configureStreams(this, config);
+	if (ret)
+		return ret;
+
+	activeStreams_.clear();
+	for (auto const &iter : config) {
+		Stream *stream = iter.first;
+		const StreamConfiguration &cfg = iter.second;
+
+		stream->configuration_ = cfg;
+		activeStreams_.push_back(stream);
+	}
+
+	return 0;
 }
 
 int Camera::exclusiveAccess()