Include buffer size limits in NetEq config struct
This change includes max_packets_in_buffer and max_delay_ms in the
NetEq config struct. The packet buffer is also no longer limited in
terms of payload sizes (bytes), only number of packets.
The old constants governing the packet buffer limits are deleted.
BUG=3083
R=turaj@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/14389004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5989 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index a035259..d9424dc 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -765,13 +765,9 @@
// exceeds a threshold.
int num_packets;
int max_num_packets;
- int buffer_size_byte;
- int max_buffer_size_byte;
const float kBufferingThresholdScale = 0.9f;
- neteq_->PacketBufferStatistics(&num_packets, &max_num_packets,
- &buffer_size_byte, &max_buffer_size_byte);
- if (num_packets > max_num_packets * kBufferingThresholdScale ||
- buffer_size_byte > max_buffer_size_byte * kBufferingThresholdScale) {
+ neteq_->PacketBufferStatistics(&num_packets, &max_num_packets);
+ if (num_packets > max_num_packets * kBufferingThresholdScale) {
initial_delay_manager_->DisableBuffering();
return false;
}
diff --git a/webrtc/modules/audio_coding/neteq4/decision_logic_unittest.cc b/webrtc/modules/audio_coding/neteq4/decision_logic_unittest.cc
index d596c05..60a4b62 100644
--- a/webrtc/modules/audio_coding/neteq4/decision_logic_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq4/decision_logic_unittest.cc
@@ -24,7 +24,7 @@
int fs_hz = 8000;
int output_size_samples = fs_hz / 100; // Samples per 10 ms.
DecoderDatabase decoder_database;
- PacketBuffer packet_buffer(10, 1000);
+ PacketBuffer packet_buffer(10);
DelayPeakDetector delay_peak_detector;
DelayManager delay_manager(240, &delay_peak_detector);
BufferLevelFilter buffer_level_filter;
diff --git a/webrtc/modules/audio_coding/neteq4/interface/neteq.h b/webrtc/modules/audio_coding/neteq4/interface/neteq.h
index 8defe4f..64a23e8 100644
--- a/webrtc/modules/audio_coding/neteq4/interface/neteq.h
+++ b/webrtc/modules/audio_coding/neteq4/interface/neteq.h
@@ -70,10 +70,15 @@
struct Config {
Config()
: sample_rate_hz(16000),
- enable_audio_classifier(false) {}
+ enable_audio_classifier(false),
+ max_packets_in_buffer(50),
+ // |max_delay_ms| has the same effect as calling SetMaximumDelay().
+ max_delay_ms(2000) {}
int sample_rate_hz; // Initial vale. Will change with input data.
bool enable_audio_classifier;
+ int max_packets_in_buffer;
+ int max_delay_ms;
};
enum ReturnCodes {
@@ -107,13 +112,9 @@
kFrameSplitError,
kRedundancySplitError,
kPacketBufferCorruption,
- kOversizePacket,
kSyncPacketNotAccepted
};
- static const int kMaxNumPacketsInBuffer = 50; // TODO(hlundin): Remove.
- static const int kMaxBytesInBuffer = 113280; // TODO(hlundin): Remove.
-
// Creates a new NetEq object, with parameters set in |config|. The |config|
// object will only have to be valid for the duration of the call to this
// method.
@@ -179,7 +180,8 @@
// Sets a maximum delay in milliseconds for packet buffer. The latency will
// not exceed the given value, even required delay (given the channel
- // conditions) is higher.
+ // conditions) is higher. Calling this method has the same effect as setting
+ // the |max_delay_ms| value in the NetEq::Config struct.
virtual bool SetMaximumDelay(int delay_ms) = 0;
// The smallest latency required. This is computed bases on inter-arrival
@@ -249,9 +251,7 @@
// Current usage of packet-buffer and it's limits.
virtual void PacketBufferStatistics(int* current_num_packets,
- int* max_num_packets,
- int* current_memory_size_bytes,
- int* max_memory_size_bytes) const = 0;
+ int* max_num_packets) const = 0;
// Get sequence number and timestamp of the latest RTP.
// This method is to facilitate NACK.
diff --git a/webrtc/modules/audio_coding/neteq4/mock/mock_packet_buffer.h b/webrtc/modules/audio_coding/neteq4/mock/mock_packet_buffer.h
index 37fa90d..b1d8ef9 100644
--- a/webrtc/modules/audio_coding/neteq4/mock/mock_packet_buffer.h
+++ b/webrtc/modules/audio_coding/neteq4/mock/mock_packet_buffer.h
@@ -19,8 +19,8 @@
class MockPacketBuffer : public PacketBuffer {
public:
- MockPacketBuffer(size_t max_number_of_packets, size_t max_payload_memory)
- : PacketBuffer(max_number_of_packets, max_payload_memory) {}
+ MockPacketBuffer(size_t max_number_of_packets)
+ : PacketBuffer(max_number_of_packets) {}
virtual ~MockPacketBuffer() { Die(); }
MOCK_METHOD0(Die, void());
MOCK_METHOD0(Flush,
diff --git a/webrtc/modules/audio_coding/neteq4/neteq.cc b/webrtc/modules/audio_coding/neteq4/neteq.cc
index bfcd86a..48dacea 100644
--- a/webrtc/modules/audio_coding/neteq4/neteq.cc
+++ b/webrtc/modules/audio_coding/neteq4/neteq.cc
@@ -32,12 +32,12 @@
BufferLevelFilter* buffer_level_filter = new BufferLevelFilter;
DecoderDatabase* decoder_database = new DecoderDatabase;
DelayPeakDetector* delay_peak_detector = new DelayPeakDetector;
- DelayManager* delay_manager = new DelayManager(kMaxNumPacketsInBuffer,
- delay_peak_detector);
+ DelayManager* delay_manager =
+ new DelayManager(config.max_packets_in_buffer, delay_peak_detector);
+ delay_manager->SetMaximumDelay(config.max_delay_ms);
DtmfBuffer* dtmf_buffer = new DtmfBuffer(config.sample_rate_hz);
DtmfToneGenerator* dtmf_tone_generator = new DtmfToneGenerator;
- PacketBuffer* packet_buffer = new PacketBuffer(kMaxNumPacketsInBuffer,
- kMaxBytesInBuffer);
+ PacketBuffer* packet_buffer = new PacketBuffer(config.max_packets_in_buffer);
PayloadSplitter* payload_splitter = new PayloadSplitter;
TimestampScaler* timestamp_scaler = new TimestampScaler(*decoder_database);
AccelerateFactory* accelerate_factory = new AccelerateFactory;
diff --git a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
index cf73f71..38a5456 100644
--- a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
@@ -364,12 +364,9 @@
}
void NetEqImpl::PacketBufferStatistics(int* current_num_packets,
- int* max_num_packets,
- int* current_memory_size_bytes,
- int* max_memory_size_bytes) const {
+ int* max_num_packets) const {
CriticalSectionScoped lock(crit_sect_.get());
- packet_buffer_->BufferStat(current_num_packets, max_num_packets,
- current_memory_size_bytes, max_memory_size_bytes);
+ packet_buffer_->BufferStat(current_num_packets, max_num_packets);
}
int NetEqImpl::DecodedRtpInfo(int* sequence_number, uint32_t* timestamp) const {
@@ -610,9 +607,6 @@
new_codec_ = true;
update_sample_rate_and_channels = true;
LOG_F(LS_WARNING) << "Packet buffer flushed";
- } else if (ret == PacketBuffer::kOversizePacket) {
- LOG_F(LS_WARNING) << "Packet larger than packet buffer";
- return kOversizePacket;
} else if (ret != PacketBuffer::kOK) {
LOG_FERR1(LS_WARNING, InsertPacketList, packet_list.size());
PacketBuffer::DeleteAllPackets(&packet_list);
diff --git a/webrtc/modules/audio_coding/neteq4/neteq_impl.h b/webrtc/modules/audio_coding/neteq4/neteq_impl.h
index 6fef213..5801d97 100644
--- a/webrtc/modules/audio_coding/neteq4/neteq_impl.h
+++ b/webrtc/modules/audio_coding/neteq4/neteq_impl.h
@@ -186,9 +186,7 @@
virtual void FlushBuffers();
virtual void PacketBufferStatistics(int* current_num_packets,
- int* max_num_packets,
- int* current_memory_size_bytes,
- int* max_memory_size_bytes) const;
+ int* max_num_packets) const;
// Get sequence number and timestamp of the latest RTP.
// This method is to facilitate NACK.
diff --git a/webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc b/webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc
index 15a1c8b..aedd8d5 100644
--- a/webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc
@@ -102,13 +102,13 @@
delay_peak_detector_ = new DelayPeakDetector;
}
if (use_mock_delay_manager_) {
- mock_delay_manager_ = new MockDelayManager(NetEq::kMaxNumPacketsInBuffer,
+ mock_delay_manager_ = new MockDelayManager(config_.max_packets_in_buffer,
delay_peak_detector_);
EXPECT_CALL(*mock_delay_manager_, set_streaming_mode(false)).Times(1);
delay_manager_ = mock_delay_manager_;
} else {
delay_manager_ =
- new DelayManager(NetEq::kMaxNumPacketsInBuffer, delay_peak_detector_);
+ new DelayManager(config_.max_packets_in_buffer, delay_peak_detector_);
}
if (use_mock_dtmf_buffer_) {
mock_dtmf_buffer_ = new MockDtmfBuffer(config_.sample_rate_hz);
@@ -123,12 +123,10 @@
dtmf_tone_generator_ = new DtmfToneGenerator;
}
if (use_mock_packet_buffer_) {
- mock_packet_buffer_ = new MockPacketBuffer(NetEq::kMaxNumPacketsInBuffer,
- NetEq::kMaxBytesInBuffer);
+ mock_packet_buffer_ = new MockPacketBuffer(config_.max_packets_in_buffer);
packet_buffer_ = mock_packet_buffer_;
} else {
- packet_buffer_ = new PacketBuffer(NetEq::kMaxNumPacketsInBuffer,
- NetEq::kMaxBytesInBuffer);
+ packet_buffer_ = new PacketBuffer(config_.max_packets_in_buffer);
}
if (use_mock_payload_splitter_) {
mock_payload_splitter_ = new MockPayloadSplitter;
@@ -381,7 +379,7 @@
neteq_->RegisterPayloadType(kDecoderPCM16B, kPayloadType));
// Insert packets. The buffer should not flush.
- for (int i = 1; i <= NetEq::kMaxNumPacketsInBuffer; ++i) {
+ for (int i = 1; i <= config_.max_packets_in_buffer; ++i) {
EXPECT_EQ(NetEq::kOK,
neteq_->InsertPacket(
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
diff --git a/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc
index 90dc717..93f2567 100644
--- a/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc
@@ -945,18 +945,6 @@
EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError());
}
-TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(OversizePacket)) {
- // Payload size is greater than packet buffer size
- const int kPayloadBytes = NetEq::kMaxBytesInBuffer + 1;
- uint8_t payload[kPayloadBytes] = {0};
- WebRtcRTPHeader rtp_info;
- PopulateRtpInfo(0, 0, &rtp_info);
- rtp_info.header.payloadType = 103; // iSAC, no packet splitting.
- EXPECT_EQ(NetEq::kFail,
- neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
- EXPECT_EQ(NetEq::kOversizePacket, neteq_->LastError());
-}
-
TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) {
const int kPayloadBytes = 100;
uint8_t payload[kPayloadBytes] = {0};
diff --git a/webrtc/modules/audio_coding/neteq4/packet_buffer.cc b/webrtc/modules/audio_coding/neteq4/packet_buffer.cc
index 0cc0854..33ff9a6 100644
--- a/webrtc/modules/audio_coding/neteq4/packet_buffer.cc
+++ b/webrtc/modules/audio_coding/neteq4/packet_buffer.cc
@@ -36,14 +36,8 @@
const Packet* new_packet_;
};
-// Constructor. The arguments define the maximum number of slots and maximum
-// payload memory (excluding RTP headers) that the buffer will accept.
-PacketBuffer::PacketBuffer(size_t max_number_of_packets,
- size_t max_memory_bytes)
- : max_number_of_packets_(max_number_of_packets),
- max_memory_bytes_(max_memory_bytes),
- current_memory_bytes_(0) {
-}
+PacketBuffer::PacketBuffer(size_t max_number_of_packets)
+ : max_number_of_packets_(max_number_of_packets) {}
// Destructor. All packets in the buffer will be destroyed.
PacketBuffer::~PacketBuffer() {
@@ -53,7 +47,6 @@
// Flush the buffer. All packets in the buffer will be destroyed.
void PacketBuffer::Flush() {
DeleteAllPackets(&buffer_);
- current_memory_bytes_ = 0;
}
int PacketBuffer::InsertPacket(Packet* packet) {
@@ -66,22 +59,10 @@
int return_val = kOK;
- if ((buffer_.size() >= max_number_of_packets_) ||
- (current_memory_bytes_ + packet->payload_length
- > static_cast<int>(max_memory_bytes_))) {
+ if (buffer_.size() >= max_number_of_packets_) {
// Buffer is full. Flush it.
Flush();
return_val = kFlushed;
- if ((buffer_.size() >= max_number_of_packets_) ||
- (current_memory_bytes_ + packet->payload_length
- > static_cast<int>(max_memory_bytes_))) {
- // Buffer is still too small for the packet. Either the buffer limits are
- // really small, or the packet is really large. Delete the packet and
- // return an error.
- delete [] packet->payload;
- delete packet;
- return kOversizePacket;
- }
}
// Get an iterator pointing to the place in the buffer where the new packet
@@ -91,7 +72,6 @@
buffer_.rbegin(), buffer_.rend(),
NewTimestampIsLarger(packet));
buffer_.insert(rit.base(), packet); // Insert the packet at that position.
- current_memory_bytes_ += packet->payload_length;
return return_val;
}
@@ -183,8 +163,6 @@
// Assert that the packet sanity checks in InsertPacket method works.
assert(packet && packet->payload);
buffer_.pop_front();
- current_memory_bytes_ -= packet->payload_length;
- assert(current_memory_bytes_ >= 0); // Assert bookkeeping is correct.
// Discard other packets with the same timestamp. These are duplicates or
// redundant payloads that should not be used.
if (discard_count) {
@@ -209,8 +187,6 @@
Packet* temp_packet = buffer_.front();
// Assert that the packet sanity checks in InsertPacket method works.
assert(temp_packet && temp_packet->payload);
- current_memory_bytes_ -= temp_packet->payload_length;
- assert(current_memory_bytes_ >= 0); // Assert bookkeeping is correct.
DeleteFirstPacket(&buffer_);
return kOK;
}
@@ -280,14 +256,9 @@
}
}
-void PacketBuffer::BufferStat(int* num_packets,
- int* max_num_packets,
- int* current_memory_bytes,
- int* max_memory_bytes) const {
+void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const {
*num_packets = static_cast<int>(buffer_.size());
*max_num_packets = static_cast<int>(max_number_of_packets_);
- *current_memory_bytes = current_memory_bytes_;
- *max_memory_bytes = static_cast<int>(max_memory_bytes_);
}
} // namespace webrtc
diff --git a/webrtc/modules/audio_coding/neteq4/packet_buffer.h b/webrtc/modules/audio_coding/neteq4/packet_buffer.h
index e964c28..3d22ad0 100644
--- a/webrtc/modules/audio_coding/neteq4/packet_buffer.h
+++ b/webrtc/modules/audio_coding/neteq4/packet_buffer.h
@@ -29,14 +29,12 @@
kNotFound,
kBufferEmpty,
kInvalidPacket,
- kInvalidPointer,
- kOversizePacket
+ kInvalidPointer
};
// Constructor creates a buffer which can hold a maximum of
- // |max_number_of_packets| packets and |max_payload_memory| bytes of payload,
- // excluding RTP headers.
- PacketBuffer(size_t max_number_of_packets, size_t max_payload_memory);
+ // |max_number_of_packets| packets.
+ PacketBuffer(size_t max_number_of_packets);
// Deletes all packets in the buffer before destroying the buffer.
virtual ~PacketBuffer();
@@ -116,12 +114,7 @@
// The default value for |inc| is 1.
virtual void IncrementWaitingTimes(int inc = 1);
- virtual void BufferStat(int* num_packets,
- int* max_num_packets,
- int* current_memory_bytes,
- int* max_memory_bytes) const;
-
- virtual int current_memory_bytes() const { return current_memory_bytes_; }
+ virtual void BufferStat(int* num_packets, int* max_num_packets) const;
// Static method that properly deletes the first packet, and its payload
// array, in |packet_list|. Returns false if |packet_list| already was empty,
@@ -134,8 +127,6 @@
private:
size_t max_number_of_packets_;
- size_t max_memory_bytes_;
- int current_memory_bytes_;
PacketList buffer_;
DISALLOW_COPY_AND_ASSIGN(PacketBuffer);
};
diff --git a/webrtc/modules/audio_coding/neteq4/packet_buffer_unittest.cc b/webrtc/modules/audio_coding/neteq4/packet_buffer_unittest.cc
index c8109dc..387ca14 100644
--- a/webrtc/modules/audio_coding/neteq4/packet_buffer_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq4/packet_buffer_unittest.cc
@@ -70,13 +70,13 @@
// Start of test definitions.
TEST(PacketBuffer, CreateAndDestroy) {
- PacketBuffer* buffer = new PacketBuffer(10, 1000); // 10 packets, 1000 bytes.
+ PacketBuffer* buffer = new PacketBuffer(10); // 10 packets.
EXPECT_TRUE(buffer->Empty());
delete buffer;
}
TEST(PacketBuffer, InsertPacket) {
- PacketBuffer buffer(10, 1000); // 10 packets, 1000 bytes.
+ PacketBuffer buffer(10); // 10 packets.
PacketGenerator gen(17u, 4711u, 0, 10);
const int payload_len = 100;
@@ -88,7 +88,6 @@
EXPECT_EQ(4711u, next_ts);
EXPECT_FALSE(buffer.Empty());
EXPECT_EQ(1, buffer.NumPacketsInBuffer());
- EXPECT_EQ(payload_len, buffer.current_memory_bytes());
const RTPHeader* hdr = buffer.NextRtpHeader();
EXPECT_EQ(&(packet->header), hdr); // Compare pointer addresses.
@@ -98,7 +97,7 @@
// Test to flush buffer.
TEST(PacketBuffer, FlushBuffer) {
- PacketBuffer buffer(10, 1000); // 10 packets, 1000 bytes.
+ PacketBuffer buffer(10); // 10 packets.
PacketGenerator gen(0, 0, 0, 10);
const int payload_len = 10;
@@ -109,18 +108,16 @@
}
EXPECT_EQ(10, buffer.NumPacketsInBuffer());
EXPECT_FALSE(buffer.Empty());
- EXPECT_EQ(10 * payload_len, buffer.current_memory_bytes());
buffer.Flush();
// Buffer should delete the payloads itself.
EXPECT_EQ(0, buffer.NumPacketsInBuffer());
EXPECT_TRUE(buffer.Empty());
- EXPECT_EQ(0, buffer.current_memory_bytes());
}
// Test to fill the buffer over the limits, and verify that it flushes.
TEST(PacketBuffer, OverfillBuffer) {
- PacketBuffer buffer(10, 1000); // 10 packets, 1000 bytes.
+ PacketBuffer buffer(10); // 10 packets.
PacketGenerator gen(0, 0, 0, 10);
// Insert 10 small packets; should be ok.
@@ -131,7 +128,6 @@
EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacket(packet));
}
EXPECT_EQ(10, buffer.NumPacketsInBuffer());
- EXPECT_EQ(10 * payload_len, buffer.current_memory_bytes());
uint32_t next_ts;
EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts));
EXPECT_EQ(0u, next_ts); // Expect first inserted packet to be first in line.
@@ -140,30 +136,17 @@
Packet* packet = gen.NextPacket(payload_len);
EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacket(packet));
EXPECT_EQ(1, buffer.NumPacketsInBuffer());
- EXPECT_EQ(payload_len, buffer.current_memory_bytes());
EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts));
// Expect last inserted packet to be first in line.
EXPECT_EQ(packet->header.timestamp, next_ts);
- // Insert 2 large packets; expect to flush when inserting the second one.
- const int large_payload_len = 500;
- packet = gen.NextPacket(large_payload_len);
- EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacket(packet));
- EXPECT_EQ(2, buffer.NumPacketsInBuffer());
- EXPECT_EQ(payload_len + large_payload_len, buffer.current_memory_bytes());
-
- packet = gen.NextPacket(large_payload_len);
- EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacket(packet));
- EXPECT_EQ(1, buffer.NumPacketsInBuffer());
- EXPECT_EQ(large_payload_len, buffer.current_memory_bytes());
-
- // Flush buffer to delete remaining packets.
+ // Flush buffer to delete all packets.
buffer.Flush();
}
// Test inserting a list of packets.
TEST(PacketBuffer, InsertPacketList) {
- PacketBuffer buffer(10, 1000); // 10 packets, 1000 bytes.
+ PacketBuffer buffer(10); // 10 packets.
PacketGenerator gen(0, 0, 0, 10);
PacketList list;
const int payload_len = 10;
@@ -187,7 +170,6 @@
¤t_cng_pt));
EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
EXPECT_EQ(10, buffer.NumPacketsInBuffer());
- EXPECT_EQ(10 * payload_len, buffer.current_memory_bytes());
EXPECT_EQ(0, current_pt); // Current payload type changed to 0.
EXPECT_EQ(0xFF, current_cng_pt); // CNG payload type not changed.
@@ -200,7 +182,7 @@
// Expecting the buffer to flush.
// TODO(hlundin): Remove this test when legacy operation is no longer needed.
TEST(PacketBuffer, InsertPacketListChangePayloadType) {
- PacketBuffer buffer(10, 1000); // 10 packets, 1000 bytes.
+ PacketBuffer buffer(10); // 10 packets.
PacketGenerator gen(0, 0, 0, 10);
PacketList list;
const int payload_len = 10;
@@ -229,7 +211,6 @@
¤t_cng_pt));
EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
EXPECT_EQ(1, buffer.NumPacketsInBuffer()); // Only the last packet.
- EXPECT_EQ(1 * payload_len, buffer.current_memory_bytes());
EXPECT_EQ(1, current_pt); // Current payload type changed to 0.
EXPECT_EQ(0xFF, current_cng_pt); // CNG payload type not changed.
@@ -252,7 +233,7 @@
// 8 0x0005 0x00000028 0x0000001E
// 9 0x0006 0x00000032 0x00000028
TEST(PacketBuffer, ExtractOrderRedundancy) {
- PacketBuffer buffer(100, 1000); // 100 packets, 1000 bytes.
+ PacketBuffer buffer(100); // 100 packets.
const uint32_t ts_increment = 10; // Samples per packet.
const uint16_t start_seq_no = 0xFFFF - 2; // Wraps after 3 packets.
const uint32_t start_ts = 0xFFFFFFFF -
@@ -321,7 +302,7 @@
}
TEST(PacketBuffer, DiscardPackets) {
- PacketBuffer buffer(100, 1000); // 100 packets, 1000 bytes.
+ PacketBuffer buffer(100); // 100 packets.
const uint16_t start_seq_no = 17;
const uint32_t start_ts = 4711;
const uint32_t ts_increment = 10;
@@ -335,7 +316,6 @@
buffer.InsertPacket(packet);
}
EXPECT_EQ(10, buffer.NumPacketsInBuffer());
- EXPECT_EQ(10 * payload_len, buffer.current_memory_bytes());
// Discard them one by one and make sure that the right packets are at the
// front of the buffer.
@@ -351,7 +331,7 @@
}
TEST(PacketBuffer, Reordering) {
- PacketBuffer buffer(100, 1000); // 100 packets, 1000 bytes.
+ PacketBuffer buffer(100); // 100 packets.
const uint16_t start_seq_no = 17;
const uint32_t start_ts = 4711;
const uint32_t ts_increment = 10;
@@ -384,7 +364,6 @@
¤t_pt,
¤t_cng_pt));
EXPECT_EQ(10, buffer.NumPacketsInBuffer());
- EXPECT_EQ(10 * payload_len, buffer.current_memory_bytes());
// Extract them and make sure that come out in the right order.
uint32_t current_ts = start_ts;
@@ -408,18 +387,8 @@
int payload_len = 100;
PacketGenerator gen(start_seq_no, start_ts, 0, ts_increment);
- PacketBuffer* buffer = new PacketBuffer(0, 1000); // 0 packets, 1000 bytes.
- Packet* packet = gen.NextPacket(payload_len);
- EXPECT_EQ(PacketBuffer::kOversizePacket, buffer->InsertPacket(packet));
- delete buffer;
-
- buffer = new PacketBuffer(100, 10); // 100 packets, 10 bytes.
- packet = gen.NextPacket(payload_len);
- EXPECT_EQ(PacketBuffer::kOversizePacket, buffer->InsertPacket(packet));
- delete buffer;
-
- buffer = new PacketBuffer(100, 10000); // 100 packets, 10000 bytes.
- packet = NULL;
+ PacketBuffer* buffer = new PacketBuffer(100); // 100 packets.
+ Packet* packet = NULL;
EXPECT_EQ(PacketBuffer::kInvalidPacket, buffer->InsertPacket(packet));
packet = gen.NextPacket(payload_len);
delete [] packet->payload;
@@ -448,7 +417,7 @@
// 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
// discarded.
- buffer = new PacketBuffer(100, 1000); // 100 packets, 1000 bytes.
+ buffer = new PacketBuffer(100); // 100 packets.
PacketList list;
list.push_back(gen.NextPacket(payload_len)); // Valid packet.
packet = gen.NextPacket(payload_len);