diff --git a/src/api/avmodel.h b/src/api/avmodel.h index 5e3287144e24437c4d88705e245a3fd50704aa44..2391e5fe11c5eaefa7de021509ae9f03d6286cf9 100644 --- a/src/api/avmodel.h +++ b/src/api/avmodel.h @@ -219,6 +219,10 @@ Q_SIGNALS: * @param id */ void frameUpdated(const std::string& id); + /** + * Emitted when a device is plugged or unplugged + */ + void deviceEvent(); private: std::unique_ptr<AVModelPimpl> pimpl_; diff --git a/src/avmodel.cpp b/src/avmodel.cpp index 417bdfb43357f719d085d90b0d4084fda626b28a..094d79cb162d4e87cf34c2232f5e77a694698c4d 100644 --- a/src/avmodel.cpp +++ b/src/avmodel.cpp @@ -110,6 +110,10 @@ public Q_SLOTS: * @param id */ void slotFrameUpdated(const std::string& id); + /** + * Detect when a device is plugged or unplugged + */ + void slotDeviceEvent(); }; @@ -481,6 +485,8 @@ AVModelPimpl::init() #ifndef ENABLE_LIBWRAP SIZE_RENDERER = renderers_.size(); #endif + connect(&callbacksHandler, &CallbacksHandler::deviceEvent, + this, &AVModelPimpl::slotDeviceEvent); connect(&callbacksHandler, &CallbacksHandler::startedDecoding, this, &AVModelPimpl::startedDecoding); connect(&callbacksHandler, &CallbacksHandler::stoppedDecoding, @@ -684,6 +690,12 @@ AVModelPimpl::slotFrameUpdated(const std::string& id) emit linked_.frameUpdated(id); } +void +AVModelPimpl::slotDeviceEvent() +{ + emit linked_.deviceEvent(); +} + } // namespace lrc #include "api/moc_avmodel.cpp" diff --git a/src/callbackshandler.cpp b/src/callbackshandler.cpp index f94c98b209f1221de8346712f96827bb2f3442f3..6779d3f5040486e601a25e6c4e321c06abfb7eac 100644 --- a/src/callbackshandler.cpp +++ b/src/callbackshandler.cpp @@ -200,6 +200,12 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent) this, &CallbacksHandler::slotStoppedDecoding, Qt::QueuedConnection); + + connect(&VideoManager::instance(), + &VideoManagerInterface::deviceEvent, + this, + &CallbacksHandler::slotDeviceEvent, + Qt::QueuedConnection); } CallbacksHandler::~CallbacksHandler() @@ -481,5 +487,11 @@ CallbacksHandler::slotStoppedDecoding(const QString& id, const QString& shmPath) emit stoppedDecoding(id.toStdString(), shmPath.toStdString()); } +void +CallbacksHandler::slotDeviceEvent() +{ + emit deviceEvent(); +} + } // namespace lrc diff --git a/src/callbackshandler.h b/src/callbackshandler.h index d070a42c88d52890360e05bed71ce8e5d8f3c5c1..78b9e59a48c63659281b6a4c067c55f365ee30ff 100644 --- a/src/callbackshandler.h +++ b/src/callbackshandler.h @@ -248,6 +248,11 @@ Q_SIGNALS: */ void stoppedDecoding(const std::string& id, const std::string& shmPath); + /** + * Emitted when a device is plugged or unplugged + */ + void deviceEvent(); + private Q_SLOTS: /** * Emit newAccountMessage @@ -446,6 +451,11 @@ private Q_SLOTS: */ void slotStoppedDecoding(const QString& id, const QString& shmPath); + /** + * Detect when a device is plugged or unplugged + */ + void slotDeviceEvent(); + private: const api::Lrc& parent;