]> git.sesse.net Git - greproxy/blobdiff - reorderer.cpp
Make Reorderer into a Protocol.
[greproxy] / reorderer.cpp
index fe3b7b64cd98027b4be2b49eab8399ec8618d89c..b6ac6a9079906b8aaac5944ef8398f88fdc341e9 100644 (file)
@@ -12,7 +12,7 @@ Reorderer::Reorderer(Protocol* sender)
 {
 }
 
-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);
 }