OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 RTC_DCHECK(nack_); | 1971 RTC_DCHECK(nack_); |
1972 // TODO(henrik.lundin): Should we update this for all decoded packets? | 1972 // TODO(henrik.lundin): Should we update this for all decoded packets? |
1973 nack_->UpdateLastDecodedPacket(packet->sequence_number, | 1973 nack_->UpdateLastDecodedPacket(packet->sequence_number, |
1974 packet->timestamp); | 1974 packet->timestamp); |
1975 } | 1975 } |
1976 prev_sequence_number = packet->sequence_number; | 1976 prev_sequence_number = packet->sequence_number; |
1977 prev_timestamp = packet->timestamp; | 1977 prev_timestamp = packet->timestamp; |
1978 prev_payload_type = packet->payload_type; | 1978 prev_payload_type = packet->payload_type; |
1979 } | 1979 } |
1980 | 1980 |
| 1981 const bool has_cng_packet = |
| 1982 decoder_database_->IsComfortNoise(packet->payload_type); |
1981 // Store number of extracted samples. | 1983 // Store number of extracted samples. |
1982 size_t packet_duration = 0; | 1984 size_t packet_duration = 0; |
1983 if (packet->frame) { | 1985 if (packet->frame) { |
1984 packet_duration = packet->frame->Duration(); | 1986 packet_duration = packet->frame->Duration(); |
1985 // TODO(ossu): Is this the correct way to track Opus FEC packets? | 1987 // TODO(ossu): Is this the correct way to track Opus FEC packets? |
1986 if (packet->priority.codec_level > 0) { | 1988 if (packet->priority.codec_level > 0) { |
1987 stats_.SecondaryDecodedSamples(rtc::checked_cast<int>(packet_duration)); | 1989 stats_.SecondaryDecodedSamples(rtc::checked_cast<int>(packet_duration)); |
1988 } | 1990 } |
1989 } else if (!decoder_database_->IsComfortNoise(packet->payload_type)) { | 1991 } else if (!has_cng_packet) { |
1990 LOG(LS_WARNING) << "Unknown payload type " | 1992 LOG(LS_WARNING) << "Unknown payload type " |
1991 << static_cast<int>(packet->payload_type); | 1993 << static_cast<int>(packet->payload_type); |
1992 RTC_NOTREACHED(); | 1994 RTC_NOTREACHED(); |
1993 } | 1995 } |
1994 | 1996 |
1995 if (packet_duration == 0) { | 1997 if (packet_duration == 0) { |
1996 // Decoder did not return a packet duration. Assume that the packet | 1998 // Decoder did not return a packet duration. Assume that the packet |
1997 // contains the same number of samples as the previous one. | 1999 // contains the same number of samples as the previous one. |
1998 packet_duration = decoder_frame_length_; | 2000 packet_duration = decoder_frame_length_; |
1999 } | 2001 } |
2000 extracted_samples = packet->timestamp - first_timestamp + packet_duration; | 2002 extracted_samples = packet->timestamp - first_timestamp + packet_duration; |
2001 | 2003 |
2002 packet_list->push_back(std::move(*packet)); // Store packet in list. | 2004 packet_list->push_back(std::move(*packet)); // Store packet in list. |
2003 packet = rtc::Optional<Packet>(); // Ensure it's never used after the move. | 2005 packet = rtc::Optional<Packet>(); // Ensure it's never used after the move. |
2004 | 2006 |
2005 // Check what packet is available next. | 2007 // Check what packet is available next. |
2006 next_packet = packet_buffer_->PeekNextPacket(); | 2008 next_packet = packet_buffer_->PeekNextPacket(); |
2007 next_packet_available = false; | 2009 next_packet_available = false; |
2008 if (next_packet && prev_payload_type == next_packet->payload_type) { | 2010 if (next_packet && prev_payload_type == next_packet->payload_type && |
| 2011 !has_cng_packet) { |
2009 int16_t seq_no_diff = next_packet->sequence_number - prev_sequence_number; | 2012 int16_t seq_no_diff = next_packet->sequence_number - prev_sequence_number; |
2010 size_t ts_diff = next_packet->timestamp - prev_timestamp; | 2013 size_t ts_diff = next_packet->timestamp - prev_timestamp; |
2011 if (seq_no_diff == 1 || | 2014 if (seq_no_diff == 1 || |
2012 (seq_no_diff == 0 && ts_diff == decoder_frame_length_)) { | 2015 (seq_no_diff == 0 && ts_diff == decoder_frame_length_)) { |
2013 // The next sequence number is available, or the next part of a packet | 2016 // The next sequence number is available, or the next part of a packet |
2014 // that was split into pieces upon insertion. | 2017 // that was split into pieces upon insertion. |
2015 next_packet_available = true; | 2018 next_packet_available = true; |
2016 } | 2019 } |
2017 prev_sequence_number = next_packet->sequence_number; | 2020 prev_sequence_number = next_packet->sequence_number; |
2018 } | 2021 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2126 } | 2129 } |
2127 } | 2130 } |
2128 | 2131 |
2129 void NetEqImpl::CreateDecisionLogic() { | 2132 void NetEqImpl::CreateDecisionLogic() { |
2130 decision_logic_.reset(DecisionLogic::Create( | 2133 decision_logic_.reset(DecisionLogic::Create( |
2131 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), | 2134 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), |
2132 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), | 2135 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), |
2133 tick_timer_.get())); | 2136 tick_timer_.get())); |
2134 } | 2137 } |
2135 } // namespace webrtc | 2138 } // namespace webrtc |
OLD | NEW |