[libcamera-devel] [PATCH v2 4/4] libcamera: camera: ensure streams belong to camera

Niklas Söderlund niklas.soderlund at ragnatech.se
Thu Feb 28 03:16:26 CET 2019


Before calling into the pipeline handler make sure the streams provided
by the application actually belongs to the camera.

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 src/libcamera/camera.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 4f0833300b9b7ffc..52992e577b6ab011 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -337,6 +337,11 @@ Camera::streamConfiguration(std::set<Stream *> &streams)
 	if (disconnected_ || !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);
 }
 
@@ -378,6 +383,11 @@ int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &config)
 		return -EINVAL;
 	}
 
+	for (auto const &iter : config) {
+		if (streams_.find(iter.first) == streams_.end())
+			return -EINVAL;
+	}
+
 	ret = pipe_->configureStreams(this, config);
 	if (ret)
 		return ret;
-- 
2.20.1



More information about the libcamera-devel mailing list