]> git.sesse.net Git - greproxy/blob - reorderer.h
Port greproxy to all the new classes and stuff.
[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 Protocol {
26 public:
27         Reorderer(Protocol* sender);
28         void send_packet(uint16_t proto, const std::string& data, int seq);
29         virtual int fd() const { assert(false); }
30
31 private:
32         void check_ts_discontinuity(uint16_t proto, const std::string &data, bool silence);
33
34         Protocol* sender;
35         int last_seq;
36
37         std::priority_queue<GREPacket, std::vector<GREPacket>, std::greater<GREPacket>> packet_buffer;
38         std::map<int, int> ccs;
39 };
40
41 #endif  // !defined(_REORDERER_H)