[libcamera-devel,v2,08/12] android: camera_device: Use camera3 stream format

Message ID 20200902152236.69770-9-jacopo@jmondi.org
State Superseded, archived
Delegated to: Jacopo Mondi
Headers show
Series
  • android: camera_device: Fix JPEG/RAW sizes
Related show

Commit Message

Jacopo Mondi Sept. 2, 2020, 3:22 p.m. UTC
When iterating the camera3_stream_t received from the Android camera
framework to identify the MJPEG streams, the format check was performed
on the CameraStream created when iterating the non-MJPEG streams and not
on the format actually requested by Android. As the next patches will
remove the creation of CameraStream instances for MJPEG streams, use the
camera3_stream format to prepare for that.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_device.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Sept. 5, 2020, 9:40 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Wed, Sep 02, 2020 at 05:22:32PM +0200, Jacopo Mondi wrote:
> When iterating the camera3_stream_t received from the Android camera
> framework to identify the MJPEG streams, the format check was performed
> on the CameraStream created when iterating the non-MJPEG streams and not
> on the format actually requested by Android. As the next patches will
> remove the creation of CameraStream instances for MJPEG streams, use the
> camera3_stream format to prepare for that.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/android/camera_device.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index ace7f6b17b4a..7fc61e3e4da7 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1230,9 +1230,10 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>  	/* Now handle MJPEG streams, adding a new stream if required. */
>  	for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
>  		camera3_stream_t *stream = stream_list->streams[i];
> +		PixelFormat format = toPixelFormat(stream->format);
>  		bool match = false;
>  
> -		if (streams_[i].format != formats::MJPEG)
> +		if (format != formats::MJPEG)

This could also be

		if (stream->format != HAL_PIXEL_FORMAT_BLOB)

to avoid the toPixelFormat() call.

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

>  			continue;
>  
>  		/* Search for a compatible stream */

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index ace7f6b17b4a..7fc61e3e4da7 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1230,9 +1230,10 @@  int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 	/* Now handle MJPEG streams, adding a new stream if required. */
 	for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
 		camera3_stream_t *stream = stream_list->streams[i];
+		PixelFormat format = toPixelFormat(stream->format);
 		bool match = false;
 
-		if (streams_[i].format != formats::MJPEG)
+		if (format != formats::MJPEG)
 			continue;
 
 		/* Search for a compatible stream */