libcamera  v0.0.0+100-debian/0_git20200629+e7aa92a-8-9-g77f5237c-dirty (2021-05-05T16:20:29+01:00)
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 #include <libcamera/class.h>
15 
16 namespace libcamera {
17 
18 class Camera;
19 class FrameBuffer;
20 class Stream;
21 
23 {
24 public:
25  FrameBufferAllocator(std::shared_ptr<Camera> camera);
27 
28  int allocate(Stream *stream);
29  int free(Stream *stream);
30 
31  bool allocated() const { return !buffers_.empty(); }
32  const std::vector<std::unique_ptr<FrameBuffer>> &buffers(Stream *stream) const;
33 
34 private:
36 
37  std::shared_ptr<Camera> camera_;
38  std::map<Stream *, std::vector<std::unique_ptr<FrameBuffer>>> buffers_;
39 };
40 
41 } /* namespace libcamera */
42 
43 #endif /* __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__ */
const std::vector< std::unique_ptr< FrameBuffer > > & buffers(Stream *stream) const
Retrieve the buffers allocated for a stream.
Definition: framebuffer_allocator.cpp:146
Utilities to help constructing class interfaces.
FrameBuffer allocator for applications.
Definition: framebuffer_allocator.h:22
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
Top-level libcamera namespace.
Definition: bound_method.h:15
bool allocated() const
Check if the allocator has allocated buffers for any stream.
Definition: framebuffer_allocator.h:31
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
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