libcamera v0.4.0+5314-fc77c53d-nvm
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
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
19namespace libcamera {
20
21class Fence;
22class Request;
23
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
42private:
43 friend class FrameBuffer;
44
45 std::vector<Plane> planes_;
46};
47
48class FrameBuffer : public Extensible
49{
50 LIBCAMERA_DECLARE_PRIVATE()
51
52public:
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
73private:
74 LIBCAMERA_DISABLE_COPY_AND_MOVE(FrameBuffer)
75};
76
77} /* namespace libcamera */
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:49
Request * request() const
Retrieve the request this buffer belongs to.
Definition framebuffer.cpp:379
std::unique_ptr< Fence > releaseFence()
Extract the Fence associated with this Framebuffer.
Definition framebuffer.cpp:436
const FrameMetadata & metadata() const
Retrieve the dynamic metadata.
Definition framebuffer.cpp:388
void setCookie(uint64_t cookie)
Set the cookie.
Definition framebuffer.cpp:417
const std::vector< Plane > & planes() const
Retrieve the static plane descriptors.
Definition framebuffer.cpp:361
uint64_t cookie() const
Retrieve the cookie.
Definition framebuffer.cpp:403
A frame capture request.
Definition request.h:30
RAII-style wrapper for file descriptors.
Definition shared_fd.h:17
Top-level libcamera namespace.
Definition bound_method.h:15
File descriptor wrapper.
A memory region to store a single plane of a frame.
Definition framebuffer.h:53
unsigned int length
The plane length in bytes.
Definition framebuffer.h:57
unsigned int offset
The plane offset in bytes.
Definition framebuffer.h:56
static constexpr unsigned int kInvalidOffset
Invalid offset value, to identify uninitialized planes.
Definition framebuffer.h:54
SharedFD fd
The dmabuf file descriptor.
Definition framebuffer.h:55
Per-plane frame metadata.
Definition framebuffer.h:31
unsigned int bytesused
Number of bytes occupied by the data in the plane, including line padding.
Definition framebuffer.h:32
Metadata related to a captured frame.
Definition framebuffer.h:24
uint64_t timestamp
Time when the frame was captured.
Definition framebuffer.h:37
Status
Define the frame completion status.
Definition framebuffer.h:25
@ FrameCancelled
Definition framebuffer.h:28
@ FrameError
Definition framebuffer.h:27
@ FrameSuccess
Definition framebuffer.h:26
unsigned int sequence
Frame sequence number.
Definition framebuffer.h:36
Span< const Plane > planes() const
Retrieve the array of per-plane metadata.
Definition framebuffer.h:40
Span< Plane > planes()
Retrieve the array of per-plane metadata.
Definition framebuffer.h:39
Status status
Status of the frame.
Definition framebuffer.h:35