summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/stream.h3
-rw-r--r--src/libcamera/stream.cpp19
2 files changed, 22 insertions, 0 deletions
diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index f0ae7e62..efec695a 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -9,6 +9,7 @@
#include <map>
#include <memory>
+#include <ostream>
#include <string>
#include <vector>
@@ -70,6 +71,8 @@ enum StreamRole {
using StreamRoles = std::vector<StreamRole>;
+std::ostream &operator<<(std::ostream &out, StreamRole role);
+
class Stream
{
public:
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
*/