[{"id":26585,"web_url":"https://patchwork.libcamera.org/comment/26585/","msgid":"<e51cedd1-8d09-aacb-d5a6-7dc8787ac628@flowerpot.me>","date":"2023-03-07T13:20:36","subject":"Re: [libcamera-devel] [PATCH v3 3/9] libcamera: Use MediaDeviceBase\n\tin base classes","submitter":{"id":155,"url":"https://patchwork.libcamera.org/api/people/155/","name":"Sophie Tyalie","email":"lilly@flowerpot.me"},"content":"Hi Harvey,\n\nI'm currently using your patch set as the basis for my own work and I've \nfound a bug\nwhile using it. The function `createDevice` doesn't create a \nMediaDevice, but a\n`MediaDeviceBase` instead during device enumeration. As such previously \nworking\nnon-virtual cameras aren't detected by the pipeline handlers anymore and \nthe whole\nsystem doesn't work.\n\nOn my local branch I've been able to fix this by making `createDevice` a \ntemplated\nfunction to allow selection which child of MediaDeviceBase should be \ninitiated. I\nwould disencourage any movement of pinning createDevice down to only be \nable to\ninitiate a `MediaDevice` object, as I use your work in order to make USB \nconnected\ndevices discoverable, which are independent of `MediaDevice`\n\n\nOn 05/01/2023 05:37, Cheng-Hao Yang wrote:\n> Use MediaDeviceBase instead of MediaDevice in other base classes\n> like PipelineHandler and DeviceEnumerator.\n>\n> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n> ---\n>   .../libcamera/internal/device_enumerator.h    | 12 ++++----\n>   .../internal/device_enumerator_sysfs.h        |  4 +--\n>   .../internal/device_enumerator_udev.h         |  8 ++---\n>   include/libcamera/internal/pipeline_handler.h | 12 ++++----\n>   src/libcamera/device_enumerator.cpp           | 30 +++++++++----------\n>   src/libcamera/device_enumerator_sysfs.cpp     |  4 +--\n>   src/libcamera/device_enumerator_udev.cpp      |  4 +--\n>   src/libcamera/pipeline/imx8-isi/imx8-isi.cpp  |  2 +-\n>   src/libcamera/pipeline/ipu3/ipu3.cpp          |  4 +--\n>   .../pipeline/raspberrypi/raspberrypi.cpp      |  4 +--\n>   src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  2 +-\n>   src/libcamera/pipeline/simple/simple.cpp      |  4 +--\n>   src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |  2 +-\n>   src/libcamera/pipeline/vimc/vimc.cpp          |  2 +-\n>   src/libcamera/pipeline_handler.cpp            | 18 +++++------\n>   15 files changed, 56 insertions(+), 56 deletions(-)\n>\n> diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h\n> index 72ec9a60..87a2b5ce 100644\n> --- a/include/libcamera/internal/device_enumerator.h\n> +++ b/include/libcamera/internal/device_enumerator.h\n> @@ -15,7 +15,7 @@\n>\n>   namespace libcamera {\n>\n> -class MediaDevice;\n> +class MediaDeviceBase;\n>\n>   class DeviceMatch\n>   {\n> @@ -24,7 +24,7 @@ public:\n>\n>   \tvoid add(const std::string &entity);\n>\n> -\tbool match(const MediaDevice *device) const;\n> +\tbool match(const MediaDeviceBase *device) const;\n>\n>   private:\n>   \tstd::string driver_;\n> @@ -41,17 +41,17 @@ public:\n>   \tvirtual int init() = 0;\n>   \tvirtual int enumerate() = 0;\n>\n> -\tstd::shared_ptr<MediaDevice> search(const DeviceMatch &dm);\n> +\tstd::shared_ptr<MediaDeviceBase> search(const DeviceMatch &dm);\n>\n>   \tSignal<> devicesAdded;\n>\n>   protected:\n> -\tstd::unique_ptr<MediaDevice> createDevice(const std::string &deviceNode);\n> -\tvoid addDevice(std::unique_ptr<MediaDevice> media);\n> +\tstd::unique_ptr<MediaDeviceBase> createDevice(const std::string &deviceNode);\n> +\tvoid addDevice(std::unique_ptr<MediaDeviceBase> media);\n>   \tvoid removeDevice(const std::string &deviceNode);\n>   \n>   private:\n> -\tstd::vector<std::shared_ptr<MediaDevice>> devices_;\n> +\tstd::vector<std::shared_ptr<MediaDeviceBase>> devices_;\n>   };\n>   \n>   } /* namespace libcamera */\n> diff --git a/include/libcamera/internal/device_enumerator_sysfs.h b/include/libcamera/internal/device_enumerator_sysfs.h\n> index 3e84b83f..920fd984 100644\n> --- a/include/libcamera/internal/device_enumerator_sysfs.h\n> +++ b/include/libcamera/internal/device_enumerator_sysfs.h\n> @@ -12,7 +12,7 @@\n>   \n>   #include \"libcamera/internal/device_enumerator.h\"\n>   \n> -class MediaDevice;\n> +class MediaDeviceBase;\n>   \n>   namespace libcamera {\n>   \n> @@ -23,7 +23,7 @@ public:\n>   \tint enumerate();\n>   \n>   private:\n> -\tint populateMediaDevice(MediaDevice *media);\n> +\tint populateMediaDevice(MediaDeviceBase *media);\n>   \tstd::string lookupDeviceNode(int major, int minor);\n>   };\n>   \n> diff --git a/include/libcamera/internal/device_enumerator_udev.h b/include/libcamera/internal/device_enumerator_udev.h\n> index 1b3360df..a833f7a6 100644\n> --- a/include/libcamera/internal/device_enumerator_udev.h\n> +++ b/include/libcamera/internal/device_enumerator_udev.h\n> @@ -23,7 +23,7 @@ struct udev_monitor;\n>   namespace libcamera {\n>   \n>   class EventNotifier;\n> -class MediaDevice;\n> +class MediaDeviceBase;\n>   class MediaEntity;\n>   \n>   class DeviceEnumeratorUdev final : public DeviceEnumerator\n> @@ -39,7 +39,7 @@ private:\n>   \tusing DependencyMap = std::map<dev_t, std::list<MediaEntity *>>;\n>   \n>   \tstruct MediaDeviceDeps {\n> -\t\tMediaDeviceDeps(std::unique_ptr<MediaDevice> media,\n> +\t\tMediaDeviceDeps(std::unique_ptr<MediaDeviceBase> media,\n>   \t\t\t\tDependencyMap deps)\n>   \t\t\t: media_(std::move(media)), deps_(std::move(deps))\n>   \t\t{\n> @@ -50,12 +50,12 @@ private:\n>   \t\t\treturn media_ == other.media_;\n>   \t\t}\n>   \n> -\t\tstd::unique_ptr<MediaDevice> media_;\n> +\t\tstd::unique_ptr<MediaDeviceBase> media_;\n>   \t\tDependencyMap deps_;\n>   \t};\n>   \n>   \tint addUdevDevice(struct udev_device *dev);\n> -\tint populateMediaDevice(MediaDevice *media, DependencyMap *deps);\n> +\tint populateMediaDevice(MediaDeviceBase *media, DependencyMap *deps);\n>   \tstd::string lookupDeviceNode(dev_t devnum);\n>   \n>   \tint addV4L2Device(dev_t devnum);\n> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> index ec4f662d..1223b1cb 100644\n> --- a/include/libcamera/internal/pipeline_handler.h\n> +++ b/include/libcamera/internal/pipeline_handler.h\n> @@ -30,7 +30,7 @@ class CameraManager;\n>   class DeviceEnumerator;\n>   class DeviceMatch;\n>   class FrameBuffer;\n> -class MediaDevice;\n> +class MediaDeviceBase;\n>   class PipelineHandler;\n>   class Request;\n>   \n> @@ -42,8 +42,8 @@ public:\n>   \tvirtual ~PipelineHandler();\n>   \n>   \tvirtual bool match(DeviceEnumerator *enumerator) = 0;\n> -\tMediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator,\n> -\t\t\t\t\tconst DeviceMatch &dm);\n> +\tMediaDeviceBase *acquireMediaDevice(DeviceEnumerator *enumerator,\n> +\t\t\t\t\t    const DeviceMatch &dm);\n>   \n>   \tbool acquire();\n>   \tvoid release(Camera *camera);\n> @@ -69,7 +69,7 @@ public:\n>   \n>   protected:\n>   \tvoid registerCamera(std::shared_ptr<Camera> camera);\n> -\tvoid hotplugMediaDevice(MediaDevice *media);\n> +\tvoid hotplugMediaDevice(MediaDeviceBase *media);\n>   \n>   \tvirtual int queueRequestDevice(Camera *camera, Request *request) = 0;\n>   \tvirtual void stopDevice(Camera *camera) = 0;\n> @@ -81,13 +81,13 @@ protected:\n>   private:\n>   \tvoid unlockMediaDevices();\n>   \n> -\tvoid mediaDeviceDisconnected(MediaDevice *media);\n> +\tvoid mediaDeviceDisconnected(MediaDeviceBase *media);\n>   \tvirtual void disconnect();\n>   \n>   \tvoid doQueueRequest(Request *request);\n>   \tvoid doQueueRequests();\n>   \n> -\tstd::vector<std::shared_ptr<MediaDevice>> mediaDevices_;\n> +\tstd::vector<std::shared_ptr<MediaDeviceBase>> mediaDevices_;\n>   \tstd::vector<std::weak_ptr<Camera>> cameras_;\n>   \n>   \tstd::queue<Request *> waitingRequests_;\n> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> index f2e055de..ed5d7af3 100644\n> --- a/src/libcamera/device_enumerator.cpp\n> +++ b/src/libcamera/device_enumerator.cpp\n> @@ -13,7 +13,7 @@\n>   \n>   #include \"libcamera/internal/device_enumerator_sysfs.h\"\n>   #include \"libcamera/internal/device_enumerator_udev.h\"\n> -#include \"libcamera/internal/media_device.h\"\n> +#include \"libcamera/internal/media_device_base.h\"\n>   \n>   /**\n>    * \\file device_enumerator.h\n> @@ -25,12 +25,12 @@\n>    * At the core of the enumeration is the DeviceEnumerator class, responsible\n>    * for enumerating all media devices in the system. It handles all interactions\n>    * with the operating system in a platform-specific way. For each media device\n> - * found an instance of MediaDevice is created to store information about the\n> + * found an instance of MediaDeviceBase is created to store information about the\n>    * device gathered from the kernel through the Media Controller API.\n>    *\n>    * The DeviceEnumerator can enumerate all or specific media devices in the\n>    * system. When a new media device is added the enumerator creates a\n> - * corresponding MediaDevice instance.\n> + * corresponding MediaDeviceBase instance.\n>    *\n>    * The enumerator supports searching among enumerated devices based on criteria\n>    * expressed in a DeviceMatch object.\n> @@ -91,7 +91,7 @@ void DeviceMatch::add(const std::string &entity)\n>    *\n>    * \\return true if the media device matches the search pattern, false otherwise\n>    */\n> -bool DeviceMatch::match(const MediaDevice *device) const\n> +bool DeviceMatch::match(const MediaDeviceBase *device) const\n>   {\n>   \tif (driver_ != device->driver())\n>   \t\treturn false;\n> @@ -120,7 +120,7 @@ bool DeviceMatch::match(const MediaDevice *device) const\n>    * The DeviceEnumerator class is responsible for all interactions with the\n>    * operating system related to media devices. It enumerates all media devices\n>    * in the system, and for each device found creates an instance of the\n> - * MediaDevice class and stores it internally. The list of media devices can\n> + * MediaDeviceBase class and stores it internally. The list of media devices can\n>    * then be searched using DeviceMatch search patterns.\n>    *\n>    * The enumerator also associates media device entities with device node paths.\n> @@ -161,7 +161,7 @@ std::unique_ptr<DeviceEnumerator> DeviceEnumerator::create()\n>   \n>   DeviceEnumerator::~DeviceEnumerator()\n>   {\n> -\tfor (const std::shared_ptr<MediaDevice> &media : devices_) {\n> +\tfor (const std::shared_ptr<MediaDeviceBase> &media : devices_) {\n>   \t\tif (media->busy())\n>   \t\t\tLOG(DeviceEnumerator, Error)\n>   \t\t\t\t<< \"Removing media device \" << media->deviceNode()\n> @@ -209,9 +209,9 @@ DeviceEnumerator::~DeviceEnumerator()\n>    *\n>    * \\return Created media device instance on success, or nullptr otherwise\n>    */\n> -std::unique_ptr<MediaDevice> DeviceEnumerator::createDevice(const std::string &deviceNode)\n> +std::unique_ptr<MediaDeviceBase> DeviceEnumerator::createDevice(const std::string &deviceNode)\n>   {\n> -\tstd::unique_ptr<MediaDevice> media = std::make_unique<MediaDevice>(deviceNode);\n> +\tstd::unique_ptr<MediaDeviceBase> media = std::make_unique<MediaDeviceBase>(deviceNode);\n\nYou create here a MediaDeviceBase instead of a MediaDevice (or like). \nDue to this the\ndevice population and enumeration doesn't work for children of \nMediaDeviceBase (e.g.\nMediaDevice).\n\nYou should make `createDevice` function a template and allow the \nselection of the\nclass to create by the users of `createDevice`. This has at least \nreliably worked\nfor me.\n\n>   \n>   \tint ret = media->populate();\n>   \tif (ret < 0) {\n> @@ -247,7 +247,7 @@ std::unique_ptr<MediaDevice> DeviceEnumerator::createDevice(const std::string &d\n>    * This function shall be called after all members of the entities of the\n>    * media graph have been confirmed to be initialized.\n>    */\n> -void DeviceEnumerator::addDevice(std::unique_ptr<MediaDevice> media)\n> +void DeviceEnumerator::addDevice(std::unique_ptr<MediaDeviceBase> media)\n>   {\n>   \tLOG(DeviceEnumerator, Debug)\n>   \t\t<< \"Added device \" << media->deviceNode() << \": \" << media->driver();\n> @@ -263,12 +263,12 @@ void DeviceEnumerator::addDevice(std::unique_ptr<MediaDevice> media)\n>    * \\param[in] deviceNode Path to the media device to remove\n>    *\n>    * Remove the media device identified by \\a deviceNode previously added to the\n> - * enumerator with addDevice(). The media device's MediaDevice::disconnected\n> + * enumerator with addDevice(). The media device's MediaDeviceBase::disconnected\n>    * signal is emitted.\n>    */\n>   void DeviceEnumerator::removeDevice(const std::string &deviceNode)\n>   {\n> -\tstd::shared_ptr<MediaDevice> media;\n> +\tstd::shared_ptr<MediaDeviceBase> media;\n>   \n>   \tfor (auto iter = devices_.begin(); iter != devices_.end(); ++iter) {\n>   \t\tif ((*iter)->deviceNode() == deviceNode) {\n> @@ -297,14 +297,14 @@ void DeviceEnumerator::removeDevice(const std::string &deviceNode)\n>    *\n>    * Search in the enumerated media devices that are not already in use for a\n>    * match described in \\a dm. If a match is found and the caller intends to use\n> - * it the caller is responsible for acquiring the MediaDevice object and\n> + * it the caller is responsible for acquiring the MediaDeviceBase object and\n>    * releasing it when done with it.\n>    *\n> - * \\return pointer to the matching MediaDevice, or nullptr if no match is found\n> + * \\return pointer to the matching MediaDeviceBase, or nullptr if no match is found\n>    */\n> -std::shared_ptr<MediaDevice> DeviceEnumerator::search(const DeviceMatch &dm)\n> +std::shared_ptr<MediaDeviceBase> DeviceEnumerator::search(const DeviceMatch &dm)\n>   {\n> -\tfor (std::shared_ptr<MediaDevice> &media : devices_) {\n> +\tfor (std::shared_ptr<MediaDeviceBase> &media : devices_) {\n>   \t\tif (media->busy())\n>   \t\t\tcontinue;\n>   \n> diff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp\n> index 686bb809..22bbe44f 100644\n> --- a/src/libcamera/device_enumerator_sysfs.cpp\n> +++ b/src/libcamera/device_enumerator_sysfs.cpp\n> @@ -73,7 +73,7 @@ int DeviceEnumeratorSysfs::enumerate()\n>   \t\t\tcontinue;\n>   \t\t}\n>   \n> -\t\tstd::unique_ptr<MediaDevice> media = createDevice(devnode);\n> +\t\tstd::unique_ptr<MediaDeviceBase> media = createDevice(devnode);\n\ni.e.\n   std::unique_ptr<MediaDeviceBase> media = \ncreateDevice<MediaDevice>(devnode);\n\n>   \t\tif (!media)\n>   \t\t\tcontinue;\n>   \n> @@ -93,7 +93,7 @@ int DeviceEnumeratorSysfs::enumerate()\n>   \treturn 0;\n>   }\n>   \n> -int DeviceEnumeratorSysfs::populateMediaDevice(MediaDevice *media)\n> +int DeviceEnumeratorSysfs::populateMediaDevice(MediaDeviceBase *media)\n>   {\n>   \t/* Associate entities to device node paths. */\n>   \tfor (MediaEntity *entity : media->entities()) {\n> diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> index 5317afbd..8be8a8d2 100644\n> --- a/src/libcamera/device_enumerator_udev.cpp\n> +++ b/src/libcamera/device_enumerator_udev.cpp\n> @@ -76,7 +76,7 @@ int DeviceEnumeratorUdev::addUdevDevice(struct udev_device *dev)\n>   \t\treturn -ENODEV;\n>   \n>   \tif (!strcmp(subsystem, \"media\")) {\n> -\t\tstd::unique_ptr<MediaDevice> media =\n> +\t\tstd::unique_ptr<MediaDeviceBase> media =\n>   \t\t\tcreateDevice(udev_device_get_devnode(dev));\n>   \t\tif (!media)\n>   \t\t\treturn -ENODEV;\n> @@ -193,7 +193,7 @@ done:\n>   \treturn 0;\n>   }\n>   \n> -int DeviceEnumeratorUdev::populateMediaDevice(MediaDevice *media, DependencyMap *deps)\n> +int DeviceEnumeratorUdev::populateMediaDevice(MediaDeviceBase *media, DependencyMap *deps)\n>   {\n>   \tstd::set<dev_t> children;\n>   \n> diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> index 0c67e35d..f41e10c3 100644\n> --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> @@ -865,7 +865,7 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator)\n>   \tdm.add(\"mxc_isi.0\");\n>   \tdm.add(\"mxc_isi.0.capture\");\n>   \n> -\tisiDev_ = acquireMediaDevice(enumerator, dm);\n> +\tisiDev_ = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, dm));\n>   \tif (!isiDev_)\n>   \t\treturn false;\n>   \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index e4d79ea4..c3f3c815 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -923,11 +923,11 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n>   \timgu_dm.add(\"ipu3-imgu 1 viewfinder\");\n>   \timgu_dm.add(\"ipu3-imgu 1 3a stat\");\n>   \n> -\tcio2MediaDev_ = acquireMediaDevice(enumerator, cio2_dm);\n> +\tcio2MediaDev_ = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, cio2_dm));\n>   \tif (!cio2MediaDev_)\n>   \t\treturn false;\n>   \n> -\timguMediaDev_ = acquireMediaDevice(enumerator, imgu_dm);\n> +\timguMediaDev_ = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, imgu_dm));\n>   \tif (!imguMediaDev_)\n>   \t\treturn false;\n>   \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 8569df17..355cd556 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -1160,7 +1160,7 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)\n>   bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n>   {\n>   \tDeviceMatch unicam(\"unicam\");\n> -\tMediaDevice *unicamDevice = acquireMediaDevice(enumerator, unicam);\n> +\tMediaDevice *unicamDevice = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, unicam));\n>   \n>   \tif (!unicamDevice) {\n>   \t\tLOG(RPI, Debug) << \"Unable to acquire a Unicam instance\";\n> @@ -1168,7 +1168,7 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n>   \t}\n>   \n>   \tDeviceMatch isp(\"bcm2835-isp\");\n> -\tMediaDevice *ispDevice = acquireMediaDevice(enumerator, isp);\n> +\tMediaDevice *ispDevice = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, isp));\n>   \n>   \tif (!ispDevice) {\n>   \t\tLOG(RPI, Debug) << \"Unable to acquire ISP instance\";\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index eb9ad65c..c14711ef 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -1146,7 +1146,7 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n>   \tdm.add(\"rkisp1_stats\");\n>   \tdm.add(\"rkisp1_params\");\n>   \n> -\tmedia_ = acquireMediaDevice(enumerator, dm);\n> +\tmedia_ = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, dm));\n>   \tif (!media_)\n>   \t\treturn false;\n>   \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index a32de7f3..e6f4fad3 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -1391,7 +1391,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n>   \n>   \tfor (const SimplePipelineInfo &inf : supportedDevices) {\n>   \t\tDeviceMatch dm(inf.driver);\n> -\t\tmedia_ = acquireMediaDevice(enumerator, dm);\n> +\t\tmedia_ = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, dm));\n>   \t\tif (media_) {\n>   \t\t\tinfo = &inf;\n>   \t\t\tbreak;\n> @@ -1403,7 +1403,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n>   \n>   \tfor (const auto &[name, streams] : info->converters) {\n>   \t\tDeviceMatch converterMatch(name);\n> -\t\tconverter_ = acquireMediaDevice(enumerator, converterMatch);\n> +\t\tconverter_ = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, converterMatch));\n>   \t\tif (converter_) {\n>   \t\t\tnumStreams = streams;\n>   \t\t\tbreak;\n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index 277465b7..b97ec95e 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -389,7 +389,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n>   \tMediaDevice *media;\n>   \tDeviceMatch dm(\"uvcvideo\");\n>   \n> -\tmedia = acquireMediaDevice(enumerator, dm);\n> +\tmedia = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, dm));\n>   \tif (!media)\n>   \t\treturn false;\n>   \n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index 204f5ad7..0aaaa628 100644\n> --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> @@ -454,7 +454,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n>   \tdm.add(\"RGB/YUV Input\");\n>   \tdm.add(\"Scaler\");\n>   \n> -\tMediaDevice *media = acquireMediaDevice(enumerator, dm);\n> +\tMediaDevice *media = dynamic_cast<MediaDevice *>(acquireMediaDevice(enumerator, dm));\n>   \tif (!media)\n>   \t\treturn false;\n>   \n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index cfade490..613698a1 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -73,7 +73,7 @@ PipelineHandler::PipelineHandler(CameraManager *manager)\n>   \n>   PipelineHandler::~PipelineHandler()\n>   {\n> -\tfor (std::shared_ptr<MediaDevice> media : mediaDevices_)\n> +\tfor (std::shared_ptr<MediaDeviceBase> media : mediaDevices_)\n>   \t\tmedia->release();\n>   }\n>   \n> @@ -126,10 +126,10 @@ PipelineHandler::~PipelineHandler()\n>    *\n>    * \\return A pointer to the matching MediaDevice, or nullptr if no match is found\n>    */\n> -MediaDevice *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator,\n> -\t\t\t\t\t\t const DeviceMatch &dm)\n> +MediaDeviceBase *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator,\n> +\t\t\t\t\t\t     const DeviceMatch &dm)\n>   {\n> -\tstd::shared_ptr<MediaDevice> media = enumerator->search(dm);\n> +\tstd::shared_ptr<MediaDeviceBase> media = enumerator->search(dm);\n>   \tif (!media)\n>   \t\treturn nullptr;\n>   \n> @@ -170,7 +170,7 @@ bool PipelineHandler::acquire()\n>   \t\treturn true;\n>   \t}\n>   \n> -\tfor (std::shared_ptr<MediaDevice> &media : mediaDevices_) {\n> +\tfor (std::shared_ptr<MediaDeviceBase> &media : mediaDevices_) {\n>   \t\tif (!media->lock()) {\n>   \t\t\tunlockMediaDevices();\n>   \t\t\treturn false;\n> @@ -223,7 +223,7 @@ void PipelineHandler::releaseDevice([[maybe_unused]] Camera *camera)\n>   \n>   void PipelineHandler::unlockMediaDevices()\n>   {\n> -\tfor (std::shared_ptr<MediaDevice> &media : mediaDevices_)\n> +\tfor (std::shared_ptr<MediaDeviceBase> &media : mediaDevices_)\n>   \t\tmedia->unlock();\n>   }\n>   \n> @@ -556,7 +556,7 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)\n>   \t * to the camera.\n>   \t */\n>   \tstd::vector<dev_t> devnums;\n> -\tfor (const std::shared_ptr<MediaDevice> &media : mediaDevices_) {\n> +\tfor (const std::shared_ptr<MediaDeviceBase> &media : mediaDevices_) {\n>   \t\tfor (const MediaEntity *entity : media->entities()) {\n>   \t\t\tif (entity->pads().size() == 1 &&\n>   \t\t\t    (entity->pads()[0]->flags() & MEDIA_PAD_FL_SINK) &&\n> @@ -582,7 +582,7 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)\n>    * handler gets notified and automatically disconnects all the cameras it has\n>    * registered without requiring any manual intervention.\n>    */\n> -void PipelineHandler::hotplugMediaDevice(MediaDevice *media)\n> +void PipelineHandler::hotplugMediaDevice(MediaDeviceBase *media)\n>   {\n>   \tmedia->disconnected.connect(this, [=]() { mediaDeviceDisconnected(media); });\n>   }\n> @@ -590,7 +590,7 @@ void PipelineHandler::hotplugMediaDevice(MediaDevice *media)\n>   /**\n>    * \\brief Slot for the MediaDevice disconnected signal\n>    */\n> -void PipelineHandler::mediaDeviceDisconnected(MediaDevice *media)\n> +void PipelineHandler::mediaDeviceDisconnected(MediaDeviceBase *media)\n>   {\n>   \tmedia->disconnected.disconnect(this);\n>   \n\nBest regards\nSophie","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 90616BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Mar 2023 13:20:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D5111626B4;\n\tTue,  7 Mar 2023 14:20:41 +0100 (CET)","from mout-p-101.mailbox.org (mout-p-101.mailbox.org\n\t[80.241.56.151])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6AC6462693\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Mar 2023 14:20:40 +0100 (CET)","from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PWGKK3ftzz9sby\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Mar 2023 14:20:37 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678195241;\n\tbh=tVE172SQwn6FgqDZEMsBnjOo9EGWiJqp4H+DCid2VV8=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=vjqCe3YEMV0e7VLbD3zJB4mGD2iRVo2PnrQENxSXtkmRmq3gY26fn9/k54R90bWLw\n\txQuk1R71EVFJBwxtAmmYBO38YxIL5qcAN0JoB8zVvH11rROn8Nt7/OVMeT68V+yCPu\n\tMohsxlJuxTUOnpW7eT3flSl3JruCk4V8/kWz308E2QeabMbmoRgeZ4fFw4zhoVoO+N\n\t1cjYzL/gY6tlTvYT+Z+CdsCZkzHKi9lJG/UpnXutX/KCcMkIYqlekP+V6Mn2evBYp2\n\tX2FA60OLmMMYCTOXE2VOPRyw2orUfs5Agq+nGE3Ado9+BJF4CR955stCzA08I1atvF\n\tdyVZOflacpsKQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=flowerpot.me;\n\ts=MBO0001; t=1678195237;\n\th=from:from:reply-to:reply-to:subject:subject:date:date:\n\tmessage-id:message-id:to:to:cc:mime-version:mime-version:\n\tcontent-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=3CcLkOuuTRsgd914TAqURjQ+2dm4mx7u7XELjov0CZk=;\n\tb=OAtBavLByTIOFzVdSWE4ouu/10zLn3jejMt7qT+gzktzwmhXopDkidkQStxdPQTYoQ0nM/\n\tOBdrtoF3yBr2+6IL3kgx9fFgQisSRuWgJRdfc0sVZY7HuO5Hvav2wqYlgrvIuK3dPf2oyf\n\tyekAoUpdbFh4Cu7T9dUrHfS2f03yF2/ECBWdRi83XsM9pepVRhrEZALrbi6CVrY3bO5E9n\n\tJ86KsrdfgjUgfnb7JFFWDoSoArOAkmAM5tIxa/Zpcw947ohJ/vL8pyZamxAZyH56ZU6krt\n\t3A1j4RYl4LGLcStMZa+G+hZkSospTG+5+iBp06qZvhVbQGbm6ghXN0KXXoKh4A=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=flowerpot.me\n\theader.i=@flowerpot.me header.b=\"OAtBavLB\"; \n\tdkim-atps=neutral","Message-ID":"<e51cedd1-8d09-aacb-d5a6-7dc8787ac628@flowerpot.me>","Date":"Tue, 7 Mar 2023 14:20:36 +0100","MIME-Version":"1.0","Content-Language":"en-US","To":"libcamera-devel@lists.libcamera.org","References":"<20230105043726.679968-1-chenghaoyang@google.com>\n\t<20230105043726.679968-4-chenghaoyang@google.com>","In-Reply-To":"<20230105043726.679968-4-chenghaoyang@google.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 3/9] libcamera: Use MediaDeviceBase\n\tin base classes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Sophie Tyalie via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"20230105043726.679968-4-chenghaoyang@google.com","Cc":"Sophie Tyalie <lilly@flowerpot.me>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]