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) 2019, Google Inc.
4  *
5  * buffer.h - Buffer handling
6  */
7 #ifndef __LIBCAMERA_BUFFER_H__
8 #define __LIBCAMERA_BUFFER_H__
9 
10 #include <stdint.h>
11 #include <vector>
12 
13 #include <libcamera/class.h>
15 
16 namespace libcamera {
17 
18 class Request;
19 
20 struct FrameMetadata {
21  enum Status {
25  };
26 
27  struct Plane {
28  unsigned int bytesused;
29  };
30 
32  unsigned int sequence;
33  uint64_t timestamp;
34  std::vector<Plane> planes;
35 };
36 
37 class FrameBuffer final
38 {
39 public:
40  struct Plane {
42  unsigned int length;
43  };
44 
45  FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);
46 
47  const std::vector<Plane> &planes() const { return planes_; }
48 
49  Request *request() const { return request_; }
50  void setRequest(Request *request) { request_ = request; }
51  const FrameMetadata &metadata() const { return metadata_; }
52 
53  unsigned int cookie() const { return cookie_; }
54  void setCookie(unsigned int cookie) { cookie_ = cookie; }
55 
56  void cancel() { metadata_.status = FrameMetadata::FrameCancelled; }
57 
58 private:
60 
61  friend class V4L2VideoDevice; /* Needed to update metadata_. */
62 
63  std::vector<Plane> planes_;
64 
65  Request *request_;
66  FrameMetadata metadata_;
67 
68  unsigned int cookie_;
69 };
70 
71 } /* namespace libcamera */
72 
73 #endif /* __LIBCAMERA_BUFFER_H__ */
Utilities to help constructing class interfaces.
Status status
Status of the frame.
Definition: buffer.h:31
Request * request() const
Retrieve the request this buffer belongs to.
Definition: buffer.h:49
unsigned int cookie() const
Retrieve the cookie.
Definition: buffer.h:53
RAII-style wrapper for file descriptors.
Definition: file_descriptor.h:14
Status
Define the frame completion status.
Definition: buffer.h:21
Top-level libcamera namespace.
Definition: bound_method.h:15
unsigned int length
The plane length in bytes.
Definition: buffer.h:42
const FrameMetadata & metadata() const
Retrieve the dynamic metadata.
Definition: buffer.h:51
Frame buffer data and its associated dynamic metadata.
Definition: buffer.h:37
void setCookie(unsigned int cookie)
Set the cookie.
Definition: buffer.h:54
Metadata related to a captured frame.
Definition: buffer.h:20
V4L2VideoDevice object and API.
Definition: v4l2_videodevice.h:172
uint64_t timestamp
Time when the frame was captured.
Definition: buffer.h:33
File descriptor wrapper.
A frame capture request.
Definition: request.h:27
Per-plane frame metadata.
Definition: buffer.h:27
std::vector< Plane > planes
Array of per-plane metadata.
Definition: buffer.h:34
#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
Disable copy and move construction and assignment of the klass.
FileDescriptor fd
The dmabuf file descriptor.
Definition: buffer.h:41
void setRequest(Request *request)
Set the request this buffer belongs to.
Definition: buffer.h:50
A memory region to store a single plane of a frame.
Definition: buffer.h:40
unsigned int sequence
Frame sequence number.
Definition: buffer.h:32
unsigned int bytesused
Number of bytes occupied by the data in the plane, including line padding.
Definition: buffer.h:28
void cancel()
Marks the buffer as cancelled.
Definition: buffer.h:56
const std::vector< Plane > & planes() const
Retrieve the static plane descriptors.
Definition: buffer.h:47