libcamera  v0.2.0+85-1c5830a9
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  * 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 
23 namespace libcamera {
24 
25 class Camera;
26 class CameraControlValidator;
27 class FrameBuffer;
28 class Stream;
29 
30 class Request : public Extensible
31 {
33 
34 public:
35  enum Status {
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 
68 private:
70 
71  ControlList *controls_;
72  ControlList *metadata_;
73  BufferMap bufferMap_;
74 
75  const uint64_t cookie_;
76  Status status_;
77 };
78 
79 std::ostream &operator<<(std::ostream &out, const Request &r);
80 
81 } /* namespace libcamera */
Definition: request.h:36
Utilities to help constructing class interfaces.
ControlList & controls()
Retrieve the request&#39;s ControlList.
Definition: request.h:53
bool hasPendingBuffers() const
Check if a request has buffers yet to be completed.
Definition: request.cpp:572
Video stream for a camera.
Definition: stream.h:74
Top-level libcamera namespace.
Definition: backtrace.h:17
std::map< const Stream *, FrameBuffer * > BufferMap
A map of Stream to FrameBuffer pointers.
Definition: request.h:46
Definition: request.h:37
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
Frame buffer data and its associated dynamic metadata.
Definition: framebuffer.h:49
FrameBuffer * findBuffer(const Stream *stream) const
Return the buffer associated with a stream.
Definition: request.cpp:510
uint32_t sequence() const
Retrieve the sequence number for the request.
Definition: request.cpp:542
Definition: request.h:43
#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:55
ControlList & metadata()
Retrieve the request&#39;s metadata.
Definition: request.h:54
A frame capture request.
Definition: request.h:30
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
Signal & slot implementation.
Status
Definition: request.h:35
std::string toString() const
Generate a string representation of the Request internals.
Definition: request.cpp:585
Camera device.
Definition: camera.h:113
void reuse(ReuseFlag flags=Default)
Reset the request for reuse.
Definition: request.cpp:382
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:41
Associate a list of ControlId with their values for an object.
Definition: controls.h:349
Framework to manage controls related to an object.
Definition: request.h:42
Definition: request.h:38
Status status() const
Retrieve the request completion status.
Definition: request.h:62
uint64_t cookie() const
Retrieve the cookie set when the request was created.
Definition: request.h:61
Request(Camera *camera, uint64_t cookie=0)
Create a capture request for a camera.
Definition: request.cpp:347