libcamera  v0.0.0
Supporting cameras in Linux since 2019
framebuffer_allocator.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2019, Google Inc.
4  *
5  * framebuffer_allocator.h - FrameBuffer allocator
6  */
7 #ifndef __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__
8 #define __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__
9 
10 #include <map>
11 #include <memory>
12 #include <vector>
13 
14 namespace libcamera {
15 
16 class Camera;
17 class FrameBuffer;
18 class Stream;
19 
21 {
22 public:
23  FrameBufferAllocator(std::shared_ptr<Camera> camera);
24  FrameBufferAllocator(const Camera &) = delete;
25  FrameBufferAllocator &operator=(const Camera &) = delete;
26 
28 
29  int allocate(Stream *stream);
30  int free(Stream *stream);
31 
32  bool allocated() const { return !buffers_.empty(); }
33  const std::vector<std::unique_ptr<FrameBuffer>> &buffers(Stream *stream) const;
34 
35 private:
36  std::shared_ptr<Camera> camera_;
37  std::map<Stream *, std::vector<std::unique_ptr<FrameBuffer>>> buffers_;
38 };
39 
40 } /* namespace libcamera */
41 
42 #endif /* __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__ */
Camera device.
Definition: camera.h:70
FrameBuffer allocator for applications.
Definition: framebuffer_allocator.h:21
int free(Stream *stream)
Free buffers previously allocated for a stream.
Definition: framebuffer_allocator.cpp:115
int allocate(Stream *stream)
Allocate buffers for a configured stream.
Definition: framebuffer_allocator.cpp:88
const std::vector< std::unique_ptr< FrameBuffer > > & buffers(Stream *stream) const
Retrieve the buffers allocated for a stream.
Definition: framebuffer_allocator.cpp:146
bool allocated() const
Check if the allocator has allocated buffers for any stream.
Definition: framebuffer_allocator.h:32
FrameBufferAllocator(std::shared_ptr< Camera > camera)
Construct a FrameBufferAllocator serving a camera.
Definition: framebuffer_allocator.cpp:60
Video stream for a camera.
Definition: stream.h:70