summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-29 15:15:23 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-05-23 00:27:14 +0300
commit77ae64eb24bf6c2fe241b6f7b841315b1ee15707 (patch)
tree7c85eba53482bf3212644acc7b02796dea2a3b48 /include
parenta40023e6cc005dfc57cc535167ee44761f3ed9f6 (diff)
libcamera: Refactor the camera configuration storage and API
Refactor the CameraConfiguration structure to not rely on Stream instances. This is a step towards making the camera configuration object more powerful with configuration validation using "try" semantics. The CameraConfiguration now exposes a simple vector-like API to access the contained stream configurations. Both operator[]() and at() are provided to access elements. The isEmpty() method is renamed to empty() and the methods reordered to match the std::vector class. As applications need access to the Stream instances associated with the configuration entries in order to associate buffers with streams when creating requests, expose the stream selected by the pipeline handler through a new StreamConfiguration::stream(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/camera.h36
-rw-r--r--include/libcamera/stream.h12
2 files changed, 33 insertions, 15 deletions
diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h
index 42ba5201..284e5276 100644
--- a/include/libcamera/camera.h
+++ b/include/libcamera/camera.h
@@ -25,30 +25,36 @@ class Request;
class CameraConfiguration
{
public:
- using iterator = std::vector<Stream *>::iterator;
- using const_iterator = std::vector<Stream *>::const_iterator;
+ using iterator = std::vector<StreamConfiguration>::iterator;
+ using const_iterator = std::vector<StreamConfiguration>::const_iterator;
CameraConfiguration();
+ void addConfiguration(const StreamConfiguration &cfg);
+
+ bool isValid() const;
+
+ StreamConfiguration &at(unsigned int index);
+ const StreamConfiguration &at(unsigned int index) const;
+ StreamConfiguration &operator[](unsigned int index)
+ {
+ return at(index);
+ }
+ const StreamConfiguration &operator[](unsigned int index) const
+ {
+ return at(index);
+ }
+
iterator begin();
- iterator end();
const_iterator begin() const;
+ iterator end();
const_iterator end() const;
- bool isValid() const;
- bool isEmpty() const;
+ bool empty() const;
std::size_t size() const;
- Stream *front();
- const Stream *front() const;
-
- Stream *operator[](unsigned int index) const;
- StreamConfiguration &operator[](Stream *stream);
- const StreamConfiguration &operator[](Stream *stream) const;
-
private:
- std::vector<Stream *> order_;
- std::map<Stream *, StreamConfiguration> config_;
+ std::vector<StreamConfiguration> config_;
};
class Camera final
@@ -72,7 +78,7 @@ public:
const std::set<Stream *> &streams() const;
CameraConfiguration generateConfiguration(const StreamRoles &roles);
- int configure(const CameraConfiguration &config);
+ int configure(CameraConfiguration &config);
int allocateBuffers();
int freeBuffers();
diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 59bdf217..e38c0e7e 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -16,14 +16,26 @@
namespace libcamera {
class Camera;
+class Stream;
struct StreamConfiguration {
+ StreamConfiguration()
+ : stream_(nullptr)
+ {
+ }
+
unsigned int pixelFormat;
Size size;
unsigned int bufferCount;
+ Stream *stream() const { return stream_; }
+ void setStream(Stream *stream) { stream_ = stream; }
+
std::string toString() const;
+
+private:
+ Stream *stream_;
};
enum StreamRole {