]> git.sesse.net Git - greproxy/blobdiff - reorderer.cpp
Update email address.
[greproxy] / reorderer.cpp
index 697f8189d3a05da187d0fb74ed8149f86f50d19c..c2823e5254c94a85c7201d61efbb613d27d88073 100644 (file)
@@ -66,6 +66,8 @@ void Reorderer::send_packet(uint16_t proto, const string& data, int seq)
        packet.ts = now;
        packet_buffer.push(packet);
 
+       bool did_reorder = false;
+
        while (!packet_buffer.empty() &&
               (last_seq == -1 || packet_buffer.top().seq <= last_seq + 1)) {
                int front_seq = packet_buffer.top().seq;
@@ -87,13 +89,17 @@ void Reorderer::send_packet(uint16_t proto, const string& data, int seq)
                last_seq = front_seq;
                last_sent_packet = now;
                if (!packet_buffer.empty()) {
-                       ++num_reorders;
+                       did_reorder = true;
                        if (!silence) {
                                printf("Reordering with packet buffer size %d: seq=%d new_front_seq=%d\n", int(packet_buffer.size()), front_seq, packet_buffer.top().seq);
                                silence = true;
                        }
                }
        }
+
+       if (did_reorder) {
+               ++num_reorders;
+       }
 }
 
 void Reorderer::check_ts_discontinuity(uint16_t proto, const string &data, bool silence)
@@ -110,8 +116,11 @@ void Reorderer::check_ts_discontinuity(uint16_t proto, const string &data, bool
                        int cc = pkt[3] & 0xf;
                        if (has_payload) {
                                int last_cc = ccs[pid];
-                               if (!silence && cc != ((last_cc + 1) & 0xf)) {
-                                       printf("Pid %d discontinuity (expected %d, got %d)\n", pid, (last_cc + 1) & 0xf, cc);
+                               if (cc != ((last_cc + 1) & 0xf)) {
+                                       if (!silence) {
+                                               printf("Pid %d discontinuity (expected %d, got %d)\n", pid, (last_cc + 1) & 0xf, cc);
+                                       }
+                                       ++num_ts_discontinuities;
                                }
                                ccs[pid] = cc;
                        }