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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 assert(decoder); // Should always get a valid object, since we have | 592 assert(decoder); // Should always get a valid object, since we have |
593 // already checked that the payload types are known. | 593 // already checked that the payload types are known. |
594 decoder->IncomingPacket(packet_list.front()->payload, | 594 decoder->IncomingPacket(packet_list.front()->payload, |
595 packet_list.front()->payload_length, | 595 packet_list.front()->payload_length, |
596 packet_list.front()->header.sequenceNumber, | 596 packet_list.front()->header.sequenceNumber, |
597 packet_list.front()->header.timestamp, | 597 packet_list.front()->header.timestamp, |
598 receive_timestamp); | 598 receive_timestamp); |
599 } | 599 } |
600 | 600 |
601 // Insert packets in buffer. | 601 // Insert packets in buffer. |
602 size_t temp_bufsize = packet_buffer_->NumPacketsInBuffer(); | 602 const size_t buffer_length_before_insert = |
603 packet_buffer_->NumPacketsInBuffer(); | |
603 ret = packet_buffer_->InsertPacketList( | 604 ret = packet_buffer_->InsertPacketList( |
604 &packet_list, | 605 &packet_list, |
605 *decoder_database_, | 606 *decoder_database_, |
606 ¤t_rtp_payload_type_, | 607 ¤t_rtp_payload_type_, |
607 ¤t_cng_rtp_payload_type_); | 608 ¤t_cng_rtp_payload_type_); |
608 if (ret == PacketBuffer::kFlushed) { | 609 if (ret == PacketBuffer::kFlushed) { |
609 // Reset DSP timestamp etc. if packet buffer flushed. | 610 // Reset DSP timestamp etc. if packet buffer flushed. |
610 new_codec_ = true; | 611 new_codec_ = true; |
611 update_sample_rate_and_channels = true; | 612 update_sample_rate_and_channels = true; |
612 } else if (ret != PacketBuffer::kOK) { | 613 } else if (ret != PacketBuffer::kOK) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 SetSampleRateAndChannels(decoder_info->fs_hz, decoder->Channels()); | 649 SetSampleRateAndChannels(decoder_info->fs_hz, decoder->Channels()); |
649 } | 650 } |
650 | 651 |
651 // TODO(hlundin): Move this code to DelayManager class. | 652 // TODO(hlundin): Move this code to DelayManager class. |
652 const DecoderDatabase::DecoderInfo* dec_info = | 653 const DecoderDatabase::DecoderInfo* dec_info = |
653 decoder_database_->GetDecoderInfo(main_header.payloadType); | 654 decoder_database_->GetDecoderInfo(main_header.payloadType); |
654 assert(dec_info); // Already checked that the payload type is known. | 655 assert(dec_info); // Already checked that the payload type is known. |
655 delay_manager_->LastDecoderType(dec_info->codec_type); | 656 delay_manager_->LastDecoderType(dec_info->codec_type); |
656 if (delay_manager_->last_pack_cng_or_dtmf() == 0) { | 657 if (delay_manager_->last_pack_cng_or_dtmf() == 0) { |
657 // Calculate the total speech length carried in each packet. | 658 // Calculate the total speech length carried in each packet. |
658 temp_bufsize = packet_buffer_->NumPacketsInBuffer() - temp_bufsize; | 659 const size_t buffer_length_after_insert = |
659 temp_bufsize *= decoder_frame_length_; | 660 packet_buffer_->NumPacketsInBuffer(); |
660 | 661 |
661 if ((temp_bufsize > 0) && | 662 if (buffer_length_after_insert > buffer_length_before_insert) { |
minyue-webrtc
2015/08/27 09:09:30
Since we introduced size_t - size_t here, it shoul
Peter Kasting
2015/08/27 09:14:54
I wouldn't have caught this even had I just done t
| |
662 (temp_bufsize != decision_logic_->packet_length_samples())) { | 663 const size_t packet_length_samples = |
663 decision_logic_->set_packet_length_samples(temp_bufsize); | 664 (buffer_length_after_insert - buffer_length_before_insert) * |
664 delay_manager_->SetPacketAudioLength( | 665 decoder_frame_length_; |
665 static_cast<int>((1000 * temp_bufsize) / fs_hz_)); | 666 if (packet_length_samples != decision_logic_->packet_length_samples()) { |
667 decision_logic_->set_packet_length_samples(packet_length_samples); | |
668 delay_manager_->SetPacketAudioLength( | |
669 rtc::checked_cast<int>((1000 * packet_length_samples) / fs_hz_)); | |
670 } | |
666 } | 671 } |
667 | 672 |
668 // Update statistics. | 673 // Update statistics. |
669 if ((int32_t) (main_header.timestamp - timestamp_) >= 0 && | 674 if ((int32_t) (main_header.timestamp - timestamp_) >= 0 && |
670 !new_codec_) { | 675 !new_codec_) { |
671 // Only update statistics if incoming packet is not older than last played | 676 // Only update statistics if incoming packet is not older than last played |
672 // out packet, and if new codec flag is not set. | 677 // out packet, and if new codec flag is not set. |
673 delay_manager_->Update(main_header.sequenceNumber, main_header.timestamp, | 678 delay_manager_->Update(main_header.sequenceNumber, main_header.timestamp, |
674 fs_hz_); | 679 fs_hz_); |
675 } | 680 } |
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1970 | 1975 |
1971 void NetEqImpl::CreateDecisionLogic() { | 1976 void NetEqImpl::CreateDecisionLogic() { |
1972 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, | 1977 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, |
1973 playout_mode_, | 1978 playout_mode_, |
1974 decoder_database_.get(), | 1979 decoder_database_.get(), |
1975 *packet_buffer_.get(), | 1980 *packet_buffer_.get(), |
1976 delay_manager_.get(), | 1981 delay_manager_.get(), |
1977 buffer_level_filter_.get())); | 1982 buffer_level_filter_.get())); |
1978 } | 1983 } |
1979 } // namespace webrtc | 1984 } // namespace webrtc |
OLD | NEW |