libcamera: pipeline_handler: Keep track of MediaDevice
Instead of requiring each pipeline handle implementation to keep track of calling release() on its media devices upon deletion, keep track of them in the base class. Add a helper that pipeline handlers shall use to acquire a media device instead of directly interacting with the DeviceEnumerator. This also means that pipeline handler implementations do no need to keep a shared_ptr<> reference to the media devices they store locally as the PipelineHandler base class will keep a shared_ptr<> reference to all media devices consumed for the entire lifetime of the pipeline handler implementation. Centrally keeping track of media devices will also be beneficial to implement exclusive access to pipelines across processes. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -22,6 +22,7 @@ class Camera;
|
||||
class CameraConfiguration;
|
||||
class CameraManager;
|
||||
class DeviceEnumerator;
|
||||
class DeviceMatch;
|
||||
class MediaDevice;
|
||||
class PipelineHandler;
|
||||
class Request;
|
||||
@@ -53,6 +54,8 @@ public:
|
||||
virtual ~PipelineHandler();
|
||||
|
||||
virtual bool match(DeviceEnumerator *enumerator) = 0;
|
||||
MediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator,
|
||||
const DeviceMatch &dm);
|
||||
|
||||
virtual CameraConfiguration
|
||||
streamConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0;
|
||||
@@ -84,6 +87,7 @@ private:
|
||||
void mediaDeviceDisconnected(MediaDevice *media);
|
||||
virtual void disconnect();
|
||||
|
||||
std::vector<std::shared_ptr<MediaDevice>> mediaDevices_;
|
||||
std::vector<std::weak_ptr<Camera>> cameras_;
|
||||
std::map<const Camera *, std::unique_ptr<CameraData>> cameraData_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user