NetEq: Use TickTimer in PacketBuffer
This change makes use of the TickTimer::Stopwatch in Packets. When a
packet is inserted into the PacketBuffer, a Stopwatch object is
attached to it. When the packet is extracted from the buffer, the
Stopwatch is read to know how long the packet waited in the buffer.
BUG=webrtc:5608
Review URL: https://codereview.webrtc.org/1917913002
Cr-Commit-Position: refs/heads/master@{#12508}
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index ef470e5..cca1c4c 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -536,7 +536,8 @@
packet->header.numCSRCs = 0;
packet->payload_length = payload.size();
packet->primary = true;
- packet->waiting_time = 0;
+ // Waiting time will be set upon inserting the packet in the buffer.
+ RTC_DCHECK(!packet->waiting_time);
packet->payload = new uint8_t[packet->payload_length];
packet->sync_packet = is_sync_packet;
if (!packet->payload) {
@@ -1002,7 +1003,6 @@
*operation = kUndefined;
// Increment time counters.
- packet_buffer_->IncrementWaitingTimes();
stats_.IncreaseCounter(output_size_samples_, fs_hz_);
assert(sync_buffer_.get());
@@ -1931,8 +1931,7 @@
return -1;
}
stats_.PacketsDiscarded(discard_count);
- // Store waiting time in ms; packets->waiting_time is in "output blocks".
- stats_.StoreWaitingTime(packet->waiting_time * kOutputSizeMs);
+ stats_.StoreWaitingTime(packet->waiting_time->ElapsedMs());
assert(packet->payload_length > 0);
packet_list->push_back(packet); // Store packet in list.