| OLD | NEW |
| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 switches::kEnableAudioTrackProcessing)) { | 226 switches::kEnableAudioTrackProcessing)) { |
| 227 return; | 227 return; |
| 228 } | 228 } |
| 229 | 229 |
| 230 const bool enable_aec = GetPropertyFromConstraints( | 230 const bool enable_aec = GetPropertyFromConstraints( |
| 231 constraints, MediaConstraintsInterface::kEchoCancellation); | 231 constraints, MediaConstraintsInterface::kEchoCancellation); |
| 232 const bool enable_ns = GetPropertyFromConstraints( | 232 const bool enable_ns = GetPropertyFromConstraints( |
| 233 constraints, MediaConstraintsInterface::kNoiseSuppression); | 233 constraints, MediaConstraintsInterface::kNoiseSuppression); |
| 234 const bool enable_high_pass_filter = GetPropertyFromConstraints( | 234 const bool enable_high_pass_filter = GetPropertyFromConstraints( |
| 235 constraints, MediaConstraintsInterface::kHighpassFilter); | 235 constraints, MediaConstraintsInterface::kHighpassFilter); |
| 236 const bool start_aec_dump = GetPropertyFromConstraints( | |
| 237 constraints, MediaConstraintsInterface::kInternalAecDump); | |
| 238 #if defined(IOS) || defined(ANDROID) | 236 #if defined(IOS) || defined(ANDROID) |
| 239 const bool enable_experimental_aec = false; | 237 const bool enable_experimental_aec = false; |
| 240 const bool enable_typing_detection = false; | 238 const bool enable_typing_detection = false; |
| 241 #else | 239 #else |
| 242 const bool enable_experimental_aec = GetPropertyFromConstraints( | 240 const bool enable_experimental_aec = GetPropertyFromConstraints( |
| 243 constraints, MediaConstraintsInterface::kExperimentalEchoCancellation); | 241 constraints, MediaConstraintsInterface::kExperimentalEchoCancellation); |
| 244 const bool enable_typing_detection = GetPropertyFromConstraints( | 242 const bool enable_typing_detection = GetPropertyFromConstraints( |
| 245 constraints, MediaConstraintsInterface::kTypingNoiseDetection); | 243 constraints, MediaConstraintsInterface::kTypingNoiseDetection); |
| 246 #endif | 244 #endif |
| 247 | 245 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 263 | 261 |
| 264 if (enable_ns) | 262 if (enable_ns) |
| 265 EnableNoiseSuppression(audio_processing_.get()); | 263 EnableNoiseSuppression(audio_processing_.get()); |
| 266 | 264 |
| 267 if (enable_high_pass_filter) | 265 if (enable_high_pass_filter) |
| 268 EnableHighPassFilter(audio_processing_.get()); | 266 EnableHighPassFilter(audio_processing_.get()); |
| 269 | 267 |
| 270 if (enable_typing_detection) | 268 if (enable_typing_detection) |
| 271 EnableTypingDetection(audio_processing_.get()); | 269 EnableTypingDetection(audio_processing_.get()); |
| 272 | 270 |
| 273 if (enable_aec && start_aec_dump) | |
| 274 StartAecDump(audio_processing_.get()); | |
| 275 | 271 |
| 276 // Configure the audio format the audio processing is running on. This | 272 // Configure the audio format the audio processing is running on. This |
| 277 // has to be done after all the needed components are enabled. | 273 // has to be done after all the needed components are enabled. |
| 278 CHECK_EQ(audio_processing_->set_sample_rate_hz(kAudioProcessingSampleRate), | 274 CHECK_EQ(audio_processing_->set_sample_rate_hz(kAudioProcessingSampleRate), |
| 279 0); | 275 0); |
| 280 CHECK_EQ(audio_processing_->set_num_channels(kAudioProcessingNumberOfChannel, | 276 CHECK_EQ(audio_processing_->set_num_channels(kAudioProcessingNumberOfChannel, |
| 281 kAudioProcessingNumberOfChannel), | 277 kAudioProcessingNumberOfChannel), |
| 282 0); | 278 0); |
| 283 } | 279 } |
| 284 | 280 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 DCHECK_EQ(err, 0) << "ProcessStream() error: " << err; | 341 DCHECK_EQ(err, 0) << "ProcessStream() error: " << err; |
| 346 | 342 |
| 347 // TODO(xians): Add support for AGC, typing detection, audio level | 343 // TODO(xians): Add support for AGC, typing detection, audio level |
| 348 // calculation, stereo swapping. | 344 // calculation, stereo swapping. |
| 349 } | 345 } |
| 350 | 346 |
| 351 void MediaStreamAudioProcessor::StopAudioProcessing() { | 347 void MediaStreamAudioProcessor::StopAudioProcessing() { |
| 352 if (!audio_processing_.get()) | 348 if (!audio_processing_.get()) |
| 353 return; | 349 return; |
| 354 | 350 |
| 355 // It is safe to stop the AEC dump even it is not started. | |
| 356 StopAecDump(audio_processing_.get()); | |
| 357 | |
| 358 audio_processing_.reset(); | 351 audio_processing_.reset(); |
| 359 } | 352 } |
| 360 | 353 |
| 361 } // namespace content | 354 } // namespace content |
| OLD | NEW |