Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qandroidaudiodecoder_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QANDROIDAUDIODECODER_P_H
5#define QANDROIDAUDIODECODER_P_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#include "private/qplatformaudiodecoder_p.h"
18
19#include <QtCore/qurl.h>
20#include <QThread>
21
22#include "media/NdkMediaCodec.h"
23#include "media/NdkMediaExtractor.h"
24#include "media/NdkMediaFormat.h"
25#include "media/NdkMediaError.h"
26
27
29
30class Decoder : public QObject
31{
33public:
35 ~Decoder();
36
37public slots:
38 void setSource(const QUrl &source);
39 void doDecode();
40 void stop();
41
44 void durationChanged(const qint64 duration);
45 void error(const QAudioDecoder::Error error, const QString &errorString);
46 void finished();
47 void decodingChanged(bool decoding);
48
49private:
50 void createDecoder();
51
52 AMediaCodec *m_codec = nullptr;
53 AMediaExtractor *m_extractor = nullptr;
54 AMediaFormat *m_format = nullptr;
55
56 QAudioFormat m_outputFormat;
57 QString m_formatError;
58 bool m_inputEOS;
59};
60
61
63{
65public:
67 virtual ~QAndroidAudioDecoder();
68
69 QUrl source() const override { return m_source; }
70 void setSource(const QUrl &fileName) override;
71
72 QIODevice *sourceDevice() const override { return m_device; }
73 void setSourceDevice(QIODevice *device) override;
74
75 void start() override;
76 void stop() override;
77
78 QAudioFormat audioFormat() const override { return {}; }
79 void setAudioFormat(const QAudioFormat &/*format*/) override {}
80
81 QAudioBuffer read() override;
82 bool bufferAvailable() const override;
83
84 qint64 position() const override;
85 qint64 duration() const override;
86
88 void setSourceUrl(const QUrl &source);
89
90private slots:
91 void positionChanged(QAudioBuffer audioBuffer, qint64 position);
92 void durationChanged(qint64 duration);
94 void readDevice();
95 void finished();
96
97private:
98 bool requestPermissions();
99 bool createTempFile();
100 void decode();
101
102 QIODevice *m_device = nullptr;
103 Decoder *m_decoder;
104
105 QList<QPair<QAudioBuffer, int>> m_audioBuffer;
106 QUrl m_source;
107
108 qint64 m_position = -1;
109 qint64 m_duration = -1;
110
111 QByteArray m_deviceBuffer;
112
113 QThread *m_threadDecoder = nullptr;
114};
115
117
118#endif // QANDROIDAUDIODECODER_P_H
IOBluetoothDevice * device
void error(const QAudioDecoder::Error error, const QString &errorString)
void decodingChanged(bool decoding)
void finished()
void positionChanged(const QAudioBuffer &buffer, qint64 position)
void setSource(const QUrl &source)
void durationChanged(const qint64 duration)
bool bufferAvailable() const override
QAudioFormat audioFormat() const override
QUrl source() const override
void setSourceUrl(const QUrl &source)
QAudioBuffer read() override
qint64 duration() const override
qint64 position() const override
QIODevice * sourceDevice() const override
void setSourceDevice(QIODevice *device) override
void setSource(const QUrl &fileName) override
QAndroidAudioDecoder(QAudioDecoder *parent)
void setAudioFormat(const QAudioFormat &) override
\inmodule QtMultimedia
The QAudioDecoder class implements decoding audio.
Error
Defines a media player error condition.
The QAudioFormat class stores audio stream parameter information.
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
QAudioDecoder::Error error() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
DBusConnection const char DBusError * error
GLenum GLuint buffer
GLsizei GLsizei GLchar * source
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_OBJECT
#define slots
#define signals
long long qint64
Definition qtypes.h:60