[libcamera-devel] [RFC 7/7] android: camera_device: Make CameraStream a class
Kieran Bingham
kieran.bingham at ideasonboard.com
Wed Sep 2 16:11:04 CEST 2020
On 02/09/2020 14:08, 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.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
A good end to the series ;-)
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> src/android/camera_device.cpp | 9 +++++----
> src/android/camera_device.h | 14 ++++++++------
> 2 files changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index aef9a6fb4be1..ee7de2ad6389 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -168,8 +168,9 @@ MappedCamera3Buffer::MappedCamera3Buffer(const buffer_handle_t camera3buffer,
> }
> }
>
> -CameraStream::CameraStream(PixelFormat f, Size s, unsigned int i, Encoder *encoder)
> - : format(f), size(s), index_(i), encoder_(encoder)
> +CameraStream::CameraStream(PixelFormat format, Size size,
> + unsigned int i, Encoder *encoder)
s/i/idx/ ? or index as the others are all expanded too?
> + : format_(format), size_(size), index_(i), encoder_(encoder)
> {
> }
>
> @@ -1414,7 +1415,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;
>
> /*
> @@ -1478,7 +1479,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();
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index da9d5c0435f0..7d78363c3f76 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -27,19 +27,21 @@
>
> class CameraMetadata;
>
> -struct CameraStream {
> +class CameraStream
> +{
> public:
> - CameraStream(libcamera::PixelFormat, libcamera::Size, unsigned int i,
> - Encoder *encoder = nullptr);
> + CameraStream(libcamera::PixelFormat format, libcamera::Size size,
> + unsigned int i, Encoder *encoder = nullptr);
> ~CameraStream();
>
> + libcamera::PixelFormat format() const { return format_; }
> + libcamera::Size size() const { return size_; }
> unsigned int index() const { return index_; }
> Encoder *encoder() const { return encoder_; }
>
> - 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
--
Kieran
More information about the libcamera-devel
mailing list