[1/2] libcamera: orientation: Provide a orientationToString() helper
diff mbox series

Message ID 20250627074208.49872-2-uajain@igalia.com
State New
Headers show
Series
  • gstreamer: Report mounting-rotation of camera sensor
Related show

Commit Message

Umang Jain June 27, 2025, 7:42 a.m. UTC
Provide a orientationToString() helper to convert Orientation enum
to a std::string.

Signed-off-by: Umang Jain <uajain@igalia.com>
---
 include/libcamera/orientation.h |  1 +
 src/libcamera/orientation.cpp   | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/orientation.h b/include/libcamera/orientation.h
index a3b40e63..f0ef8f1c 100644
--- a/include/libcamera/orientation.h
+++ b/include/libcamera/orientation.h
@@ -24,6 +24,7 @@  enum class Orientation {
 };
 
 Orientation orientationFromRotation(int angle, bool *success = nullptr);
+std::string orientationToString(const Orientation &orientation);
 
 std::ostream &operator<<(std::ostream &out, const Orientation &orientation);
 
diff --git a/src/libcamera/orientation.cpp b/src/libcamera/orientation.cpp
index 7d7d21ae..f5493673 100644
--- a/src/libcamera/orientation.cpp
+++ b/src/libcamera/orientation.cpp
@@ -8,6 +8,7 @@ 
 #include <libcamera/orientation.h>
 
 #include <array>
+#include <sstream>
 
 /**
  * \file orientation.h
@@ -91,6 +92,19 @@  Orientation orientationFromRotation(int angle, bool *success)
 	return Orientation::Rotate0;
 }
 
+/**
+ * \brief Generate a string representation of \a orientation item
+ * \param[in] orientation The Orientation item
+ * \return A std::string representation for \a orientation
+ */
+std::string orientationToString(const Orientation &orientation)
+{
+	std::stringstream ss;
+	ss << orientation;
+
+	return ss.str();
+}
+
 /**
  * \brief Prints human-friendly names for Orientation items
  * \param[in] out The output stream