From patchwork Thu Jan 5 04:37:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 18089 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C8CDBC3291 for ; Thu, 5 Jan 2023 04:38:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 660D7625E7; Thu, 5 Jan 2023 05:38:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1672893481; bh=aNPoTsAaz6S8cvpjer+u/7q8UypJB4kTfGr6+27c49s=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=w3jf3j3zy9cIGi9gypbyPQj3nHMTztSppIqaclQ8TFxWXBx1Cex06kIjLAEwDZwGk tOMHhyv/2GKkLuyy91iS+skY2/SE5GxUKHafOmykGpNvoJ9VMpEuw1p/DgZT27fusl SaPW7lr39ZPlEoylrM47+u0mgJMlhzPBhdCV7xFF21JT96VY25kbLWjGtPCxdOWs6H +ujx1ZQ0R3TRAOTFWEQG8nrdoET64X8fjfW3mzVJcioUb7eYtn8ZNgzd/4UsTGew+I ct5fmxs72SvZkGrRfWTYj8UJtXzACUBt+yX0B3p+wzLHuelb1l6vF0+JTifaHKdeES ZjKPlnmE8ilWw== Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 82406625DF for ; Thu, 5 Jan 2023 05:37:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PpLPkagq"; dkim-atps=neutral Received: by mail-pj1-x1030.google.com with SMTP id o7-20020a17090a0a0700b00226c9b82c3aso870333pjo.3 for ; Wed, 04 Jan 2023 20:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2dcd59yRSKL3Fk+Qlt8vuBFn/l2W1oyI0rRReM2jI7U=; b=PpLPkagqqtmb9YhCAShk7cctSzR4l09bUfF5hspxHlTzmTWZLdMTlRSCzgRi+Uy689 z1OHUYlBuTI72VE1vQQKQvX/5tPZV3b71vXkAPznGcgv5LB++34gCtioxUU+qvZURgtF UKb983nxnU1+sKib2Jaz+YV5yS7lkw2pQaKBk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2dcd59yRSKL3Fk+Qlt8vuBFn/l2W1oyI0rRReM2jI7U=; b=KGbpXI2h7sEpZTD9XJzMlMOZqp8Z+wd35RwyTotbvmta0ZIMPBZHTjF3aTi35HDaQ9 3OOtwbG10etDjM9hWDplqIUAyn+0BgFjNYjvVyRTkQni7vFU/RQoFP1gwAafbivFd0LF ifo6fWn90+ulOUIgHGV+QdSK2421kfN36bbsQ6gD0IP1fgwktAfwE85a7OUF0bqVbFjr qDaiTo/qmWVIZfj9SfWd1WrJZ4sevB7BGEXpYGKrwGxYwYwZGBIowThtTwzOgBiUHOAM cJlHYaxayYX7J5vinvd57LtTZPs54oRnQ1oko/8s5aGRAJFXQQ19Ry7xl5Ek/FaYjFHG c3mg== X-Gm-Message-State: AFqh2kopjzj7Z5aiskTGmSeZ+ct4v4Mc+i5PysBa2lud4A15PYN64odB UXxUewSdVloWTq0uWIpR3VCcOrX8pPKEfdX5 X-Google-Smtp-Source: AMrXdXtJ5/qLA8RdyuOhL5OsrgLLCdUD/QLzBG5Nlcyzt4uD0ibixtiE1yaVOlz2QfDgi3OGX9LRfw== X-Received: by 2002:a17:903:200b:b0:192:467e:7379 with SMTP id s11-20020a170903200b00b00192467e7379mr44389317pla.49.1672893476455; Wed, 04 Jan 2023 20:37:56 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (46.165.189.35.bc.googleusercontent.com. [35.189.165.46]) by smtp.gmail.com with ESMTPSA id x23-20020a170902b41700b00188c5f0f9e9sm25015200plr.199.2023.01.04.20.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 20:37:56 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Thu, 5 Jan 2023 04:37:20 +0000 Message-Id: <20230105043726.679968-4-chenghaoyang@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230105043726.679968-1-chenghaoyang@google.com> References: <20230105043726.679968-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/9] libcamera: Use MediaDeviceBase in base classes X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harvey Yang via libcamera-devel From: Harvey Yang Reply-To: Harvey Yang Cc: Harvey Yang , Harvey Yang Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use MediaDeviceBase instead of MediaDevice in other base classes like PipelineHandler and DeviceEnumerator. Signed-off-by: Harvey Yang --- .../libcamera/internal/device_enumerator.h | 12 ++++---- .../internal/device_enumerator_sysfs.h | 4 +-- .../internal/device_enumerator_udev.h | 8 ++--- include/libcamera/internal/pipeline_handler.h | 12 ++++---- src/libcamera/device_enumerator.cpp | 30 +++++++++---------- src/libcamera/device_enumerator_sysfs.cpp | 4 +-- src/libcamera/device_enumerator_udev.cpp | 4 +-- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 2 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 +-- .../pipeline/raspberrypi/raspberrypi.cpp | 4 +-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/simple/simple.cpp | 4 +-- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- src/libcamera/pipeline_handler.cpp | 18 +++++------ 15 files changed, 56 insertions(+), 56 deletions(-) diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h index 72ec9a60..87a2b5ce 100644 --- a/include/libcamera/internal/device_enumerator.h +++ b/include/libcamera/internal/device_enumerator.h @@ -15,7 +15,7 @@ namespace libcamera { -class MediaDevice; +class MediaDeviceBase; class DeviceMatch { @@ -24,7 +24,7 @@ public: void add(const std::string &entity); - bool match(const MediaDevice *device) const; + bool match(const MediaDeviceBase *device) const; private: std::string driver_; @@ -41,17 +41,17 @@ public: virtual int init() = 0; virtual int enumerate() = 0; - std::shared_ptr search(const DeviceMatch &dm); + std::shared_ptr search(const DeviceMatch &dm); Signal<> devicesAdded; protected: - std::unique_ptr createDevice(const std::string &deviceNode); - void addDevice(std::unique_ptr media); + std::unique_ptr createDevice(const std::string &deviceNode); + void addDevice(std::unique_ptr media); void removeDevice(const std::string &deviceNode); private: - std::vector> devices_; + std::vector> devices_; }; } /* namespace libcamera */ diff --git a/include/libcamera/internal/device_enumerator_sysfs.h b/include/libcamera/internal/device_enumerator_sysfs.h index 3e84b83f..920fd984 100644 --- a/include/libcamera/internal/device_enumerator_sysfs.h +++ b/include/libcamera/internal/device_enumerator_sysfs.h @@ -12,7 +12,7 @@ #include "libcamera/internal/device_enumerator.h" -class MediaDevice; +class MediaDeviceBase; namespace libcamera { @@ -23,7 +23,7 @@ public: int enumerate(); private: - int populateMediaDevice(MediaDevice *media); + int populateMediaDevice(MediaDeviceBase *media); std::string lookupDeviceNode(int major, int minor); }; diff --git a/include/libcamera/internal/device_enumerator_udev.h b/include/libcamera/internal/device_enumerator_udev.h index 1b3360df..a833f7a6 100644 --- a/include/libcamera/internal/device_enumerator_udev.h +++ b/include/libcamera/internal/device_enumerator_udev.h @@ -23,7 +23,7 @@ struct udev_monitor; namespace libcamera { class EventNotifier; -class MediaDevice; +class MediaDeviceBase; class MediaEntity; class DeviceEnumeratorUdev final : public DeviceEnumerator @@ -39,7 +39,7 @@ private: using DependencyMap = std::map>; struct MediaDeviceDeps { - MediaDeviceDeps(std::unique_ptr media, + MediaDeviceDeps(std::unique_ptr media, DependencyMap deps) : media_(std::move(media)), deps_(std::move(deps)) { @@ -50,12 +50,12 @@ private: return media_ == other.media_; } - std::unique_ptr media_; + std::unique_ptr media_; DependencyMap deps_; }; int addUdevDevice(struct udev_device *dev); - int populateMediaDevice(MediaDevice *media, DependencyMap *deps); + int populateMediaDevice(MediaDeviceBase *media, DependencyMap *deps); std::string lookupDeviceNode(dev_t devnum); int addV4L2Device(dev_t devnum); diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index ec4f662d..1223b1cb 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -30,7 +30,7 @@ class CameraManager; class DeviceEnumerator; class DeviceMatch; class FrameBuffer; -class MediaDevice; +class MediaDeviceBase; class PipelineHandler; class Request; @@ -42,8 +42,8 @@ public: virtual ~PipelineHandler(); virtual bool match(DeviceEnumerator *enumerator) = 0; - MediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator, - const DeviceMatch &dm); + MediaDeviceBase *acquireMediaDevice(DeviceEnumerator *enumerator, + const DeviceMatch &dm); bool acquire(); void release(Camera *camera); @@ -69,7 +69,7 @@ public: protected: void registerCamera(std::shared_ptr camera); - void hotplugMediaDevice(MediaDevice *media); + void hotplugMediaDevice(MediaDeviceBase *media); virtual int queueRequestDevice(Camera *camera, Request *request) = 0; virtual void stopDevice(Camera *camera) = 0; @@ -81,13 +81,13 @@ protected: private: void unlockMediaDevices(); - void mediaDeviceDisconnected(MediaDevice *media); + void mediaDeviceDisconnected(MediaDeviceBase *media); virtual void disconnect(); void doQueueRequest(Request *request); void doQueueRequests(); - std::vector> mediaDevices_; + std::vector> mediaDevices_; std::vector> cameras_; std::queue waitingRequests_; diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index f2e055de..ed5d7af3 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -13,7 +13,7 @@ #include "libcamera/internal/device_enumerator_sysfs.h" #include "libcamera/internal/device_enumerator_udev.h" -#include "libcamera/internal/media_device.h" +#include "libcamera/internal/media_device_base.h" /** * \file device_enumerator.h @@ -25,12 +25,12 @@ * At the core of the enumeration is the DeviceEnumerator class, responsible * for enumerating all media devices in the system. It handles all interactions * with the operating system in a platform-specific way. For each media device - * found an instance of MediaDevice is created to store information about the + * found an instance of MediaDeviceBase is created to store information about the * device gathered from the kernel through the Media Controller API. * * The DeviceEnumerator can enumerate all or specific media devices in the * system. When a new media device is added the enumerator creates a - * corresponding MediaDevice instance. + * corresponding MediaDeviceBase instance. * * The enumerator supports searching among enumerated devices based on criteria * expressed in a DeviceMatch object. @@ -91,7 +91,7 @@ void DeviceMatch::add(const std::string &entity) * * \return true if the media device matches the search pattern, false otherwise */ -bool DeviceMatch::match(const MediaDevice *device) const +bool DeviceMatch::match(const MediaDeviceBase *device) const { if (driver_ != device->driver()) return false; @@ -120,7 +120,7 @@ bool DeviceMatch::match(const MediaDevice *device) const * The DeviceEnumerator class is responsible for all interactions with the * operating system related to media devices. It enumerates all media devices * in the system, and for each device found creates an instance of the - * MediaDevice class and stores it internally. The list of media devices can + * MediaDeviceBase class and stores it internally. The list of media devices can * then be searched using DeviceMatch search patterns. * * The enumerator also associates media device entities with device node paths. @@ -161,7 +161,7 @@ std::unique_ptr DeviceEnumerator::create() DeviceEnumerator::~DeviceEnumerator() { - for (const std::shared_ptr &media : devices_) { + for (const std::shared_ptr &media : devices_) { if (media->busy()) LOG(DeviceEnumerator, Error) << "Removing media device " << media->deviceNode() @@ -209,9 +209,9 @@ DeviceEnumerator::~DeviceEnumerator() * * \return Created media device instance on success, or nullptr otherwise */ -std::unique_ptr DeviceEnumerator::createDevice(const std::string &deviceNode) +std::unique_ptr DeviceEnumerator::createDevice(const std::string &deviceNode) { - std::unique_ptr media = std::make_unique(deviceNode); + std::unique_ptr media = std::make_unique(deviceNode); int ret = media->populate(); if (ret < 0) { @@ -247,7 +247,7 @@ std::unique_ptr DeviceEnumerator::createDevice(const std::string &d * This function shall be called after all members of the entities of the * media graph have been confirmed to be initialized. */ -void DeviceEnumerator::addDevice(std::unique_ptr media) +void DeviceEnumerator::addDevice(std::unique_ptr media) { LOG(DeviceEnumerator, Debug) << "Added device " << media->deviceNode() << ": " << media->driver(); @@ -263,12 +263,12 @@ void DeviceEnumerator::addDevice(std::unique_ptr media) * \param[in] deviceNode Path to the media device to remove * * Remove the media device identified by \a deviceNode previously added to the - * enumerator with addDevice(). The media device's MediaDevice::disconnected + * enumerator with addDevice(). The media device's MediaDeviceBase::disconnected * signal is emitted. */ void DeviceEnumerator::removeDevice(const std::string &deviceNode) { - std::shared_ptr media; + std::shared_ptr media; for (auto iter = devices_.begin(); iter != devices_.end(); ++iter) { if ((*iter)->deviceNode() == deviceNode) { @@ -297,14 +297,14 @@ void DeviceEnumerator::removeDevice(const std::string &deviceNode) * * Search in the enumerated media devices that are not already in use for a * match described in \a dm. If a match is found and the caller intends to use - * it the caller is responsible for acquiring the MediaDevice object and + * it the caller is responsible for acquiring the MediaDeviceBase object and * releasing it when done with it. * - * \return pointer to the matching MediaDevice, or nullptr if no match is found + * \return pointer to the matching MediaDeviceBase, or nullptr if no match is found */ -std::shared_ptr DeviceEnumerator::search(const DeviceMatch &dm) +std::shared_ptr DeviceEnumerator::search(const DeviceMatch &dm) { - for (std::shared_ptr &media : devices_) { + for (std::shared_ptr &media : devices_) { if (media->busy()) continue; diff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp index 686bb809..22bbe44f 100644 --- a/src/libcamera/device_enumerator_sysfs.cpp +++ b/src/libcamera/device_enumerator_sysfs.cpp @@ -73,7 +73,7 @@ int DeviceEnumeratorSysfs::enumerate() continue; } - std::unique_ptr media = createDevice(devnode); + std::unique_ptr media = createDevice(devnode); if (!media) continue; @@ -93,7 +93,7 @@ int DeviceEnumeratorSysfs::enumerate() return 0; } -int DeviceEnumeratorSysfs::populateMediaDevice(MediaDevice *media) +int DeviceEnumeratorSysfs::populateMediaDevice(MediaDeviceBase *media) { /* Associate entities to device node paths. */ for (MediaEntity *entity : media->entities()) { diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp index 5317afbd..8be8a8d2 100644 --- a/src/libcamera/device_enumerator_udev.cpp +++ b/src/libcamera/device_enumerator_udev.cpp @@ -76,7 +76,7 @@ int DeviceEnumeratorUdev::addUdevDevice(struct udev_device *dev) return -ENODEV; if (!strcmp(subsystem, "media")) { - std::unique_ptr media = + std::unique_ptr media = createDevice(udev_device_get_devnode(dev)); if (!media) return -ENODEV; @@ -193,7 +193,7 @@ done: return 0; } -int DeviceEnumeratorUdev::populateMediaDevice(MediaDevice *media, DependencyMap *deps) +int DeviceEnumeratorUdev::populateMediaDevice(MediaDeviceBase *media, DependencyMap *deps) { std::set children; diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 0c67e35d..f41e10c3 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -865,7 +865,7 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) dm.add("mxc_isi.0"); dm.add("mxc_isi.0.capture"); - isiDev_ = acquireMediaDevice(enumerator, dm); + isiDev_ = dynamic_cast(acquireMediaDevice(enumerator, dm)); if (!isiDev_) return false; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index e4d79ea4..c3f3c815 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -923,11 +923,11 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) imgu_dm.add("ipu3-imgu 1 viewfinder"); imgu_dm.add("ipu3-imgu 1 3a stat"); - cio2MediaDev_ = acquireMediaDevice(enumerator, cio2_dm); + cio2MediaDev_ = dynamic_cast(acquireMediaDevice(enumerator, cio2_dm)); if (!cio2MediaDev_) return false; - imguMediaDev_ = acquireMediaDevice(enumerator, imgu_dm); + imguMediaDev_ = dynamic_cast(acquireMediaDevice(enumerator, imgu_dm)); if (!imguMediaDev_) return false; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8569df17..355cd556 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1160,7 +1160,7 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) { DeviceMatch unicam("unicam"); - MediaDevice *unicamDevice = acquireMediaDevice(enumerator, unicam); + MediaDevice *unicamDevice = dynamic_cast(acquireMediaDevice(enumerator, unicam)); if (!unicamDevice) { LOG(RPI, Debug) << "Unable to acquire a Unicam instance"; @@ -1168,7 +1168,7 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) } DeviceMatch isp("bcm2835-isp"); - MediaDevice *ispDevice = acquireMediaDevice(enumerator, isp); + MediaDevice *ispDevice = dynamic_cast(acquireMediaDevice(enumerator, isp)); if (!ispDevice) { LOG(RPI, Debug) << "Unable to acquire ISP instance"; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index eb9ad65c..c14711ef 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1146,7 +1146,7 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator) dm.add("rkisp1_stats"); dm.add("rkisp1_params"); - media_ = acquireMediaDevice(enumerator, dm); + media_ = dynamic_cast(acquireMediaDevice(enumerator, dm)); if (!media_) return false; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index a32de7f3..e6f4fad3 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1391,7 +1391,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) for (const SimplePipelineInfo &inf : supportedDevices) { DeviceMatch dm(inf.driver); - media_ = acquireMediaDevice(enumerator, dm); + media_ = dynamic_cast(acquireMediaDevice(enumerator, dm)); if (media_) { info = &inf; break; @@ -1403,7 +1403,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) for (const auto &[name, streams] : info->converters) { DeviceMatch converterMatch(name); - converter_ = acquireMediaDevice(enumerator, converterMatch); + converter_ = dynamic_cast(acquireMediaDevice(enumerator, converterMatch)); if (converter_) { numStreams = streams; break; diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 277465b7..b97ec95e 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -389,7 +389,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) MediaDevice *media; DeviceMatch dm("uvcvideo"); - media = acquireMediaDevice(enumerator, dm); + media = dynamic_cast(acquireMediaDevice(enumerator, dm)); if (!media) return false; diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 204f5ad7..0aaaa628 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -454,7 +454,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) dm.add("RGB/YUV Input"); dm.add("Scaler"); - MediaDevice *media = acquireMediaDevice(enumerator, dm); + MediaDevice *media = dynamic_cast(acquireMediaDevice(enumerator, dm)); if (!media) return false; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index cfade490..613698a1 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -73,7 +73,7 @@ PipelineHandler::PipelineHandler(CameraManager *manager) PipelineHandler::~PipelineHandler() { - for (std::shared_ptr media : mediaDevices_) + for (std::shared_ptr media : mediaDevices_) media->release(); } @@ -126,10 +126,10 @@ PipelineHandler::~PipelineHandler() * * \return A pointer to the matching MediaDevice, or nullptr if no match is found */ -MediaDevice *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator, - const DeviceMatch &dm) +MediaDeviceBase *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator, + const DeviceMatch &dm) { - std::shared_ptr media = enumerator->search(dm); + std::shared_ptr media = enumerator->search(dm); if (!media) return nullptr; @@ -170,7 +170,7 @@ bool PipelineHandler::acquire() return true; } - for (std::shared_ptr &media : mediaDevices_) { + for (std::shared_ptr &media : mediaDevices_) { if (!media->lock()) { unlockMediaDevices(); return false; @@ -223,7 +223,7 @@ void PipelineHandler::releaseDevice([[maybe_unused]] Camera *camera) void PipelineHandler::unlockMediaDevices() { - for (std::shared_ptr &media : mediaDevices_) + for (std::shared_ptr &media : mediaDevices_) media->unlock(); } @@ -556,7 +556,7 @@ void PipelineHandler::registerCamera(std::shared_ptr camera) * to the camera. */ std::vector devnums; - for (const std::shared_ptr &media : mediaDevices_) { + for (const std::shared_ptr &media : mediaDevices_) { for (const MediaEntity *entity : media->entities()) { if (entity->pads().size() == 1 && (entity->pads()[0]->flags() & MEDIA_PAD_FL_SINK) && @@ -582,7 +582,7 @@ void PipelineHandler::registerCamera(std::shared_ptr camera) * handler gets notified and automatically disconnects all the cameras it has * registered without requiring any manual intervention. */ -void PipelineHandler::hotplugMediaDevice(MediaDevice *media) +void PipelineHandler::hotplugMediaDevice(MediaDeviceBase *media) { media->disconnected.connect(this, [=]() { mediaDeviceDisconnected(media); }); } @@ -590,7 +590,7 @@ void PipelineHandler::hotplugMediaDevice(MediaDevice *media) /** * \brief Slot for the MediaDevice disconnected signal */ -void PipelineHandler::mediaDeviceDisconnected(MediaDevice *media) +void PipelineHandler::mediaDeviceDisconnected(MediaDeviceBase *media) { media->disconnected.disconnect(this);