libcamera v0.6.0 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>
16#include <libcamera/base/shared_fd.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 {
26 FrameSuccess,
27 FrameError,
28 FrameCancelled,
29 FrameStartup,
30 };
31
32 struct Plane {
33 unsigned int bytesused;
34 };
35
36 Status status;
37 unsigned int sequence;
38 uint64_t timestamp;
39
40 Span<Plane> planes() { return planes_; }
41 Span<const Plane> planes() const { return planes_; }
42
43 private:
44 friend class FrameBuffer;
45
46 std::vector<Plane> planes_;
47};
48
49 class FrameBuffer : public Extensible
50{
51 LIBCAMERA_DECLARE_PRIVATE()
52
53 public:
54 struct Plane {
55 static constexpr unsigned int kInvalidOffset = std::numeric_limits<unsigned int>::max();
56 SharedFD fd;
57 unsigned int offset = kInvalidOffset;
58 unsigned int length;
59 };
60
61 FrameBuffer(Span<const Plane> planes, unsigned int cookie = 0);
62 FrameBuffer(std::unique_ptr<Private> d);
63 virtual ~FrameBuffer() {}
64
65 Span<const Plane> planes() const;
66 Request *request() const;
67 const FrameMetadata &metadata() const;
68
69 uint64_t cookie() const;
70 void setCookie(uint64_t cookie);
71
72 std::unique_ptr<Fence> releaseFence();
73
74 private:
75 LIBCAMERA_DISABLE_COPY_AND_MOVE(FrameBuffer)
76};
77
78} /* namespace libcamera */
class.h
Utilities to help constructing class interfaces.
LIBCAMERA_DECLARE_PRIVATE
#define LIBCAMERA_DECLARE_PRIVATE()
Declare private data for a public class.
Definition class.h:56
LIBCAMERA_DISABLE_COPY_AND_MOVE
#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
Disable copy and move construction and assignment of the klass.
Definition class.h:29
libcamera::Extensible::Extensible
Extensible(std::unique_ptr< Private > d)
Construct an instance of an Extensible class.
Definition class.cpp:154
libcamera::Fence
Synchronization primitive to manage resources.
Definition fence.h:16
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
libcamera::FrameBuffer::request
Request * request() const
Retrieve the request this buffer belongs to.
Definition framebuffer.cpp:386
libcamera::FrameBuffer::releaseFence
std::unique_ptr< Fence > releaseFence()
Extract the Fence associated with this Framebuffer.
Definition framebuffer.cpp:443
libcamera::FrameBuffer::metadata
const FrameMetadata & metadata() const
Retrieve the dynamic metadata.
Definition framebuffer.cpp:395
libcamera::FrameBuffer::planes
Span< const Plane > planes() const
Retrieve the static plane descriptors.
Definition framebuffer.cpp:368
libcamera::FrameBuffer::FrameBuffer
FrameBuffer(Span< const Plane > planes, unsigned int cookie=0)
Construct a FrameBuffer with an array of planes.
Definition framebuffer.cpp:318
libcamera::FrameBuffer::setCookie
void setCookie(uint64_t cookie)
Set the cookie.
Definition framebuffer.cpp:424
libcamera::FrameBuffer::cookie
uint64_t cookie() const
Retrieve the cookie.
Definition framebuffer.cpp:410
libcamera::Request
A frame capture request.
Definition request.h:30
libcamera::SharedFD
RAII-style wrapper for file descriptors.
Definition shared_fd.h:17
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
shared_fd.h
File descriptor wrapper.
libcamera::FrameBuffer::Plane
A memory region to store a single plane of a frame.
Definition framebuffer.h:54
libcamera::FrameBuffer::Plane::kInvalidOffset
static constexpr unsigned int kInvalidOffset
Invalid offset value, to identify uninitialized planes.
Definition framebuffer.h:55
libcamera::FrameBuffer::Plane::fd
SharedFD fd
The dmabuf file descriptor.
Definition framebuffer.h:56
libcamera::FrameBuffer::Plane::length
unsigned int length
The plane length in bytes.
Definition framebuffer.h:58
libcamera::FrameBuffer::Plane::offset
unsigned int offset
The plane offset in bytes.
Definition framebuffer.h:57
libcamera::FrameMetadata::Plane
Per-plane frame metadata.
Definition framebuffer.h:32
libcamera::FrameMetadata::Plane::bytesused
unsigned int bytesused
Number of bytes occupied by the data in the plane, including line padding.
Definition framebuffer.h:33
libcamera::FrameMetadata
Metadata related to a captured frame.
Definition framebuffer.h:24
libcamera::FrameMetadata::Status
Status
Define the frame completion status.
Definition framebuffer.h:25
libcamera::FrameMetadata::FrameCancelled
@ FrameCancelled
Definition framebuffer.h:28
libcamera::FrameMetadata::FrameStartup
@ FrameStartup
Definition framebuffer.h:29
libcamera::FrameMetadata::FrameSuccess
@ FrameSuccess
Definition framebuffer.h:26
libcamera::FrameMetadata::FrameError
@ FrameError
Definition framebuffer.h:27
libcamera::FrameMetadata::planes
Span< const Plane > planes() const
Retrieve the array of per-plane metadata.
Definition framebuffer.h:41
libcamera::FrameMetadata::status
Status status
Status of the frame.
Definition framebuffer.h:36
libcamera::FrameMetadata::sequence
unsigned int sequence
Frame sequence number.
Definition framebuffer.h:37
libcamera::FrameMetadata::planes
Span< Plane > planes()
Retrieve the array of per-plane metadata.
Definition framebuffer.h:40
libcamera::FrameMetadata::timestamp
uint64_t timestamp
Time when the frame was captured.
Definition framebuffer.h:38