forked from strfry/qwebrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqwebrtcdatachannel.hpp
59 lines (53 loc) · 1.59 KB
/
qwebrtcdatachannel.hpp
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
#pragma once
#include <memory>
#include <QByteArray>
#include <QObject>
struct QWebRTCDataChannelConfig {
bool isOrdered = true;
/**
* The length of the time window (in milliseconds) during which transmissions
* and retransmissions may occur in unreliable mode.
*/
uint16_t maxPacketLifeTime = 0;
/**
* The maximum number of retransmissions that are attempted in unreliable mode.
*/
uint16_t maxRetransmits;
/**
* Returns whether this data channel was negotiated by the application or not.
*/
bool isNegotiated = false;
/** The identifier for this data channel. */
int channelId = 0;
/**
* The name of the sub-protocol used with this data channel, if any. Otherwise
* this returns an empty string.
*/
QString protocol;
};
class QWebRTCDataChannel : public QObject {
Q_OBJECT
public:
enum ChannelState {
Connecting,
Open,
Closing,
Closed
};
// Sends data as text
virtual bool sendData(const QString&) = 0;
// Treats the data as binary data, copies the raw data buffer (i.e. it does not take ownership of the data pointer)
virtual bool sendData(const QByteArray&) = 0;
// closes the data channel
virtual void close() = 0;
virtual QString label() = 0;
virtual bool isReliable() = 0;
virtual QString protocol() = 0;
virtual bool isNegotiated() = 0;
virtual ChannelState channelState() = 0;
virtual uint64_t bufferedAmount() = 0;
Q_SIGNALS:
void dataReceived(QByteArray);
void channelStateChanged();
void bufferAmountChanged();
};