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

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

Issue 2326953003: Added a ParsePayload method to AudioDecoder. (Closed)
Patch Set: Added some casts from size_t to int. Created 4 years, 3 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
« no previous file with comments | « webrtc/modules/audio_coding/neteq/packet_buffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1c8713c48744e3d77b195ff24007d3d11e2a66e6..c5b23dce068c3df75b816579b2964500fd828b7d 100644
--- a/webrtc/modules/audio_coding/neteq/packet_buffer.cc
+++ b/webrtc/modules/audio_coding/neteq/packet_buffer.cc
@@ -68,7 +68,7 @@ bool PacketBuffer::Empty() const {
}
int PacketBuffer::InsertPacket(Packet* packet) {
- if (!packet || packet->payload.empty()) {
+ if (!packet || packet->empty()) {
if (packet) {
delete packet;
}
@@ -209,7 +209,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.empty());
+ RTC_DCHECK(packet && !packet->empty());
buffer_.pop_front();
// Discard other packets with the same timestamp. These are duplicates or
@@ -237,8 +237,8 @@ int PacketBuffer::DiscardNextPacket() {
return kBufferEmpty;
}
// Assert that the packet sanity checks in InsertPacket method works.
- assert(buffer_.front());
- assert(!buffer_.front()->payload.empty());
+ RTC_DCHECK(buffer_.front());
+ RTC_DCHECK(!buffer_.front()->empty());
DeleteFirstPacket(&buffer_);
return kOK;
}
@@ -260,26 +260,32 @@ int PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit) {
return DiscardOldPackets(timestamp_limit, 0);
}
+void PacketBuffer::DiscardPacketsWithPayloadType(uint8_t payload_type) {
+ for (auto it = buffer_.begin(); it != buffer_.end(); /* */) {
+ Packet *packet = *it;
+ if (packet->header.payloadType == payload_type) {
+ delete packet;
+ it = buffer_.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+
size_t PacketBuffer::NumPacketsInBuffer() const {
return buffer_.size();
}
-size_t PacketBuffer::NumSamplesInBuffer(DecoderDatabase* decoder_database,
- size_t last_decoded_length) const {
- PacketList::const_iterator it;
+size_t PacketBuffer::NumSamplesInBuffer(size_t last_decoded_length) const {
size_t num_samples = 0;
size_t last_duration = last_decoded_length;
- for (it = buffer_.begin(); it != buffer_.end(); ++it) {
- Packet* packet = (*it);
- AudioDecoder* decoder =
- decoder_database->GetDecoder(packet->header.payloadType);
- if (decoder) {
+ for (Packet* packet : buffer_) {
+ if (packet->frame) {
if (!packet->primary) {
continue;
}
- int duration = decoder->PacketDuration(packet->payload.data(),
- packet->payload.size());
- if (duration >= 0) {
+ size_t duration = packet->frame->Duration();
+ if (duration > 0) {
last_duration = duration; // Save the most up-to-date (valid) duration.
}
}
« no previous file with comments | « webrtc/modules/audio_coding/neteq/packet_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698