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

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

Issue 2307493002: NetEq: Flush and reset if the speech and cng sample rates mismatch (Closed)
Patch Set: Changing names again 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 | « no previous file | webrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc » ('j') | 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 0e512b64d1277a43c91a03f3e230b5e08265ab2a..ba469a6cd683f3d77ca05d8cd427f7cfaa66c88f 100644
--- a/webrtc/modules/audio_coding/neteq/packet_buffer.cc
+++ b/webrtc/modules/audio_coding/neteq/packet_buffer.cc
@@ -22,7 +22,7 @@
#include "webrtc/modules/audio_coding/neteq/tick_timer.h"
namespace webrtc {
-
+namespace {
// Predicate used when inserting packets in the buffer list.
// Operator() returns true when |packet| goes before |new_packet|.
class NewTimestampIsLarger {
@@ -38,6 +38,17 @@ class NewTimestampIsLarger {
const Packet* new_packet_;
};
+// Returns true if both payload types are known to the decoder database, and
+// have the same sample rate.
+bool EqualSampleRates(uint8_t pt1,
+ uint8_t pt2,
+ const DecoderDatabase& decoder_database) {
+ auto di1 = decoder_database.GetDecoderInfo(pt1);
+ auto di2 = decoder_database.GetDecoderInfo(pt2);
+ return di1 && di2 && di1->SampleRateHz() == di2->SampleRateHz();
+}
+} // namespace
+
PacketBuffer::PacketBuffer(size_t max_number_of_packets,
const TickTimer* tick_timer)
: max_number_of_packets_(max_number_of_packets), tick_timer_(tick_timer) {}
@@ -126,8 +137,12 @@ int PacketBuffer::InsertPacketList(
rtc::Optional<uint8_t>(packet->header.payloadType);
} else if (!decoder_database.IsDtmf(packet->header.payloadType)) {
// This must be speech.
- if (*current_rtp_payload_type &&
- **current_rtp_payload_type != packet->header.payloadType) {
+ if ((*current_rtp_payload_type &&
+ **current_rtp_payload_type != packet->header.payloadType) ||
+ (*current_cng_rtp_payload_type &&
+ !EqualSampleRates(packet->header.payloadType,
+ **current_cng_rtp_payload_type,
+ decoder_database))) {
*current_cng_rtp_payload_type = rtc::Optional<uint8_t>();
Flush();
flushed = true;
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698