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

Side by Side Diff: content/renderer/media/media_stream_audio_processor.cc

Issue 190713004: Only turn on the audio processing by default for MEDIA_DEVICE_AUDIO_CAPTURE (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: added unittest to protect the use cases. Created 6 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/media_stream_audio_processor.h" 5 #include "content/renderer/media/media_stream_audio_processor.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "content/public/common/content_switches.h" 9 #include "content/public/common/content_switches.h"
10 #include "content/renderer/media/media_stream_audio_processor_options.h" 10 #include "content/renderer/media/media_stream_audio_processor_options.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Handles mixing and resampling between input and output parameters. 136 // Handles mixing and resampling between input and output parameters.
137 media::AudioConverter audio_converter_; 137 media::AudioConverter audio_converter_;
138 scoped_ptr<media::AudioBus> audio_wrapper_; 138 scoped_ptr<media::AudioBus> audio_wrapper_;
139 scoped_ptr<media::AudioFifo> fifo_; 139 scoped_ptr<media::AudioFifo> fifo_;
140 }; 140 };
141 141
142 MediaStreamAudioProcessor::MediaStreamAudioProcessor( 142 MediaStreamAudioProcessor::MediaStreamAudioProcessor(
143 const media::AudioParameters& source_params, 143 const media::AudioParameters& source_params,
144 const blink::WebMediaConstraints& constraints, 144 const blink::WebMediaConstraints& constraints,
145 int effects, 145 int effects,
146 MediaStreamType type,
146 WebRtcPlayoutDataSource* playout_data_source) 147 WebRtcPlayoutDataSource* playout_data_source)
147 : render_delay_ms_(0), 148 : render_delay_ms_(0),
148 playout_data_source_(playout_data_source), 149 playout_data_source_(playout_data_source),
149 audio_mirroring_(false), 150 audio_mirroring_(false),
150 typing_detected_(false) { 151 typing_detected_(false) {
151 capture_thread_checker_.DetachFromThread(); 152 capture_thread_checker_.DetachFromThread();
152 render_thread_checker_.DetachFromThread(); 153 render_thread_checker_.DetachFromThread();
153 InitializeAudioProcessingModule(constraints, effects); 154 InitializeAudioProcessingModule(constraints, effects, type);
154 InitializeCaptureConverter(source_params); 155 InitializeCaptureConverter(source_params);
155 } 156 }
156 157
157 MediaStreamAudioProcessor::~MediaStreamAudioProcessor() { 158 MediaStreamAudioProcessor::~MediaStreamAudioProcessor() {
158 DCHECK(main_thread_checker_.CalledOnValidThread()); 159 DCHECK(main_thread_checker_.CalledOnValidThread());
159 StopAudioProcessing(); 160 StopAudioProcessing();
160 } 161 }
161 162
162 void MediaStreamAudioProcessor::PushCaptureData(media::AudioBus* audio_source) { 163 void MediaStreamAudioProcessor::PushCaptureData(media::AudioBus* audio_source) {
163 DCHECK(capture_thread_checker_.CalledOnValidThread()); 164 DCHECK(capture_thread_checker_.CalledOnValidThread());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 render_converter_.reset(); 227 render_converter_.reset();
227 } 228 }
228 229
229 void MediaStreamAudioProcessor::GetStats(AudioProcessorStats* stats) { 230 void MediaStreamAudioProcessor::GetStats(AudioProcessorStats* stats) {
230 stats->typing_noise_detected = 231 stats->typing_noise_detected =
231 (base::subtle::Acquire_Load(&typing_detected_) != false); 232 (base::subtle::Acquire_Load(&typing_detected_) != false);
232 GetAecStats(audio_processing_.get(), stats); 233 GetAecStats(audio_processing_.get(), stats);
233 } 234 }
234 235
235 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( 236 void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
236 const blink::WebMediaConstraints& constraints, int effects) { 237 const blink::WebMediaConstraints& constraints, int effects,
238 MediaStreamType type) {
237 DCHECK(!audio_processing_); 239 DCHECK(!audio_processing_);
238 if (!CommandLine::ForCurrentProcess()->HasSwitch( 240 if (!CommandLine::ForCurrentProcess()->HasSwitch(
239 switches::kEnableAudioTrackProcessing)) { 241 switches::kEnableAudioTrackProcessing)) {
240 return; 242 return;
241 } 243 }
242 244
243 RTCMediaConstraints native_constraints(constraints); 245 RTCMediaConstraints native_constraints(constraints);
244 ApplyFixedAudioConstraints(&native_constraints); 246
247 // Only apply the fixed constraints for gUM of MEDIA_DEVICE_AUDIO_CAPTURE.
248 DCHECK(IsAudioMediaType(type));
249 if (type == MEDIA_DEVICE_AUDIO_CAPTURE)
250 ApplyFixedAudioConstraints(&native_constraints);
251
245 if (effects & media::AudioParameters::ECHO_CANCELLER) { 252 if (effects & media::AudioParameters::ECHO_CANCELLER) {
246 // If platform echo canceller is enabled, disable the software AEC. 253 // If platform echo canceller is enabled, disable the software AEC.
247 native_constraints.AddMandatory( 254 native_constraints.AddMandatory(
248 MediaConstraintsInterface::kEchoCancellation, 255 MediaConstraintsInterface::kEchoCancellation,
249 MediaConstraintsInterface::kValueFalse, true); 256 MediaConstraintsInterface::kValueFalse, true);
250 } 257 }
251 258
252 #if defined(OS_IOS) 259 #if defined(OS_IOS)
253 // On iOS, VPIO provides built-in AEC and AGC. 260 // On iOS, VPIO provides built-in AEC and AGC.
254 const bool enable_aec = false; 261 const bool enable_aec = false;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 if (!audio_processing_.get()) 452 if (!audio_processing_.get())
446 return; 453 return;
447 454
448 if (playout_data_source_) 455 if (playout_data_source_)
449 playout_data_source_->RemovePlayoutSink(this); 456 playout_data_source_->RemovePlayoutSink(this);
450 457
451 audio_processing_.reset(); 458 audio_processing_.reset();
452 } 459 }
453 460
454 } // namespace content 461 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698