apps: cam: Print enum string for camera properties
diff mbox series

Message ID 20250703140631.29979-1-uajain@igalia.com
State New
Headers show
Series
  • apps: cam: Print enum string for camera properties
Related show

Commit Message

Umang Jain July 3, 2025, 2:06 p.m. UTC
Some camera properties might be set as a enumeration for e.g.
properties::Location. Instead of printing the int32_t values
for the enumeration, print the enum string as well. This will
enhance the readability for the user.

Signed-off-by: Umang Jain <uajain@igalia.com>
---
 src/apps/cam/camera_session.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index f63fcb22..feef1585 100644
--- a/src/apps/cam/camera_session.cpp
+++ b/src/apps/cam/camera_session.cpp
@@ -236,7 +236,17 @@  void CameraSession::listProperties() const
 		const ControlId *id = properties::properties.at(key);
 
 		std::cout << "Property: " << id->name() << " = "
-			  << value.toString() << std::endl;
+			  << value.toString();
+
+		if (value.type() == ControlTypeInteger32) {
+			int32_t val = value.get<int32_t>();
+			const auto &iter = id->enumerators().find(val);
+
+			if (iter != id->enumerators().end())
+				std::cout << " [ " << iter->second << " ]";
+		}
+
+		std::cout << std::endl;
 	}
 }