Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 1769883002: Remove the type parameter to NetEq::GetAudio (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@acm-rec-delete-vad
Patch Set: After review Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 if (error != 0) { 144 if (error != 0) {
145 error_code_ = error; 145 error_code_ = error;
146 return kFail; 146 return kFail;
147 } 147 }
148 return kOK; 148 return kOK;
149 } 149 }
150 150
151 namespace { 151 namespace {
152 void SetAudioFrameActivityAndType(bool vad_enabled, 152 void SetAudioFrameActivityAndType(bool vad_enabled,
153 NetEqOutputType type, 153 NetEqImpl::OutputType type,
154 AudioFrame::VADActivity last_vad_activity, 154 AudioFrame::VADActivity last_vad_activity,
155 AudioFrame* audio_frame) { 155 AudioFrame* audio_frame) {
156 switch (type) { 156 switch (type) {
157 case kOutputNormal: { 157 case NetEqImpl::OutputType::kNormalSpeech: {
158 audio_frame->speech_type_ = AudioFrame::kNormalSpeech; 158 audio_frame->speech_type_ = AudioFrame::kNormalSpeech;
159 audio_frame->vad_activity_ = AudioFrame::kVadActive; 159 audio_frame->vad_activity_ = AudioFrame::kVadActive;
160 break; 160 break;
161 } 161 }
162 case kOutputVADPassive: { 162 case NetEqImpl::OutputType::kVadPassive: {
163 // This should only be reached if the VAD is enabled. 163 // This should only be reached if the VAD is enabled.
164 RTC_DCHECK(vad_enabled); 164 RTC_DCHECK(vad_enabled);
165 audio_frame->speech_type_ = AudioFrame::kNormalSpeech; 165 audio_frame->speech_type_ = AudioFrame::kNormalSpeech;
166 audio_frame->vad_activity_ = AudioFrame::kVadPassive; 166 audio_frame->vad_activity_ = AudioFrame::kVadPassive;
167 break; 167 break;
168 } 168 }
169 case kOutputCNG: { 169 case NetEqImpl::OutputType::kCNG: {
170 audio_frame->speech_type_ = AudioFrame::kCNG; 170 audio_frame->speech_type_ = AudioFrame::kCNG;
171 audio_frame->vad_activity_ = AudioFrame::kVadPassive; 171 audio_frame->vad_activity_ = AudioFrame::kVadPassive;
172 break; 172 break;
173 } 173 }
174 case kOutputPLC: { 174 case NetEqImpl::OutputType::kPLC: {
175 audio_frame->speech_type_ = AudioFrame::kPLC; 175 audio_frame->speech_type_ = AudioFrame::kPLC;
176 audio_frame->vad_activity_ = last_vad_activity; 176 audio_frame->vad_activity_ = last_vad_activity;
177 break; 177 break;
178 } 178 }
179 case kOutputPLCtoCNG: { 179 case NetEqImpl::OutputType::kPLCCNG: {
180 audio_frame->speech_type_ = AudioFrame::kPLCCNG; 180 audio_frame->speech_type_ = AudioFrame::kPLCCNG;
181 audio_frame->vad_activity_ = AudioFrame::kVadPassive; 181 audio_frame->vad_activity_ = AudioFrame::kVadPassive;
182 break; 182 break;
183 } 183 }
184 default: 184 default:
185 RTC_NOTREACHED(); 185 RTC_NOTREACHED();
186 } 186 }
187 if (!vad_enabled) { 187 if (!vad_enabled) {
188 // Always set kVadUnknown when receive VAD is inactive. 188 // Always set kVadUnknown when receive VAD is inactive.
189 audio_frame->vad_activity_ = AudioFrame::kVadUnknown; 189 audio_frame->vad_activity_ = AudioFrame::kVadUnknown;
190 } 190 }
191 } 191 }
192 } 192 }
193 193
194 int NetEqImpl::GetAudio(AudioFrame* audio_frame, NetEqOutputType* type) { 194 int NetEqImpl::GetAudio(AudioFrame* audio_frame) {
195 TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio"); 195 TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio");
196 rtc::CritScope lock(&crit_sect_); 196 rtc::CritScope lock(&crit_sect_);
197 int error = GetAudioInternal(audio_frame); 197 int error = GetAudioInternal(audio_frame);
198 RTC_DCHECK_EQ( 198 RTC_DCHECK_EQ(
199 audio_frame->sample_rate_hz_, 199 audio_frame->sample_rate_hz_,
200 rtc::checked_cast<int>(audio_frame->samples_per_channel_ * 100)); 200 rtc::checked_cast<int>(audio_frame->samples_per_channel_ * 100));
201 if (error != 0) { 201 if (error != 0) {
202 error_code_ = error; 202 error_code_ = error;
203 return kFail; 203 return kFail;
204 } 204 }
205 if (type) {
206 *type = LastOutputType();
207 }
208 SetAudioFrameActivityAndType(vad_->enabled(), LastOutputType(), 205 SetAudioFrameActivityAndType(vad_->enabled(), LastOutputType(),
209 last_vad_activity_, audio_frame); 206 last_vad_activity_, audio_frame);
210 last_vad_activity_ = audio_frame->vad_activity_; 207 last_vad_activity_ = audio_frame->vad_activity_;
211 last_output_sample_rate_hz_ = audio_frame->sample_rate_hz_; 208 last_output_sample_rate_hz_ = audio_frame->sample_rate_hz_;
212 RTC_DCHECK(last_output_sample_rate_hz_ == 8000 || 209 RTC_DCHECK(last_output_sample_rate_hz_ == 8000 ||
213 last_output_sample_rate_hz_ == 16000 || 210 last_output_sample_rate_hz_ == 16000 ||
214 last_output_sample_rate_hz_ == 32000 || 211 last_output_sample_rate_hz_ == 32000 ||
215 last_output_sample_rate_hz_ == 48000) 212 last_output_sample_rate_hz_ == 48000)
216 << "Unexpected sample rate " << last_output_sample_rate_hz_; 213 << "Unexpected sample rate " << last_output_sample_rate_hz_;
217 return kOK; 214 return kOK;
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 } 2058 }
2062 2059
2063 // Create DecisionLogic if it is not created yet, then communicate new sample 2060 // Create DecisionLogic if it is not created yet, then communicate new sample
2064 // rate and output size to DecisionLogic object. 2061 // rate and output size to DecisionLogic object.
2065 if (!decision_logic_.get()) { 2062 if (!decision_logic_.get()) {
2066 CreateDecisionLogic(); 2063 CreateDecisionLogic();
2067 } 2064 }
2068 decision_logic_->SetSampleRate(fs_hz_, output_size_samples_); 2065 decision_logic_->SetSampleRate(fs_hz_, output_size_samples_);
2069 } 2066 }
2070 2067
2071 NetEqOutputType NetEqImpl::LastOutputType() { 2068 NetEqImpl::OutputType NetEqImpl::LastOutputType() {
2072 assert(vad_.get()); 2069 assert(vad_.get());
2073 assert(expand_.get()); 2070 assert(expand_.get());
2074 if (last_mode_ == kModeCodecInternalCng || last_mode_ == kModeRfc3389Cng) { 2071 if (last_mode_ == kModeCodecInternalCng || last_mode_ == kModeRfc3389Cng) {
2075 return kOutputCNG; 2072 return OutputType::kCNG;
2076 } else if (last_mode_ == kModeExpand && expand_->MuteFactor(0) == 0) { 2073 } else if (last_mode_ == kModeExpand && expand_->MuteFactor(0) == 0) {
2077 // Expand mode has faded down to background noise only (very long expand). 2074 // Expand mode has faded down to background noise only (very long expand).
2078 return kOutputPLCtoCNG; 2075 return OutputType::kPLCCNG;
2079 } else if (last_mode_ == kModeExpand) { 2076 } else if (last_mode_ == kModeExpand) {
2080 return kOutputPLC; 2077 return OutputType::kPLC;
2081 } else if (vad_->running() && !vad_->active_speech()) { 2078 } else if (vad_->running() && !vad_->active_speech()) {
2082 return kOutputVADPassive; 2079 return OutputType::kVadPassive;
2083 } else { 2080 } else {
2084 return kOutputNormal; 2081 return OutputType::kNormalSpeech;
2085 } 2082 }
2086 } 2083 }
2087 2084
2088 void NetEqImpl::CreateDecisionLogic() { 2085 void NetEqImpl::CreateDecisionLogic() {
2089 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, 2086 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_,
2090 playout_mode_, 2087 playout_mode_,
2091 decoder_database_.get(), 2088 decoder_database_.get(),
2092 *packet_buffer_.get(), 2089 *packet_buffer_.get(),
2093 delay_manager_.get(), 2090 delay_manager_.get(),
2094 buffer_level_filter_.get())); 2091 buffer_level_filter_.get()));
2095 } 2092 }
2096 } // namespace webrtc 2093 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.h ('k') | webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698