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..77c4578a6f4b343258b098f2659490c98a576252 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,19 @@ class NewTimestampIsLarger { |
const Packet* new_packet_; |
}; |
+// Returns true if either payload types is empty; or if both payload types are |
minyue-webrtc
2016/09/01 09:35:32
"Returns true if either payload types is empty" ca
hlundin-webrtc
2016/09/01 10:31:10
Done.
|
+// known to the decoder database, and have the same sample rate. |
+bool EqualSampleRates(rtc::Optional<uint8_t> pt1, |
+ rtc::Optional<uint8_t> pt2, |
+ const DecoderDatabase& decoder_database) { |
+ if (!pt1 || !pt2) |
+ return true; |
+ 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 +139,10 @@ 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) || |
+ !EqualSampleRates(rtc::Optional<uint8_t>(packet->header.payloadType), |
+ *current_cng_rtp_payload_type, decoder_database)) { |
*current_cng_rtp_payload_type = rtc::Optional<uint8_t>(); |
Flush(); |
flushed = true; |