diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2020-03-04 10:57:42 +0100 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2020-03-04 13:29:50 +0100 |
commit | 6e21318ca9748e6ddaf9f38052b7896e63ebb81f (patch) | |
tree | 7c70609476bc0e6e9f8d051f80eb738c9ac25077 /src/multimedia/doc/snippets/multimedia-snippets | |
parent | 89dc35385037339072159d1e5fc8e325010b2dc0 (diff) |
QMediaPlayer: Update gst-pipeline docs
Added docs for using QAbstractVideoSurface
and example how to use QVideoWidget.
Change-Id: I27a105a3859086e6fa5d8a19672ef791ce9e5cca
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/multimedia/doc/snippets/multimedia-snippets')
-rw-r--r-- | src/multimedia/doc/snippets/multimedia-snippets/media.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp index 8ec7cb072..7fd6259ea 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp @@ -56,6 +56,7 @@ #include "qaudioprobe.h" #include "qaudiorecorder.h" #include "qvideoprobe.h" +#include <QAbstractVideoSurface> class MediaExample : public QObject { Q_OBJECT @@ -197,6 +198,36 @@ void MediaExample::MediaPlayer() player->play(); //! [Pipeline] + //! [Pipeline Surface] + class Surface : public QAbstractVideoSurface + { + public: + Surface(QObject *p) : QAbstractVideoSurface(p) { } + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const override + { + // Make sure that the driver supports this pixel format. + return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_YUYV; + } + + // Video frames are handled here. + bool present(const QVideoFrame &) override { return true; } + }; + + player = new QMediaPlayer; + player->setVideoOutput(new Surface(player)); + player->setMedia(QUrl("gst-pipeline: videotestsrc ! qtvideosink")); + player->play(); + //! [Pipeline Surface] + + //! [Pipeline Widget] + player = new QMediaPlayer; + videoWidget = new QVideoWidget; + videoWidget->show(); + player->setVideoOutput(videoWidget); + player->setMedia(QUrl("gst-pipeline: videotestsrc ! xvimagesink name=\"qtvideosink\"")); + player->play(); + //! [Pipeline Widget] + //! [Pipeline appsrc] QImage img("images/qt-logo.png"); img = img.convertToFormat(QImage::Format_ARGB32); |