Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1250)

Unified Diff: webrtc/modules/audio_coding/neteq/packet_buffer.cc

Issue 2289093003: NetEq: Changed Packet::payload to be an rtc::Buffer (Closed)
Patch Set: Changed Buffer constructor calls to SetData or SetSize Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/neteq/packet_buffer.cc
diff --git a/webrtc/modules/audio_coding/neteq/packet_buffer.cc b/webrtc/modules/audio_coding/neteq/packet_buffer.cc
index f1b898e34cf079f2590a823643ea9374fb13c94b..517db0a39d6b576ac39eab478c96b6cf01cff288 100644
--- a/webrtc/modules/audio_coding/neteq/packet_buffer.cc
+++ b/webrtc/modules/audio_coding/neteq/packet_buffer.cc
@@ -57,7 +57,7 @@ bool PacketBuffer::Empty() const {
}
int PacketBuffer::InsertPacket(Packet* packet) {
- if (!packet || !packet->payload) {
+ if (!packet || packet->payload.empty()) {
if (packet) {
delete packet;
}
@@ -88,7 +88,6 @@ int PacketBuffer::InsertPacket(Packet* packet) {
// packet to list.
if (rit != buffer_.rend() &&
packet->header.timestamp == (*rit)->header.timestamp) {
- delete [] packet->payload;
delete packet;
return return_val;
}
@@ -99,7 +98,6 @@ int PacketBuffer::InsertPacket(Packet* packet) {
PacketList::iterator it = rit.base();
if (it != buffer_.end() &&
packet->header.timestamp == (*it)->header.timestamp) {
- delete [] (*it)->payload;
delete *it;
it = buffer_.erase(it);
}
@@ -193,7 +191,7 @@ Packet* PacketBuffer::GetNextPacket(size_t* discard_count) {
Packet* packet = buffer_.front();
// Assert that the packet sanity checks in InsertPacket method works.
- assert(packet && packet->payload);
+ assert(packet && !packet->payload.empty());
buffer_.pop_front();
// Discard other packets with the same timestamp. These are duplicates or
@@ -222,7 +220,7 @@ int PacketBuffer::DiscardNextPacket() {
}
// Assert that the packet sanity checks in InsertPacket method works.
assert(buffer_.front());
- assert(buffer_.front()->payload);
+ assert(!buffer_.front()->payload.empty());
DeleteFirstPacket(&buffer_);
return kOK;
}
@@ -261,8 +259,8 @@ size_t PacketBuffer::NumSamplesInBuffer(DecoderDatabase* decoder_database,
if (!packet->primary) {
continue;
}
- int duration =
- decoder->PacketDuration(packet->payload, packet->payload_length);
+ int duration = decoder->PacketDuration(packet->payload.data(),
+ packet->payload.size());
if (duration >= 0) {
last_duration = duration; // Save the most up-to-date (valid) duration.
}
@@ -277,7 +275,6 @@ bool PacketBuffer::DeleteFirstPacket(PacketList* packet_list) {
return false;
}
Packet* first_packet = packet_list->front();
- delete [] first_packet->payload;
delete first_packet;
packet_list->pop_front();
return true;

Powered by Google App Engine
This is Rietveld 408576698