The IPAManager class implements a singleton pattern due to the need of accessing the instance in a static member function. The function now takes a pointer to a PipelineHandler, which we can use to access the CameraManager, and from there, the IPAManager. Add accessors to the internal API to expose the CameraManager from the PipelineHandler, and the IPAManager from the CameraManager. This requires allocating the IPAManager dynamically to avoid a loop in includes. Use those accessors to replace the IPAManager singleton. Update the IPA interface unit test to instantiate a CameraManager instead of an IPAManager and ProcessManager, to reflect the new way that the IPAManager is accessed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2023, Ideas on Board Oy.
|
|
*
|
|
* Camera manager private data
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <libcamera/camera_manager.h>
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <sys/types.h>
|
|
#include <vector>
|
|
|
|
#include <libcamera/base/class.h>
|
|
#include <libcamera/base/mutex.h>
|
|
#include <libcamera/base/thread.h>
|
|
#include <libcamera/base/thread_annotations.h>
|
|
|
|
#include "libcamera/internal/process.h"
|
|
|
|
namespace libcamera {
|
|
|
|
class Camera;
|
|
class DeviceEnumerator;
|
|
class IPAManager;
|
|
class PipelineHandlerFactoryBase;
|
|
|
|
class CameraManager::Private : public Extensible::Private, public Thread
|
|
{
|
|
LIBCAMERA_DECLARE_PUBLIC(CameraManager)
|
|
|
|
public:
|
|
Private();
|
|
|
|
int start();
|
|
void addCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
|
|
void removeCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
|
|
|
|
IPAManager *ipaManager() const { return ipaManager_.get(); }
|
|
|
|
protected:
|
|
void run() override;
|
|
|
|
private:
|
|
int init();
|
|
void createPipelineHandlers();
|
|
void pipelineFactoryMatch(const PipelineHandlerFactoryBase *factory);
|
|
void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_);
|
|
|
|
/*
|
|
* This mutex protects
|
|
*
|
|
* - initialized_ and status_ during initialization
|
|
* - cameras_ after initialization
|
|
*/
|
|
mutable Mutex mutex_;
|
|
std::vector<std::shared_ptr<Camera>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
|
|
|
|
ConditionVariable cv_;
|
|
bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
|
|
int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
|
|
|
|
std::unique_ptr<DeviceEnumerator> enumerator_;
|
|
|
|
std::unique_ptr<IPAManager> ipaManager_;
|
|
ProcessManager processManager_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|