NetEq: Changed Packet::payload to be an rtc::Buffer

That is, rather than keeping a separate pointer and size.
This helps automate memory management in NetEq and will be useful in the
work to minimize the AudioDecoder interface as part of the injectable
audio codec work.

I'm planning a follow-up that will change the current management of Packet* to wrapping them in unique_ptr instead.

Review-Url: https://codereview.webrtc.org/2289093003
Cr-Commit-Position: refs/heads/master@{#14002}
This commit is contained in:
ossu
2016-08-31 08:51:13 -07:00
committed by Commit bot
parent 5955e24fe8
commit dc431ce07e
7 changed files with 102 additions and 163 deletions

View File

@ -59,9 +59,8 @@ Packet* PacketGenerator::NextPacket(int payload_size_bytes) {
packet->header.ssrc = 0x12345678;
packet->header.numCSRCs = 0;
packet->header.paddingLength = 0;
packet->payload_length = payload_size_bytes;
packet->primary = true;
packet->payload = new uint8_t[payload_size_bytes];
packet->payload.SetSize(payload_size_bytes);
++seq_no_;
ts_ += frame_size_;
return packet;
@ -284,7 +283,6 @@ TEST(PacketBuffer, ExtractOrderRedundancy) {
Packet* packet = buffer.GetNextPacket(&drop_count);
EXPECT_EQ(0u, drop_count);
EXPECT_EQ(packet, expect_order[i]); // Compare pointer addresses.
delete[] packet->payload;
delete packet;
}
EXPECT_TRUE(buffer.Empty());
@ -359,7 +357,6 @@ TEST(PacketBuffer, Reordering) {
ASSERT_FALSE(packet == NULL);
EXPECT_EQ(current_ts, packet->header.timestamp);
current_ts += ts_increment;
delete [] packet->payload;
delete packet;
}
EXPECT_TRUE(buffer.Empty());
@ -379,8 +376,7 @@ TEST(PacketBuffer, Failures) {
Packet* packet = NULL;
EXPECT_EQ(PacketBuffer::kInvalidPacket, buffer->InsertPacket(packet));
packet = gen.NextPacket(payload_len);
delete [] packet->payload;
packet->payload = NULL;
packet->payload.Clear();
EXPECT_EQ(PacketBuffer::kInvalidPacket, buffer->InsertPacket(packet));
// Packet is deleted by the PacketBuffer.
@ -409,8 +405,7 @@ TEST(PacketBuffer, Failures) {
PacketList list;
list.push_back(gen.NextPacket(payload_len)); // Valid packet.
packet = gen.NextPacket(payload_len);
delete [] packet->payload;
packet->payload = NULL; // Invalid.
packet->payload.Clear(); // Invalid.
list.push_back(packet);
list.push_back(gen.NextPacket(payload_len)); // Valid packet.
MockDecoderDatabase decoder_database;
@ -486,9 +481,7 @@ TEST(PacketBuffer, ComparePackets) {
EXPECT_FALSE(*a <= *b);
EXPECT_TRUE(*a >= *b);
delete [] a->payload;
delete a;
delete [] b->payload;
delete b;
}