android: camera_device: Queue request using Worker

Add a CameraWorker class member to the CameraDevice class and
queue capture requests to it to delegate its handling. Start and
stop the CameraWorker when the libcamera::Camera is started or
stopped.

Tie the CaptureRequest lifetime to the Camera3RequestDescriptor's one
by storing it as unique_ptr<> in the descriptor to simplify handling
of request creation and deletion.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi
2020-10-06 17:56:50 +02:00
parent 8806863b0b
commit 4b1aa21db0
2 changed files with 28 additions and 21 deletions
+6 -1
View File
@@ -25,6 +25,7 @@
#include "libcamera/internal/message.h"
#include "camera_stream.h"
#include "camera_worker.h"
#include "jpeg/encoder.h"
class CameraMetadata;
@@ -73,7 +74,8 @@ private:
CameraDevice(unsigned int id, const std::shared_ptr<libcamera::Camera> &camera);
struct Camera3RequestDescriptor {
Camera3RequestDescriptor(unsigned int frameNumber,
Camera3RequestDescriptor(libcamera::Camera *camera,
unsigned int frameNumber,
unsigned int numBuffers);
~Camera3RequestDescriptor();
@@ -81,6 +83,7 @@ private:
uint32_t numBuffers;
camera3_stream_buffer_t *buffers;
std::vector<std::unique_ptr<libcamera::FrameBuffer>> frameBuffers;
std::unique_ptr<CaptureRequest> request;
};
struct Camera3StreamConfiguration {
@@ -108,6 +111,8 @@ private:
unsigned int id_;
camera3_device_t camera3Device_;
CameraWorker worker_;
bool running_;
std::shared_ptr<libcamera::Camera> camera_;
std::unique_ptr<libcamera::CameraConfiguration> config_;