Loading...
Searching...
No Matches
framebuffer.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* Frame buffer handling
*/
#pragma once
#include <limits>
#include <memory>
#include <stdint.h>
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/shared_fd.h>
#include <libcamera/base/span.h>
namespace libcamera {
class Fence;
class Request;
struct FrameMetadata {
enum Status {
FrameSuccess,
FrameError,
FrameCancelled,
FrameStartup,
};
struct Plane {
unsigned int bytesused;
};
Status status;
unsigned int sequence;
uint64_t timestamp;
Span<Plane> planes() { return planes_; }
Span<const Plane> planes() const { return planes_; }
private:
friend class FrameBuffer;
std::vector<Plane> planes_;
};
class FrameBuffer : public Extensible
{
LIBCAMERA_DECLARE_PRIVATE()
public:
struct Plane {
static constexpr unsigned int kInvalidOffset = std::numeric_limits<unsigned int>::max();
SharedFD fd;
unsigned int offset = kInvalidOffset;
unsigned int length;
};
FrameBuffer(Span<const Plane> planes, unsigned int cookie = 0);
FrameBuffer(std::unique_ptr<Private> d);
virtual ~FrameBuffer() {}
Span<const Plane> planes() const;
Request *request() const;
const FrameMetadata &metadata() const;
uint64_t cookie() const;
void setCookie(uint64_t cookie);
std::unique_ptr<Fence> releaseFence();
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(FrameBuffer)
};
} /* 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