summaryrefslogtreecommitdiff
path: root/include/libcamera/framebuffer_allocator.h
blob: a96aaeae58ce109a08f96155c16d777e3f66cd3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* 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:
	FrameBufferAllocator(std::shared_ptr<Camera> camera);
	FrameBufferAllocator(const FrameBufferAllocator &) = delete;
	FrameBufferAllocator &operator=(const FrameBufferAllocator &) = 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:
	std::shared_ptr<Camera> camera_;
	std::map<Stream *, std::vector<std::unique_ptr<FrameBuffer>>> buffers_;
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__ */