Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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/qmultimediautils_p.h>
19#include <QtMultimedia/private/qplatformaudiodecoder_p.h>
20#include <QtMultimedia/private/qtmultimediaglobal_p.h>
21#include <QtMultimedia/qaudiodecoder.h>
22#include <QtCore/qobject.h>
23#include <QtCore/qmutex.h>
24#include <QtCore/qurl.h>
25#include <QtCore/private/qexpected_p.h>
26
27#include <common/qgst_p.h>
28#include <common/qgst_bus_observer_p.h>
29#include <common/qgstpipeline_p.h>
30
31#include <gst/app/gstappsink.h>
32
34
36
38{
40
41public:
44
45 QUrl source() const override;
46 void setSource(const QUrl &fileName) override;
47
48 QIODevice *sourceDevice() const override;
49 void setSourceDevice(QIODevice *device) override;
50
51 void start() override;
52 void stop() override;
53
54 QAudioFormat audioFormat() const override;
55 void setAudioFormat(const QAudioFormat &format) override;
56
57 QAudioBuffer read() override;
58
59 // GStreamerBusMessageFilter interface
60 bool processBusMessage(const QGstreamerMessage &message) override;
61
62 bool canReadQrc() const override;
63
64private slots:
65 void updateDuration();
66
67private:
68 explicit QGstreamerAudioDecoder(QAudioDecoder *parent);
69
70 static GstFlowReturn new_sample(GstAppSink *sink, gpointer user_data);
71 GstFlowReturn newSample(GstAppSink *sink);
72
73 void setAudioFlags(bool wantNativeAudio);
74 void addAppSink();
75 void removeAppSink();
76
77 void processInvalidMedia(QAudioDecoder::Error errorCode, const QString &errorString);
78 static std::chrono::nanoseconds getPositionFromBuffer(GstBuffer *buffer);
79
80 bool processBusMessageError(const QGstreamerMessage &);
81 bool processBusMessageDuration(const QGstreamerMessage &);
82 bool processBusMessageWarning(const QGstreamerMessage &);
83 bool processBusMessageInfo(const QGstreamerMessage &);
84 bool processBusMessageEOS(const QGstreamerMessage &);
85 bool processBusMessageStateChanged(const QGstreamerMessage &);
86 bool processBusMessageStreamsSelected(const QGstreamerMessage &);
87
88 QGstPipeline m_playbin;
89 QGstBin m_outputBin;
90 QGstElement m_audioConvert;
91 QGstAppSink m_appSink;
92
93 QUrl mSource;
94 QIODevice *mDevice = nullptr;
95 QAudioFormat mFormat;
96
97 int m_buffersAvailable = 0;
98
99 int m_durationQueries = 0;
100
101 qint32 m_currentSessionId{};
102
103 QGObjectHandlerScopedConnection m_deepNotifySourceConnection;
104};
105
106QT_END_NAMESPACE
107
108#endif // QGSTREAMERPLAYERSESSION_H
The QAudioFormat class stores audio stream parameter information.
void setSourceDevice(QIODevice *device) override
QAudioFormat audioFormat() const override
QIODevice * sourceDevice() const override
void setSource(const QUrl &fileName) override
static q23::expected< QPlatformAudioDecoder *, QString > create(QAudioDecoder *parent)
void setAudioFormat(const QAudioFormat &format) override
QAudioBuffer read() override
bool processBusMessage(const QGstreamerMessage &message) override
bool canReadQrc() const override
QGstCaps capsForAudioFormat(const QAudioFormat &format)
Definition qgstutils.cpp:83
Combined button and popup list for selecting options.
@ GST_PLAY_FLAG_AUDIO
@ GST_PLAY_FLAG_SOFT_VOLUME
@ GST_PLAY_FLAG_DOWNLOAD
@ GST_PLAY_FLAG_BUFFERING
@ GST_PLAY_FLAG_NATIVE_AUDIO
@ GST_PLAY_FLAG_NATIVE_VIDEO
@ GST_PLAY_FLAG_VIDEO
QCompactGstMessageAdaptor(const QGstreamerMessage &m)