libcamera  v0.3.2+116-83c5ad0f
Supporting cameras in Linux since 2019
camera.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2021, Google Inc.
4  *
5  * Camera private data
6  */
7 
8 #pragma once
9 
10 #include <atomic>
11 #include <list>
12 #include <memory>
13 #include <set>
14 #include <string>
15 
16 #include <libcamera/base/class.h>
17 
18 #include <libcamera/camera.h>
19 
20 namespace libcamera {
21 
22 class CameraControlValidator;
23 class PipelineHandler;
24 class Stream;
25 
27 {
29 
30 public:
32  ~Private();
33 
34  PipelineHandler *pipe() { return pipe_.get(); }
35 
36  std::list<Request *> queuedRequests_;
39 
40  uint32_t requestSequence_;
41 
42  const CameraControlValidator *validator() const { return validator_.get(); }
43 
44 private:
45  enum State {
46  CameraAvailable,
47  CameraAcquired,
48  CameraConfigured,
49  CameraStopping,
50  CameraRunning,
51  };
52 
53  bool isAcquired() const;
54  bool isRunning() const;
55  int isAccessAllowed(State state, bool allowDisconnected = false,
56  const char *from = __builtin_FUNCTION()) const;
57  int isAccessAllowed(State low, State high,
58  bool allowDisconnected = false,
59  const char *from = __builtin_FUNCTION()) const;
60 
61  void disconnect();
62  void setState(State state);
63 
64  std::shared_ptr<PipelineHandler> pipe_;
65  std::string id_;
66  std::set<Stream *> streams_;
67  std::set<const Stream *> activeStreams_;
68 
69  bool disconnected_;
70  std::atomic<State> state_;
71 
72  std::unique_ptr<CameraControlValidator> validator_;
73 };
74 
75 } /* namespace libcamera */
Base class for private data managed through a d-pointer.
Definition: class.h:64
Utilities to help constructing class interfaces.
ControlList properties_
The list of properties supported by the camera.
Definition: camera.h:38
Camera device handling.
Top-level libcamera namespace.
Definition: backtrace.h:17
PipelineHandler * pipe()
Retrieve the pipeline handler related to this camera.
Definition: camera.h:34
ControlInfoMap controlInfo_
The set of controls supported by the camera.
Definition: camera.h:37
#define LIBCAMERA_DECLARE_PUBLIC(klass)
Declare public data for a private class.
A control validator for Camera instances.
Definition: camera_controls.h:16
uint32_t requestSequence_
The queuing sequence number of the request.
Definition: camera.h:40
A map of ControlId to ControlInfo.
Definition: controls.h:336
Private()
Construct an instance of an Extensible class private data.
Definition: class.cpp:194
Create and manage cameras based on a set of media devices.
Definition: pipeline_handler.h:33
Camera device.
Definition: camera.h:113
Base class for camera private data.
Definition: camera.h:26
const CameraControlValidator * validator() const
Retrieve the control validator related to this camera.
Definition: camera.h:42
Associate a list of ControlId with their values for an object.
Definition: controls.h:380
std::list< Request * > queuedRequests_
The list of queued and not yet completed requests.
Definition: camera.h:36