Avoid NetEq triggering a Framelength change when receiving an FEC packet.
Internally in NetEq, an FEC packet looks very similar to a split packet, which caused NetEq to miscalculate the frame length of FEC packets. This incorrect framelength calculation was incorrectly handled as a framelength change by NetEq.
Bug: webrtc:8410
Change-Id: Icaea961d055e49d7726b87811881db0b9149805b
Reviewed-on: https://webrtc-review.googlesource.com/12420
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20373}
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 36d6b27..e7757ae 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -730,9 +730,12 @@
}
}
+ // Calculate the number of primary (non-FEC/RED) packets.
+ const int number_of_primary_packets = std::count_if(
+ parsed_packet_list.begin(), parsed_packet_list.end(),
+ [](const Packet& in) { return in.priority.codec_level == 0; });
+
// Insert packets in buffer.
- const size_t buffer_length_before_insert =
- packet_buffer_->NumPacketsInBuffer();
const int ret = packet_buffer_->InsertPacketList(
&parsed_packet_list, *decoder_database_, ¤t_rtp_payload_type_,
¤t_cng_rtp_payload_type_, &stats_);
@@ -795,13 +798,9 @@
dec_info->IsDtmf());
if (delay_manager_->last_pack_cng_or_dtmf() == 0) {
// Calculate the total speech length carried in each packet.
- const size_t buffer_length_after_insert =
- packet_buffer_->NumPacketsInBuffer();
-
- if (buffer_length_after_insert > buffer_length_before_insert) {
+ if (number_of_primary_packets > 0) {
const size_t packet_length_samples =
- (buffer_length_after_insert - buffer_length_before_insert) *
- decoder_frame_length_;
+ number_of_primary_packets * decoder_frame_length_;
if (packet_length_samples != decision_logic_->packet_length_samples()) {
decision_logic_->set_packet_length_samples(packet_length_samples);
delay_manager_->SetPacketAudioLength(