Files
external_libcamera/include/libcamera/camera_manager.h
Laurent Pinchart b566e97aac libcamera: camera_manager: Bind CameraManager to threads
The CameraManager class uses the event dispatcher of the current thread.
This makes the CameraManager::eventDispatcher() and
CameraManager::setEventDispatcher() methods inconsistent, as they access
different event dispatcher instances depending on the calling thread.

Fix this by inheriting from the Object class, which binds the
CameraManager to a thread, and use the event dispatcher of the bound
thread.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-17 18:32:38 +03:00

57 lines
1.3 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2018, Google Inc.
*
* camera_manager.h - Camera management
*/
#ifndef __LIBCAMERA_CAMERA_MANAGER_H__
#define __LIBCAMERA_CAMERA_MANAGER_H__
#include <memory>
#include <string>
#include <vector>
#include <libcamera/object.h>
namespace libcamera {
class Camera;
class DeviceEnumerator;
class EventDispatcher;
class PipelineHandler;
class CameraManager : public Object
{
public:
int start();
void stop();
const std::vector<std::shared_ptr<Camera>> &cameras() const { return cameras_; }
std::shared_ptr<Camera> get(const std::string &name);
void addCamera(std::shared_ptr<Camera> camera);
void removeCamera(Camera *camera);
static CameraManager *instance();
static const std::string &version() { return version_; }
void setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);
EventDispatcher *eventDispatcher();
private:
CameraManager();
CameraManager(const CameraManager &) = delete;
CameraManager &operator=(const CameraManager &) = delete;
~CameraManager();
std::unique_ptr<DeviceEnumerator> enumerator_;
std::vector<std::shared_ptr<PipelineHandler>> pipes_;
std::vector<std::shared_ptr<Camera>> cameras_;
static const std::string version_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_CAMERA_MANAGER_H__ */