Files
external_libcamera/src/libcamera/include/pipeline_handler.h
Laurent Pinchart f3695e9b09 libcamera: camera_manager: Register cameras with the camera manager
Cameras are listed through a double indirection, first iterating over
all available pipeline handlers, and then listing the cameras they each
support. To simplify the API make the pipeline handlers register the
cameras with the camera manager directly, which lets the camera manager
easily expose the list of all available cameras.

The PipelineHandler API gets simplified as the handlers don't need to
expose the list of cameras they have created.

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>
2019-01-21 11:13:49 +02:00

59 lines
1.3 KiB
C++

/* 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 CameraManager;
class DeviceEnumerator;
class PipelineHandler
{
public:
virtual ~PipelineHandler() { };
virtual bool match(CameraManager *manager, DeviceEnumerator *enumerator) = 0;
};
class PipelineHandlerFactory
{
public:
PipelineHandlerFactory(const char *name);
virtual ~PipelineHandlerFactory() { };
virtual PipelineHandler *create() = 0;
const std::string &name() const { return name_; }
static void registerType(PipelineHandlerFactory *factory);
static std::vector<PipelineHandlerFactory *> &factories();
private:
std::string name_;
};
#define REGISTER_PIPELINE_HANDLER(handler) \
class handler##Factory : public PipelineHandlerFactory { \
public: \
handler##Factory() : PipelineHandlerFactory(#handler) { } \
PipelineHandler *create() final { \
return new handler(); \
} \
}; \
static handler##Factory global_##handler##Factory;
} /* namespace libcamera */
#endif /* __LIBCAMERA_PIPELINE_HANDLER_H__ */