From 9fba45e999f7c65f3cecf8fc914befd3d8b6db80 Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Fri, 12 Jul 2019 13:45:05 +0200 Subject: 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 Reviewed-by: Paul Wicking --- src/imports/multimedia/qdeclarativeaudio.cpp | 10 ++++ .../multimedia-snippets/images/qt-logo.png | Bin 0 -> 1301 bytes .../doc/snippets/multimedia-snippets/media.cpp | 31 +++++++++++ .../multimedia-snippets/multimedia-snippets.pro | 3 +- .../snippets/multimedia-snippets/qtvideosink.qml | 61 +++++++++++++++++++++ src/multimedia/playback/qmediaplayer.cpp | 12 ++++ 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/multimedia/doc/snippets/multimedia-snippets/images/qt-logo.png create mode 100644 src/multimedia/doc/snippets/multimedia-snippets/qtvideosink.qml diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 65606b3cf..7c2e5e8a4 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -1301,6 +1301,16 @@ void QDeclarativeAudio::_q_mediaChanged(const QMediaContent &media) This property holds the source URL of the media. Setting the \l source property clears the current \l playlist, if any. + + Since Qt 5.12.2, the url scheme \c gst-pipeline provides custom pipelines + for the GStreamer backend. + + If the pipeline contains a \c qtvideosink element, + the current VideoOutput will be used for rendering video. + + \snippet multimedia-snippets/qtvideosink.qml complete + + \sa QMediaPlayer::setMedia() */ /*! diff --git a/src/multimedia/doc/snippets/multimedia-snippets/images/qt-logo.png b/src/multimedia/doc/snippets/multimedia-snippets/images/qt-logo.png new file mode 100644 index 000000000..dff772951 Binary files /dev/null and b/src/multimedia/doc/snippets/multimedia-snippets/images/qt-logo.png differ 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 #include +#include #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(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) -- cgit v1.2.3