diff options
Diffstat (limited to 'src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder_p.h')
-rw-r--r-- | src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder_p.h | 98 |
1 files changed, 35 insertions, 63 deletions
diff --git a/src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder_p.h b/src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder_p.h index 85ff53041..6415fa824 100644 --- a/src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder_p.h +++ b/src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGSTREAMERAUDIODECODERCONTROL_H #define QGSTREAMERAUDIODECODERCONTROL_H @@ -51,34 +15,33 @@ // We mean it. // +#include <QtMultimedia/private/qmultimediautils_p.h> +#include <QtMultimedia/private/qplatformaudiodecoder_p.h> #include <QtMultimedia/private/qtmultimediaglobal_p.h> -#include <QObject> +#include <QtMultimedia/qaudiodecoder.h> +#include <QtCore/qobject.h> #include <QtCore/qmutex.h> #include <QtCore/qurl.h> -#include "private/qplatformaudiodecoder_p.h" -#include <qgstpipeline_p.h> -#include "qaudiodecoder.h" +#include <common/qgstpipeline_p.h> +#include <common/qgst_p.h> #if QT_CONFIG(gstreamer_app) -#include <qgstappsrc_p.h> +# include <common/qgstappsource_p.h> #endif -#include <qgst_p.h> #include <gst/app/gstappsink.h> QT_BEGIN_NAMESPACE class QGstreamerMessage; -class QGstreamerAudioDecoder - : public QPlatformAudioDecoder, - public QGstreamerBusMessageFilter +class QGstreamerAudioDecoder final : public QPlatformAudioDecoder, public QGstreamerBusMessageFilter { Q_OBJECT public: - QGstreamerAudioDecoder(QAudioDecoder *parent); + static QMaybe<QPlatformAudioDecoder *> create(QAudioDecoder *parent); virtual ~QGstreamerAudioDecoder(); QUrl source() const override; @@ -94,7 +57,6 @@ public: void setAudioFormat(const QAudioFormat &format) override; QAudioBuffer read() override; - bool bufferAvailable() const override; qint64 position() const override; qint64 duration() const override; @@ -102,41 +64,51 @@ public: // GStreamerBusMessageFilter interface bool processBusMessage(const QGstreamerMessage &message) override; -#if QT_CONFIG(gstreamer_app) - QGstAppSrc *appsrc() const { return m_appSrc; } - static void configureAppSrcElement(GObject*, GObject*, GParamSpec*, QGstreamerAudioDecoder *_this); -#endif - - static GstFlowReturn new_sample(GstAppSink *sink, gpointer user_data); - private slots: void updateDuration(); private: + explicit QGstreamerAudioDecoder(QAudioDecoder *parent); + +#if QT_CONFIG(gstreamer_app) + static GstFlowReturn new_sample(GstAppSink *sink, gpointer user_data); + GstFlowReturn newSample(GstAppSink *sink); + + static void configureAppSrcElement(GObject *, GObject *, GParamSpec *, + QGstreamerAudioDecoder *_this); +#endif + void setAudioFlags(bool wantNativeAudio); void addAppSink(); void removeAppSink(); - void processInvalidMedia(QAudioDecoder::Error errorCode, const QString& errorString); - static qint64 getPositionFromBuffer(GstBuffer* buffer); + bool handlePlaybinMessage(const QGstreamerMessage &); + + void processInvalidMedia(QAudioDecoder::Error errorCode, const QString &errorString); + static std::chrono::nanoseconds getPositionFromBuffer(GstBuffer *buffer); QGstPipeline m_playbin; QGstBin m_outputBin; QGstElement m_audioConvert; - GstAppSink *m_appSink = nullptr; - QGstAppSrc *m_appSrc = nullptr; + QGstAppSink m_appSink; + QGstAppSource *m_appSrc = nullptr; QUrl mSource; QIODevice *mDevice = nullptr; QAudioFormat mFormat; - mutable QMutex m_buffersMutex; int m_buffersAvailable = 0; - qint64 m_position = -1; - qint64 m_duration = -1; + static constexpr auto invalidDuration = std::chrono::milliseconds::max(); + static constexpr auto invalidPosition = std::chrono::milliseconds::max(); + std::chrono::milliseconds m_position{ invalidPosition }; + std::chrono::milliseconds m_duration{ invalidDuration }; int m_durationQueries = 0; + + qint32 m_currentSessionId{}; + + QGObjectHandlerScopedConnection m_deepNotifySourceConnection; }; QT_END_NAMESPACE |