libcamera  v0.0.0+2749-f23f3922
Supporting cameras in Linux since 2019
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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/base/class.h>
14 
16 
17 namespace libcamera {
18 
19 class Request;
20 
21 struct FrameMetadata {
22  enum Status {
26  };
27 
28  struct Plane {
29  unsigned int bytesused;
30  };
31 
33  unsigned int sequence;
34  uint64_t timestamp;
35  std::vector<Plane> planes;
36 };
37 
38 class FrameBuffer final
39 {
40 public:
41  struct Plane {
43  unsigned int length;
44  };
45 
46  FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);
47 
48  const std::vector<Plane> &planes() const { return planes_; }
49 
50  Request *request() const { return request_; }
51  void setRequest(Request *request) { request_ = request; }
52  const FrameMetadata &metadata() const { return metadata_; }
53 
54  unsigned int cookie() const { return cookie_; }
55  void setCookie(unsigned int cookie) { cookie_ = cookie; }
56 
57  void cancel() { metadata_.status = FrameMetadata::FrameCancelled; }
58 
59 private:
61 
62  friend class V4L2VideoDevice; /* Needed to update metadata_. */
63 
64  std::vector<Plane> planes_;
65 
66  Request *request_;
67  FrameMetadata metadata_;
68 
69  unsigned int cookie_;
70 };
71 
72 } /* namespace libcamera */
73 
74 #endif /* __LIBCAMERA_BUFFER_H__ */
Utilities to help constructing class interfaces.
Status status
Status of the frame.
Definition: buffer.h:32
Request * request() const
Retrieve the request this buffer belongs to.
Definition: buffer.h:50
unsigned int cookie() const
Retrieve the cookie.
Definition: buffer.h:54
RAII-style wrapper for file descriptors.
Definition: file_descriptor.h:14
Status
Define the frame completion status.
Definition: buffer.h:22
Top-level libcamera namespace.
Definition: bound_method.h:15
unsigned int length
The plane length in bytes.
Definition: buffer.h:43
const FrameMetadata & metadata() const
Retrieve the dynamic metadata.
Definition: buffer.h:52
Frame buffer data and its associated dynamic metadata.
Definition: buffer.h:38
void setCookie(unsigned int cookie)
Set the cookie.
Definition: buffer.h:55
Metadata related to a captured frame.
Definition: buffer.h:21
V4L2VideoDevice object and API.
Definition: v4l2_videodevice.h:173
uint64_t timestamp
Time when the frame was captured.
Definition: buffer.h:34
File descriptor wrapper.
A frame capture request.
Definition: request.h:28
Per-plane frame metadata.
Definition: buffer.h:28
std::vector< Plane > planes
Array of per-plane metadata.
Definition: buffer.h:35
#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:42
void setRequest(Request *request)
Set the request this buffer belongs to.
Definition: buffer.h:51
A memory region to store a single plane of a frame.
Definition: buffer.h:41
unsigned int sequence
Frame sequence number.
Definition: buffer.h:33
unsigned int bytesused
Number of bytes occupied by the data in the plane, including line padding.
Definition: buffer.h:29
void cancel()
Marks the buffer as cancelled.
Definition: buffer.h:57
const std::vector< Plane > & planes() const
Retrieve the static plane descriptors.
Definition: buffer.h:48