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

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

Issue 1772583002: Delete VAD methods from AcmReceiver and move functionality inside NetEq (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@neteq-getaudio-frame
Patch Set: 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
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 int error = 141 int error =
142 InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true); 142 InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true);
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 {
152 void SetAudioFrameActivityAndType(bool vad_enabled,
153 NetEqOutputType type,
154 AudioFrame::VADActivity last_vad_activity,
155 AudioFrame* audio_frame) {
156 switch (type) {
157 case kOutputNormal: {
158 audio_frame->speech_type_ = AudioFrame::kNormalSpeech;
159 audio_frame->vad_activity_ = AudioFrame::kVadActive;
160 break;
161 }
162 case kOutputVADPassive: {
163 // This should only be reached if the VAD is enabled.
164 RTC_DCHECK(vad_enabled);
165 audio_frame->speech_type_ = AudioFrame::kNormalSpeech;
166 audio_frame->vad_activity_ = AudioFrame::kVadPassive;
167 break;
168 }
169 case kOutputCNG: {
170 audio_frame->speech_type_ = AudioFrame::kCNG;
171 audio_frame->vad_activity_ = AudioFrame::kVadPassive;
172 break;
173 }
174 case kOutputPLC: {
175 audio_frame->speech_type_ = AudioFrame::kPLC;
176 audio_frame->vad_activity_ = last_vad_activity;
177 break;
178 }
179 case kOutputPLCtoCNG: {
180 audio_frame->speech_type_ = AudioFrame::kPLCCNG;
181 audio_frame->vad_activity_ = AudioFrame::kVadPassive;
182 break;
183 }
184 default:
185 RTC_NOTREACHED();
186 }
187 if (!vad_enabled) {
188 // Always set kVadUnknown when receive VAD is inactive.
189 audio_frame->vad_activity_ = AudioFrame::kVadUnknown;
190 }
191 }
192 }
kwiberg-webrtc 2016/03/08 09:27:07 } // namespace
hlundin-webrtc 2016/03/08 10:11:17 Acknowledged. Will be fixed in a follow-up, to sav
kwiberg-webrtc 2016/03/08 10:16:30 My precioussss...
193
151 int NetEqImpl::GetAudio(AudioFrame* audio_frame, NetEqOutputType* type) { 194 int NetEqImpl::GetAudio(AudioFrame* audio_frame, NetEqOutputType* type) {
152 TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio"); 195 TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio");
153 rtc::CritScope lock(&crit_sect_); 196 rtc::CritScope lock(&crit_sect_);
154 int error = GetAudioInternal(audio_frame); 197 int error = GetAudioInternal(audio_frame);
155 RTC_DCHECK_EQ( 198 RTC_DCHECK_EQ(
156 audio_frame->sample_rate_hz_, 199 audio_frame->sample_rate_hz_,
157 rtc::checked_cast<int>(audio_frame->samples_per_channel_ * 100)); 200 rtc::checked_cast<int>(audio_frame->samples_per_channel_ * 100));
158 if (error != 0) { 201 if (error != 0) {
159 error_code_ = error; 202 error_code_ = error;
160 return kFail; 203 return kFail;
161 } 204 }
162 if (type) { 205 if (type) {
163 *type = LastOutputType(); 206 *type = LastOutputType();
164 } 207 }
208 SetAudioFrameActivityAndType(vad_->enabled(), LastOutputType(),
209 last_vad_activity_, audio_frame);
210 last_vad_activity_ = audio_frame->vad_activity_;
165 last_output_sample_rate_hz_ = audio_frame->sample_rate_hz_; 211 last_output_sample_rate_hz_ = audio_frame->sample_rate_hz_;
166 RTC_DCHECK(last_output_sample_rate_hz_ == 8000 || 212 RTC_DCHECK(last_output_sample_rate_hz_ == 8000 ||
167 last_output_sample_rate_hz_ == 16000 || 213 last_output_sample_rate_hz_ == 16000 ||
168 last_output_sample_rate_hz_ == 32000 || 214 last_output_sample_rate_hz_ == 32000 ||
169 last_output_sample_rate_hz_ == 48000) 215 last_output_sample_rate_hz_ == 48000)
170 << "Unexpected sample rate " << last_output_sample_rate_hz_; 216 << "Unexpected sample rate " << last_output_sample_rate_hz_;
171 return kOK; 217 return kOK;
172 } 218 }
173 219
174 int NetEqImpl::RegisterPayloadType(NetEqDecoder codec, 220 int NetEqImpl::RegisterPayloadType(NetEqDecoder codec,
(...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 2087
2042 void NetEqImpl::CreateDecisionLogic() { 2088 void NetEqImpl::CreateDecisionLogic() {
2043 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, 2089 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_,
2044 playout_mode_, 2090 playout_mode_,
2045 decoder_database_.get(), 2091 decoder_database_.get(),
2046 *packet_buffer_.get(), 2092 *packet_buffer_.get(),
2047 delay_manager_.get(), 2093 delay_manager_.get(),
2048 buffer_level_filter_.get())); 2094 buffer_level_filter_.get()));
2049 } 2095 }
2050 } // namespace webrtc 2096 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698