summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-10-23 02:51:10 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-11-25 10:52:05 +0200
commitbaf3be12effed489770aaf02b9df3b743d4b7e50 (patch)
tree78f47129a41d41c09b7089be4bf80c79b54cd134 /src
parentc7bbe0ca3a015f9b4d59724d8489ff90b6be2e81 (diff)
libcamera: stream: Add operator<<() to print StreamRole as a string
libcamera prints stream role values in log messages. To be more user-friendly, add a specialization of operator<<() to print the role name as a string instead of a numerical value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/stream.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index 686e693b..67f30815 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -418,6 +418,25 @@ std::string StreamConfiguration::toString() const
*/
/**
+ * \brief Insert a text representation of a StreamRole into an output stream
+ * \param[in] out The output stream
+ * \param[in] role The StreamRole
+ * \return The output stream \a out
+ */
+std::ostream &operator<<(std::ostream &out, StreamRole role)
+{
+ static constexpr std::array<const char *, 4> names{
+ "Raw",
+ "StillCapture",
+ "VideoRecording",
+ "Viewfinder",
+ };
+
+ out << names[static_cast<std::underlying_type_t<StreamRole>>(role)];
+ return out;
+}
+
+/**
* \typedef StreamRoles
* \brief A vector of StreamRole
*/