<html><head></head><body>This does not seem to bind to versions correctly. Also error handling seems missing.<br><br><div class="gmail_quote">Le 1 février 2019 15:01:52 GMT+02:00, Pierre Lamot <pierre@videolabs.io> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">From: Alexandre Janniaux <alexandre.janniaux@gmail.com><hr> modules/gui/qt/Makefile.am | 9 +<br> .../video_renderer/videorendererwayland.cpp | 154 ++++++++++++++++++<br> .../video_renderer/videorendererwayland.hpp | 63 +++++++<br> 3 files changed, 226 insertions(+)<br> create mode 100644 modules/gui/qt/components/video_renderer/videorendererwayland.cpp<br> create mode 100644 modules/gui/qt/components/video_renderer/videorendererwayland.hpp<br><br>diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am<br>index 7d0132c6a1..e9cd3e61d4 100644<br>--- a/modules/gui/qt/Makefile.am<br>+++ b/modules/gui/qt/Makefile.am<br>@@ -166,6 +166,11 @@ if HAVE_WIN32<br> libqt_plugin_la_SOURCES += \<br> gui/qt/main_interface_win32.cpp gui/qt/main_interface_win32.hpp<br> endif<br>+if HAVE_WAYLAND<br>+libqt_plugin_la_SOURCES += \<br>+ gui/qt/components/video_renderer/videorendererwayland.hpp \<br>+ gui/qt/components/video_renderer/videorendererwayland.cpp<br>+endif<br> <br> # Meta-object compilation<br> <br>@@ -260,6 +265,10 @@ if HAVE_WIN32<br> nodist_libqt_plugin_la_SOURCES += gui/qt/main_interface_win32.moc.cpp<br> endif<br> <br>+if HAVE_WAYLAND<br>+nodist_libqt_plugin_la_SOURCES += gui/qt/components/video_renderer/videorendererwayland.moc.cpp<br>+endif<br>+<br> nodist_libqt_plugin_la_SOURCES += \<br> gui/qt/ui/equalizer.h \<br> gui/qt/ui/video_effects.h \<br>diff --git a/modules/gui/qt/components/video_renderer/videorendererwayland.cpp b/modules/gui/qt/components/video_renderer/videorendererwayland.cpp<br>new file mode 100644<br>index 0000000000..120bb9a24c<br>--- /dev/null<br>+++ b/modules/gui/qt/components/video_renderer/videorendererwayland.cpp<br>@@ -0,0 +1,154 @@<br>+#include "videorendererwayland.hpp"<br>+#include <QtQuick/QSGImageNode><br>+#include <QtQuick/QSGRectangleNode><br>+#include <QtQuick/QQuickWindow><br>+#include <vlc_vout_window.h><br>+#include "main_interface.hpp"<br>+<br>+#include QPNI_HEADER<br>+#include <wayland-client.h><br>+#include <wayland-client-protocol.h><br>+<br>+void VideoRendererWayland::registry_global( void *data, wl_registry *registry,<br>+ uint32_t name, const char *intf,<br>+ uint32_t version )<br>+{<br>+ VideoRendererWayland *renderer = static_cast<VideoRendererWayland*>( data );<br>+<br>+ if( !strcmp(intf, "wl_compositor") )<br>+ renderer->m_compositor = static_cast<wl_compositor*>(<br>+ wl_registry_bind( registry, name,<br>+ &wl_compositor_interface,<br>+ version ));<br>+<br>+ else<br>+ if( !strcmp(intf, "wl_subcompositor") )<br>+ renderer->m_subcompositor = static_cast<wl_subcompositor*>(<br>+ wl_registry_bind( registry, name,<br>+ &wl_subcompositor_interface,<br>+ version ));<br>+}<br>+<br>+void VideoRendererWayland::registry_global_remove( void *, wl_registry *, uint32_t )<br>+{<br>+ // nothing to do<br>+}<br>+<br>+VideoRendererWayland::VideoRendererWayland( MainInterface* p_mi, QObject* parent )<br>+ : VideoRenderer( parent )<br>+ , m_mainInterface( p_mi )<br>+{<br>+ assert( m_mainInterface );<br>+ m_surfaceProvider = new VideoSurfaceWayland( this, this );<br>+}<br>+<br>+VideoRendererWayland::~VideoRendererWayland()<br>+{<br>+ if( m_subsurface )<br>+ wl_subsurface_destroy( m_subsurface );<br>+ if( m_surface )<br>+ wl_surface_destroy( m_surface );<br>+ if( m_compositor )<br>+ wl_compositor_destroy( m_compositor );<br>+ if( m_subcompositor )<br>+ wl_subcompositor_destroy( m_subcompositor );<br>+}<br>+<br>+void VideoRendererWayland::enableVideo(unsigned width, unsigned height, bool fullscreen)<br>+{<br>+ VideoRenderer::enableVideo(width, height, fullscreen);<br>+ if (!m_hasVideo) //no window out has been set<br>+ return;<br>+<br>+ m_voutWindow->type = VOUT_WINDOW_TYPE_WAYLAND;<br>+<br>+ QPlatformNativeInterface *qni = qApp->platformNativeInterface();<br>+<br>+ m_voutWindow->display.wl = static_cast<wl_display *>(<br>+ qni->nativeResourceForIntegration(QByteArrayLiteral("wl_display")));<br>+<br>+ const wl_registry_listener registry_cbs =<br>+ {<br>+ registry_global,<br>+ registry_global_remove,<br>+ };<br>+<br>+ wl_registry *registry = wl_display_get_registry( m_voutWindow->display.wl );<br>+ wl_registry_add_listener( registry, ®istry_cbs, this );<br>+ wl_display_roundtrip( m_voutWindow->display.wl );<br>+ wl_registry_destroy( registry );<br>+<br>+ if( !m_compositor || !m_subcompositor )<br>+ return; // TODO: what to do<br>+<br>+ QWindow *root_window = m_mainInterface->window()->windowHandle();<br>+ wl_surface *root_surface = static_cast<wl_surface *>(<br>+ qni->nativeResourceForWindow( QByteArrayLiteral("surface"),<br>+ root_window ));<br>+<br>+ m_surface =<br>+ m_voutWindow->handle.wl = wl_compositor_create_surface( m_compositor );<br>+ m_subsurface = wl_subcompositor_get_subsurface( m_subcompositor,<br>+ m_voutWindow->handle.wl,<br>+ root_surface );<br>+<br>+ wl_subsurface_place_below( m_subsurface, root_surface );<br>+ wl_subsurface_set_desync( m_subsurface );<br>+<br>+ /* HACK: disable event input on surface, so that Qt don't try<br>+ * to cast it's userdata */<br>+ wl_region *region = wl_compositor_create_region( m_compositor );<br>+ wl_region_add( region, 0, 0, 0, 0 );<br>+ wl_surface_set_input_region( m_voutWindow->handle.wl, region );<br>+ wl_region_destroy( region );<br>+}<br>+<br>+<br>+void VideoRendererWayland::disableVideo()<br>+{<br>+ VideoRenderer::disableVideo();<br>+ if( m_subsurface )<br>+ wl_subsurface_destroy( m_subsurface );<br>+ if( m_surface )<br>+ wl_surface_destroy( m_surface );<br>+ if( m_subcompositor )<br>+ wl_subcompositor_destroy( m_subcompositor );<br>+ if( m_compositor )<br>+ wl_compositor_destroy( m_compositor );<br>+ m_subsurface = nullptr; m_surface = nullptr;<br>+ m_compositor = nullptr; m_subcompositor = nullptr;<br>+}<br>+<br>+VideoSurfaceProvider *VideoRendererWayland::getVideoSurfaceProvider()<br>+{<br>+ return m_surfaceProvider;<br>+}<br>+<br>+VideoSurfaceWayland::VideoSurfaceWayland(VideoRendererWayland* renderer, QObject* parent)<br>+ : VideoSurfaceProvider( parent )<br>+ , m_renderer(renderer)<br>+{<br>+ connect(this, &VideoSurfaceWayland::mouseMoved, m_renderer, &VideoRenderer::onMouseMoved, Qt::QueuedConnection);<br>+ connect(this, &VideoSurfaceWayland::mousePressed, m_renderer, &VideoRenderer::onMousePressed, Qt::QueuedConnection);<br>+ connect(this, &VideoSurfaceWayland::mouseDblClicked, m_renderer, &VideoRenderer::onMouseDoubleClick, Qt::QueuedConnection);<br>+ connect(this, &VideoSurfaceWayland::mouseReleased, m_renderer, &VideoRenderer::onMouseReleased, Qt::QueuedConnection);<br>+<br>+ connect(this, &VideoSurfaceWayland::surfaceSizeChanged, m_renderer, &VideoRenderer::onSurfaceSizeChanged);<br>+<br>+ connect(m_renderer, &VideoRendererWayland::updated, this, &VideoSurfaceWayland::update, Qt::QueuedConnection);<br>+}<br>+<br>+QSGNode* VideoSurfaceWayland::updatePaintNode(QQuickItem* item, QSGNode* oldNode, QQuickItem::UpdatePaintNodeData*)<br>+{<br>+ QSGRectangleNode* node = static_cast<QSGRectangleNode*>(oldNode);<br>+<br>+ if (!node)<br>+ {<br>+ node = item->window()->createRectangleNode();<br>+ node->setColor(Qt::transparent);<br>+ }<br>+ node->setRect(item->boundingRect());<br>+<br>+ return node;<br>+}<br>+<br>diff --git a/modules/gui/qt/components/video_renderer/videorendererwayland.hpp b/modules/gui/qt/components/video_renderer/videorendererwayland.hpp<br>new file mode 100644<br>index 0000000000..c3c3462368<br>--- /dev/null<br>+++ b/modules/gui/qt/components/video_renderer/videorendererwayland.hpp<br>@@ -0,0 +1,63 @@<br>+#ifndef VLC_QT_VIDEORENDERERWL_HPP<br>+#define VLC_QT_VIDEORENDERERWL_HPP<br>+<br>+#include <inttypes.h><br>+#include <QtQuick/QQuickItem><br>+#include <QMutex><br>+#include <QtQuick/QSGRectangleNode><br>+#include <components/qml_main_context.hpp><br>+#include "qt.hpp"<br>+<br>+#include "videorenderer.hpp"<br>+<br>+class MainInterface;<br>+class VideoSurfaceWayland;<br>+<br>+struct wl_compositor;<br>+struct wl_subcompositor;<br>+struct wl_subsurface;<br>+struct wl_registry;<br>+<br>+class VideoRendererWayland: public VideoRenderer<br>+{<br>+ Q_OBJECT<br>+public:<br>+ VideoRendererWayland(MainInterface* p_mi, QObject *parent = nullptr);<br>+ ~VideoRendererWayland() override;<br>+<br>+ void enableVideo(unsigned int width, unsigned int height, bool fullscreen);<br>+ void disableVideo();<br>+<br>+ VideoSurfaceProvider *getVideoSurfaceProvider() override;<br>+<br>+signals:<br>+ void updated();<br>+<br>+private:<br>+ /* wayland registry callbacks */<br>+ static void registry_global( void *, wl_registry *, uint32_t,<br>+ const char *, uint32_t );<br>+ static void registry_global_remove( void *, wl_registry *, uint32_t );<br>+<br>+ MainInterface *m_mainInterface;<br>+ VideoSurfaceWayland *m_surfaceProvider = nullptr;<br>+ wl_compositor *m_compositor = nullptr;<br>+ wl_subcompositor *m_subcompositor = nullptr;<br>+ wl_subsurface *m_subsurface = nullptr;<br>+ wl_surface *m_surface = nullptr;<br>+};<br>+<br>+class VideoSurfaceWayland : public VideoSurfaceProvider<br>+{<br>+ Q_OBJECT<br>+public:<br>+ VideoSurfaceWayland(VideoRendererWayland* renderer, QObject* parent = nullptr);<br>+<br>+private:<br>+ QSGNode *updatePaintNode(QQuickItem* item, QSGNode *, QQuickItem::UpdatePaintNodeData *) override;<br>+<br>+private:<br>+ VideoRendererWayland* m_renderer = nullptr;<br>+};<br>+<br>+#endif // VLC_QT_VIDEORENDERERWL_HPP</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>