summaryrefslogtreecommitdiff
path: root/src/libcamera/include
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2018-12-20 01:32:05 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2018-12-31 00:58:29 +0100
commit7f8ef1bb99adeb5c849d5747f874412a89d1f193 (patch)
tree651518d3ab512454d7c42e350bf2e8e00baba4d7 /src/libcamera/include
parent01107c2490682add1a334ad8c58573e46ae50f31 (diff)
libcamera: pipeline_handler: add PipelineHandler class
Provide a PipelineHandler which represents a handler for one or more media devices and provides one or more cameras. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/include')
-rw-r--r--src/libcamera/include/pipeline_handler.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
new file mode 100644
index 00000000..d70056a1
--- /dev/null
+++ b/src/libcamera/include/pipeline_handler.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2018, Google Inc.
+ *
+ * pipeline_handler.h - Pipeline handler infrastructure
+ */
+#ifndef __LIBCAMERA_PIPELINE_HANDLER_H__
+#define __LIBCAMERA_PIPELINE_HANDLER_H__
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include <libcamera/camera.h>
+
+namespace libcamera {
+
+class DeviceEnumerator;
+class PipelineHandlerFactory;
+
+class PipelineHandler
+{
+public:
+ virtual ~PipelineHandler() { };
+
+ virtual bool match(DeviceEnumerator *enumerator) = 0;
+
+ virtual unsigned int count() = 0;
+ virtual Camera *camera(unsigned int id) = 0;
+};
+
+class PipelineHandlerFactory
+{
+public:
+ virtual ~PipelineHandlerFactory() { };
+
+ virtual PipelineHandler *create() = 0;
+
+ static void registerType(const std::string &name, PipelineHandlerFactory *factory);
+ static PipelineHandler *create(const std::string &name, DeviceEnumerator *enumerator);
+ static std::vector<std::string> handlers();
+
+private:
+ static std::map<std::string, PipelineHandlerFactory *> &registry();
+};
+
+#define REGISTER_PIPELINE_HANDLER(handler) \
+ class handler##Factory : public PipelineHandlerFactory { \
+ public: \
+ handler##Factory() \
+ { \
+ PipelineHandlerFactory::registerType(#handler, this); \
+ } \
+ virtual PipelineHandler *create() { \
+ return new handler(); \
+ } \
+ }; \
+ static handler##Factory global_##handler##Factory;
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_PIPELINE_HANDLER_H__ */