| 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 QAUDIODECODER_H |
| 5 | #define QAUDIODECODER_H |
| 6 | |
| 7 | #include <QtCore/qobject.h> |
| 8 | #include <QtMultimedia/qaudiobuffer.h> |
| 9 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | |
| 12 | class QAudioDecoderPrivate; |
| 13 | class Q_MULTIMEDIA_EXPORT QAudioDecoder : public QObject |
| 14 | { |
| 15 | Q_OBJECT |
| 16 | Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) |
| 17 | Q_PROPERTY(bool isDecoding READ isDecoding NOTIFY isDecodingChanged) |
| 18 | Q_PROPERTY(QString error READ errorString) |
| 19 | Q_PROPERTY(bool bufferAvailable READ bufferAvailable NOTIFY bufferAvailableChanged) |
| 20 | |
| 21 | public: |
| 22 | enum Error |
| 23 | { |
| 24 | NoError, |
| 25 | ResourceError, |
| 26 | FormatError, |
| 27 | AccessDeniedError, |
| 28 | NotSupportedError |
| 29 | }; |
| 30 | Q_ENUM(Error) |
| 31 | |
| 32 | explicit QAudioDecoder(QObject *parent = nullptr); |
| 33 | ~QAudioDecoder() override; |
| 34 | |
| 35 | bool isSupported() const; |
| 36 | bool isDecoding() const; |
| 37 | |
| 38 | QUrl source() const; |
| 39 | void setSource(const QUrl &fileName); |
| 40 | |
| 41 | QIODevice* sourceDevice() const; |
| 42 | void setSourceDevice(QIODevice *device); |
| 43 | |
| 44 | QAudioFormat audioFormat() const; |
| 45 | void setAudioFormat(const QAudioFormat &format); |
| 46 | |
| 47 | Error error() const; |
| 48 | QString errorString() const; |
| 49 | |
| 50 | QAudioBuffer read() const; |
| 51 | bool bufferAvailable() const; |
| 52 | |
| 53 | qint64 position() const; |
| 54 | qint64 duration() const; |
| 55 | |
| 56 | public Q_SLOTS: |
| 57 | void start(); |
| 58 | void stop(); |
| 59 | |
| 60 | Q_SIGNALS: |
| 61 | void bufferAvailableChanged(bool); |
| 62 | void bufferReady(); |
| 63 | void finished(); |
| 64 | void isDecodingChanged(bool); |
| 65 | |
| 66 | void formatChanged(const QAudioFormat &format); |
| 67 | |
| 68 | void error(QAudioDecoder::Error error); |
| 69 | |
| 70 | void sourceChanged(); |
| 71 | |
| 72 | void positionChanged(qint64 position); |
| 73 | void durationChanged(qint64 duration); |
| 74 | |
| 75 | private: |
| 76 | Q_DISABLE_COPY(QAudioDecoder) |
| 77 | Q_DECLARE_PRIVATE(QAudioDecoder) |
| 78 | |
| 79 | // ### Qt7: remove unused member |
| 80 | QT6_ONLY(void *unused = nullptr;) // for ABI compatibility |
| 81 | }; |
| 82 | |
| 83 | QT_END_NAMESPACE |
| 84 | |
| 85 | #endif // QAUDIODECODER_H |
| 86 | |