[v3,10/17] libcamera: stream: Add operator<<(StreamConfiguration)
diff mbox series

Message ID 20241206101344.767170-11-stefan.klug@ideasonboard.com
State Accepted
Delegated to: Paul Elder
Headers show
Series
  • rkisp1: Fix aspect ratio and ScalerCrop
Related show

Commit Message

Stefan Klug Dec. 6, 2024, 10:13 a.m. UTC
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

The StreamConfiguration class only implmenets toString() but doesn't
offer an overload of operator<<() which is convenient to use.

Add an overload for operator<<(StreamConfiguration) which is based on
the usage of StreamConfiguration::toString().

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 include/libcamera/stream.h |  2 ++
 src/libcamera/stream.cpp   | 13 +++++++++++++
 2 files changed, 15 insertions(+)

Comments

Stefan Klug Dec. 11, 2024, 4:59 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch. 

As it is already on mainline, no need to review it again...

Best regards,
Stefan

On Fri, Dec 06, 2024 at 11:13:32AM +0100, Stefan Klug wrote:
> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> 
> The StreamConfiguration class only implmenets toString() but doesn't
> offer an overload of operator<<() which is convenient to use.
> 
> Add an overload for operator<<(StreamConfiguration) which is based on
> the usage of StreamConfiguration::toString().
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
>  include/libcamera/stream.h |  2 ++
>  src/libcamera/stream.cpp   | 13 +++++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
> index 071b71698acb..ea228aea7d56 100644
> --- a/include/libcamera/stream.h
> +++ b/include/libcamera/stream.h
> @@ -61,6 +61,8 @@ private:
>  	StreamFormats formats_;
>  };
>  
> +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg);
> +
>  enum class StreamRole {
>  	Raw,
>  	StillCapture,
> diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
> index 1f75dbbc5b64..a093abf48c7c 100644
> --- a/src/libcamera/stream.cpp
> +++ b/src/libcamera/stream.cpp
> @@ -395,6 +395,19 @@ std::string StreamConfiguration::toString() const
>  	return size.toString() + "-" + pixelFormat.toString();
>  }
>  
> +/**
> + * \brief Insert a text representation of a StreamConfiguration into an output
> + * stream
> + * \param[in] out The output stream
> + * \param[in] cfg The StreamConfiguration
> + * \return The output stream \a out
> + */
> +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg)
> +{
> +	out << cfg.toString();
> +	return out;
> +}
> +
>  /**
>   * \enum StreamRole
>   * \brief Identify the role a stream is intended to play
> -- 
> 2.43.0
>

Patch
diff mbox series

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 071b71698acb..ea228aea7d56 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -61,6 +61,8 @@  private:
 	StreamFormats formats_;
 };
 
+std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg);
+
 enum class StreamRole {
 	Raw,
 	StillCapture,
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index 1f75dbbc5b64..a093abf48c7c 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -395,6 +395,19 @@  std::string StreamConfiguration::toString() const
 	return size.toString() + "-" + pixelFormat.toString();
 }
 
+/**
+ * \brief Insert a text representation of a StreamConfiguration into an output
+ * stream
+ * \param[in] out The output stream
+ * \param[in] cfg The StreamConfiguration
+ * \return The output stream \a out
+ */
+std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg)
+{
+	out << cfg.toString();
+	return out;
+}
+
 /**
  * \enum StreamRole
  * \brief Identify the role a stream is intended to play