diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-03-15 14:32:10 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-04-06 07:41:18 +0000 |
commit | d90a02dc9b8d69bd8346ff165d3c11e5603bc2be (patch) | |
tree | f5baf570c77a786dccdd70406ffcf50bf1057fb5 /src/multimediawidgets/qvideowidget.cpp | |
parent | 0a32b48f0204d62b922c490de90eeae54b5b5b27 (diff) |
Get windowed playback working again
And start moving over to the new QVideoSink API.
Fun side effect: HW accelerated video decoding does work with
this change on Linux.
Change-Id: Ic88d13b4fc7028b300349f9bf7ed1a7b3e08d37c
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimediawidgets/qvideowidget.cpp')
-rw-r--r-- | src/multimediawidgets/qvideowidget.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp index 6dc019378..a739f8e96 100644 --- a/src/multimediawidgets/qvideowidget.cpp +++ b/src/multimediawidgets/qvideowidget.cpp @@ -43,6 +43,7 @@ #include <QtCore/qobject.h> #include <QtMultimedia/qtmultimediaglobal.h> #include <qvideowindowcontrol.h> +#include <qvideosink.h> #include <qobject.h> #include <qvideosurfaceformat.h> @@ -287,6 +288,12 @@ void QVideoWidgetPrivate::_q_dimensionsChanged() q_func()->update(); } +void QVideoWidgetPrivate::_q_newFrame(const QVideoFrame &frame) +{ + lastFrame = frame; + q_ptr->update(); +} + /*! \class QVideoWidget @@ -317,6 +324,9 @@ QVideoWidget::QVideoWidget(QWidget *parent) , d_ptr(new QVideoWidgetPrivate) { d_ptr->q_ptr = this; + d_ptr->videoSink = new QVideoSink(this); + d_ptr->videoSink->setGraphicsType(QVideoSink::NativeWindow); + d_ptr->videoSink->setNativeWindowId(winId()); } /*! @@ -362,6 +372,11 @@ QAbstractVideoSurface *QVideoWidget::videoSurface() const return d->backend->videoSurface(); } +QVideoSink *QVideoWidget::videoSink() const +{ + return d_ptr->videoSink; +} + /*! \property QVideoWidget::aspectRatioMode \brief how video is scaled with respect to its aspect ratio. @@ -652,6 +667,11 @@ void QVideoWidget::paintEvent(QPaintEvent *event) { Q_D(QVideoWidget); + if (d->videoSink && d->lastFrame.isValid()) { + QPainter painter(this); + d->videoSink->paint(&painter, d->lastFrame); + return; + } if (d->backend) { d->backend->paintEvent(event); } else if (testAttribute(Qt::WA_OpaquePaintEvent)) { |