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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true); | 144 InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true); |
145 | 145 |
146 if (error != 0) { | 146 if (error != 0) { |
147 error_code_ = error; | 147 error_code_ = error; |
148 return kFail; | 148 return kFail; |
149 } | 149 } |
150 return kOK; | 150 return kOK; |
151 } | 151 } |
152 | 152 |
153 int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio, | 153 int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio, |
154 size_t* samples_per_channel, int* num_channels, | 154 size_t* samples_per_channel, size_t* num_channels, |
155 NetEqOutputType* type) { | 155 NetEqOutputType* type) { |
156 TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio"); | 156 TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio"); |
157 CriticalSectionScoped lock(crit_sect_.get()); | 157 CriticalSectionScoped lock(crit_sect_.get()); |
158 int error = GetAudioInternal(max_length, output_audio, samples_per_channel, | 158 int error = GetAudioInternal(max_length, output_audio, samples_per_channel, |
159 num_channels); | 159 num_channels); |
160 if (error != 0) { | 160 if (error != 0) { |
161 error_code_ = error; | 161 error_code_ = error; |
162 return kFail; | 162 return kFail; |
163 } | 163 } |
164 if (type) { | 164 if (type) { |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 // but don't update statistics. | 737 // but don't update statistics. |
738 delay_manager_->set_last_pack_cng_or_dtmf(0); | 738 delay_manager_->set_last_pack_cng_or_dtmf(0); |
739 delay_manager_->ResetPacketIatCount(); | 739 delay_manager_->ResetPacketIatCount(); |
740 } | 740 } |
741 return 0; | 741 return 0; |
742 } | 742 } |
743 | 743 |
744 int NetEqImpl::GetAudioInternal(size_t max_length, | 744 int NetEqImpl::GetAudioInternal(size_t max_length, |
745 int16_t* output, | 745 int16_t* output, |
746 size_t* samples_per_channel, | 746 size_t* samples_per_channel, |
747 int* num_channels) { | 747 size_t* num_channels) { |
748 PacketList packet_list; | 748 PacketList packet_list; |
749 DtmfEvent dtmf_event; | 749 DtmfEvent dtmf_event; |
750 Operations operation; | 750 Operations operation; |
751 bool play_dtmf; | 751 bool play_dtmf; |
752 int return_value = GetDecision(&operation, &packet_list, &dtmf_event, | 752 int return_value = GetDecision(&operation, &packet_list, &dtmf_event, |
753 &play_dtmf); | 753 &play_dtmf); |
754 if (return_value != 0) { | 754 if (return_value != 0) { |
755 last_mode_ = kModeError; | 755 last_mode_ = kModeError; |
756 return return_value; | 756 return return_value; |
757 } | 757 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 size_t num_output_samples = output_size_samples_ * sync_buffer_->Channels(); | 861 size_t num_output_samples = output_size_samples_ * sync_buffer_->Channels(); |
862 if (num_output_samples > max_length) { | 862 if (num_output_samples > max_length) { |
863 LOG(LS_WARNING) << "Output array is too short. " << max_length << " < " << | 863 LOG(LS_WARNING) << "Output array is too short. " << max_length << " < " << |
864 output_size_samples_ << " * " << sync_buffer_->Channels(); | 864 output_size_samples_ << " * " << sync_buffer_->Channels(); |
865 num_output_samples = max_length; | 865 num_output_samples = max_length; |
866 num_output_samples_per_channel = max_length / sync_buffer_->Channels(); | 866 num_output_samples_per_channel = max_length / sync_buffer_->Channels(); |
867 } | 867 } |
868 const size_t samples_from_sync = | 868 const size_t samples_from_sync = |
869 sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel, | 869 sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel, |
870 output); | 870 output); |
871 *num_channels = static_cast<int>(sync_buffer_->Channels()); | 871 *num_channels = sync_buffer_->Channels(); |
872 if (sync_buffer_->FutureLength() < expand_->overlap_length()) { | 872 if (sync_buffer_->FutureLength() < expand_->overlap_length()) { |
873 // The sync buffer should always contain |overlap_length| samples, but now | 873 // The sync buffer should always contain |overlap_length| samples, but now |
874 // too many samples have been extracted. Reinstall the |overlap_length| | 874 // too many samples have been extracted. Reinstall the |overlap_length| |
875 // lookahead by moving the index. | 875 // lookahead by moving the index. |
876 const size_t missing_lookahead_samples = | 876 const size_t missing_lookahead_samples = |
877 expand_->overlap_length() - sync_buffer_->FutureLength(); | 877 expand_->overlap_length() - sync_buffer_->FutureLength(); |
878 RTC_DCHECK_GE(sync_buffer_->next_index(), missing_lookahead_samples); | 878 RTC_DCHECK_GE(sync_buffer_->next_index(), missing_lookahead_samples); |
879 sync_buffer_->set_next_index(sync_buffer_->next_index() - | 879 sync_buffer_->set_next_index(sync_buffer_->next_index() - |
880 missing_lookahead_samples); | 880 missing_lookahead_samples); |
881 } | 881 } |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 | 2045 |
2046 void NetEqImpl::CreateDecisionLogic() { | 2046 void NetEqImpl::CreateDecisionLogic() { |
2047 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, | 2047 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, |
2048 playout_mode_, | 2048 playout_mode_, |
2049 decoder_database_.get(), | 2049 decoder_database_.get(), |
2050 *packet_buffer_.get(), | 2050 *packet_buffer_.get(), |
2051 delay_manager_.get(), | 2051 delay_manager_.get(), |
2052 buffer_level_filter_.get())); | 2052 buffer_level_filter_.get())); |
2053 } | 2053 } |
2054 } // namespace webrtc | 2054 } // namespace webrtc |
OLD | NEW |