[libcamera-devel,v2,1/2] android: camera_device: Provide toString() helper for stream_type
diff mbox series

Message ID 20211125131224.927640-2-umang.jain@ideasonboard.com
State Accepted
Headers show
Series
  • Improve stream type logging
Related show

Commit Message

Umang Jain Nov. 25, 2021, 1:12 p.m. UTC
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@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/android/camera_device.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Nov. 25, 2021, 1:45 p.m. UTC | #1
Hi Umang,

Thank you for the patch.

On Thu, Nov 25, 2021 at 06:42:23PM +0530, Umang Jain wrote:
> 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@ideasonboard.com>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/android/camera_device.cpp | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index f2e0bdbd..ad4bf07c 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -175,6 +175,21 @@ 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";
> +	default:
> +		LOG(HAL, Warning) << "Unknown stream type: " << stream_type;
> +		return "Unknown";
> +	}
> +}
> +
>  #if defined(OS_CHROMEOS)
>  /*
>   * Check whether the crop_rotate_scale_degrees values for all streams in
> @@ -548,7 +563,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)

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index f2e0bdbd..ad4bf07c 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -175,6 +175,21 @@  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";
+	default:
+		LOG(HAL, Warning) << "Unknown stream type: " << stream_type;
+		return "Unknown";
+	}
+}
+
 #if defined(OS_CHROMEOS)
 /*
  * Check whether the crop_rotate_scale_degrees values for all streams in
@@ -548,7 +563,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)