-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvoice_client.h
46 lines (38 loc) · 1.69 KB
/
voice_client.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
#ifndef VOICECLIENT_HPP
#define VOICECLIENT_HPP
// ------------------------------------------------------------------------------------------------------------------
#include <QObject>
#include <QIODevice>
#include <QAudioFormat>
// ------------------------------------------------------------------------------------------------------------------
class QUdpSocket;
class CLanMetadataClient;
// ------------------------------------------------------------------------------------------------------------------
class CVoiceClient : public QIODevice
{
Q_OBJECT
public:
CVoiceClient(QObject *parent, CLanMetadataClient *metadataClient, QAudioFormat format);
// Liest Daten aus dem Puffer (Daten kommen von anderen Gesprächsteilnehmern)
qint64 readData(char *data, qint64 maxlen) override;
// Schreibt Daten in UDP Socket -> zu anderen Clients
qint64 writeData(const char *data, qint64 len) override;
// Wie viele Daten sind aktuell im Puffer?
qint64 bytesAvailable() const override { return m_ReadBuffer.size() + QIODevice::bytesAvailable(); }
// Aktuell gleich zu bytesAvailable()
qint64 size() const override { return m_ReadBuffer.size(); }
// Port, auf dem Voice-Pakete empfangen werden
uint16_t port() const;
public slots:
void onSocketReadyRead();
signals:
void voiceDataReady();
private:
CLanMetadataClient *m_MetadataClient;
QAudioFormat m_Format;
QUdpSocket *m_Socket;
QByteArray m_ReadBuffer;
};
// ------------------------------------------------------------------------------------------------------------------
#endif
// ------------------------------------------------------------------------------------------------------------------