[libcamera-devel,RFC,3/7] android: camera_device: Check correct stream format

Message ID 20200902130846.55910-4-jacopo@jmondi.org
State Superseded, archived
Delegated to: Jacopo Mondi
Headers show
Series
  • android: camera_device: Turn CameraStream into a class
Related show

Commit Message

Jacopo Mondi Sept. 2, 2020, 1:08 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.

Fix this by checking the camera3_stream format.

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

Comments

Kieran Bingham Sept. 2, 2020, 1:25 p.m. UTC | #1
Hi Jacopo,

On 02/09/2020 14:08, 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.
> 
> Fix this by checking the camera3_stream format.
> 
> 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 5a70db832aa5..01f4b3a45566 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)

I'm not sure how it's the 'wrong' format to check. The
CameraStream->format is already stored as a
toPixelFormat(stream->format) isn't it ?


In the event of a JPEG stream - the CameraStream is created with
formats::MJPEG ...


Even with that said, I don't think this patch is 'wrong', I just don't
see the need.... but I see the story continues in the next patches...


> +		if (format != formats::MJPEG)
>  			continue;
>  
>  		/* Search for a compatible stream */
>
Jacopo Mondi Sept. 2, 2020, 1:43 p.m. UTC | #2
Hi Kieran,

On Wed, Sep 02, 2020 at 02:25:27PM +0100, Kieran Bingham wrote:
> Hi Jacopo,
>
> On 02/09/2020 14:08, 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.
> >
> > Fix this by checking the camera3_stream format.
> >
> > 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 5a70db832aa5..01f4b3a45566 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)
>
> I'm not sure how it's the 'wrong' format to check. The
> CameraStream->format is already stored as a
> toPixelFormat(stream->format) isn't it ?

You are right, the Subject says "correct" which implies the existing
is wrong, which is not (assuming _BLOB -> MJPEG unconditionally).

You'll see in the next patches the real reason for this change is that
when this loop is entered after [5/7] is that there's not streams_[i]
anymore associated with BLOB streams, this prepares for it to be
removed safely. The commit message is a bit confused maybe.

>
>
> In the event of a JPEG stream - the CameraStream is created with
> formats::MJPEG ...

Yes, for now :) I see no reason why it should change, but..

>
>
> Even with that said, I don't think this patch is 'wrong', I just don't
> see the need.... but I see the story continues in the next patches...
>

Yes, hope it makes sense looking the next patches

>
> > +		if (format != formats::MJPEG)
> >  			continue;
> >
> >  		/* Search for a compatible stream */
> >
>
> --
> Regards
> --
> Kieran
Kieran Bingham Sept. 2, 2020, 2:15 p.m. UTC | #3
On 02/09/2020 14:43, Jacopo Mondi wrote:
> Hi Kieran,
> 
> On Wed, Sep 02, 2020 at 02:25:27PM +0100, Kieran Bingham wrote:
>> Hi Jacopo,
>>
>> On 02/09/2020 14:08, 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.
>>>
>>> Fix this by checking the camera3_stream format.
>>>
>>> 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 5a70db832aa5..01f4b3a45566 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)
>>
>> I'm not sure how it's the 'wrong' format to check. The
>> CameraStream->format is already stored as a
>> toPixelFormat(stream->format) isn't it ?
> 
> You are right, the Subject says "correct" which implies the existing
> is wrong, which is not (assuming _BLOB -> MJPEG unconditionally).
> 
> You'll see in the next patches the real reason for this change is that
> when this loop is entered after [5/7] is that there's not streams_[i]
> anymore associated with BLOB streams, this prepares for it to be
> removed safely. The commit message is a bit confused maybe.

Sure, well I don't mind if it changes any way...

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> 
>>
>>
>> In the event of a JPEG stream - the CameraStream is created with
>> formats::MJPEG ...
> 
> Yes, for now :) I see no reason why it should change, but..
> 
>>
>>
>> Even with that said, I don't think this patch is 'wrong', I just don't
>> see the need.... but I see the story continues in the next patches...
>>
> 
> Yes, hope it makes sense looking the next patches
> 
>>
>>> +		if (format != formats::MJPEG)
>>>  			continue;
>>>
>>>  		/* Search for a compatible stream */
>>>
>>
>> --
>> Regards
>> --
>> Kieran
Niklas Söderlund Sept. 4, 2020, 6:13 a.m. UTC | #4
Hi Jacopo,

Thanks for your work.

On 2020-09-02 15:08:42 +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.
> 
> Fix this by checking the camera3_stream format.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  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 5a70db832aa5..01f4b3a45566 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 */
> -- 
> 2.28.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 5a70db832aa5..01f4b3a45566 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 */