Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qgstreameraudiodecoder_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QGSTREAMERAUDIODECODERCONTROL_H
5#define QGSTREAMERAUDIODECODERCONTROL_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtMultimedia/private/qtmultimediaglobal_p.h>
19#include <QObject>
20#include <QtCore/qmutex.h>
21#include <QtCore/qurl.h>
22
23#include <private/qplatformaudiodecoder_p.h>
24#include <private/qmultimediautils_p.h>
25#include <qgstpipeline_p.h>
26#include "qaudiodecoder.h"
27
28#if QT_CONFIG(gstreamer_app)
29#include <qgstappsrc_p.h>
30#endif
31
32#include <qgst_p.h>
33#include <gst/app/gstappsink.h>
34
36
38
40 : public QPlatformAudioDecoder,
42{
44
45public:
48
49 QUrl source() const override;
50 void setSource(const QUrl &fileName) override;
51
52 QIODevice *sourceDevice() const override;
53 void setSourceDevice(QIODevice *device) override;
54
55 void start() override;
56 void stop() override;
57
58 QAudioFormat audioFormat() const override;
59 void setAudioFormat(const QAudioFormat &format) override;
60
61 QAudioBuffer read() override;
62 bool bufferAvailable() const override;
63
64 qint64 position() const override;
65 qint64 duration() const override;
66
67 // GStreamerBusMessageFilter interface
68 bool processBusMessage(const QGstreamerMessage &message) override;
69
70#if QT_CONFIG(gstreamer_app)
71 QGstAppSrc *appsrc() const { return m_appSrc; }
72 static void configureAppSrcElement(GObject*, GObject*, GParamSpec*, QGstreamerAudioDecoder *_this);
73#endif
74
75 static GstFlowReturn new_sample(GstAppSink *sink, gpointer user_data);
76
77private slots:
78 void updateDuration();
79
80private:
82
83 void setAudioFlags(bool wantNativeAudio);
84 void addAppSink();
85 void removeAppSink();
86
87 void processInvalidMedia(QAudioDecoder::Error errorCode, const QString& errorString);
88 static qint64 getPositionFromBuffer(GstBuffer* buffer);
89
90 QGstPipeline m_playbin;
91 QGstBin m_outputBin;
92 QGstElement m_audioConvert;
93 GstAppSink *m_appSink = nullptr;
94 QGstAppSrc *m_appSrc = nullptr;
95
96 QUrl mSource;
97 QIODevice *mDevice = nullptr;
98 QAudioFormat mFormat;
99
100 mutable QMutex m_buffersMutex;
101 int m_buffersAvailable = 0;
102
103 qint64 m_position = -1;
104 qint64 m_duration = -1;
105
106 int m_durationQueries = 0;
107};
108
110
111#endif // QGSTREAMERPLAYERSESSION_H
IOBluetoothDevice * device
\inmodule QtMultimedia
The QAudioDecoder class implements decoding audio.
Error
Defines a media player error condition.
The QAudioFormat class stores audio stream parameter information.
void setSourceDevice(QIODevice *device) override
QAudioFormat audioFormat() const override
static GstFlowReturn new_sample(GstAppSink *sink, gpointer user_data)
QIODevice * sourceDevice() const override
void setSource(const QUrl &fileName) override
qint64 duration() const override
void setAudioFormat(const QAudioFormat &format) override
bool bufferAvailable() const override
QAudioBuffer read() override
qint64 position() const override
bool processBusMessage(const QGstreamerMessage &message) override
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtCore
Definition qmutex.h:285
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void * user_data
GLenum GLuint buffer
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum format
GLsizei GLenum GLboolean sink
#define Q_OBJECT
#define slots
long long qint64
Definition qtypes.h:55
view create()