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
buffer.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2020, Google Inc.
4  *
5  * buffer.h - Internal buffer handling
6  */
7 #ifndef __LIBCAMERA_INTERNAL_BUFFER_H__
8 #define __LIBCAMERA_INTERNAL_BUFFER_H__
9 
10 #include <sys/mman.h>
11 #include <vector>
12 
13 #include <libcamera/class.h>
14 #include <libcamera/buffer.h>
15 #include <libcamera/span.h>
16 
17 namespace libcamera {
18 
20 {
21 public:
22  using Plane = Span<uint8_t>;
23 
24  ~MappedBuffer();
25 
26  MappedBuffer(MappedBuffer &&other);
28 
29  bool isValid() const { return error_ == 0; }
30  int error() const { return error_; }
31  const std::vector<Plane> &maps() const { return maps_; }
32 
33 protected:
34  MappedBuffer();
35 
36  int error_;
37  std::vector<Plane> maps_;
38 
39 private:
41 };
42 
44 {
45 public:
46  MappedFrameBuffer(const FrameBuffer *buffer, int flags);
47 };
48 
49 } /* namespace libcamera */
50 
51 #endif /* __LIBCAMERA_INTERNAL_BUFFER_H__ */
Utilities to help constructing class interfaces.
Top-level libcamera namespace.
Definition: bound_method.h:15
Span< uint8_t > Plane
A mapped region of memory accessible to the CPU.
Definition: buffer.h:22
Frame buffer data and its associated dynamic metadata.
Definition: buffer.h:37
int error() const
Retrieve the map error status.
Definition: buffer.h:30
Map a FrameBuffer using the MappedBuffer interface.
Definition: buffer.h:43
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
const std::vector< Plane > & maps() const
Retrieve the mapped planes.
Definition: buffer.h:31
std::vector< Plane > maps_
Stores the internal mapped planes.
Definition: buffer.h:37
Buffer handling.
Provide an interface to support managing memory mapped buffers.
Definition: buffer.h:19
int error_
Stores the error value if present.
Definition: buffer.h:36
bool isValid() const
Check if the MappedBuffer instance is valid.
Definition: buffer.h:29
MappedBuffer & operator=(MappedBuffer &&other)
Move assignment operator, replace the mappings with those of other.
Definition: buffer.cpp:292
MappedBuffer()
Construct an empty MappedBuffer.
Definition: buffer.cpp:263