[1/1] libcamera: Add StreamRole into StreamConfiguration
diff mbox series

Message ID 20240916045802.3799103-2-chenghaoyang@google.com
State New
Headers show
Series
  • Add StreamRole into StreamConfiguration
Related show

Commit Message

Cheng-Hao Yang Sept. 16, 2024, 4:51 a.m. UTC
From: Han-Lin Chen <hanlinchen@chromium.org>

Add StreamRole into StreamConfigurations, so the user can configure
a specific stream as a specific role. Some platforms will configure
differently for different roles internally.

Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>
---
 include/libcamera/stream.h |  2 ++
 src/libcamera/stream.cpp   | 12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 071b7169..1dccba5e 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -21,6 +21,7 @@  namespace libcamera {
 
 class Camera;
 class Stream;
+enum class StreamRole;
 
 class StreamFormats
 {
@@ -50,6 +51,7 @@  struct StreamConfiguration {
 
 	std::optional<ColorSpace> colorSpace;
 
+	StreamRole role;
 	Stream *stream() const { return stream_; }
 	void setStream(Stream *stream) { stream_ = stream; }
 	const StreamFormats &formats() const { return formats_; }
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index 1f75dbbc..3e378d0d 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -281,7 +281,7 @@  SizeRange StreamFormats::range(const PixelFormat &pixelformat) const
  */
 StreamConfiguration::StreamConfiguration()
 	: pixelFormat(0), stride(0), frameSize(0), bufferCount(0),
-	  stream_(nullptr)
+	  role(StreamRole::Viewfinder), stream_(nullptr)
 {
 }
 
@@ -290,7 +290,7 @@  StreamConfiguration::StreamConfiguration()
  */
 StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
 	: pixelFormat(0), stride(0), frameSize(0), bufferCount(0),
-	  stream_(nullptr), formats_(formats)
+	  role(StreamRole::Viewfinder), stream_(nullptr), formats_(formats)
 {
 }
 
@@ -350,6 +350,14 @@  StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
  * color spaces can be supported and in what combinations.
  */
 
+/**
+ * \var StreamConfiguration::role
+ * \brief The StreamRole that this StreamConfiguration should be set to
+ *
+ * Some applications may want to assign a StreamConfiguration to a certain
+ * role of Stream.
+ */
+
 /**
  * \fn StreamConfiguration::stream()
  * \brief Retrieve the stream associated with the configuration