summaryrefslogtreecommitdiffstats
path: root/src/plugins/gstreamer/audiodecoder
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-01-12 14:22:08 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-22 07:02:55 +0000
commit98148969b112f82d2b49e77950ea5f6d8b37b8b2 (patch)
tree48fffe0533a647bb53bec7e6e33dee1b95fcd849 /src/plugins/gstreamer/audiodecoder
parentb947bcabfef5f0df32a4e09b55eaa581281b4edd (diff)
Get rid of plugins for MM backends
There's no need for having those in plugins and we can further remove abstractions and simplify our code if the code is directly compiled into Qt Multimedia. Change-Id: I5267a6a776375d99be8f0de4207f0288d963e620 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins/gstreamer/audiodecoder')
-rw-r--r--src/plugins/gstreamer/audiodecoder/CMakeLists.txt43
-rw-r--r--src/plugins/gstreamer/audiodecoder/audiodecoder.json4
-rw-r--r--src/plugins/gstreamer/audiodecoder/audiodecoder.pro22
-rw-r--r--src/plugins/gstreamer/audiodecoder/qgstreameraudiodecodercontrol.cpp599
-rw-r--r--src/plugins/gstreamer/audiodecoder/qgstreameraudiodecodercontrol.h146
-rw-r--r--src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderservice.cpp71
-rw-r--r--src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderservice.h68
-rw-r--r--src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.cpp93
-rw-r--r--src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.h72
9 files changed, 0 insertions, 1118 deletions
diff --git a/src/plugins/gstreamer/audiodecoder/CMakeLists.txt b/src/plugins/gstreamer/audiodecoder/CMakeLists.txt
deleted file mode 100644
index 019cd5a48..000000000
--- a/src/plugins/gstreamer/audiodecoder/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# Generated from audiodecoder.pro.
-
-#####################################################################
-## QGstreamerAudioDecoderServicePlugin Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGstreamerAudioDecoderServicePlugin
- OUTPUT_NAME gstaudiodecoder
- TYPE mediaservice
- SOURCES
- qgstreameraudiodecodercontrol.cpp qgstreameraudiodecodercontrol.h
- qgstreameraudiodecoderservice.cpp qgstreameraudiodecoderservice.h
- qgstreameraudiodecoderserviceplugin.cpp qgstreameraudiodecoderserviceplugin.h
- INCLUDE_DIRECTORIES
- ${CMAKE_CURRENT_SOURCE_DIR}
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::CorePrivate
- Qt::Gui
- Qt::MultimediaPrivate
- Qt::Network
- gstreamer
- Qt::MultimediaPrivate
-)
-
-#### Keys ignored in scope 1:.:.:audiodecoder.pro:<TRUE>:
-# OTHER_FILES = "audiodecoder.json"
-
-## Scopes:
-#####################################################################
-
-qt_internal_extend_target(QGstreamerAudioDecoderServicePlugin CONDITION TARGET Qt::Widgets
- DEFINES
- HAVE_WIDGETS
- PUBLIC_LIBRARIES
- Qt::MultimediaWidgetsPrivate
- Qt::Widgets
-)
-
-qt_internal_extend_target(QGstreamerAudioDecoderServicePlugin CONDITION QT_FEATURE_gstreamer_app
- PUBLIC_LIBRARIES
- gstreamer_app
-)
diff --git a/src/plugins/gstreamer/audiodecoder/audiodecoder.json b/src/plugins/gstreamer/audiodecoder/audiodecoder.json
deleted file mode 100644
index 4314f2efa..000000000
--- a/src/plugins/gstreamer/audiodecoder/audiodecoder.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "Keys": ["gstreameraudiodecode"],
- "Services": ["org.qt-project.qt.audiodecode"]
-}
diff --git a/src/plugins/gstreamer/audiodecoder/audiodecoder.pro b/src/plugins/gstreamer/audiodecoder/audiodecoder.pro
deleted file mode 100644
index 7e61beccc..000000000
--- a/src/plugins/gstreamer/audiodecoder/audiodecoder.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-TARGET = gstaudiodecoder
-
-include(../common.pri)
-
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/qgstreameraudiodecoderservice.h \
- $$PWD/qgstreameraudiodecodercontrol.h \
- $$PWD/qgstreameraudiodecoderserviceplugin.h
-
-SOURCES += \
- $$PWD/qgstreameraudiodecoderservice.cpp \
- $$PWD/qgstreameraudiodecodercontrol.cpp \
- $$PWD/qgstreameraudiodecoderserviceplugin.cpp
-
-OTHER_FILES += \
- audiodecoder.json
-
-PLUGIN_TYPE = mediaservice
-PLUGIN_CLASS_NAME = QGstreamerAudioDecoderServicePlugin
-load(qt_plugin)
diff --git a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecodercontrol.cpp b/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecodercontrol.cpp
deleted file mode 100644
index 439a6b957..000000000
--- a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecodercontrol.cpp
+++ /dev/null
@@ -1,599 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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$
-**
-****************************************************************************/
-//#define DEBUG_DECODER
-
-#include "qgstreameraudiodecodercontrol.h"
-#include <private/qgstreamerbushelper_p.h>
-
-#include <private/qgstutils_p.h>
-
-#include <gst/gstvalue.h>
-#include <gst/base/gstbasesrc.h>
-
-#include <QtCore/qdatetime.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qstandardpaths.h>
-#include <QtCore/qurl.h>
-
-#define MAX_BUFFERS_IN_QUEUE 4
-
-QT_BEGIN_NAMESPACE
-
-typedef enum {
- GST_PLAY_FLAG_VIDEO = 0x00000001,
- GST_PLAY_FLAG_AUDIO = 0x00000002,
- GST_PLAY_FLAG_TEXT = 0x00000004,
- GST_PLAY_FLAG_VIS = 0x00000008,
- GST_PLAY_FLAG_SOFT_VOLUME = 0x00000010,
- GST_PLAY_FLAG_NATIVE_AUDIO = 0x00000020,
- GST_PLAY_FLAG_NATIVE_VIDEO = 0x00000040,
- GST_PLAY_FLAG_DOWNLOAD = 0x00000080,
- GST_PLAY_FLAG_BUFFERING = 0x000000100
-} GstPlayFlags;
-
-QGstreamerAudioDecoderControl::QGstreamerAudioDecoderControl(QObject *parent)
- : QAudioDecoderControl(parent),
- m_state(QAudioDecoder::StoppedState),
- m_pendingState(QAudioDecoder::StoppedState),
- m_busHelper(0),
- m_bus(0),
- m_playbin(0),
- m_outputBin(0),
- m_audioConvert(0),
- m_appSink(0),
-#if QT_CONFIG(gstreamer_app)
- m_appSrc(0),
-#endif
- mDevice(0),
- m_buffersAvailable(0),
- m_position(-1),
- m_duration(-1),
- m_durationQueries(0)
-{
- // Create pipeline here
- m_playbin = gst_element_factory_make("playbin", NULL);
-
- if (m_playbin != 0) {
- // Sort out messages
- m_bus = gst_element_get_bus(m_playbin);
- m_busHelper = new QGstreamerBusHelper(m_bus, this);
- m_busHelper->installMessageFilter(this);
-
- // Set the rest of the pipeline up
- setAudioFlags(true);
-
- m_audioConvert = gst_element_factory_make("audioconvert", NULL);
-
- m_outputBin = gst_bin_new("audio-output-bin");
- gst_bin_add(GST_BIN(m_outputBin), m_audioConvert);
-
- // add ghostpad
- GstPad *pad = gst_element_get_static_pad(m_audioConvert, "sink");
- Q_ASSERT(pad);
- gst_element_add_pad(GST_ELEMENT(m_outputBin), gst_ghost_pad_new("sink", pad));
- gst_object_unref(GST_OBJECT(pad));
-
- g_object_set(G_OBJECT(m_playbin), "audio-sink", m_outputBin, NULL);
-#if QT_CONFIG(gstreamer_app)
- g_signal_connect(G_OBJECT(m_playbin), "deep-notify::source", (GCallback) &QGstreamerAudioDecoderControl::configureAppSrcElement, (gpointer)this);
-#endif
-
- // Set volume to 100%
- gdouble volume = 1.0;
- g_object_set(G_OBJECT(m_playbin), "volume", volume, NULL);
- }
-}
-
-QGstreamerAudioDecoderControl::~QGstreamerAudioDecoderControl()
-{
- if (m_playbin) {
- stop();
-
- delete m_busHelper;
-#if QT_CONFIG(gstreamer_app)
- delete m_appSrc;
-#endif
- gst_object_unref(GST_OBJECT(m_bus));
- gst_object_unref(GST_OBJECT(m_playbin));
- }
-}
-
-#if QT_CONFIG(gstreamer_app)
-void QGstreamerAudioDecoderControl::configureAppSrcElement(GObject* object, GObject *orig, GParamSpec *pspec, QGstreamerAudioDecoderControl* self)
-{
- Q_UNUSED(object);
- Q_UNUSED(pspec);
-
- // In case we switch from appsrc to not
- if (!self->appsrc())
- return;
-
- GstElement *appsrc;
- g_object_get(orig, "source", &appsrc, NULL);
-
- if (!self->appsrc()->setup(appsrc))
- qWarning()<<"Could not setup appsrc element";
-
- g_object_unref(G_OBJECT(appsrc));
-}
-#endif
-
-bool QGstreamerAudioDecoderControl::processBusMessage(const QGstreamerMessage &message)
-{
- GstMessage* gm = message.rawMessage();
- if (gm) {
- if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_DURATION) {
- updateDuration();
- } else if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_playbin)) {
- switch (GST_MESSAGE_TYPE(gm)) {
- case GST_MESSAGE_STATE_CHANGED:
- {
- GstState oldState;
- GstState newState;
- GstState pending;
-
- gst_message_parse_state_changed(gm, &oldState, &newState, &pending);
-
-#ifdef DEBUG_DECODER
- QStringList states;
- states << "GST_STATE_VOID_PENDING" << "GST_STATE_NULL" << "GST_STATE_READY" << "GST_STATE_PAUSED" << "GST_STATE_PLAYING";
-
- qDebug() << QString("state changed: old: %1 new: %2 pending: %3") \
- .arg(states[oldState]) \
- .arg(states[newState]) \
- .arg(states[pending]) << "internal" << m_state;
-#endif
-
- QAudioDecoder::State prevState = m_state;
-
- switch (newState) {
- case GST_STATE_VOID_PENDING:
- case GST_STATE_NULL:
- m_state = QAudioDecoder::StoppedState;
- break;
- case GST_STATE_READY:
- m_state = QAudioDecoder::StoppedState;
- break;
- case GST_STATE_PLAYING:
- m_state = QAudioDecoder::DecodingState;
- break;
- case GST_STATE_PAUSED:
- m_state = QAudioDecoder::DecodingState;
-
- //gstreamer doesn't give a reliable indication the duration
- //information is ready, GST_MESSAGE_DURATION is not sent by most elements
- //the duration is queried up to 5 times with increasing delay
- m_durationQueries = 5;
- updateDuration();
- break;
- }
-
- if (prevState != m_state)
- emit stateChanged(m_state);
- }
- break;
-
- case GST_MESSAGE_EOS:
- m_pendingState = m_state = QAudioDecoder::StoppedState;
- emit finished();
- emit stateChanged(m_state);
- break;
-
- case GST_MESSAGE_ERROR: {
- GError *err;
- gchar *debug;
- gst_message_parse_error(gm, &err, &debug);
- if (err->domain == GST_STREAM_ERROR && err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND)
- processInvalidMedia(QAudioDecoder::FormatError, tr("Cannot play stream of type: <unknown>"));
- else
- processInvalidMedia(QAudioDecoder::ResourceError, QString::fromUtf8(err->message));
- qWarning() << "Error:" << QString::fromUtf8(err->message);
- g_error_free(err);
- g_free(debug);
- }
- break;
- case GST_MESSAGE_WARNING:
- {
- GError *err;
- gchar *debug;
- gst_message_parse_warning (gm, &err, &debug);
- qWarning() << "Warning:" << QString::fromUtf8(err->message);
- g_error_free (err);
- g_free (debug);
- }
- break;
-#ifdef DEBUG_DECODER
- case GST_MESSAGE_INFO:
- {
- GError *err;
- gchar *debug;
- gst_message_parse_info (gm, &err, &debug);
- qDebug() << "Info:" << QString::fromUtf8(err->message);
- g_error_free (err);
- g_free (debug);
- }
- break;
-#endif
- default:
- break;
- }
- } else if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ERROR) {
- GError *err;
- gchar *debug;
- gst_message_parse_error(gm, &err, &debug);
- QAudioDecoder::Error qerror = QAudioDecoder::ResourceError;
- if (err->domain == GST_STREAM_ERROR) {
- switch (err->code) {
- case GST_STREAM_ERROR_DECRYPT:
- case GST_STREAM_ERROR_DECRYPT_NOKEY:
- qerror = QAudioDecoder::AccessDeniedError;
- break;
- case GST_STREAM_ERROR_FORMAT:
- case GST_STREAM_ERROR_DEMUX:
- case GST_STREAM_ERROR_DECODE:
- case GST_STREAM_ERROR_WRONG_TYPE:
- case GST_STREAM_ERROR_TYPE_NOT_FOUND:
- case GST_STREAM_ERROR_CODEC_NOT_FOUND:
- qerror = QAudioDecoder::FormatError;
- break;
- default:
- break;
- }
- } else if (err->domain == GST_CORE_ERROR) {
- switch (err->code) {
- case GST_CORE_ERROR_MISSING_PLUGIN:
- qerror = QAudioDecoder::FormatError;
- break;
- default:
- break;
- }
- }
-
- processInvalidMedia(qerror, QString::fromUtf8(err->message));
- g_error_free(err);
- g_free(debug);
- }
- }
-
- return false;
-}
-
-QString QGstreamerAudioDecoderControl::sourceFilename() const
-{
- return mSource;
-}
-
-void QGstreamerAudioDecoderControl::setSourceFilename(const QString &fileName)
-{
- stop();
- mDevice = 0;
-#if QT_CONFIG(gstreamer_app)
- if (m_appSrc)
- m_appSrc->deleteLater();
- m_appSrc = 0;
-#endif
-
- bool isSignalRequired = (mSource != fileName);
- mSource = fileName;
- if (isSignalRequired)
- emit sourceChanged();
-}
-
-QIODevice *QGstreamerAudioDecoderControl::sourceDevice() const
-{
- return mDevice;
-}
-
-void QGstreamerAudioDecoderControl::setSourceDevice(QIODevice *device)
-{
- stop();
- mSource.clear();
- bool isSignalRequired = (mDevice != device);
- mDevice = device;
- if (isSignalRequired)
- emit sourceChanged();
-}
-
-void QGstreamerAudioDecoderControl::start()
-{
- if (!m_playbin) {
- processInvalidMedia(QAudioDecoder::ResourceError, "Playbin element is not valid");
- return;
- }
-
- addAppSink();
-
- if (!mSource.isEmpty()) {
- g_object_set(G_OBJECT(m_playbin), "uri", QUrl::fromLocalFile(mSource).toEncoded().constData(), NULL);
- } else if (mDevice) {
-#if QT_CONFIG(gstreamer_app)
- // make sure we can read from device
- if (!mDevice->isOpen() || !mDevice->isReadable()) {
- processInvalidMedia(QAudioDecoder::AccessDeniedError, "Unable to read from specified device");
- return;
- }
-
- if (!m_appSrc)
- m_appSrc = new QGstAppSrc(this);
- m_appSrc->setStream(mDevice);
-
- g_object_set(G_OBJECT(m_playbin), "uri", "appsrc://", NULL);
-#endif
- } else {
- return;
- }
-
- // Set audio format
- if (m_appSink) {
- if (mFormat.isValid()) {
- setAudioFlags(false);
- GstCaps *caps = QGstUtils::capsForAudioFormat(mFormat);
- gst_app_sink_set_caps(m_appSink, caps);
- gst_caps_unref(caps);
- } else {
- // We want whatever the native audio format is
- setAudioFlags(true);
- gst_app_sink_set_caps(m_appSink, NULL);
- }
- }
-
- m_pendingState = QAudioDecoder::DecodingState;
- if (gst_element_set_state(m_playbin, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
- qWarning() << "GStreamer; Unable to start decoding process";
- m_pendingState = m_state = QAudioDecoder::StoppedState;
-
- emit stateChanged(m_state);
- }
-}
-
-void QGstreamerAudioDecoderControl::stop()
-{
- if (m_playbin) {
- gst_element_set_state(m_playbin, GST_STATE_NULL);
- removeAppSink();
-
- QAudioDecoder::State oldState = m_state;
- m_pendingState = m_state = QAudioDecoder::StoppedState;
-
- // GStreamer thread is stopped. Can safely access m_buffersAvailable
- if (m_buffersAvailable != 0) {
- m_buffersAvailable = 0;
- emit bufferAvailableChanged(false);
- }
-
- if (m_position != -1) {
- m_position = -1;
- emit positionChanged(m_position);
- }
-
- if (m_duration != -1) {
- m_duration = -1;
- emit durationChanged(m_duration);
- }
-
- if (oldState != m_state)
- emit stateChanged(m_state);
- }
-}
-
-QAudioFormat QGstreamerAudioDecoderControl::audioFormat() const
-{
- return mFormat;
-}
-
-void QGstreamerAudioDecoderControl::setAudioFormat(const QAudioFormat &format)
-{
- if (mFormat != format) {
- mFormat = format;
- emit formatChanged(mFormat);
- }
-}
-
-QAudioBuffer QGstreamerAudioDecoderControl::read()
-{
- QAudioBuffer audioBuffer;
-
- int buffersAvailable;
- {
- QMutexLocker locker(&m_buffersMutex);
- buffersAvailable = m_buffersAvailable;
-
- // need to decrement before pulling a buffer
- // to make sure assert in QGstreamerAudioDecoderControl::new_buffer works
- m_buffersAvailable--;
- }
-
-
- if (buffersAvailable) {
- if (buffersAvailable == 1)
- emit bufferAvailableChanged(false);
-
- const char* bufferData = 0;
- int bufferSize = 0;
-
- GstSample *sample = gst_app_sink_pull_sample(m_appSink);
- GstBuffer *buffer = gst_sample_get_buffer(sample);
- GstMapInfo mapInfo;
- gst_buffer_map(buffer, &mapInfo, GST_MAP_READ);
- bufferData = (const char*)mapInfo.data;
- bufferSize = mapInfo.size;
- QAudioFormat format = QGstUtils::audioFormatForSample(sample);
-
- if (format.isValid()) {
- // XXX At the moment we have to copy data from GstBuffer into QAudioBuffer.
- // We could improve performance by implementing QAbstractAudioBuffer for GstBuffer.
- qint64 position = getPositionFromBuffer(buffer);
- audioBuffer = QAudioBuffer(QByteArray((const char*)bufferData, bufferSize), format, position);
- position /= 1000; // convert to milliseconds
- if (position != m_position) {
- m_position = position;
- emit positionChanged(m_position);
- }
- }
- gst_buffer_unmap(buffer, &mapInfo);
- gst_sample_unref(sample);
- }
-
- return audioBuffer;
-}
-
-bool QGstreamerAudioDecoderControl::bufferAvailable() const
-{
- QMutexLocker locker(&m_buffersMutex);
- return m_buffersAvailable > 0;
-}
-
-qint64 QGstreamerAudioDecoderControl::position() const
-{
- return m_position;
-}
-
-qint64 QGstreamerAudioDecoderControl::duration() const
-{
- return m_duration;
-}
-
-void QGstreamerAudioDecoderControl::processInvalidMedia(QAudioDecoder::Error errorCode, const QString& errorString)
-{
- stop();
- emit error(int(errorCode), errorString);
-}
-
-GstFlowReturn QGstreamerAudioDecoderControl::new_sample(GstAppSink *, gpointer user_data)
-{
- // "Note that the preroll buffer will also be returned as the first buffer when calling gst_app_sink_pull_buffer()."
- QGstreamerAudioDecoderControl *control = reinterpret_cast<QGstreamerAudioDecoderControl*>(user_data);
-
- int buffersAvailable;
- {
- QMutexLocker locker(&control->m_buffersMutex);
- buffersAvailable = control->m_buffersAvailable;
- control->m_buffersAvailable++;
- Q_ASSERT(control->m_buffersAvailable <= MAX_BUFFERS_IN_QUEUE);
- }
-
- if (!buffersAvailable)
- QMetaObject::invokeMethod(control, "bufferAvailableChanged", Qt::QueuedConnection, Q_ARG(bool, true));
- QMetaObject::invokeMethod(control, "bufferReady", Qt::QueuedConnection);
- return GST_FLOW_OK;
-}
-
-void QGstreamerAudioDecoderControl::setAudioFlags(bool wantNativeAudio)
-{
- int flags = 0;
- if (m_playbin) {
- g_object_get(G_OBJECT(m_playbin), "flags", &flags, NULL);
- // make sure not to use GST_PLAY_FLAG_NATIVE_AUDIO unless desired
- // it prevents audio format conversion
- flags &= ~(GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_NATIVE_VIDEO | GST_PLAY_FLAG_TEXT | GST_PLAY_FLAG_VIS | GST_PLAY_FLAG_NATIVE_AUDIO);
- flags |= GST_PLAY_FLAG_AUDIO;
- if (wantNativeAudio)
- flags |= GST_PLAY_FLAG_NATIVE_AUDIO;
- g_object_set(G_OBJECT(m_playbin), "flags", flags, NULL);
- }
-}
-
-void QGstreamerAudioDecoderControl::addAppSink()
-{
- if (m_appSink)
- return;
-
- m_appSink = (GstAppSink*)gst_element_factory_make("appsink", NULL);
-
- GstAppSinkCallbacks callbacks;
- memset(&callbacks, 0, sizeof(callbacks));
- callbacks.new_sample = &new_sample;
- gst_app_sink_set_callbacks(m_appSink, &callbacks, this, NULL);
- gst_app_sink_set_max_buffers(m_appSink, MAX_BUFFERS_IN_QUEUE);
- gst_base_sink_set_sync(GST_BASE_SINK(m_appSink), FALSE);
-
- gst_bin_add(GST_BIN(m_outputBin), GST_ELEMENT(m_appSink));
- gst_element_link(m_audioConvert, GST_ELEMENT(m_appSink));
-}
-
-void QGstreamerAudioDecoderControl::removeAppSink()
-{
- if (!m_appSink)
- return;
-
- gst_element_unlink(m_audioConvert, GST_ELEMENT(m_appSink));
- gst_bin_remove(GST_BIN(m_outputBin), GST_ELEMENT(m_appSink));
-
- m_appSink = 0;
-}
-
-void QGstreamerAudioDecoderControl::updateDuration()
-{
- gint64 gstDuration = 0;
- int duration = -1;
-
- if (m_playbin && qt_gst_element_query_duration(m_playbin, GST_FORMAT_TIME, &gstDuration))
- duration = gstDuration / 1000000;
-
- if (m_duration != duration) {
- m_duration = duration;
- emit durationChanged(m_duration);
- }
-
- if (m_duration > 0)
- m_durationQueries = 0;
-
- if (m_durationQueries > 0) {
- //increase delay between duration requests
- int delay = 25 << (5 - m_durationQueries);
- QTimer::singleShot(delay, this, SLOT(updateDuration()));
- m_durationQueries--;
- }
-}
-
-qint64 QGstreamerAudioDecoderControl::getPositionFromBuffer(GstBuffer* buffer)
-{
- qint64 position = GST_BUFFER_TIMESTAMP(buffer);
- if (position >= 0)
- position = position / G_GINT64_CONSTANT(1000); // microseconds
- else
- position = -1;
- return position;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecodercontrol.h b/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecodercontrol.h
deleted file mode 100644
index 9e94088a8..000000000
--- a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecodercontrol.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERAUDIODECODERCONTROL_H
-#define QGSTREAMERAUDIODECODERCONTROL_H
-
-#include <QtMultimedia/private/qtmultimediaglobal_p.h>
-#include <QObject>
-#include <QtCore/qmutex.h>
-#include "qaudiodecodercontrol.h"
-#include <private/qgstreamerbushelper_p.h>
-#include "qaudiodecoder.h"
-
-#if QT_CONFIG(gstreamer_app)
-#include <private/qgstappsrc_p.h>
-#endif
-
-#include <gst/gst.h>
-#include <gst/app/gstappsink.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerBusHelper;
-class QGstreamerMessage;
-
-class QGstreamerAudioDecoderControl
- : public QAudioDecoderControl,
- public QGstreamerBusMessageFilter
-{
-Q_OBJECT
-Q_INTERFACES(QGstreamerBusMessageFilter)
-
-public:
- QGstreamerAudioDecoderControl(QObject *parent);
- virtual ~QGstreamerAudioDecoderControl();
-
- // QAudioDecoder interface
- QAudioDecoder::State state() const override { return m_state; }
-
- QString sourceFilename() const override;
- void setSourceFilename(const QString &fileName) override;
-
- QIODevice *sourceDevice() const override;
- void setSourceDevice(QIODevice *device) override;
-
- void start() override;
- void stop() override;
-
- QAudioFormat audioFormat() const override;
- void setAudioFormat(const QAudioFormat &format) override;
-
- QAudioBuffer read() override;
- bool bufferAvailable() const override;
-
- qint64 position() const override;
- qint64 duration() const override;
-
- // GStreamerBusMessageFilter interface
- bool processBusMessage(const QGstreamerMessage &message) override;
-
- QGstreamerBusHelper *bus() const { return m_busHelper; }
- QAudioDecoder::State pendingState() const { return m_pendingState; }
-
-#if QT_CONFIG(gstreamer_app)
- QGstAppSrc *appsrc() const { return m_appSrc; }
- static void configureAppSrcElement(GObject*, GObject*, GParamSpec*, QGstreamerAudioDecoderControl *_this);
-#endif
-
- static GstFlowReturn new_sample(GstAppSink *sink, gpointer user_data);
-
-private slots:
- void updateDuration();
-
-private:
- void setAudioFlags(bool wantNativeAudio);
- void addAppSink();
- void removeAppSink();
-
- void processInvalidMedia(QAudioDecoder::Error errorCode, const QString& errorString);
- static qint64 getPositionFromBuffer(GstBuffer* buffer);
-
- QAudioDecoder::State m_state;
- QAudioDecoder::State m_pendingState;
- QGstreamerBusHelper *m_busHelper;
- GstBus *m_bus;
- GstElement *m_playbin;
- GstElement *m_outputBin;
- GstElement *m_audioConvert;
- GstAppSink *m_appSink;
-
-#if QT_CONFIG(gstreamer_app)
- QGstAppSrc *m_appSrc;
-#endif
-
- QString mSource;
- QIODevice *mDevice; // QWeakPointer perhaps
- QAudioFormat mFormat;
-
- mutable QMutex m_buffersMutex;
- int m_buffersAvailable;
-
- qint64 m_position;
- qint64 m_duration;
-
- int m_durationQueries;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGSTREAMERPLAYERSESSION_H
diff --git a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderservice.cpp b/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderservice.cpp
deleted file mode 100644
index 125ba4d1c..000000000
--- a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderservice.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-#include <QtCore/qvariant.h>
-#include <QtCore/qdebug.h>
-
-#include "qgstreameraudiodecoderservice.h"
-#include "qgstreameraudiodecodercontrol.h"
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerAudioDecoderService::QGstreamerAudioDecoderService(QObject *parent)
- : QMediaService(parent)
-{
- m_control = new QGstreamerAudioDecoderControl(this);
-}
-
-QGstreamerAudioDecoderService::~QGstreamerAudioDecoderService()
-{
-}
-
-QObject *QGstreamerAudioDecoderService::requestControl(const char *name)
-{
- if (qstrcmp(name, QAudioDecoderControl_iid) == 0)
- return m_control;
-
- return 0;
-}
-
-void QGstreamerAudioDecoderService::releaseControl(QObject *control)
-{
- Q_UNUSED(control);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderservice.h b/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderservice.h
deleted file mode 100644
index defa5345c..000000000
--- a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderservice.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERAUDIODECODERSERVICE_H
-#define QGSTREAMERAUDIODECODERSERVICE_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qiodevice.h>
-
-#include <qmediaservice.h>
-
-QT_BEGIN_NAMESPACE
-class QGstreamerAudioDecoderControl;
-class QGstreamerAudioDecoderControl;
-
-class QGstreamerAudioDecoderService : public QMediaService
-{
- Q_OBJECT
-public:
- QGstreamerAudioDecoderService(QObject *parent = 0);
- ~QGstreamerAudioDecoderService();
-
- QObject *requestControl(const char *name) override;
- void releaseControl(QObject *control) override;
-
-private:
- QGstreamerAudioDecoderControl *m_control;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.cpp b/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.cpp
deleted file mode 100644
index d9e6a2a38..000000000
--- a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-#include "qgstreameraudiodecoderserviceplugin.h"
-
-#include "qgstreameraudiodecoderservice.h"
-#include <private/qgstutils_p.h>
-
-#include <QtCore/qstring.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/QDir>
-#include <QtCore/QDebug>
-
-// #define QT_SUPPORTEDMIMETYPES_DEBUG
-
-QMediaService* QGstreamerAudioDecoderServicePlugin::create(const QString &key)
-{
- QGstUtils::initializeGst();
-
- if (key == QLatin1String(Q_MEDIASERVICE_AUDIODECODER))
- return new QGstreamerAudioDecoderService;
-
- qWarning() << "Gstreamer audio decoder service plugin: unsupported key:" << key;
- return 0;
-}
-
-void QGstreamerAudioDecoderServicePlugin::release(QMediaService *service)
-{
- delete service;
-}
-
-QMultimedia::SupportEstimate QGstreamerAudioDecoderServicePlugin::hasSupport(const QString &mimeType,
- const QStringList &codecs) const
-{
- if (m_supportedMimeTypeSet.isEmpty())
- updateSupportedMimeTypes();
-
- return QGstUtils::hasSupport(mimeType, codecs, m_supportedMimeTypeSet);
-}
-
-static bool isDecoderOrDemuxer(GstElementFactory *factory)
-{
- return gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DEMUXER)
- || gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DECODER
- | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO);
-}
-
-void QGstreamerAudioDecoderServicePlugin::updateSupportedMimeTypes() const
-{
- m_supportedMimeTypeSet = QGstUtils::supportedMimeTypes(isDecoderOrDemuxer);
-}
-
-QStringList QGstreamerAudioDecoderServicePlugin::supportedMimeTypes() const
-{
- return QStringList();
-}
-
diff --git a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.h b/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.h
deleted file mode 100644
index d1b96043b..000000000
--- a/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERAUDIODECODERSERVICEPLUGIN_H
-#define QGSTREAMERAUDIODECODERSERVICEPLUGIN_H
-
-#include <qmediaserviceproviderplugin.h>
-#include <QtCore/qset.h>
-#include <QtCore/QObject>
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerAudioDecoderServicePlugin
- : public QMediaServiceProviderPlugin
- , public QMediaServiceSupportedFormatsInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "audiodecoder.json")
-
-public:
- QMediaService* create(const QString &key) override;
- void release(QMediaService *service) override;
-
- QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList &codecs) const override;
- QStringList supportedMimeTypes() const override;
-
-private:
- void updateSupportedMimeTypes() const;
-
- mutable QSet<QString> m_supportedMimeTypeSet;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGSTREAMERAUDIODECODERSERVICEPLUGIN_H