diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-07-12 13:45:05 +0200 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-08-14 09:49:49 +0200 |
commit | 9fba45e999f7c65f3cecf8fc914befd3d8b6db80 (patch) | |
tree | 49cd4ee1ddc4837905ae252c450d0946030cd593 /src/multimedia | |
parent | 075fa6203856bdf9f58e737ee2f5d2a843a85cad (diff) |
GStreamer: Add docs for custom pipelines
The feature was added in 5.12.2.
And it is relevant only for GStreamer backend.
Change-Id: I87e22e506158dc61bb7f111e74806e7eb8c28d7a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r-- | src/multimedia/doc/snippets/multimedia-snippets/images/qt-logo.png | bin | 0 -> 1301 bytes | |||
-rw-r--r-- | src/multimedia/doc/snippets/multimedia-snippets/media.cpp | 31 | ||||
-rw-r--r-- | src/multimedia/doc/snippets/multimedia-snippets/multimedia-snippets.pro | 3 | ||||
-rw-r--r-- | src/multimedia/doc/snippets/multimedia-snippets/qtvideosink.qml | 61 | ||||
-rw-r--r-- | src/multimedia/playback/qmediaplayer.cpp | 12 |
5 files changed, 106 insertions, 1 deletions
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/images/qt-logo.png b/src/multimedia/doc/snippets/multimedia-snippets/images/qt-logo.png Binary files differnew file mode 100644 index 000000000..dff772951 --- /dev/null +++ b/src/multimedia/doc/snippets/multimedia-snippets/images/qt-logo.png diff --git a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp index 7cabfabf3..4e8c06409 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp @@ -40,6 +40,7 @@ /* Media related snippets */ #include <QFile> #include <QTimer> +#include <QBuffer> #include "qmediaplaylist.h" #include "qmediarecorder.h" @@ -189,6 +190,36 @@ void MediaExample::MediaPlayer() player->play(); //! [Movie playlist] + + //! [Pipeline] + player = new QMediaPlayer; + player->setMedia(QUrl("gst-pipeline: videotestsrc ! autovideosink")); + player->play(); + //! [Pipeline] + + //! [Pipeline appsrc] + QImage img("images/qt-logo.png"); + img = img.convertToFormat(QImage::Format_ARGB32); + QByteArray ba(reinterpret_cast<const char *>(img.bits()), img.sizeInBytes()); + QBuffer buffer(&ba); + buffer.open(QIODevice::ReadOnly); + player = new QMediaPlayer; + player->setMedia(QUrl("gst-pipeline: appsrc blocksize=4294967295 ! \ + video/x-raw,format=BGRx,framerate=30/1,width=200,height=147 ! \ + coloreffects preset=heat ! videoconvert ! video/x-raw,format=I420 ! jpegenc ! rtpjpegpay ! \ + udpsink host=127.0.0.1 port=5000"), &buffer); + player->play(); + + QMediaPlayer *receiver = new QMediaPlayer; + videoWidget = new QVideoWidget; + receiver->setVideoOutput(videoWidget); + receiver->setMedia(QUrl("gst-pipeline: udpsrc port=5000 ! \ + application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! \ + xvimagesink name=qtvideosink")); + receiver->play(); + // Content will be shown in this widget. + videoWidget->show(); + //! [Pipeline appsrc] } void MediaExample::MediaRecorder() diff --git a/src/multimedia/doc/snippets/multimedia-snippets/multimedia-snippets.pro b/src/multimedia/doc/snippets/multimedia-snippets/multimedia-snippets.pro index 9571b026e..c13090a79 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/multimedia-snippets.pro +++ b/src/multimedia/doc/snippets/multimedia-snippets/multimedia-snippets.pro @@ -21,4 +21,5 @@ SOURCES += \ qsound.cpp OTHER_FILES += \ - soundeffect.qml + soundeffect.qml \ + qtvideosink.qml diff --git a/src/multimedia/doc/snippets/multimedia-snippets/qtvideosink.qml b/src/multimedia/doc/snippets/multimedia-snippets/qtvideosink.qml new file mode 100644 index 000000000..a4ae07f30 --- /dev/null +++ b/src/multimedia/doc/snippets/multimedia-snippets/qtvideosink.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtMultimedia 5.12 + +//! [complete] +Item { + MediaPlayer { + id: mediaplayer + source: "gst-pipeline: videotestsrc ! qtvideosink" + } + + VideoOutput { + anchors.fill: parent + source: mediaplayer + } + + MouseArea { + id: playArea + anchors.fill: parent + onPressed: mediaplayer.play(); + } +} +//! [complete] diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp index e90035cce..0013b3459 100644 --- a/src/multimedia/playback/qmediaplayer.cpp +++ b/src/multimedia/playback/qmediaplayer.cpp @@ -1005,6 +1005,18 @@ void QMediaPlayer::setPlaybackRate(qreal rate) It does not wait for the media to finish loading and does not check for errors. Listen for the mediaStatusChanged() and error() signals to be notified when the media is loaded and when an error occurs during loading. + + Since Qt 5.12.2, the url scheme \c gst-pipeline provides custom pipelines + for the GStreamer backend. + + \snippet multimedia-snippets/media.cpp Pipeline + + If the pipeline contains a video sink element named \c qtvideosink, + current QVideoWidget can be used to render the video. + + If the pipeline contains appsrc element, it will be used to push data from \a stream. + + \snippet multimedia-snippets/media.cpp Pipeline appsrc */ void QMediaPlayer::setMedia(const QMediaContent &media, QIODevice *stream) |