#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);
+
+ int get_reorders() const { return num_reorders; }
+ int get_lost_packets() const { return num_lost_packets; }
+ int get_ts_discontinuities() const { return num_ts_discontinuities; }
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;
+
+ int num_reorders = 0, num_lost_packets = 0, num_ts_discontinuities = 0;
};
#endif // !defined(_REORDERER_H)