[RFC,04/12] libcamera: Add a direction (input or output) to the stream configuration
diff mbox series

Message ID 20250827090739.86955-5-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Bayer Re-Processing
Related show

Commit Message

David Plowman Aug. 27, 2025, 9:07 a.m. UTC
We are now going to support input streams as well as output streams, for
example for passing in the Bayer image for raw re-processing.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 include/libcamera/stream.h | 10 ++++++++++
 src/libcamera/stream.cpp   |  7 +++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index b5e8f0a9..39fed302 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -37,6 +37,11 @@  private:
 	std::map<PixelFormat, std::vector<SizeRange>> formats_;
 };
 
+enum class StreamDirection {
+	Input,
+	Output
+};
+
 struct StreamConfiguration {
 	StreamConfiguration();
 	StreamConfiguration(const StreamFormats &formats);
@@ -46,6 +51,8 @@  struct StreamConfiguration {
 	unsigned int stride;
 	unsigned int frameSize;
 
+	StreamDirection direction;
+
 	unsigned int bufferCount;
 
 	std::optional<ColorSpace> colorSpace;
@@ -53,6 +60,8 @@  struct StreamConfiguration {
 	Stream *stream() const { return stream_; }
 	void setStream(Stream *stream) { stream_ = stream; }
 	const StreamFormats &formats() const { return formats_; }
+	bool isOutput() const { return direction == StreamDirection::Output; }
+	bool isInput() const { return direction == StreamDirection::Input; }
 
 	std::string toString() const;
 
@@ -68,6 +77,7 @@  enum class StreamRole {
 	StillCapture,
 	VideoRecording,
 	Viewfinder,
+	RawInput
 };
 
 std::ostream &operator<<(std::ostream &out, StreamRole role);
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index f091487c..e970c8e5 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -280,8 +280,8 @@  SizeRange StreamFormats::range(const PixelFormat &pixelformat) const
  * handlers provide StreamFormats.
  */
 StreamConfiguration::StreamConfiguration()
-	: pixelFormat(0), stride(0), frameSize(0), bufferCount(0),
-	  stream_(nullptr)
+	: pixelFormat(0), stride(0), frameSize(0),
+	  direction(StreamDirection::Output), bufferCount(0), stream_(nullptr)
 {
 }
 
@@ -409,6 +409,9 @@  std::ostream &operator<<(std::ostream &out, const StreamConfiguration &cfg)
 {
 	out << cfg.size << "-" << cfg.pixelFormat << "/"
 	    << ColorSpace::toString(cfg.colorSpace);
+	if (cfg.direction == StreamDirection::Input)
+		out << "/"
+		    << "in";
 	return out;
 }