[libcamera-devel] [PATCH v2 12/12] android: camera_device: Make CameraStream a class
Hirokazu Honda
hiroh at google.com
Mon Sep 7 09:41:11 CEST 2020
I am starting to review these patches today.
This change LGTM.
On Sat, Sep 5, 2020 at 1:11 AM Jacopo Mondi <jacopo at jmondi.org> wrote:
> Hi me
>
> On Wed, Sep 02, 2020 at 05:22:36PM +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: Kieran Bingham <kieran.bingham at ideasonboard.com>
> > Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> > ---
> > 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 28d8e081eab0..88c85ad183d2 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 index, Encoder *encoder)
> > + : format_(format), size_(size), index_(index), encoder_(encoder)
> > {
> > }
> >
> > @@ -1415,7 +1416,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;
> >
> > /*
> > @@ -1479,7 +1480,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 3c57ffec265d..729b2556011b 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 index, Encoder *encoder = nullptr);
> > ~CameraStream();
> >
> > + libcamera::PixelFormat format() const { return format_; }
> > + libcamera::Size size() const { return size_; }
>
> Should these be const & ?
>
>
Yes, it should be. Returning const reference reduces a copy.
> > 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
> > --
> > 2.28.0
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20200907/da015a2f/attachment.htm>
More information about the libcamera-devel
mailing list