X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=reorderer.h;h=d7f585c50c7066c92e58a28dabde9e53dbe34692;hb=HEAD;hp=393e327f7dbe86053fb374fd9601720c3a9e8195;hpb=8e81c01b2de70c5e7e1a73d25ebbece0a95bd2c8;p=greproxy diff --git a/reorderer.h b/reorderer.h index 393e327..d7f585c 100644 --- a/reorderer.h +++ b/reorderer.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -13,29 +14,37 @@ #include "protocol.h" struct GREPacket { - int seq; + uint32_t seq; uint16_t proto; std::string data; + timeval ts; bool operator> (const GREPacket &other) const { return seq > other.seq; } }; -class Reorderer : public Protocol { +class Reorderer : public Sender { public: - Reorderer(Protocol* sender); - void send_packet(uint16_t proto, const std::string& data, int seq); - virtual int fd() const { assert(false); } + Reorderer(Sender* sender); + void send_packet(uint16_t proto, const std::string& data, uint32_t 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 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, std::greater> packet_buffer; std::map ccs; + + int num_reorders = 0, num_lost_packets = 0, num_ts_discontinuities = 0; }; #endif // !defined(_REORDERER_H)