[libcamera-devel,v2,11/16] libcamera: stream: StreamConfiguration: Add StreamFormats information

Message ID 20190612004359.15772-12-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: Add support for format information and validation
Related show

Commit Message

Niklas Söderlund June 12, 2019, 12:43 a.m. UTC
Allow StreamFormats to be associated to a StreamConfiguration. The
intention is that pipeline handlers should associate formats to a
StreamConfiguration when it's created in generateConfiguration().

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 include/libcamera/stream.h |  8 ++++----
 src/libcamera/stream.cpp   | 25 +++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)

Comments

Jacopo Mondi June 13, 2019, 4:58 p.m. UTC | #1
Hi Niklas,

On Wed, Jun 12, 2019 at 02:43:54AM +0200, Niklas Söderlund wrote:
> Allow StreamFormats to be associated to a StreamConfiguration. The
> intention is that pipeline handlers should associate formats to a
> StreamConfiguration when it's created in generateConfiguration().
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  include/libcamera/stream.h |  8 ++++----
>  src/libcamera/stream.cpp   | 25 +++++++++++++++++++++++++
>  2 files changed, 29 insertions(+), 4 deletions(-)
>
> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
> index 48daf5ac23f55d85..5b4fea324ce449b1 100644
> --- a/include/libcamera/stream.h
> +++ b/include/libcamera/stream.h
> @@ -35,10 +35,8 @@ private:
>  };
>
>  struct StreamConfiguration {
> -	StreamConfiguration()
> -		: stream_(nullptr)
> -	{
> -	}
> +	StreamConfiguration();
> +	StreamConfiguration(const StreamFormats &formats);
>
>  	unsigned int pixelFormat;
>  	Size size;
> @@ -47,11 +45,13 @@ struct StreamConfiguration {
>
>  	Stream *stream() const { return stream_; }
>  	void setStream(Stream *stream) { stream_ = stream; }
> +	const StreamFormats &formats() const { return formats_; }
>
>  	std::string toString() const;
>
>  private:
>  	Stream *stream_;
> +	StreamFormats formats_;
>  };
>
>  enum StreamRole {
> diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
> index 52340c2644aac8d8..254a5e10db24287d 100644
> --- a/src/libcamera/stream.cpp
> +++ b/src/libcamera/stream.cpp
> @@ -268,6 +268,19 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const
>   * configured for a single video stream.
>   */
>
> +StreamConfiguration::StreamConfiguration()
> +	: stream_(nullptr)
> +{

No need to "formats_ = {};", right?
> +}
> +
> +/**
> + * \brief Construct a configuration with stream formats
> + */
> +StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
> +	: stream_(nullptr), formats_(formats)
> +{
> +}
> +
>  /**
>   * \var StreamConfiguration::size
>   * \brief Stream size in pixels
> @@ -308,6 +321,18 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const
>   * \param[in] stream The stream
>   */
>
> +/**
> + * \fn StreamConfiguration::formats()
> + * \brief Retrieve advisory stream format information
> + *
> + * Retrieve information about pixel formats and sizes for possible stream
> + * configuration. The size information is advisory and not guaranteed to
> + * be fully satisfied by the hardware, users should always inspect the actual

fully satisfied/supported/

> + * size used by the device after a camera have been configured.

have been/has been/
s/used by/applied on/

> + *
> + * \return Stream formats information
> + */
> +

I'm just not sure about the use of the term 'advisory', to me has a
different meaning, but as I'm not a native speaker you should not
trust me. Kieran ?

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j
>  /**
>   * \brief Assemble and return a string describing the configuration
>   *
> --
> 2.21.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 48daf5ac23f55d85..5b4fea324ce449b1 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -35,10 +35,8 @@  private:
 };
 
 struct StreamConfiguration {
-	StreamConfiguration()
-		: stream_(nullptr)
-	{
-	}
+	StreamConfiguration();
+	StreamConfiguration(const StreamFormats &formats);
 
 	unsigned int pixelFormat;
 	Size size;
@@ -47,11 +45,13 @@  struct StreamConfiguration {
 
 	Stream *stream() const { return stream_; }
 	void setStream(Stream *stream) { stream_ = stream; }
+	const StreamFormats &formats() const { return formats_; }
 
 	std::string toString() const;
 
 private:
 	Stream *stream_;
+	StreamFormats formats_;
 };
 
 enum StreamRole {
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index 52340c2644aac8d8..254a5e10db24287d 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -268,6 +268,19 @@  SizeRange StreamFormats::range(unsigned int pixelformat) const
  * configured for a single video stream.
  */
 
+StreamConfiguration::StreamConfiguration()
+	: stream_(nullptr)
+{
+}
+
+/**
+ * \brief Construct a configuration with stream formats
+ */
+StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
+	: stream_(nullptr), formats_(formats)
+{
+}
+
 /**
  * \var StreamConfiguration::size
  * \brief Stream size in pixels
@@ -308,6 +321,18 @@  SizeRange StreamFormats::range(unsigned int pixelformat) const
  * \param[in] stream The stream
  */
 
+/**
+ * \fn StreamConfiguration::formats()
+ * \brief Retrieve advisory stream format information
+ *
+ * Retrieve information about pixel formats and sizes for possible stream
+ * configuration. The size information is advisory and not guaranteed to
+ * be fully satisfied by the hardware, users should always inspect the actual
+ * size used by the device after a camera have been configured.
+ *
+ * \return Stream formats information
+ */
+
 /**
  * \brief Assemble and return a string describing the configuration
  *