<html><head></head><body>Video sink and video renderer are other names (arguably better) for vout display.<br><br>Reusing them for window is confusing imo.<br><br><div class="gmail_quote">Le 1 février 2019 15:01:48 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"> VideoSurface provide a QQuickItem which can be embed within a QML scene to<br> represent the video node.<br><br> VideoSurfaceProvider is the actual implementation of the VideoSurface which will<br> be selected at runtime<br><br> VideoRenderer implement a video sink which will be in charge of rendering the video<hr> modules/gui/qt/Makefile.am | 6 +<br> .../video_renderer/videorenderer.cpp | 63 +++++++<br> .../video_renderer/videorenderer.hpp | 37 ++++<br> .../video_renderer/videosurface.cpp | 170 ++++++++++++++++++<br> .../video_renderer/videosurface.hpp | 102 +++++++++++<br> 5 files changed, 378 insertions(+)<br> create mode 100644 modules/gui/qt/components/video_renderer/videorenderer.cpp<br> create mode 100644 modules/gui/qt/components/video_renderer/videorenderer.hpp<br> create mode 100644 modules/gui/qt/components/video_renderer/videosurface.cpp<br> create mode 100644 modules/gui/qt/components/video_renderer/videosurface.hpp<br><br>diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am<br>index d48aa0c1e2..c061c8a2bd 100644<br>--- a/modules/gui/qt/Makefile.am<br>+++ b/modules/gui/qt/Makefile.am<br>@@ -98,6 +98,10 @@ libqt_plugin_la_SOURCES = \<br> gui/qt/components/controller.cpp gui/qt/components/controller.hpp \<br> gui/qt/components/controller_widget.cpp \<br> gui/qt/components/controller_widget.hpp \<br>+ gui/qt/components/video_renderer/videosurface.cpp \<br>+ gui/qt/components/video_renderer/videosurface.hpp \<br>+ gui/qt/components/video_renderer/videorenderer.cpp \<br>+ gui/qt/components/video_renderer/videorenderer.hpp \<br> gui/qt/components/custom_menus.cpp \<br> gui/qt/components/custom_menus.hpp \<br> gui/qt/components/epg/EPGChannels.cpp \<br>@@ -216,6 +220,8 @@ nodist_libqt_plugin_la_SOURCES = \<br> gui/qt/components/controller.moc.cpp \<br> gui/qt/components/controller_widget.moc.cpp \<br> gui/qt/components/custom_menus.moc.cpp \<br>+ gui/qt/components/video_renderer/videosurface.moc.cpp \<br>+ gui/qt/components/video_renderer/videorenderer.moc.cpp \<br> gui/qt/components/epg/EPGChannels.moc.cpp \<br> gui/qt/components/epg/EPGProgram.moc.cpp \<br> gui/qt/components/epg/EPGRuler.moc.cpp \<br>diff --git a/modules/gui/qt/components/video_renderer/videorenderer.cpp b/modules/gui/qt/components/video_renderer/videorenderer.cpp<br>new file mode 100644<br>index 0000000000..09150f372d<br>--- /dev/null<br>+++ b/modules/gui/qt/components/video_renderer/videorenderer.cpp<br>@@ -0,0 +1,63 @@<br>+#include "videorenderer.hpp"<br>+<br>+VideoRenderer::VideoRenderer(QObject* parent)<br>+ : QObject(parent)<br>+{<br>+}<br>+<br>+void VideoRenderer::setupVoutWindow(vout_window_t* window)<br>+{<br>+ QMutexLocker lock(&m_voutlock);<br>+ m_voutWindow = window;<br>+ m_hasVideo = false;<br>+}<br>+<br>+void VideoRenderer::enableVideo(unsigned /*width*/, unsigned /*height*/, bool /*fullscreen*/)<br>+{<br>+ QMutexLocker lock(&m_voutlock);<br>+ if (m_voutWindow)<br>+ m_hasVideo = true;<br>+}<br>+<br>+void VideoRenderer::disableVideo()<br>+{<br>+ QMutexLocker lock(&m_voutlock);<br>+ if (m_voutWindow)<br>+ m_hasVideo = false;<br>+}<br>+<br>+void VideoRenderer::onMousePressed(int vlcButton)<br>+{<br>+ QMutexLocker lock(&m_voutlock);<br>+ if (m_hasVideo)<br>+ vout_window_ReportMousePressed(m_voutWindow, vlcButton);<br>+}<br>+<br>+void VideoRenderer::onMouseReleased(int vlcButton)<br>+{<br>+ QMutexLocker lock(&m_voutlock);<br>+ if (m_hasVideo)<br>+ vout_window_ReportMouseReleased(m_voutWindow, vlcButton);<br>+}<br>+<br>+void VideoRenderer::onMouseDoubleClick(int vlcButton)<br>+{<br>+ QMutexLocker lock(&m_voutlock);<br>+ if (m_hasVideo)<br>+ vout_window_ReportMouseDoubleClick(m_voutWindow, vlcButton);<br>+}<br>+<br>+void VideoRenderer::onMouseMoved(float x, float y)<br>+{<br>+ QMutexLocker lock(&m_voutlock);<br>+ if (m_hasVideo)<br>+ vout_window_ReportMouseMoved(m_voutWindow, x, y);<br>+}<br>+<br>+void VideoRenderer::onSurfaceSizeChanged(QSizeF size)<br>+{<br>+<br>+ QMutexLocker lock(&m_voutlock);<br>+ if (m_hasVideo)<br>+ vout_window_ReportSize(m_voutWindow, size.width(), size.height());<br>+}<br>diff --git a/modules/gui/qt/components/video_renderer/videorenderer.hpp b/modules/gui/qt/components/video_renderer/videorenderer.hpp<br>new file mode 100644<br>index 0000000000..98e3ea26c2<br>--- /dev/null<br>+++ b/modules/gui/qt/components/video_renderer/videorenderer.hpp<br>@@ -0,0 +1,37 @@<br>+#ifndef VIDEORENDERER_HPP<br>+#define VIDEORENDERER_HPP<br>+<br>+#include <QObject><br>+#include <QMutex><br>+#include "qt.hpp"<br>+#include "vlc_vout_window.h"<br>+#include "videosurface.hpp"<br>+<br>+class VideoRenderer : public QObject<br>+{<br>+ Q_OBJECT<br>+public:<br>+ VideoRenderer(QObject* parent = nullptr);<br>+ virtual ~VideoRenderer() {}<br>+<br>+ virtual void setupVoutWindow(vout_window_t* window);<br>+ virtual void enableVideo(unsigned width, unsigned height, bool fullscreen);<br>+ virtual void disableVideo();<br>+<br>+ virtual VideoSurfaceProvider* getVideoSurfaceProvider() = 0;<br>+<br>+public slots:<br>+ void onMousePressed( int vlcButton );<br>+ void onMouseReleased( int vlcButton );<br>+ void onMouseDoubleClick( int vlcButton );<br>+ void onMouseMoved( float x, float y );<br>+ void onSurfaceSizeChanged(QSizeF size);<br>+<br>+protected:<br>+ QMutex m_voutlock;<br>+ vout_window_t* m_voutWindow = nullptr;<br>+ bool m_hasVideo = false;<br>+<br>+};<br>+<br>+#endif // VIDEORENDERER_HPP<br>diff --git a/modules/gui/qt/components/video_renderer/videosurface.cpp b/modules/gui/qt/components/video_renderer/videosurface.cpp<br>new file mode 100644<br>index 0000000000..39b453c3c1<br>--- /dev/null<br>+++ b/modules/gui/qt/components/video_renderer/videosurface.cpp<br>@@ -0,0 +1,170 @@<br>+/*****************************************************************************<br>+ * Copyright (C) 2019 VLC authors and VideoLAN<br>+ *<br>+ * This program is free software; you can redistribute it and/or modify<br>+ * it under the terms of the GNU General Public License as published by<br>+ * the Free Software Foundation; either version 2 of the License, or<br>+ * (at your option) any later version.<br>+ *<br>+ * This program is distributed in the hope that it will be useful,<br>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>+ * GNU General Public License for more details.<br>+ *<br>+ * You should have received a copy of the GNU General Public License<br>+ * along with this program; if not, write to the Free Software<br>+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br>+ *****************************************************************************/<br>+#include "videosurface.hpp"<br>+#include "main_interface.hpp"<br>+<br>+<br>+VideoSurfaceProvider::VideoSurfaceProvider(QObject* parent)<br>+ : QObject(parent)<br>+{<br>+}<br>+<br>+VideoSurface::VideoSurface(QQuickItem* parent)<br>+ : QQuickItem(parent)<br>+{<br>+ setAcceptHoverEvents(true);<br>+ setAcceptedMouseButtons(Qt::AllButtons);<br>+ setFlag(ItemAcceptsInputMethod, true);<br>+ setFlag(ItemHasContents, true);<br>+<br>+ connect(this, &QQuickItem::widthChanged, this, &VideoSurface::onSurfaceSizeChanged);<br>+ connect(this, &QQuickItem::heightChanged, this, &VideoSurface::onSurfaceSizeChanged);<br>+}<br>+<br>+QmlMainContext*VideoSurface::getCtx()<br>+{<br>+ return m_mainCtx;<br>+}<br>+<br>+void VideoSurface::setCtx(QmlMainContext* mainctx)<br>+{<br>+ m_mainCtx = mainctx;<br>+ emit ctxChanged(mainctx);<br>+}<br>+<br>+QSize VideoSurface::getSourceSize() const<br>+{<br>+ return m_sourceSize;<br>+}<br>+<br>+int VideoSurface::qtMouseButton2VLC( Qt::MouseButton qtButton )<br>+{<br>+ switch( qtButton )<br>+ {<br>+ case Qt::LeftButton:<br>+ return 0;<br>+ case Qt::RightButton:<br>+ return 2;<br>+ case Qt::MiddleButton:<br>+ return 1;<br>+ default:<br>+ return -1;<br>+ }<br>+}<br>+<br>+void VideoSurface::mousePressEvent(QMouseEvent* event)<br>+{<br>+ int vlc_button = qtMouseButton2VLC( event->button() );<br>+ if( vlc_button >= 0 )<br>+ {<br>+ emit mousePressed(vlc_button);<br>+ event->accept();<br>+ }<br>+ else<br>+ event->ignore();<br>+}<br>+<br>+void VideoSurface::mouseReleaseEvent(QMouseEvent* event)<br>+{<br>+ int vlc_button = qtMouseButton2VLC( event->button() );<br>+ if( vlc_button >= 0 )<br>+ {<br>+ emit mouseReleased(vlc_button);<br>+ event->accept();<br>+ }<br>+ else<br>+ event->ignore();<br>+}<br>+<br>+void VideoSurface::mouseMoveEvent(QMouseEvent* event)<br>+{<br>+ QPointF current_pos = event->localPos();<br>+ emit mouseMoved(current_pos.x() , current_pos.y());<br>+ event->accept();<br>+}<br>+<br>+void VideoSurface::hoverMoveEvent(QHoverEvent* event)<br>+{<br>+ QPointF current_pos = event->posF();<br>+ if (current_pos != m_oldHoverPos)<br>+ {<br>+ float scaleW = m_sourceSize.width() / width();<br>+ float scaleH = m_sourceSize.height() / height();<br>+ emit mouseMoved(current_pos.x() * scaleW, current_pos.y() * scaleH);<br>+ m_oldHoverPos = current_pos;<br>+ }<br>+ event->accept();<br>+}<br>+<br>+void VideoSurface::mouseDoubleClickEvent(QMouseEvent* event)<br>+{<br>+ int vlc_button = qtMouseButton2VLC( event->button() );<br>+ if( vlc_button >= 0 )<br>+ {<br>+ emit mouseDblClicked(vlc_button);<br>+ event->accept();<br>+ }<br>+ else<br>+ event->ignore();<br>+}<br>+<br>+Qt::CursorShape VideoSurface::getCursorShape() const<br>+{<br>+ return cursor().shape();<br>+}<br>+<br>+void VideoSurface::setCursorShape(Qt::CursorShape shape)<br>+{<br>+ setCursor(shape);<br>+}<br>+<br>+QSGNode*VideoSurface::updatePaintNode(QSGNode* node, QQuickItem::UpdatePaintNodeData* nodeData)<br>+{<br>+ if (m_provider == nullptr) {<br>+ if (m_mainCtx == nullptr)<br>+ return nullptr;<br>+ m_provider = m_mainCtx->getMainInterface()->getVideoSurfaceProvider();<br>+ if (!m_provider)<br>+ return nullptr;<br>+<br>+ //forward signal to the provider<br>+ connect(this, &VideoSurface::mouseMoved, m_provider, &VideoSurfaceProvider::mouseMoved);<br>+ connect(this, &VideoSurface::mousePressed, m_provider, &VideoSurfaceProvider::mousePressed);<br>+ connect(this, &VideoSurface::mouseDblClicked, m_provider, &VideoSurfaceProvider::mouseDblClicked);<br>+ connect(this, &VideoSurface::mouseReleased, m_provider, &VideoSurfaceProvider::mouseReleased);<br>+<br>+ connect(this, &VideoSurface::surfaceSizeChanged, m_provider, &VideoSurfaceProvider::surfaceSizeChanged);<br>+<br>+ connect(m_provider, &VideoSurfaceProvider::update, this, &VideoSurface::update);<br>+ connect(m_provider, &VideoSurfaceProvider::sourceSizeChanged, this, &VideoSurface::onSourceSizeChanged);<br>+ }<br>+ return m_provider->updatePaintNode(this, node, nodeData);<br>+}<br>+<br>+void VideoSurface::onSourceSizeChanged(QSize newSize)<br>+{<br>+ if (newSize != m_sourceSize) {<br>+ m_sourceSize = newSize;<br>+ emit sourceSizeChanged(m_sourceSize);<br>+ }<br>+}<br>+<br>+void VideoSurface::onSurfaceSizeChanged()<br>+{<br>+ emit surfaceSizeChanged(size());<br>+}<br>diff --git a/modules/gui/qt/components/video_renderer/videosurface.hpp b/modules/gui/qt/components/video_renderer/videosurface.hpp<br>new file mode 100644<br>index 0000000000..41cb257a0a<br>--- /dev/null<br>+++ b/modules/gui/qt/components/video_renderer/videosurface.hpp<br>@@ -0,0 +1,102 @@<br>+/*****************************************************************************<br>+ * Copyright (C) 2019 VLC authors and VideoLAN<br>+ *<br>+ * This program is free software; you can redistribute it and/or modify<br>+ * it under the terms of the GNU General Public License as published by<br>+ * the Free Software Foundation; either version 2 of the License, or<br>+ * (at your option) any later version.<br>+ *<br>+ * This program is distributed in the hope that it will be useful,<br>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>+ * GNU General Public License for more details.<br>+ *<br>+ * You should have received a copy of the GNU General Public License<br>+ * along with this program; if not, write to the Free Software<br>+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br>+ *****************************************************************************/<br>+#ifndef VIDEOSURFACE_HPP<br>+#define VIDEOSURFACE_HPP<br>+<br>+#include <QtQuick/QQuickItem><br>+#include <QCursor><br>+#include <components/qml_main_context.hpp><br>+#include "qt.hpp"<br>+<br>+class VideoSurfaceProvider : public QObject<br>+{<br>+ Q_OBJECT<br>+public:<br>+ VideoSurfaceProvider(QObject* parent);<br>+ virtual ~VideoSurfaceProvider() {}<br>+ virtual QSGNode* updatePaintNode(QQuickItem* item, QSGNode* oldNode, QQuickItem::UpdatePaintNodeData*) = 0;<br>+<br>+signals:<br>+ void ctxChanged(QmlMainContext*);<br>+ void sourceSizeChanged(QSize);<br>+<br>+ void surfaceSizeChanged(QSizeF);<br>+<br>+ void mousePressed( int vlcButton );<br>+ void mouseReleased( int vlcButton );<br>+ void mouseDblClicked( int vlcButton );<br>+ void mouseMoved( float x, float y );<br>+<br>+ void update();<br>+};<br>+<br>+<br>+class VideoSurface : public QQuickItem<br>+{<br>+ Q_OBJECT<br>+ Q_PROPERTY(QmlMainContext* ctx READ getCtx WRITE setCtx NOTIFY ctxChanged)<br>+ Q_PROPERTY(QSize sourceSize READ getSourceSize NOTIFY sourceSizeChanged)<br>+ Q_PROPERTY(Qt::CursorShape cursorShape READ getCursorShape WRITE setCursorShape RESET unsetCursor)<br>+<br>+public:<br>+ VideoSurface( QQuickItem* parent = nullptr );<br>+<br>+ QmlMainContext* getCtx();<br>+ void setCtx(QmlMainContext* mainctx);<br>+<br>+ QSize getSourceSize() const;<br>+<br>+protected:<br>+ int qtMouseButton2VLC( Qt::MouseButton qtButton );<br>+<br>+ virtual void mousePressEvent(QMouseEvent *event) override;<br>+ virtual void mouseReleaseEvent(QMouseEvent *event) override;<br>+ virtual void mouseMoveEvent(QMouseEvent *event) override;<br>+ virtual void hoverMoveEvent(QHoverEvent *event) override;<br>+ virtual void mouseDoubleClickEvent(QMouseEvent *event) override;<br>+<br>+ Qt::CursorShape getCursorShape() const;<br>+ void setCursorShape(Qt::CursorShape);<br>+<br>+ virtual QSGNode* updatePaintNode(QSGNode *, QQuickItem::UpdatePaintNodeData *) override;<br>+<br>+signals:<br>+ void ctxChanged(QmlMainContext*);<br>+ void sourceSizeChanged(QSize);<br>+ void surfaceSizeChanged(QSizeF);<br>+<br>+ void mousePressed( int vlcButton );<br>+ void mouseReleased( int vlcButton );<br>+ void mouseDblClicked( int vlcButton );<br>+ void mouseMoved( float x, float y );<br>+<br>+private slots:<br>+ void onSourceSizeChanged(QSize);<br>+ void onSurfaceSizeChanged();<br>+<br>+private:<br>+ QmlMainContext* m_mainCtx = nullptr;<br>+<br>+ bool m_sourceSizeChanged = false;<br>+ QSize m_sourceSize;<br>+ QPointF m_oldHoverPos;<br>+<br>+ VideoSurfaceProvider* m_provider = nullptr;<br>+};<br>+<br>+#endif // VIDEOSURFACE_HPP</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>