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>
This commit is contained in:
Laurent Pinchart 2019-01-03 13:10:37 +02:00
parent 32bf7ef239
commit f3695e9b09
6 changed files with 48 additions and 71 deletions

View file

@ -24,9 +24,11 @@ public:
int start();
void stop();
std::vector<std::string> list() const;
const std::vector<Camera *> &cameras() const { return cameras_; }
Camera *get(const std::string &name);
void addCamera(Camera *camera);
static CameraManager *instance();
void setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);
@ -40,6 +42,7 @@ private:
std::unique_ptr<DeviceEnumerator> enumerator_;
std::vector<PipelineHandler *> pipes_;
std::vector<Camera *> cameras_;
std::unique_ptr<EventDispatcher> dispatcher_;
};