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:
committed by
Commit bot
parent
d29005e485
commit
84f8cd6df4
@ -791,6 +791,8 @@ source_set("neteq") {
|
|||||||
"neteq/neteq_impl.h",
|
"neteq/neteq_impl.h",
|
||||||
"neteq/normal.cc",
|
"neteq/normal.cc",
|
||||||
"neteq/normal.h",
|
"neteq/normal.h",
|
||||||
|
"neteq/packet.cc",
|
||||||
|
"neteq/packet.h",
|
||||||
"neteq/packet_buffer.cc",
|
"neteq/packet_buffer.cc",
|
||||||
"neteq/packet_buffer.h",
|
"neteq/packet_buffer.h",
|
||||||
"neteq/payload_splitter.cc",
|
"neteq/payload_splitter.cc",
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include "webrtc/modules/audio_coding/neteq/delay_manager.h"
|
#include "webrtc/modules/audio_coding/neteq/delay_manager.h"
|
||||||
#include "webrtc/modules/audio_coding/neteq/delay_peak_detector.h"
|
#include "webrtc/modules/audio_coding/neteq/delay_peak_detector.h"
|
||||||
#include "webrtc/modules/audio_coding/neteq/packet_buffer.h"
|
#include "webrtc/modules/audio_coding/neteq/packet_buffer.h"
|
||||||
|
#include "webrtc/modules/audio_coding/neteq/tick_timer.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -24,7 +25,8 @@ TEST(DecisionLogic, CreateAndDestroy) {
|
|||||||
int fs_hz = 8000;
|
int fs_hz = 8000;
|
||||||
int output_size_samples = fs_hz / 100; // Samples per 10 ms.
|
int output_size_samples = fs_hz / 100; // Samples per 10 ms.
|
||||||
DecoderDatabase decoder_database;
|
DecoderDatabase decoder_database;
|
||||||
PacketBuffer packet_buffer(10);
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer packet_buffer(10, &tick_timer);
|
||||||
DelayPeakDetector delay_peak_detector;
|
DelayPeakDetector delay_peak_detector;
|
||||||
DelayManager delay_manager(240, &delay_peak_detector);
|
DelayManager delay_manager(240, &delay_peak_detector);
|
||||||
BufferLevelFilter buffer_level_filter;
|
BufferLevelFilter buffer_level_filter;
|
||||||
|
|||||||
@ -19,8 +19,8 @@ namespace webrtc {
|
|||||||
|
|
||||||
class MockPacketBuffer : public PacketBuffer {
|
class MockPacketBuffer : public PacketBuffer {
|
||||||
public:
|
public:
|
||||||
MockPacketBuffer(size_t max_number_of_packets)
|
MockPacketBuffer(size_t max_number_of_packets, const TickTimer* tick_timer)
|
||||||
: PacketBuffer(max_number_of_packets) {}
|
: PacketBuffer(max_number_of_packets, tick_timer) {}
|
||||||
virtual ~MockPacketBuffer() { Die(); }
|
virtual ~MockPacketBuffer() { Die(); }
|
||||||
MOCK_METHOD0(Die, void());
|
MOCK_METHOD0(Die, void());
|
||||||
MOCK_METHOD0(Flush,
|
MOCK_METHOD0(Flush,
|
||||||
|
|||||||
@ -54,7 +54,8 @@ NetEq* NetEq::Create(const NetEq::Config& config) {
|
|||||||
delay_manager->SetMaximumDelay(config.max_delay_ms);
|
delay_manager->SetMaximumDelay(config.max_delay_ms);
|
||||||
DtmfBuffer* dtmf_buffer = new DtmfBuffer(config.sample_rate_hz);
|
DtmfBuffer* dtmf_buffer = new DtmfBuffer(config.sample_rate_hz);
|
||||||
DtmfToneGenerator* dtmf_tone_generator = new DtmfToneGenerator;
|
DtmfToneGenerator* dtmf_tone_generator = new DtmfToneGenerator;
|
||||||
PacketBuffer* packet_buffer = new PacketBuffer(config.max_packets_in_buffer);
|
PacketBuffer* packet_buffer =
|
||||||
|
new PacketBuffer(config.max_packets_in_buffer, tick_timer.get());
|
||||||
PayloadSplitter* payload_splitter = new PayloadSplitter;
|
PayloadSplitter* payload_splitter = new PayloadSplitter;
|
||||||
TimestampScaler* timestamp_scaler = new TimestampScaler(*decoder_database);
|
TimestampScaler* timestamp_scaler = new TimestampScaler(*decoder_database);
|
||||||
AccelerateFactory* accelerate_factory = new AccelerateFactory;
|
AccelerateFactory* accelerate_factory = new AccelerateFactory;
|
||||||
|
|||||||
@ -105,6 +105,8 @@
|
|||||||
'statistics_calculator.h',
|
'statistics_calculator.h',
|
||||||
'normal.cc',
|
'normal.cc',
|
||||||
'normal.h',
|
'normal.h',
|
||||||
|
'packet.cc',
|
||||||
|
'packet.h',
|
||||||
'packet_buffer.cc',
|
'packet_buffer.cc',
|
||||||
'packet_buffer.h',
|
'packet_buffer.h',
|
||||||
'payload_splitter.cc',
|
'payload_splitter.cc',
|
||||||
|
|||||||
@ -536,7 +536,8 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
|
|||||||
packet->header.numCSRCs = 0;
|
packet->header.numCSRCs = 0;
|
||||||
packet->payload_length = payload.size();
|
packet->payload_length = payload.size();
|
||||||
packet->primary = true;
|
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->payload = new uint8_t[packet->payload_length];
|
||||||
packet->sync_packet = is_sync_packet;
|
packet->sync_packet = is_sync_packet;
|
||||||
if (!packet->payload) {
|
if (!packet->payload) {
|
||||||
@ -1002,7 +1003,6 @@ int NetEqImpl::GetDecision(Operations* operation,
|
|||||||
*operation = kUndefined;
|
*operation = kUndefined;
|
||||||
|
|
||||||
// Increment time counters.
|
// Increment time counters.
|
||||||
packet_buffer_->IncrementWaitingTimes();
|
|
||||||
stats_.IncreaseCounter(output_size_samples_, fs_hz_);
|
stats_.IncreaseCounter(output_size_samples_, fs_hz_);
|
||||||
|
|
||||||
assert(sync_buffer_.get());
|
assert(sync_buffer_.get());
|
||||||
@ -1931,8 +1931,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
stats_.PacketsDiscarded(discard_count);
|
stats_.PacketsDiscarded(discard_count);
|
||||||
// Store waiting time in ms; packets->waiting_time is in "output blocks".
|
stats_.StoreWaitingTime(packet->waiting_time->ElapsedMs());
|
||||||
stats_.StoreWaitingTime(packet->waiting_time * kOutputSizeMs);
|
|
||||||
assert(packet->payload_length > 0);
|
assert(packet->payload_length > 0);
|
||||||
packet_list->push_back(packet); // Store packet in list.
|
packet_list->push_back(packet); // Store packet in list.
|
||||||
|
|
||||||
|
|||||||
@ -130,10 +130,12 @@ class NetEqImplTest : public ::testing::Test {
|
|||||||
dtmf_tone_generator_ = new DtmfToneGenerator;
|
dtmf_tone_generator_ = new DtmfToneGenerator;
|
||||||
}
|
}
|
||||||
if (use_mock_packet_buffer_) {
|
if (use_mock_packet_buffer_) {
|
||||||
mock_packet_buffer_ = new MockPacketBuffer(config_.max_packets_in_buffer);
|
mock_packet_buffer_ =
|
||||||
|
new MockPacketBuffer(config_.max_packets_in_buffer, tick_timer_);
|
||||||
packet_buffer_ = mock_packet_buffer_;
|
packet_buffer_ = mock_packet_buffer_;
|
||||||
} else {
|
} else {
|
||||||
packet_buffer_ = new PacketBuffer(config_.max_packets_in_buffer);
|
packet_buffer_ =
|
||||||
|
new PacketBuffer(config_.max_packets_in_buffer, tick_timer_);
|
||||||
}
|
}
|
||||||
if (use_mock_payload_splitter_) {
|
if (use_mock_payload_splitter_) {
|
||||||
mock_payload_splitter_ = new MockPayloadSplitter;
|
mock_payload_splitter_ = new MockPayloadSplitter;
|
||||||
|
|||||||
19
webrtc/modules/audio_coding/neteq/packet.cc
Normal file
19
webrtc/modules/audio_coding/neteq/packet.cc
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "webrtc/modules/audio_coding/neteq/packet.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
Packet::Packet() = default;
|
||||||
|
|
||||||
|
Packet::~Packet() = default;
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
@ -12,7 +12,9 @@
|
|||||||
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_
|
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "webrtc/modules/audio_coding/neteq/tick_timer.h"
|
||||||
#include "webrtc/modules/include/module_common_types.h"
|
#include "webrtc/modules/include/module_common_types.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
|
|
||||||
@ -21,20 +23,15 @@ namespace webrtc {
|
|||||||
// Struct for holding RTP packets.
|
// Struct for holding RTP packets.
|
||||||
struct Packet {
|
struct Packet {
|
||||||
RTPHeader header;
|
RTPHeader header;
|
||||||
uint8_t* payload; // Datagram excluding RTP header and header extension.
|
// Datagram excluding RTP header and header extension.
|
||||||
size_t payload_length;
|
uint8_t* payload = nullptr;
|
||||||
bool primary; // Primary, i.e., not redundant payload.
|
size_t payload_length = 0;
|
||||||
int waiting_time;
|
bool primary = true; // Primary, i.e., not redundant payload.
|
||||||
bool sync_packet;
|
bool sync_packet = false;
|
||||||
|
std::unique_ptr<TickTimer::Stopwatch> waiting_time;
|
||||||
|
|
||||||
// Constructor.
|
Packet();
|
||||||
Packet()
|
~Packet();
|
||||||
: payload(NULL),
|
|
||||||
payload_length(0),
|
|
||||||
primary(true),
|
|
||||||
waiting_time(0),
|
|
||||||
sync_packet(false) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comparison operators. Establish a packet ordering based on (1) timestamp,
|
// Comparison operators. Establish a packet ordering based on (1) timestamp,
|
||||||
// (2) sequence number, (3) regular packet vs sync-packet and (4) redundancy.
|
// (2) sequence number, (3) regular packet vs sync-packet and (4) redundancy.
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
#include "webrtc/modules/audio_coding/codecs/audio_decoder.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/decoder_database.h"
|
||||||
|
#include "webrtc/modules/audio_coding/neteq/tick_timer.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -37,8 +38,9 @@ class NewTimestampIsLarger {
|
|||||||
const Packet* new_packet_;
|
const Packet* new_packet_;
|
||||||
};
|
};
|
||||||
|
|
||||||
PacketBuffer::PacketBuffer(size_t max_number_of_packets)
|
PacketBuffer::PacketBuffer(size_t max_number_of_packets,
|
||||||
: max_number_of_packets_(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.
|
// Destructor. All packets in the buffer will be destroyed.
|
||||||
PacketBuffer::~PacketBuffer() {
|
PacketBuffer::~PacketBuffer() {
|
||||||
@ -65,6 +67,8 @@ int PacketBuffer::InsertPacket(Packet* packet) {
|
|||||||
|
|
||||||
int return_val = kOK;
|
int return_val = kOK;
|
||||||
|
|
||||||
|
packet->waiting_time = tick_timer_->GetNewStopwatch();
|
||||||
|
|
||||||
if (buffer_.size() >= max_number_of_packets_) {
|
if (buffer_.size() >= max_number_of_packets_) {
|
||||||
// Buffer is full. Flush it.
|
// Buffer is full. Flush it.
|
||||||
Flush();
|
Flush();
|
||||||
@ -268,13 +272,6 @@ size_t PacketBuffer::NumSamplesInBuffer(DecoderDatabase* decoder_database,
|
|||||||
return num_samples;
|
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) {
|
bool PacketBuffer::DeleteFirstPacket(PacketList* packet_list) {
|
||||||
if (packet_list->empty()) {
|
if (packet_list->empty()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// Forward declaration.
|
|
||||||
class DecoderDatabase;
|
class DecoderDatabase;
|
||||||
|
class TickTimer;
|
||||||
|
|
||||||
// This is the actual buffer holding the packets before decoding.
|
// This is the actual buffer holding the packets before decoding.
|
||||||
class PacketBuffer {
|
class PacketBuffer {
|
||||||
@ -34,7 +34,7 @@ class PacketBuffer {
|
|||||||
|
|
||||||
// Constructor creates a buffer which can hold a maximum of
|
// Constructor creates a buffer which can hold a maximum of
|
||||||
// |max_number_of_packets| packets.
|
// |max_number_of_packets| packets.
|
||||||
PacketBuffer(size_t max_number_of_packets);
|
PacketBuffer(size_t max_number_of_packets, const TickTimer* tick_timer);
|
||||||
|
|
||||||
// Deletes all packets in the buffer before destroying the buffer.
|
// Deletes all packets in the buffer before destroying the buffer.
|
||||||
virtual ~PacketBuffer();
|
virtual ~PacketBuffer();
|
||||||
@ -116,10 +116,6 @@ class PacketBuffer {
|
|||||||
virtual size_t NumSamplesInBuffer(DecoderDatabase* decoder_database,
|
virtual size_t NumSamplesInBuffer(DecoderDatabase* decoder_database,
|
||||||
size_t last_decoded_length) const;
|
size_t last_decoded_length) const;
|
||||||
|
|
||||||
// Increase the waiting time counter for every packet in the buffer by |inc|.
|
|
||||||
// The default value for |inc| is 1.
|
|
||||||
virtual void IncrementWaitingTimes(int inc = 1);
|
|
||||||
|
|
||||||
virtual void BufferStat(int* num_packets, int* max_num_packets) const;
|
virtual void BufferStat(int* num_packets, int* max_num_packets) const;
|
||||||
|
|
||||||
// Static method that properly deletes the first packet, and its payload
|
// Static method that properly deletes the first packet, and its payload
|
||||||
@ -148,6 +144,7 @@ class PacketBuffer {
|
|||||||
private:
|
private:
|
||||||
size_t max_number_of_packets_;
|
size_t max_number_of_packets_;
|
||||||
PacketList buffer_;
|
PacketList buffer_;
|
||||||
|
const TickTimer* tick_timer_;
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(PacketBuffer);
|
RTC_DISALLOW_COPY_AND_ASSIGN(PacketBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
#include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h"
|
#include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h"
|
||||||
#include "webrtc/modules/audio_coding/neteq/packet.h"
|
#include "webrtc/modules/audio_coding/neteq/packet.h"
|
||||||
|
#include "webrtc/modules/audio_coding/neteq/tick_timer.h"
|
||||||
|
|
||||||
using ::testing::Return;
|
using ::testing::Return;
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
@ -80,13 +81,15 @@ struct PacketsToInsert {
|
|||||||
// Start of test definitions.
|
// Start of test definitions.
|
||||||
|
|
||||||
TEST(PacketBuffer, CreateAndDestroy) {
|
TEST(PacketBuffer, CreateAndDestroy) {
|
||||||
PacketBuffer* buffer = new PacketBuffer(10); // 10 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer* buffer = new PacketBuffer(10, &tick_timer); // 10 packets.
|
||||||
EXPECT_TRUE(buffer->Empty());
|
EXPECT_TRUE(buffer->Empty());
|
||||||
delete buffer;
|
delete buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PacketBuffer, InsertPacket) {
|
TEST(PacketBuffer, InsertPacket) {
|
||||||
PacketBuffer buffer(10); // 10 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer buffer(10, &tick_timer); // 10 packets.
|
||||||
PacketGenerator gen(17u, 4711u, 0, 10);
|
PacketGenerator gen(17u, 4711u, 0, 10);
|
||||||
|
|
||||||
const int payload_len = 100;
|
const int payload_len = 100;
|
||||||
@ -107,7 +110,8 @@ TEST(PacketBuffer, InsertPacket) {
|
|||||||
|
|
||||||
// Test to flush buffer.
|
// Test to flush buffer.
|
||||||
TEST(PacketBuffer, FlushBuffer) {
|
TEST(PacketBuffer, FlushBuffer) {
|
||||||
PacketBuffer buffer(10); // 10 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer buffer(10, &tick_timer); // 10 packets.
|
||||||
PacketGenerator gen(0, 0, 0, 10);
|
PacketGenerator gen(0, 0, 0, 10);
|
||||||
const int payload_len = 10;
|
const int payload_len = 10;
|
||||||
|
|
||||||
@ -127,7 +131,8 @@ TEST(PacketBuffer, FlushBuffer) {
|
|||||||
|
|
||||||
// Test to fill the buffer over the limits, and verify that it flushes.
|
// Test to fill the buffer over the limits, and verify that it flushes.
|
||||||
TEST(PacketBuffer, OverfillBuffer) {
|
TEST(PacketBuffer, OverfillBuffer) {
|
||||||
PacketBuffer buffer(10); // 10 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer buffer(10, &tick_timer); // 10 packets.
|
||||||
PacketGenerator gen(0, 0, 0, 10);
|
PacketGenerator gen(0, 0, 0, 10);
|
||||||
|
|
||||||
// Insert 10 small packets; should be ok.
|
// Insert 10 small packets; should be ok.
|
||||||
@ -156,7 +161,8 @@ TEST(PacketBuffer, OverfillBuffer) {
|
|||||||
|
|
||||||
// Test inserting a list of packets.
|
// Test inserting a list of packets.
|
||||||
TEST(PacketBuffer, InsertPacketList) {
|
TEST(PacketBuffer, InsertPacketList) {
|
||||||
PacketBuffer buffer(10); // 10 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer buffer(10, &tick_timer); // 10 packets.
|
||||||
PacketGenerator gen(0, 0, 0, 10);
|
PacketGenerator gen(0, 0, 0, 10);
|
||||||
PacketList list;
|
PacketList list;
|
||||||
const int payload_len = 10;
|
const int payload_len = 10;
|
||||||
@ -192,7 +198,8 @@ TEST(PacketBuffer, InsertPacketList) {
|
|||||||
// Expecting the buffer to flush.
|
// Expecting the buffer to flush.
|
||||||
// TODO(hlundin): Remove this test when legacy operation is no longer needed.
|
// TODO(hlundin): Remove this test when legacy operation is no longer needed.
|
||||||
TEST(PacketBuffer, InsertPacketListChangePayloadType) {
|
TEST(PacketBuffer, InsertPacketListChangePayloadType) {
|
||||||
PacketBuffer buffer(10); // 10 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer buffer(10, &tick_timer); // 10 packets.
|
||||||
PacketGenerator gen(0, 0, 0, 10);
|
PacketGenerator gen(0, 0, 0, 10);
|
||||||
PacketList list;
|
PacketList list;
|
||||||
const int payload_len = 10;
|
const int payload_len = 10;
|
||||||
@ -230,7 +237,8 @@ TEST(PacketBuffer, InsertPacketListChangePayloadType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(PacketBuffer, ExtractOrderRedundancy) {
|
TEST(PacketBuffer, ExtractOrderRedundancy) {
|
||||||
PacketBuffer buffer(100); // 100 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer buffer(100, &tick_timer); // 100 packets.
|
||||||
const int kPackets = 18;
|
const int kPackets = 18;
|
||||||
const int kFrameSize = 10;
|
const int kFrameSize = 10;
|
||||||
const int kPayloadLength = 10;
|
const int kPayloadLength = 10;
|
||||||
@ -289,7 +297,8 @@ TEST(PacketBuffer, ExtractOrderRedundancy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(PacketBuffer, DiscardPackets) {
|
TEST(PacketBuffer, DiscardPackets) {
|
||||||
PacketBuffer buffer(100); // 100 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer buffer(100, &tick_timer); // 100 packets.
|
||||||
const uint16_t start_seq_no = 17;
|
const uint16_t start_seq_no = 17;
|
||||||
const uint32_t start_ts = 4711;
|
const uint32_t start_ts = 4711;
|
||||||
const uint32_t ts_increment = 10;
|
const uint32_t ts_increment = 10;
|
||||||
@ -318,7 +327,8 @@ TEST(PacketBuffer, DiscardPackets) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(PacketBuffer, Reordering) {
|
TEST(PacketBuffer, Reordering) {
|
||||||
PacketBuffer buffer(100); // 100 packets.
|
TickTimer tick_timer;
|
||||||
|
PacketBuffer buffer(100, &tick_timer); // 100 packets.
|
||||||
const uint16_t start_seq_no = 17;
|
const uint16_t start_seq_no = 17;
|
||||||
const uint32_t start_ts = 4711;
|
const uint32_t start_ts = 4711;
|
||||||
const uint32_t ts_increment = 10;
|
const uint32_t ts_increment = 10;
|
||||||
@ -373,8 +383,9 @@ TEST(PacketBuffer, Failures) {
|
|||||||
const uint32_t ts_increment = 10;
|
const uint32_t ts_increment = 10;
|
||||||
int payload_len = 100;
|
int payload_len = 100;
|
||||||
PacketGenerator gen(start_seq_no, start_ts, 0, ts_increment);
|
PacketGenerator gen(start_seq_no, start_ts, 0, ts_increment);
|
||||||
|
TickTimer tick_timer;
|
||||||
|
|
||||||
PacketBuffer* buffer = new PacketBuffer(100); // 100 packets.
|
PacketBuffer* buffer = new PacketBuffer(100, &tick_timer); // 100 packets.
|
||||||
Packet* packet = NULL;
|
Packet* packet = NULL;
|
||||||
EXPECT_EQ(PacketBuffer::kInvalidPacket, buffer->InsertPacket(packet));
|
EXPECT_EQ(PacketBuffer::kInvalidPacket, buffer->InsertPacket(packet));
|
||||||
packet = gen.NextPacket(payload_len);
|
packet = gen.NextPacket(payload_len);
|
||||||
@ -404,7 +415,7 @@ TEST(PacketBuffer, Failures) {
|
|||||||
// Insert packet list of three packets, where the second packet has an invalid
|
// Insert packet list of three packets, where the second packet has an invalid
|
||||||
// payload. Expect first packet to be inserted, and the remaining two to be
|
// payload. Expect first packet to be inserted, and the remaining two to be
|
||||||
// discarded.
|
// discarded.
|
||||||
buffer = new PacketBuffer(100); // 100 packets.
|
buffer = new PacketBuffer(100, &tick_timer); // 100 packets.
|
||||||
PacketList list;
|
PacketList list;
|
||||||
list.push_back(gen.NextPacket(payload_len)); // Valid packet.
|
list.push_back(gen.NextPacket(payload_len)); // Valid packet.
|
||||||
packet = gen.NextPacket(payload_len);
|
packet = gen.NextPacket(payload_len);
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
#include "webrtc/modules/audio_coding/neteq/decoder_database.h"
|
#include "webrtc/modules/audio_coding/neteq/decoder_database.h"
|
||||||
|
|
||||||
@ -168,8 +169,9 @@ int PayloadSplitter::SplitFec(PacketList* packet_list,
|
|||||||
memcpy(new_packet->payload, packet->payload, packet->payload_length);
|
memcpy(new_packet->payload, packet->payload, packet->payload_length);
|
||||||
new_packet->payload_length = packet->payload_length;
|
new_packet->payload_length = packet->payload_length;
|
||||||
new_packet->primary = false;
|
new_packet->primary = false;
|
||||||
new_packet->waiting_time = packet->waiting_time;
|
|
||||||
new_packet->sync_packet = packet->sync_packet;
|
new_packet->sync_packet = packet->sync_packet;
|
||||||
|
// Waiting time should not be set here.
|
||||||
|
RTC_DCHECK(!packet->waiting_time);
|
||||||
|
|
||||||
packet_list->insert(it, new_packet);
|
packet_list->insert(it, new_packet);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user