libcamera  v0.3.2+116-83c5ad0f
Supporting cameras in Linux since 2019
framebuffer.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  * Frame buffer handling
6  */
7 
8 #pragma once
9 
10 #include <limits>
11 #include <memory>
12 #include <stdint.h>
13 #include <vector>
14 
15 #include <libcamera/base/class.h>
17 #include <libcamera/base/span.h>
18 
19 namespace libcamera {
20 
21 class Fence;
22 class Request;
23 
24 struct FrameMetadata {
25  enum Status {
29  };
30 
31  struct Plane {
32  unsigned int bytesused;
33  };
34 
36  unsigned int sequence;
37  uint64_t timestamp;
38 
39  Span<Plane> planes() { return planes_; }
40  Span<const Plane> planes() const { return planes_; }
41 
42 private:
43  friend class FrameBuffer;
44 
45  std::vector<Plane> planes_;
46 };
47 
48 class FrameBuffer : public Extensible
49 {
50  LIBCAMERA_DECLARE_PRIVATE()
51 
52 public:
53  struct Plane {
54  static constexpr unsigned int kInvalidOffset = std::numeric_limits<unsigned int>::max();
56  unsigned int offset = kInvalidOffset;
57  unsigned int length;
58  };
59 
60  FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);
61  FrameBuffer(std::unique_ptr<Private> d);
62  virtual ~FrameBuffer() {}
63 
64  const std::vector<Plane> &planes() const;
65  Request *request() const;
66  const FrameMetadata &metadata() const;
67 
68  uint64_t cookie() const;
69  void setCookie(uint64_t cookie);
70 
71  std::unique_ptr<Fence> releaseFence();
72 
73 private:
74  LIBCAMERA_DISABLE_COPY_AND_MOVE(FrameBuffer)
75 };
76 
77 } /* namespace libcamera */
RAII-style wrapper for file descriptors.
Definition: shared_fd.h:16
Span< const Plane > planes() const
Retrieve the array of per-plane metadata.
Definition: framebuffer.h:40
Status status
Status of the frame.
Definition: framebuffer.h:35
File descriptor wrapper.
Status
Define the frame completion status.
Definition: framebuffer.h:25
Top-level libcamera namespace.
Definition: bound_method.h:15
unsigned int length
The plane length in bytes.
Definition: framebuffer.h:57
Definition: framebuffer.h:27
Frame buffer data and its associated dynamic metadata.
Definition: framebuffer.h:48
Metadata related to a captured frame.
Definition: framebuffer.h:24
uint64_t timestamp
Time when the frame was captured.
Definition: framebuffer.h:37
A frame capture request.
Definition: request.h:29
Definition: framebuffer.h:26
Per-plane frame metadata.
Definition: framebuffer.h:31
SharedFD fd
The dmabuf file descriptor.
Definition: framebuffer.h:55
Definition: framebuffer.h:28
A memory region to store a single plane of a frame.
Definition: framebuffer.h:53
Span< Plane > planes()
Retrieve the array of per-plane metadata.
Definition: framebuffer.h:39
unsigned int sequence
Frame sequence number.
Definition: framebuffer.h:36
unsigned int bytesused
Number of bytes occupied by the data in the plane, including line padding.
Definition: framebuffer.h:32