libcamera: include/libcamera/request.h Source File

libcamera v0.0.4 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
request.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 * request.h - Capture request handling
6 */
7
8#pragma once
9
10#include <map>
11#include <memory>
12#include <ostream>
13#include <stdint.h>
14#include <string>
15#include <unordered_set>
16
17#include <libcamera/base/class.h>
18#include <libcamera/base/signal.h>
19
20#include <libcamera/controls.h>
21#include <libcamera/fence.h>
22
23namespace libcamera {
24
25class Camera;
26class CameraControlValidator;
27class FrameBuffer;
28class Stream;
29
30 class Request : public Extensible
31{
32 LIBCAMERA_DECLARE_PRIVATE()
33
34public:
35 enum Status {
36 RequestPending,
37 RequestComplete,
38 RequestCancelled,
39 };
40
41 enum ReuseFlag {
42 Default = 0,
43 ReuseBuffers = (1 << 0),
44 };
45
46 using BufferMap = std::map<const Stream *, FrameBuffer *>;
47
48 Request(Camera *camera, uint64_t cookie = 0);
49 ~Request();
50
51 void reuse(ReuseFlag flags = Default);
52
53 ControlList &controls() { return *controls_; }
54 ControlList &metadata() { return *metadata_; }
55 const BufferMap &buffers() const { return bufferMap_; }
56 int addBuffer(const Stream *stream, FrameBuffer *buffer,
57 std::unique_ptr<Fence> fence = nullptr);
58 FrameBuffer *findBuffer(const Stream *stream) const;
59
60 uint32_t sequence() const;
61 uint64_t cookie() const { return cookie_; }
62 Status status() const { return status_; }
63
64 bool hasPendingBuffers() const;
65
66 std::string toString() const;
67
68private:
69 LIBCAMERA_DISABLE_COPY(Request)
70
71 ControlList *controls_;
72 ControlList *metadata_;
73 BufferMap bufferMap_;
74
75 const uint64_t cookie_;
76 Status status_;
77};
78
79std::ostream &operator<<(std::ostream &out, const Request &r);
80
81} /* namespace libcamera */
class.h
Utilities to help constructing class interfaces.
LIBCAMERA_DECLARE_PRIVATE
#define LIBCAMERA_DECLARE_PRIVATE()
Declare private data for a public class.
LIBCAMERA_DISABLE_COPY
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
libcamera::Camera
Camera device.
Definition: camera.h:87
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition: controls.h:350
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:50
libcamera::Request
A frame capture request.
Definition: request.h:31
libcamera::Request::Status
Status
Definition: request.h:35
libcamera::Request::RequestPending
@ RequestPending
Definition: request.h:36
libcamera::Request::RequestCancelled
@ RequestCancelled
Definition: request.h:38
libcamera::Request::RequestComplete
@ RequestComplete
Definition: request.h:37
libcamera::Request::hasPendingBuffers
bool hasPendingBuffers() const
Check if a request has buffers yet to be completed.
Definition: request.cpp:572
libcamera::Request::addBuffer
int addBuffer(const Stream *stream, FrameBuffer *buffer, std::unique_ptr< Fence > fence=nullptr)
Add a FrameBuffer with its associated Stream to the Request.
Definition: request.cpp:462
libcamera::Request::buffers
const BufferMap & buffers() const
Retrieve the request's streams to buffers map.
Definition: request.h:55
libcamera::Request::toString
std::string toString() const
Generate a string representation of the Request internals.
Definition: request.cpp:585
libcamera::Request::BufferMap
std::map< const Stream *, FrameBuffer * > BufferMap
A map of Stream to FrameBuffer pointers.
Definition: request.h:46
libcamera::Request::sequence
uint32_t sequence() const
Retrieve the sequence number for the request.
Definition: request.cpp:542
libcamera::Request::cookie
uint64_t cookie() const
Retrieve the cookie set when the request was created.
Definition: request.h:61
libcamera::Request::ReuseFlag
ReuseFlag
Definition: request.h:41
libcamera::Request::ReuseBuffers
@ ReuseBuffers
Definition: request.h:43
libcamera::Request::Default
@ Default
Definition: request.h:42
libcamera::Request::findBuffer
FrameBuffer * findBuffer(const Stream *stream) const
Return the buffer associated with a stream.
Definition: request.cpp:510
libcamera::Request::status
Status status() const
Retrieve the request completion status.
Definition: request.h:62
libcamera::Request::metadata
ControlList & metadata()
Retrieve the request's metadata.
Definition: request.h:54
libcamera::Request::controls
ControlList & controls()
Retrieve the request's ControlList.
Definition: request.h:53
libcamera::Request::reuse
void reuse(ReuseFlag flags=Default)
Reset the request for reuse.
Definition: request.cpp:382
libcamera::Stream
Video stream for a camera.
Definition: stream.h:77
controls.h
Framework to manage controls related to an object.
fence.h
Definition of the Fence class.
libcamera
Top-level libcamera namespace.
Definition: backtrace.h:17
libcamera::operator<<
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition: geometry.cpp:91
signal.h
Signal & slot implementation.