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}
This commit is contained in:
henrik.lundin
2016-04-26 07:45:16 -07:00
committed by Commit bot
parent d29005e485
commit 84f8cd6df4
13 changed files with 81 additions and 50 deletions

View File

@ -19,6 +19,7 @@
#include "webrtc/base/logging.h"
#include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
#include "webrtc/modules/audio_coding/neteq/decoder_database.h"
#include "webrtc/modules/audio_coding/neteq/tick_timer.h"
namespace webrtc {
@ -37,8 +38,9 @@ class NewTimestampIsLarger {
const Packet* new_packet_;
};
PacketBuffer::PacketBuffer(size_t max_number_of_packets)
: max_number_of_packets_(max_number_of_packets) {}
PacketBuffer::PacketBuffer(size_t max_number_of_packets,
const TickTimer* tick_timer)
: max_number_of_packets_(max_number_of_packets), tick_timer_(tick_timer) {}
// Destructor. All packets in the buffer will be destroyed.
PacketBuffer::~PacketBuffer() {
@ -65,6 +67,8 @@ int PacketBuffer::InsertPacket(Packet* packet) {
int return_val = kOK;
packet->waiting_time = tick_timer_->GetNewStopwatch();
if (buffer_.size() >= max_number_of_packets_) {
// Buffer is full. Flush it.
Flush();
@ -268,13 +272,6 @@ size_t PacketBuffer::NumSamplesInBuffer(DecoderDatabase* decoder_database,
return num_samples;
}
void PacketBuffer::IncrementWaitingTimes(int inc) {
PacketList::iterator it;
for (it = buffer_.begin(); it != buffer_.end(); ++it) {
(*it)->waiting_time += inc;
}
}
bool PacketBuffer::DeleteFirstPacket(PacketList* packet_list) {
if (packet_list->empty()) {
return false;