libcamera: framebuffer: Prevent modifying the number of metadata planes

The number of metadata planes should always match the number of frame
buffer planes. Enforce this by making the vector private and providing
accessor functions.

As this changes the public API, update all in-tree users accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
This commit is contained in:
Laurent Pinchart 2021-09-02 04:29:03 +03:00
parent 9df775c757
commit 32635054bc
10 changed files with 34 additions and 20 deletions

View file

@ -13,6 +13,7 @@
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/span.h>
#include <libcamera/file_descriptor.h>
@ -34,7 +35,14 @@ struct FrameMetadata {
Status status;
unsigned int sequence;
uint64_t timestamp;
std::vector<Plane> planes;
Span<Plane> planes() { return planes_; }
Span<const Plane> planes() const { return planes_; }
private:
friend class FrameBuffer;
std::vector<Plane> planes_;
};
class FrameBuffer final : public Extensible