[vlc-devel] [PATCH 1/7] qt: distinguish enabled from video embed in video surface

Pierre Lamot pierre at videolabs.io
Fri Aug 14 18:48:59 CEST 2020


---
 .../gui/qt/maininterface/compositor_dcomp.cpp |  2 +-
 .../gui/qt/maininterface/main_interface.cpp   |  8 ++++----
 modules/gui/qt/maininterface/videosurface.cpp | 20 +++++++++++++++----
 modules/gui/qt/maininterface/videosurface.hpp |  9 ++++++---
 4 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/modules/gui/qt/maininterface/compositor_dcomp.cpp b/modules/gui/qt/maininterface/compositor_dcomp.cpp
index 51e20f5d81..27d4a9d026 100644
--- a/modules/gui/qt/maininterface/compositor_dcomp.cpp
+++ b/modules/gui/qt/maininterface/compositor_dcomp.cpp
@@ -212,7 +212,7 @@ MainInterface* CompositorDirectComposition::makeMainInterface()
         m_qmlVideoSurfaceProvider = std::make_unique<VideoSurfaceProvider>();
         m_rootWindow->setVideoSurfaceProvider(m_qmlVideoSurfaceProvider.get());
 
-        connect(m_qmlVideoSurfaceProvider.get(), &VideoSurfaceProvider::hasVideoChanged,
+        connect(m_qmlVideoSurfaceProvider.get(), &VideoSurfaceProvider::hasVideoEmbedChanged,
                 m_interfaceWindowHandler, &InterfaceWindowHandlerWin32::onVideoEmbedChanged);
 
 
diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp
index 6850dd0882..abfdf350d1 100644
--- a/modules/gui/qt/maininterface/main_interface.cpp
+++ b/modules/gui/qt/maininterface/main_interface.cpp
@@ -362,19 +362,19 @@ void MainInterface::setInterfaceAlwaysOnTop( bool on_top )
 
 bool MainInterface::hasEmbededVideo() const
 {
-    return m_videoSurfaceProvider && m_videoSurfaceProvider->hasVideo();
+    return m_videoSurfaceProvider && m_videoSurfaceProvider->hasVideoEmbed();
 }
 
 void MainInterface::setVideoSurfaceProvider(VideoSurfaceProvider* videoSurfaceProvider)
 {
     if (m_videoSurfaceProvider)
-        disconnect(m_videoSurfaceProvider, &VideoSurfaceProvider::hasVideoChanged, this, &MainInterface::hasEmbededVideoChanged);
+        disconnect(m_videoSurfaceProvider, &VideoSurfaceProvider::hasVideoEmbedChanged, this, &MainInterface::hasEmbededVideoChanged);
     m_videoSurfaceProvider = videoSurfaceProvider;
     if (m_videoSurfaceProvider)
-        connect(m_videoSurfaceProvider, &VideoSurfaceProvider::hasVideoChanged,
+        connect(m_videoSurfaceProvider, &VideoSurfaceProvider::hasVideoEmbedChanged,
                 this, &MainInterface::hasEmbededVideoChanged,
                 Qt::QueuedConnection);
-    emit hasEmbededVideoChanged(m_videoSurfaceProvider && m_videoSurfaceProvider->hasVideo());
+    emit hasEmbededVideoChanged(m_videoSurfaceProvider && m_videoSurfaceProvider->isEnabled());
 }
 
 VideoSurfaceProvider* MainInterface::getVideoSurfaceProvider() const
diff --git a/modules/gui/qt/maininterface/videosurface.cpp b/modules/gui/qt/maininterface/videosurface.cpp
index b69e4a3b52..de74872145 100644
--- a/modules/gui/qt/maininterface/videosurface.cpp
+++ b/modules/gui/qt/maininterface/videosurface.cpp
@@ -25,12 +25,17 @@ VideoSurfaceProvider::VideoSurfaceProvider(QObject* parent)
 {
 }
 
-bool VideoSurfaceProvider::hasVideo()
+bool VideoSurfaceProvider::isEnabled()
 {
     QMutexLocker lock(&m_voutlock);
     return m_voutWindow != nullptr;
 }
 
+bool VideoSurfaceProvider::hasVideoEmbed() const
+{
+    return m_videoEmbed;
+}
+
 void VideoSurfaceProvider::enable(vout_window_t* voutWindow)
 {
     assert(voutWindow);
@@ -38,16 +43,23 @@ void VideoSurfaceProvider::enable(vout_window_t* voutWindow)
         QMutexLocker lock(&m_voutlock);
         m_voutWindow = voutWindow;
     }
-    emit hasVideoChanged(true);
+    emit videoEnabledChanged(true);
 }
 
 void VideoSurfaceProvider::disable()
 {
+    setVideoEmbed(false);
     {
         QMutexLocker lock(&m_voutlock);
         m_voutWindow = nullptr;
     }
-    emit hasVideoChanged(false);
+    emit videoEnabledChanged(false);
+}
+
+void VideoSurfaceProvider::setVideoEmbed(bool embed)
+{
+    m_videoEmbed = embed;
+    emit hasVideoEmbedChanged(embed);
 }
 
 void VideoSurfaceProvider::onWindowClosed()
@@ -270,7 +282,7 @@ QSGNode*VideoSurface::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdatePaintN
         connect(this, &VideoSurface::keyPressed, m_provider, &VideoSurfaceProvider::onKeyPressed);
         connect(this, &VideoSurface::surfaceSizeChanged, m_provider, &VideoSurfaceProvider::onSurfaceSizeChanged);
 
-        connect(m_provider, &VideoSurfaceProvider::hasVideoChanged, this, &VideoSurface::onProviderVideoChanged);
+        connect(m_provider, &VideoSurfaceProvider::hasVideoEmbedChanged, this, &VideoSurface::onProviderVideoChanged);
 
         onSurfaceSizeChanged();
     }
diff --git a/modules/gui/qt/maininterface/videosurface.hpp b/modules/gui/qt/maininterface/videosurface.hpp
index 5ff2cd4814..a3b70daa5a 100644
--- a/modules/gui/qt/maininterface/videosurface.hpp
+++ b/modules/gui/qt/maininterface/videosurface.hpp
@@ -32,15 +32,17 @@ public:
     VideoSurfaceProvider(QObject* parent = nullptr);
     virtual ~VideoSurfaceProvider() {}
 
-    bool hasVideo();
-
     void enable(vout_window_t* voutWindow);
     void disable();
+    bool isEnabled();
 
+    void setVideoEmbed(bool embed);
+    bool hasVideoEmbed() const;
 
 signals:
     void ctxChanged(QmlMainContext*);
-    bool hasVideoChanged(bool);
+    bool videoEnabledChanged(bool);
+    bool hasVideoEmbedChanged(bool);
 
 public slots:
     void onWindowClosed();
@@ -55,6 +57,7 @@ public slots:
 protected:
     QMutex m_voutlock;
     vout_window_t* m_voutWindow = nullptr;
+    bool m_videoEmbed = false;
 };
 
 
-- 
2.25.1



More information about the vlc-devel mailing list