summaryrefslogtreecommitdiff
path: root/src/android/camera_device.h
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-09-02 11:58:00 +0200
committerJacopo Mondi <jacopo@jmondi.org>2020-09-18 11:31:56 +0200
commitc82f944399fd4ad81a440e3f852ee0fff876ba37 (patch)
tree34f9bab400746cf7d1909ffdbcc58853983aae75 /src/android/camera_device.h
parentf868f08c21f6e4eadb2e61b28cb9524a0bb144ed (diff)
android: camera_device: Rework CameraStream handling
The CameraDevice::streams_ vector of CameraStream instances is currently mostly accessed by index. The current implementation creates all the CameraStream during the first loop that inspects the camera3_stream instances and then update the index of the StreamConfiguration associated with the CameraStream during a second loop that inspects MJPEG streams. A third loop creates the JPEG encoder associated with camera streams that produce MJPEG format. As the index-based association is hard to follow and rather fragile, rework the creation and handling of CameraStream: 1) Make the StreamConfiguration index a constructor parameter and a private struct member. This disallows the creation of CameraStream without a StreamConfiguration index assigned. 2) Create CameraStream only after the associated StreamConfiguration has been identified. The first loop creates CameraStream for non-JPEG streams, the second for the JPEG ones after having identified the associated StreamConfiguration. Since we have just created the CameraStream, create the JPEG encoder at the same time instead of deferring it. This change removes all accesses by index to the CameraDevice::streams_ vector. No functional changes intended, but this change aims to make the code easier to follow and more robust. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android/camera_device.h')
-rw-r--r--src/android/camera_device.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index c0732fb8..376d001e 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -28,20 +28,24 @@
class CameraMetadata;
struct CameraStream {
- CameraStream(libcamera::PixelFormat, libcamera::Size);
+public:
+ CameraStream(libcamera::PixelFormat, libcamera::Size, unsigned int i);
~CameraStream();
- /*
- * The index of the libcamera StreamConfiguration as added during
- * configureStreams(). A single libcamera Stream may be used to deliver
- * one or more streams to the Android framework.
- */
- unsigned int index;
+ unsigned int index() const { return index_; }
libcamera::PixelFormat format;
libcamera::Size size;
Encoder *jpeg;
+
+private:
+ /*
+ * The index of the libcamera StreamConfiguration as added during
+ * configureStreams(). A single libcamera Stream may be used to deliver
+ * one or more streams to the Android framework.
+ */
+ unsigned int index_;
};
class CameraDevice : protected libcamera::Loggable