-
Notifications
You must be signed in to change notification settings - Fork 0
/
udpclient.h
46 lines (38 loc) · 845 Bytes
/
udpclient.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 UDPCLIENT_H
#define UDPCLIENT_H
#include <QObject>
#include <QUdpSocket>
#include <QString>
#include <QNetworkDatagram>
#include <QByteArray>
struct RTPPacket{
unsigned char * data;
int size;
};
struct MsgHeader{
int number;
unsigned char data_type;
unsigned char sender_id[32];
unsigned char send_dts[32];
int data_length;
};
class UdpClient : public QObject
{
Q_OBJECT
public:
UdpClient();
~UdpClient();
void init_udp_socket(QString ip,int port);
Q_INVOKABLE void send_msg(const QString& msg);
void parse_buffer(QNetworkDatagram data);
bool read_msg_header(MsgHeader& header);
int read_msg_data(unsigned char* data);
public slots:
void onReceiveMsg();
private:
QUdpSocket *udp_socket_;
QString bind_ip_address_;
QString bind_port_;
QByteArray receive_buffer_;
};
#endif // UDPCLIENT_H