| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 rtc::MsanMarkUninitialized(rtc::MakeArrayView(&ci, 1)); | 450 rtc::MsanMarkUninitialized(rtc::MakeArrayView(&ci, 1)); |
| 451 ci.pltype = payload_type; | 451 ci.pltype = payload_type; |
| 452 std::strncpy(ci.plname, di->name.c_str(), sizeof(ci.plname)); | 452 std::strncpy(ci.plname, di->name.c_str(), sizeof(ci.plname)); |
| 453 ci.plname[sizeof(ci.plname) - 1] = '\0'; | 453 ci.plname[sizeof(ci.plname) - 1] = '\0'; |
| 454 ci.plfreq = di->IsRed() || di->IsDtmf() ? 8000 : di->SampleRateHz(); | 454 ci.plfreq = di->IsRed() || di->IsDtmf() ? 8000 : di->SampleRateHz(); |
| 455 AudioDecoder* const decoder = di->GetDecoder(); | 455 AudioDecoder* const decoder = di->GetDecoder(); |
| 456 ci.channels = decoder ? decoder->Channels() : 1; | 456 ci.channels = decoder ? decoder->Channels() : 1; |
| 457 return rtc::Optional<CodecInst>(ci); | 457 return rtc::Optional<CodecInst>(ci); |
| 458 } | 458 } |
| 459 | 459 |
| 460 const SdpAudioFormat* NetEqImpl::GetDecoderFormat(int payload_type) const { | 460 rtc::Optional<SdpAudioFormat> NetEqImpl::GetDecoderFormat( |
| 461 int payload_type) const { |
| 461 rtc::CritScope lock(&crit_sect_); | 462 rtc::CritScope lock(&crit_sect_); |
| 462 const DecoderDatabase::DecoderInfo* const di = | 463 const DecoderDatabase::DecoderInfo* const di = |
| 463 decoder_database_->GetDecoderInfo(payload_type); | 464 decoder_database_->GetDecoderInfo(payload_type); |
| 464 if (!di) { | 465 if (!di) { |
| 465 return nullptr; // Payload type not registered. | 466 return rtc::Optional<SdpAudioFormat>(); // Payload type not registered. |
| 466 } | 467 } |
| 467 // This will return null if the payload type was registered without an | 468 return rtc::Optional<SdpAudioFormat>(di->GetFormat()); |
| 468 // SdpAudioFormat. | |
| 469 return di->GetFormat(); | |
| 470 } | 469 } |
| 471 | 470 |
| 472 int NetEqImpl::SetTargetNumberOfChannels() { | 471 int NetEqImpl::SetTargetNumberOfChannels() { |
| 473 return kNotImplemented; | 472 return kNotImplemented; |
| 474 } | 473 } |
| 475 | 474 |
| 476 int NetEqImpl::SetTargetSampleRate() { | 475 int NetEqImpl::SetTargetSampleRate() { |
| 477 return kNotImplemented; | 476 return kNotImplemented; |
| 478 } | 477 } |
| 479 | 478 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 RTC_DCHECK(nack_); | 773 RTC_DCHECK(nack_); |
| 775 // Update the sample rate even if the rate is not new, because of Reset(). | 774 // Update the sample rate even if the rate is not new, because of Reset(). |
| 776 nack_->UpdateSampleRate(fs_hz_); | 775 nack_->UpdateSampleRate(fs_hz_); |
| 777 } | 776 } |
| 778 } | 777 } |
| 779 | 778 |
| 780 // TODO(hlundin): Move this code to DelayManager class. | 779 // TODO(hlundin): Move this code to DelayManager class. |
| 781 const DecoderDatabase::DecoderInfo* dec_info = | 780 const DecoderDatabase::DecoderInfo* dec_info = |
| 782 decoder_database_->GetDecoderInfo(main_header.payloadType); | 781 decoder_database_->GetDecoderInfo(main_header.payloadType); |
| 783 assert(dec_info); // Already checked that the payload type is known. | 782 assert(dec_info); // Already checked that the payload type is known. |
| 784 delay_manager_->LastDecoderType(dec_info->codec_type); | 783 delay_manager_->LastDecodedWasCngOrDtmf(dec_info->IsComfortNoise() || |
| 784 dec_info->IsDtmf()); |
| 785 if (delay_manager_->last_pack_cng_or_dtmf() == 0) { | 785 if (delay_manager_->last_pack_cng_or_dtmf() == 0) { |
| 786 // Calculate the total speech length carried in each packet. | 786 // Calculate the total speech length carried in each packet. |
| 787 const size_t buffer_length_after_insert = | 787 const size_t buffer_length_after_insert = |
| 788 packet_buffer_->NumPacketsInBuffer(); | 788 packet_buffer_->NumPacketsInBuffer(); |
| 789 | 789 |
| 790 if (buffer_length_after_insert > buffer_length_before_insert) { | 790 if (buffer_length_after_insert > buffer_length_before_insert) { |
| 791 const size_t packet_length_samples = | 791 const size_t packet_length_samples = |
| 792 (buffer_length_after_insert - buffer_length_before_insert) * | 792 (buffer_length_after_insert - buffer_length_before_insert) * |
| 793 decoder_frame_length_; | 793 decoder_frame_length_; |
| 794 if (packet_length_samples != decision_logic_->packet_length_samples()) { | 794 if (packet_length_samples != decision_logic_->packet_length_samples()) { |
| (...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 } | 2109 } |
| 2110 } | 2110 } |
| 2111 | 2111 |
| 2112 void NetEqImpl::CreateDecisionLogic() { | 2112 void NetEqImpl::CreateDecisionLogic() { |
| 2113 decision_logic_.reset(DecisionLogic::Create( | 2113 decision_logic_.reset(DecisionLogic::Create( |
| 2114 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), | 2114 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), |
| 2115 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), | 2115 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), |
| 2116 tick_timer_.get())); | 2116 tick_timer_.get())); |
| 2117 } | 2117 } |
| 2118 } // namespace webrtc | 2118 } // namespace webrtc |
| OLD | NEW |