libcamera  v0.4.0
Supporting cameras in Linux since 2019
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  * 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 
16 #include <libcamera/base/class.h>
17 #include <libcamera/base/signal.h>
18 
19 #include <libcamera/controls.h>
20 #include <libcamera/fence.h>
21 
22 namespace libcamera {
23 
24 class Camera;
25 class CameraControlValidator;
26 class FrameBuffer;
27 class Stream;
28 
29 class Request : public Extensible
30 {
32 
33 public:
34  enum Status {
38  };
39 
40  enum ReuseFlag {
41  Default = 0,
42  ReuseBuffers = (1 << 0),
43  };
44 
45  using BufferMap = std::map<const Stream *, FrameBuffer *>;
46 
47  Request(Camera *camera, uint64_t cookie = 0);
48  ~Request();
49 
50  void reuse(ReuseFlag flags = Default);
51 
52  ControlList &controls() { return *controls_; }
53  ControlList &metadata() { return *metadata_; }
54  const BufferMap &buffers() const { return bufferMap_; }
55  int addBuffer(const Stream *stream, FrameBuffer *buffer,
56  std::unique_ptr<Fence> fence = nullptr);
57  FrameBuffer *findBuffer(const Stream *stream) const;
58 
59  uint32_t sequence() const;
60  uint64_t cookie() const { return cookie_; }
61  Status status() const { return status_; }
62 
63  bool hasPendingBuffers() const;
64 
65  std::string toString() const;
66 
67 private:
69 
70  ControlList *controls_;
71  ControlList *metadata_;
72  BufferMap bufferMap_;
73 
74  const uint64_t cookie_;
75  Status status_;
76 };
77 
78 std::ostream &operator<<(std::ostream &out, const Request &r);
79 
80 } /* namespace libcamera */
Definition: request.h:35
Utilities to help constructing class interfaces.
ControlList & controls()
Retrieve the request&#39;s ControlList.
Definition: request.h:52
bool hasPendingBuffers() const
Check if a request has buffers yet to be completed.
Definition: request.cpp:580
Video stream for a camera.
Definition: stream.h:75
Top-level libcamera namespace.
Definition: backtrace.h:17
std::map< const Stream *, FrameBuffer * > BufferMap
A map of Stream to FrameBuffer pointers.
Definition: request.h:45
Definition: request.h:36
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:470
Frame buffer data and its associated dynamic metadata.
Definition: framebuffer.h:48
FrameBuffer * findBuffer(const Stream *stream) const
Return the buffer associated with a stream.
Definition: request.cpp:518
uint32_t sequence() const
Retrieve the sequence number for the request.
Definition: request.cpp:550
Definition: request.h:42
#define LIBCAMERA_DECLARE_PRIVATE()
Declare private data for a public class.
const BufferMap & buffers() const
Retrieve the request&#39;s streams to buffers map.
Definition: request.h:54
ControlList & metadata()
Retrieve the request&#39;s metadata.
Definition: request.h:53
A frame capture request.
Definition: request.h:29
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
Signal & slot implementation.
Status
Definition: request.h:34
std::string toString() const
Generate a string representation of the Request internals.
Definition: request.cpp:593
Camera device.
Definition: camera.h:113
void reuse(ReuseFlag flags=Default)
Reset the request for reuse.
Definition: request.cpp:390
Base class to manage private data through a d-pointer.
Definition: class.h:61
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition: geometry.cpp:91
Definition of the Fence class.
ReuseFlag
Definition: request.h:40
Associate a list of ControlId with their values for an object.
Definition: controls.h:410
Framework to manage controls related to an object.
Definition: request.h:41
Definition: request.h:37
Status status() const
Retrieve the request completion status.
Definition: request.h:61
uint64_t cookie() const
Retrieve the cookie set when the request was created.
Definition: request.h:60
Request(Camera *camera, uint64_t cookie=0)
Create a capture request for a camera.
Definition: request.cpp:355