[02/11] libcamera: Add a direction (input or output) to the stream configuration
diff mbox series

Message ID 20251210164055.17856-3-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Bayer re-processing
Related show

Commit Message

David Plowman Dec. 10, 2025, 4:15 p.m. UTC
We are now going to support input streams as well as output streams, for
example for passing in a Bayer image for raw re-processing.

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

Comments

Isaac Scott Jan. 6, 2026, 3:57 p.m. UTC | #1
Hi David,

Quoting David Plowman (2025-12-10 16:15:17)
> We are now going to support input streams as well as output streams, for
> example for passing in a Bayer image for raw re-processing.
> 
> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
> ---
>  include/libcamera/stream.h | 10 ++++++++++
>  src/libcamera/stream.cpp   |  6 ++++--
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> 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..439c61c4 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)

Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>

>  {
>  }
>  
> @@ -409,6 +409,8 @@ 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;
>  }
>  
> -- 
> 2.47.3
>

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..439c61c4 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,8 @@  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;
 }