[libcamera-devel] [PATCH] android: camera_device: Provide toString() helper for stream_type

Umang Jain umang.jain at ideasonboard.com
Thu Nov 25 09:05:18 CET 2021


Provide a directionToString() helper to return a human-friendly name
for camera3_stream_t->stream_type. Replace the int value being printed
in configureStreams() INFO log with directionToString().

Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
---
 src/android/camera_device.cpp | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index f2e0bdbd..804a71fd 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -175,6 +175,20 @@ const char *rotationToString(int rotation)
 	return "INVALID";
 }
 
+const char *directionToString(int stream_type)
+{
+	switch (stream_type) {
+	case CAMERA3_STREAM_OUTPUT:
+		return "Output";
+	case CAMERA3_STREAM_INPUT:
+		return "Input";
+	case CAMERA3_STREAM_BIDIRECTIONAL:
+		return "Bidirectional";
+	}
+
+	return "Unknown";
+}
+
 #if defined(OS_CHROMEOS)
 /*
  * Check whether the crop_rotate_scale_degrees values for all streams in
@@ -548,7 +562,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 		PixelFormat format = capabilities_.toPixelFormat(stream->format);
 
 		LOG(HAL, Info) << "Stream #" << i
-			       << ", direction: " << stream->stream_type
+			       << ", direction: " << directionToString(stream->stream_type)
 			       << ", width: " << stream->width
 			       << ", height: " << stream->height
 			       << ", format: " << utils::hex(stream->format)
-- 
2.31.0



More information about the libcamera-devel mailing list