]> git.sesse.net Git - greproxy/blobdiff - reorderer.h
Make Reorderer handle multi-timeouts.
[greproxy] / reorderer.h
index 476093fc5e8e136d9fc4d3008d5f6eb81e82e489..622083e0563da0f968161e98654f144cc2666fd1 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef _REORDERER_H
 #define _REORDERER_H 1
 
+#include <assert.h>
 #include <stdint.h>
+#include <sys/time.h>
 
 #include <algorithm>
 #include <map>
 #include <string>
 #include <vector>
 
-class Protocol;
+#include "protocol.h"
 
 struct GREPacket {
        int seq;
        uint16_t proto;
        std::string data;
+       timeval ts;
 
        bool operator> (const GREPacket &other) const {
                return seq > other.seq;
        }
 };
 
-class Reorderer {
+class Reorderer : public Sender {
 public:
-       Reorderer(Protocol* sender);
-       void handle_packet(uint16_t proto, const std::string& data, int seq);
+       Reorderer(Sender* sender);
+       void send_packet(uint16_t proto, const std::string& data, int seq);
+       void possibly_adjust_tv(timeval *tv);
 
 private:
-       void send_packet(uint16_t proto, const std::string &data, bool silence);
+       void check_ts_discontinuity(uint16_t proto, const std::string &data, bool silence);
 
-       Protocol* sender;
+       Sender* sender;
        int last_seq;
+       timeval last_sent_packet;
 
        std::priority_queue<GREPacket, std::vector<GREPacket>, std::greater<GREPacket>> packet_buffer;
        std::map<int, int> ccs;