summaryrefslogtreecommitdiff
path: root/src/android/camera_stream.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/android/camera_stream.h')
-rw-r--r--src/android/camera_stream.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h
index e74a9a3b..0c402deb 100644
--- a/src/android/camera_stream.h
+++ b/src/android/camera_stream.h
@@ -7,12 +7,16 @@
#ifndef __ANDROID_CAMERA_STREAM_H__
#define __ANDROID_CAMERA_STREAM_H__
+#include <condition_variable>
#include <memory>
#include <mutex>
+#include <queue>
#include <vector>
#include <hardware/camera3.h>
+#include <libcamera/base/thread.h>
+
#include <libcamera/camera.h>
#include <libcamera/framebuffer.h>
#include <libcamera/framebuffer_allocator.h>
@@ -20,9 +24,9 @@
#include <libcamera/pixel_format.h>
#include "camera_request.h"
+#include "post_processor.h"
class CameraDevice;
-class PostProcessor;
class CameraStream
{
@@ -124,8 +128,38 @@ public:
int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer);
libcamera::FrameBuffer *getBuffer();
void putBuffer(libcamera::FrameBuffer *buffer);
+ void flush();
private:
+ class PostProcessorWorker : public libcamera::Thread
+ {
+ public:
+ enum class State {
+ Stopped,
+ Running,
+ Flushing,
+ };
+
+ PostProcessorWorker(PostProcessor *postProcessor);
+ ~PostProcessorWorker();
+
+ void start();
+ void queueRequest(Camera3RequestDescriptor::StreamBuffer *request);
+ void flush();
+
+ protected:
+ void run() override;
+
+ private:
+ PostProcessor *postProcessor_;
+
+ libcamera::Mutex mutex_;
+ std::condition_variable cv_;
+
+ std::queue<Camera3RequestDescriptor::StreamBuffer *> requests_;
+ State state_ = State::Stopped;
+ };
+
int waitFence(int fence);
CameraDevice *const cameraDevice_;
@@ -142,6 +176,8 @@ private:
*/
std::unique_ptr<std::mutex> mutex_;
std::unique_ptr<PostProcessor> postProcessor_;
+
+ std::unique_ptr<PostProcessorWorker> worker_;
};
#endif /* __ANDROID_CAMERA_STREAM__ */