summaryrefslogtreecommitdiff
path: root/include/libcamera/framebuffer_allocator.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libcamera/framebuffer_allocator.h')
-rw-r--r--include/libcamera/framebuffer_allocator.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h
new file mode 100644
index 00000000..42812253
--- /dev/null
+++ b/include/libcamera/framebuffer_allocator.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * framebuffer_allocator.h - FrameBuffer allocator
+ */
+#ifndef __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__
+#define __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__
+
+#include <map>
+#include <memory>
+#include <vector>
+
+namespace libcamera {
+
+class Camera;
+class FrameBuffer;
+class Stream;
+
+class FrameBufferAllocator
+{
+public:
+ static FrameBufferAllocator *create(std::shared_ptr<Camera> camera);
+
+ FrameBufferAllocator(const Camera &) = delete;
+ FrameBufferAllocator &operator=(const Camera &) = delete;
+
+ ~FrameBufferAllocator();
+
+ int allocate(Stream *stream);
+ int free(Stream *stream);
+
+ bool allocated() const { return !buffers_.empty(); }
+ const std::vector<std::unique_ptr<FrameBuffer>> &buffers(Stream *stream) const;
+
+private:
+ FrameBufferAllocator(std::shared_ptr<Camera> camera);
+
+ std::shared_ptr<Camera> camera_;
+ std::map<Stream *, std::vector<std::unique_ptr<FrameBuffer>>> buffers_;
+};
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__ */