[libcamera-devel] [PATCH v3 11/11] android: camera_device: Make CameraStream a class
Jacopo Mondi
jacopo at jmondi.org
Tue Sep 8 15:41:42 CEST 2020
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: Hirokazu Honda <hiroh at chromium.org>
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 4c1416913d00..50923df22a8f 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)
{
}
@@ -1402,7 +1403,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;
/*
@@ -1466,7 +1467,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 5ac8f05e5a07..912c59aeb5a8 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 *encoder = 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
--
2.28.0
More information about the libcamera-devel
mailing list