[libcamera-devel] [PATCH v4 10/10] android: camera_device: Make CameraStream a class
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Sep 16 00:40:56 CEST 2020
Hi Jacopo,
Thank you for the patch.
On Sat, Sep 12, 2020 at 12:11:29PM +0200, Jacopo Mondi wrote:
> Complete the transformation of CameraStream into a class and provide
> a read-only interface that allows to access its parameters but not
> modify them at run-time.
>
> No functional changes intended but this change aims to make the code
> more robust by enforcing a stricter interface in the CameraStream class.
>
> Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> Reviewed-by: Hirokazu Honda <hiroh at chromium.org>
> Reviewed-by: Hirokazu Honda <hiroh at chromium.org>
Even if Hiro reviewed the patch twice, I think a single tag is enough
;-)
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> src/android/camera_device.cpp | 11 ++++++-----
> src/android/camera_device.h | 14 ++++++++------
> 2 files changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 4d8847e72db5..7ecb2a4d82e6 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -169,8 +169,9 @@ MappedCamera3Buffer::MappedCamera3Buffer(const buffer_handle_t camera3buffer,
> }
> }
>
> -CameraStream::CameraStream(PixelFormat f, Size s, unsigned int i, Encoder *e)
> - : format(f), size(s), index_(i), encoder_(e)
> +CameraStream::CameraStream(PixelFormat format, Size size,
> + unsigned int index, Encoder *encoder)
> + : format_(format), size_(size), index_(index), encoder_(encoder)
> {
> }
>
> @@ -1403,7 +1404,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
> descriptor->buffers[i].buffer = camera3Buffers[i].buffer;
>
> /* Software streams are handled after hardware streams complete. */
> - if (cameraStream->format == formats::MJPEG)
> + if (cameraStream->format() == formats::MJPEG)
> continue;
>
> /*
> @@ -1467,7 +1468,7 @@ void CameraDevice::requestComplete(Request *request)
> CameraStream *cameraStream =
> static_cast<CameraStream *>(descriptor->buffers[i].stream->priv);
>
> - if (cameraStream->format != formats::MJPEG)
> + if (cameraStream->format() != formats::MJPEG)
> continue;
>
> Encoder *encoder = cameraStream->encoder();
> @@ -1502,7 +1503,7 @@ void CameraDevice::requestComplete(Request *request)
> exif.setMake("libcamera");
> exif.setModel("cameraModel");
> exif.setOrientation(orientation_);
> - exif.setSize(cameraStream->size);
> + exif.setSize(cameraStream->size());
> /*
> * We set the frame's EXIF timestamp as the time of encode.
> * Since the precision we need for EXIF timestamp is only one
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 49a2e7f3f8bc..1837748d2efc 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -27,18 +27,20 @@
>
> class CameraMetadata;
>
> -struct CameraStream {
> +class CameraStream
> +{
> public:
> - CameraStream(libcamera::PixelFormat, libcamera::Size, unsigned int i,
> - Encoder *e = nullptr);
> + CameraStream(libcamera::PixelFormat format, libcamera::Size size,
> + unsigned int index, Encoder *encoder = nullptr);
>
> + const libcamera::PixelFormat &format() const { return format_; }
> + const libcamera::Size &size() const { return size_; }
> unsigned int index() const { return index_; }
> Encoder *encoder() const { return encoder_.get(); }
>
> - libcamera::PixelFormat format;
> - libcamera::Size size;
> -
> private:
> + libcamera::PixelFormat format_;
> + libcamera::Size size_;
> /*
> * The index of the libcamera StreamConfiguration as added during
> * configureStreams(). A single libcamera Stream may be used to deliver
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list