]> git.sesse.net Git - greproxy/blob - reorderer.h
cdde8146a090a04ddd7d44b7ce836cef4a4850e0
[greproxy] / reorderer.h
1 #ifndef _REORDERER_H
2 #define _REORDERER_H 1
3
4 #include <assert.h>
5 #include <stdint.h>
6
7 #include <algorithm>
8 #include <map>
9 #include <queue>
10 #include <string>
11 #include <vector>
12
13 #include "protocol.h"
14
15 struct GREPacket {
16         int seq;
17         uint16_t proto;
18         std::string data;
19
20         bool operator> (const GREPacket &other) const {
21                 return seq > other.seq;
22         }
23 };
24
25 class Reorderer : public Sender {
26 public:
27         Reorderer(Sender* sender);
28         void send_packet(uint16_t proto, const std::string& data, int seq);
29
30 private:
31         void check_ts_discontinuity(uint16_t proto, const std::string &data, bool silence);
32
33         Sender* sender;
34         int last_seq;
35
36         std::priority_queue<GREPacket, std::vector<GREPacket>, std::greater<GREPacket>> packet_buffer;
37         std::map<int, int> ccs;
38 };
39
40 #endif  // !defined(_REORDERER_H)