libcamera v0.3.2 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 };
30
31 struct Plane {
32 unsigned int bytesused;
33 };
34
35 Status status;
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();
55 SharedFD fd;
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 */
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
Base class to manage private data through a d-pointer.
Definition class.h:62
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:49
libcamera::FrameBuffer::request
Request * request() const
Retrieve the request this buffer belongs to.
Definition framebuffer.cpp:379
libcamera::FrameBuffer::releaseFence
std::unique_ptr< Fence > releaseFence()
Extract the Fence associated with this Framebuffer.
Definition framebuffer.cpp:436
libcamera::FrameBuffer::FrameBuffer
FrameBuffer(const std::vector< Plane > &planes, unsigned int cookie=0)
Construct a FrameBuffer with an array of planes.
Definition framebuffer.cpp:311
libcamera::FrameBuffer::metadata
const FrameMetadata & metadata() const
Retrieve the dynamic metadata.
Definition framebuffer.cpp:388
libcamera::FrameBuffer::setCookie
void setCookie(uint64_t cookie)
Set the cookie.
Definition framebuffer.cpp:417
libcamera::FrameBuffer::planes
const std::vector< Plane > & planes() const
Retrieve the static plane descriptors.
Definition framebuffer.cpp:361
libcamera::FrameBuffer::cookie
uint64_t cookie() const
Retrieve the cookie.
Definition framebuffer.cpp:403
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:53
libcamera::FrameBuffer::Plane::kInvalidOffset
static constexpr unsigned int kInvalidOffset
Invalid offset value, to identify uninitialized planes.
Definition framebuffer.h:54
libcamera::FrameBuffer::Plane::fd
SharedFD fd
The dmabuf file descriptor.
Definition framebuffer.h:55
libcamera::FrameBuffer::Plane::length
unsigned int length
The plane length in bytes.
Definition framebuffer.h:57
libcamera::FrameBuffer::Plane::offset
unsigned int offset
The plane offset in bytes.
Definition framebuffer.h:56
libcamera::FrameMetadata::Plane
Per-plane frame metadata.
Definition framebuffer.h:31
libcamera::FrameMetadata::Plane::bytesused
unsigned int bytesused
Number of bytes occupied by the data in the plane, including line padding.
Definition framebuffer.h:32
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::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:40
libcamera::FrameMetadata::status
Status status
Status of the frame.
Definition framebuffer.h:35
libcamera::FrameMetadata::sequence
unsigned int sequence
Frame sequence number.
Definition framebuffer.h:36
libcamera::FrameMetadata::planes
Span< Plane > planes()
Retrieve the array of per-plane metadata.
Definition framebuffer.h:39
libcamera::FrameMetadata::timestamp
uint64_t timestamp
Time when the frame was captured.
Definition framebuffer.h:37