libcamera: buffer: Add FrameBuffer interface

Add a new FrameBuffer class to describe memory used to store frames.
This change just adds the new interface, future patches will migrate all
parts of libcamera to use this and replace the old Buffer interface.

This change needs to specify the const keyword for Plane::length() as to
not get Doxygen confused with FrameBuffer::Plane::length added in this
change.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund
2019-11-25 20:53:38 +01:00
parent 9c4bc73c2f
commit de9243bdc1
2 changed files with 154 additions and 1 deletions

View File

@@ -11,6 +11,8 @@
#include <stdint.h>
#include <vector>
#include <libcamera/file_descriptor.h>
namespace libcamera {
class Request;
@@ -33,6 +35,42 @@ struct FrameMetadata {
std::vector<Plane> planes;
};
class FrameBuffer final
{
public:
struct Plane {
FileDescriptor fd;
unsigned int length;
};
FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);
FrameBuffer(const FrameBuffer &) = delete;
FrameBuffer(FrameBuffer &&) = delete;
FrameBuffer &operator=(const FrameBuffer &) = delete;
FrameBuffer &operator=(FrameBuffer &&) = delete;
const std::vector<Plane> &planes() const { return planes_; }
Request *request() const { return request_; }
const FrameMetadata &metadata() const { return metadata_; };
unsigned int cookie() const { return cookie_; }
void setCookie(unsigned int cookie) { cookie_ = cookie; }
private:
friend class Request; /* Needed to update request_. */
friend class V4L2VideoDevice; /* Needed to update metadata_. */
std::vector<Plane> planes_;
Request *request_;
FrameMetadata metadata_;
unsigned int cookie_;
};
class Plane final
{
public: