-
Notifications
You must be signed in to change notification settings - Fork 0
/
audiostream.h
39 lines (30 loc) · 881 Bytes
/
audiostream.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
#ifndef AUDIOSTREAM_H
#define AUDIOSTREAM_H
#include <QFile>
#include <QAudioInput>
#include <QAudioFormat>
#include <QTcpSocket>
// This is going to be inherited by a QTcpSocket to put the audio in a socket for some client to register to and listen to the audio
class AudioStream : public QIODevice
{
Q_OBJECT
public:
explicit AudioStream(QObject *parent = 0);
void start();
void stop();
qreal level() const { return m_level; }
qint64 writeData(const char *data, qint64 len);
qint64 readData(char *data, qint64 maxlen);
signals:
void updateLevel(qreal);
public slots:
void slotClientSocket(QIODevice* client);
private:
QAudioFormat m_format;
QAudioInput* m_audioInput;
quint16 m_maxAmplitude;
qreal m_level; // 0.0 <= m_level <= 1.0
QIODevice* m_client;
bool hasClientSocket;
};
#endif // AUDIOSTREAM_H