]> git.sesse.net Git - greproxy/blobdiff - reorderer.cpp
Split Protocol into Sender and Reader.
[greproxy] / reorderer.cpp
index fe3b7b64cd98027b4be2b49eab8399ec8618d89c..e18b63f6007689161bdbf88ef3af03444ab786c2 100644 (file)
@@ -7,12 +7,12 @@
 
 using namespace std;
 
-Reorderer::Reorderer(Protocol* sender)
+Reorderer::Reorderer(Sender* sender)
        : sender(sender), last_seq(-1)
 {
 }
 
-void Reorderer::handle_packet(uint16_t proto, const string& data, int seq)
+void Reorderer::send_packet(uint16_t proto, const string& data, int seq)
 {
        bool silence = false;
        if (packet_buffer.size() >= PACKET_BUFFER_SIZE) {
@@ -43,7 +43,8 @@ void Reorderer::handle_packet(uint16_t proto, const string& data, int seq)
                //      printf("seq=%d\n", front_seq);
                //}
                const string &data = packet_buffer.top().data;
-               send_packet(packet_buffer.top().proto, data, silence);
+               check_ts_discontinuity(packet_buffer.top().proto, data, silence);
+               sender->send_packet(proto, data, seq);
                packet_buffer.pop();
                last_seq = front_seq;
                if (!silence && !packet_buffer.empty()) {
@@ -53,7 +54,7 @@ void Reorderer::handle_packet(uint16_t proto, const string& data, int seq)
        }
 }
 
-void Reorderer::send_packet(uint16_t proto, const string &data, bool silence)
+void Reorderer::check_ts_discontinuity(uint16_t proto, const string &data, bool silence)
 {
        if (data.size() == 1344) {
                for (int i = 0; i < 7; ++i) {
@@ -74,6 +75,5 @@ void Reorderer::send_packet(uint16_t proto, const string &data, bool silence)
                        }
                }
        }
-       sender->send_packet(proto, data);
 }