summaryrefslogtreecommitdiff
path: root/src/v4l2/v4l2_camera.h
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-11-22 16:22:56 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-01-12 16:10:38 +0100
commit9217f274f64f690b768d332663e1731a3ee5ef15 (patch)
treeee152928be1eaea656c929e56e27e97b175de435 /src/v4l2/v4l2_camera.h
parenteb4030f6c07174a520be1ebd73628e9ae4789569 (diff)
libcamera: Switch to FrameBuffer interface
Switch to the FrameBuffer interface where all buffers are treated as external buffers and are allocated outside the camera. Applications allocating buffers using libcamera are switched to use the FrameBufferAllocator helper. Follow-up changes to this one will finalize the transition to the new FrameBuffer interface by removing code that is left unused after this change. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/v4l2/v4l2_camera.h')
-rw-r--r--src/v4l2/v4l2_camera.h39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h
index 06eab0e1..f1f04d9e 100644
--- a/src/v4l2/v4l2_camera.h
+++ b/src/v4l2/v4l2_camera.h
@@ -9,50 +9,38 @@
#define __V4L2_CAMERA_H__
#include <deque>
-#include <linux/videodev2.h>
#include <mutex>
+#include <utility>
#include <libcamera/buffer.h>
#include <libcamera/camera.h>
#include <libcamera/file_descriptor.h>
+#include <libcamera/framebuffer_allocator.h>
#include "semaphore.h"
using namespace libcamera;
-class V4L2FrameMetadata
+class V4L2Camera : public Object
{
public:
- V4L2FrameMetadata(Buffer *buffer);
-
- int index() const { return index_; }
-
- unsigned int bytesused() const { return bytesused_; }
- uint64_t timestamp() const { return timestamp_; }
- unsigned int sequence() const { return sequence_; }
-
- FrameMetadata::Status status() const { return status_; }
-
-private:
- int index_;
+ struct Buffer {
+ Buffer(unsigned int index, const FrameMetadata &data)
+ : index(index), data(data)
+ {
+ }
- unsigned int bytesused_;
- uint64_t timestamp_;
- unsigned int sequence_;
+ unsigned int index;
+ FrameMetadata data;
+ };
- FrameMetadata::Status status_;
-};
-
-class V4L2Camera : public Object
-{
-public:
V4L2Camera(std::shared_ptr<Camera> camera);
~V4L2Camera();
int open();
void close();
void getStreamConfig(StreamConfiguration *streamConfig);
- std::vector<V4L2FrameMetadata> completedBuffers();
+ std::vector<Buffer> completedBuffers();
int configure(StreamConfiguration *streamConfigOut,
const Size &size, PixelFormat pixelformat,
@@ -78,9 +66,10 @@ private:
bool isRunning_;
std::mutex bufferLock_;
+ FrameBufferAllocator *bufferAllocator_;
std::deque<std::unique_ptr<Request>> pendingRequests_;
- std::deque<std::unique_ptr<V4L2FrameMetadata>> completedBuffers_;
+ std::deque<std::unique_ptr<Buffer>> completedBuffers_;
};
#endif /* __V4L2_CAMERA_H__ */