From baf3be12effed489770aaf02b9df3b743d4b7e50 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 23 Oct 2022 02:51:10 +0300 Subject: 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 Reviewed-by: Paul Elder Reviewed-by: Jacopo Mondi --- src/libcamera/stream.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/libcamera/stream.cpp') 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 @@ -417,6 +417,25 @@ std::string StreamConfiguration::toString() const * acceptable. */ +/** + * \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 names{ + "Raw", + "StillCapture", + "VideoRecording", + "Viewfinder", + }; + + out << names[static_cast>(role)]; + return out; +} + /** * \typedef StreamRoles * \brief A vector of StreamRole -- cgit v1.2.1