-
Notifications
You must be signed in to change notification settings - Fork 0
/
decodergeneric.h
109 lines (78 loc) · 2.5 KB
/
decodergeneric.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
This file is part of Waver
Copyright (C) 2021 Peter Papp
Please visit https://launchpad.net/waver for details
*/
#ifndef DECODERGENERIC_H
#define DECODERGENERIC_H
#include <QAudioBuffer>
#include <QAudioDecoder>
#include <QAudioFormat>
#include <QByteArray>
#include <QDateTime>
#include <QFile>
#include <QMutex>
#include <QObject>
#include <QString>
#include <QtGlobal>
#include <QtMath>
#include <QThread>
#include <QUrl>
#include <QVector>
#include <QWaitCondition>
#include "decodergenericnetworksource.h"
#include "globals.h"
#include "radiotitlecallback.h"
#ifdef QT_DEBUG
#include <QDebug>
#endif
class DecoderGeneric : public QObject
{
Q_OBJECT
public:
explicit DecoderGeneric(RadioTitleCallback::RadioTitleCallbackInfo radioTitleCallbackInfo, QObject *parent = nullptr);
~DecoderGeneric();
void setParameters(QUrl url, QAudioFormat decodedFormat, qint64 waitUnderBytes, bool isRadio, bool removeBeginningSilence);
void setDecodeDelay(unsigned long microseconds);
qint64 getDecodedMicroseconds();
double downloadPercent();
bool isFile();
private:
QAudioDecoder *audioDecoder;
QUrl url;
QAudioFormat decodedFormat;
qint64 waitUnderBytes;
bool isRadio;
bool removeBeginningSilence;
QFile *file;
QThread networkThread;
DecoderGenericNetworkSource *networkSource;
QMutex waitMutex;
QWaitCondition waitCondition;
bool networkDeviceSet;
unsigned long decodeDelay;
qint64 decodedMicroseconds;
double silenceThreshold;
RadioTitleCallback::RadioTitleCallbackInfo radioTitleCallbackInfo;
private slots:
void networkReady();
void networkChanged();
void networkError(QString errorString);
void networkInfo(QString infoString);
void networkSessionExpired();
void decoderBufferReady();
void decoderFinished();
void decoderError(QAudioDecoder::Error error);
public slots:
void run();
void start();
signals:
void bufferAvailable(QAudioBuffer *buffer);
void networkBufferChanged();
void finished();
void errorMessage(QString info, QString error);
void infoMessage(QString info);
void sessionExpired();
void networkStarting(bool starting);
};
#endif // DECODERGENERIC_H