| 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_options.h" | 5 #include "content/renderer/media/media_stream_audio_processor_options.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 // Constant constraint keys which enables default audio constraints on | 50 // Constant constraint keys which enables default audio constraints on |
| 51 // mediastreams with audio. | 51 // mediastreams with audio. |
| 52 struct { | 52 struct { |
| 53 const char* key; | 53 const char* key; |
| 54 bool value; | 54 bool value; |
| 55 } const kDefaultAudioConstraints[] = { | 55 } const kDefaultAudioConstraints[] = { |
| 56 { MediaAudioConstraints::kEchoCancellation, true }, | 56 { MediaAudioConstraints::kEchoCancellation, true }, |
| 57 { MediaAudioConstraints::kGoogEchoCancellation, true }, | 57 { MediaAudioConstraints::kGoogEchoCancellation, true }, |
| 58 #if defined(OS_ANDROID) || defined(OS_IOS) | 58 #if defined(OS_ANDROID) |
| 59 { MediaAudioConstraints::kGoogExperimentalEchoCancellation, false }, | 59 { MediaAudioConstraints::kGoogExperimentalEchoCancellation, false }, |
| 60 #else | 60 #else |
| 61 // Enable the extended filter mode AEC on all non-mobile platforms. | 61 // Enable the extended filter mode AEC on all non-mobile platforms. |
| 62 { MediaAudioConstraints::kGoogExperimentalEchoCancellation, true }, | 62 { MediaAudioConstraints::kGoogExperimentalEchoCancellation, true }, |
| 63 #endif | 63 #endif |
| 64 { MediaAudioConstraints::kGoogAutoGainControl, true }, | 64 { MediaAudioConstraints::kGoogAutoGainControl, true }, |
| 65 { MediaAudioConstraints::kGoogExperimentalAutoGainControl, true }, | 65 { MediaAudioConstraints::kGoogExperimentalAutoGainControl, true }, |
| 66 { MediaAudioConstraints::kGoogNoiseSuppression, true }, | 66 { MediaAudioConstraints::kGoogNoiseSuppression, true }, |
| 67 { MediaAudioConstraints::kGoogHighpassFilter, true }, | 67 { MediaAudioConstraints::kGoogHighpassFilter, true }, |
| 68 { MediaAudioConstraints::kGoogTypingNoiseDetection, true }, | 68 { MediaAudioConstraints::kGoogTypingNoiseDetection, true }, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 *field = rtc::Optional<bool>(value); | 141 *field = rtc::Optional<bool>(value); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace | 145 } // namespace |
| 146 | 146 |
| 147 // TODO(xians): Remove this method after the APM in WebRtc is deprecated. | 147 // TODO(xians): Remove this method after the APM in WebRtc is deprecated. |
| 148 void MediaAudioConstraints::ApplyFixedAudioConstraints( | 148 void MediaAudioConstraints::ApplyFixedAudioConstraints( |
| 149 cricket::AudioOptions* options) { | 149 cricket::AudioOptions* options) { |
| 150 SetIfNotSet(&options->echo_cancellation, true); | 150 SetIfNotSet(&options->echo_cancellation, true); |
| 151 #if defined(OS_ANDROID) || defined(OS_IOS) | 151 #if defined(OS_ANDROID) |
| 152 SetIfNotSet(&options->extended_filter_aec, false); | 152 SetIfNotSet(&options->extended_filter_aec, false); |
| 153 #else | 153 #else |
| 154 // Enable the extended filter mode AEC on all non-mobile platforms. | 154 // Enable the extended filter mode AEC on all non-mobile platforms. |
| 155 SetIfNotSet(&options->extended_filter_aec, true); | 155 SetIfNotSet(&options->extended_filter_aec, true); |
| 156 #endif | 156 #endif |
| 157 SetIfNotSet(&options->auto_gain_control, true); | 157 SetIfNotSet(&options->auto_gain_control, true); |
| 158 SetIfNotSet(&options->experimental_agc, true); | 158 SetIfNotSet(&options->experimental_agc, true); |
| 159 SetIfNotSet(&options->noise_suppression, true); | 159 SetIfNotSet(&options->noise_suppression, true); |
| 160 SetIfNotSet(&options->highpass_filter, true); | 160 SetIfNotSet(&options->highpass_filter, true); |
| 161 SetIfNotSet(&options->typing_detection, true); | 161 SetIfNotSet(&options->typing_detection, true); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // Map |fraction_poor_delays| to an Echo Cancellation quality and log in UMA | 342 // Map |fraction_poor_delays| to an Echo Cancellation quality and log in UMA |
| 343 // histogram. See DelayBasedEchoQuality for information on histogram | 343 // histogram. See DelayBasedEchoQuality for information on histogram |
| 344 // buckets. | 344 // buckets. |
| 345 UMA_HISTOGRAM_ENUMERATION("WebRTC.AecDelayBasedQuality", | 345 UMA_HISTOGRAM_ENUMERATION("WebRTC.AecDelayBasedQuality", |
| 346 EchoDelayFrequencyToQuality(fraction_poor_delays), | 346 EchoDelayFrequencyToQuality(fraction_poor_delays), |
| 347 DELAY_BASED_ECHO_QUALITY_MAX); | 347 DELAY_BASED_ECHO_QUALITY_MAX); |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | 350 |
| 351 void EnableEchoCancellation(AudioProcessing* audio_processing) { | 351 void EnableEchoCancellation(AudioProcessing* audio_processing) { |
| 352 #if defined(OS_ANDROID) || defined(OS_IOS) | 352 #if defined(OS_ANDROID) |
| 353 // Mobile devices are using AECM. | 353 // Mobile devices are using AECM. |
| 354 CHECK_EQ(0, audio_processing->echo_control_mobile()->set_routing_mode( | 354 CHECK_EQ(0, audio_processing->echo_control_mobile()->set_routing_mode( |
| 355 webrtc::EchoControlMobile::kSpeakerphone)); | 355 webrtc::EchoControlMobile::kSpeakerphone)); |
| 356 CHECK_EQ(0, audio_processing->echo_control_mobile()->Enable(true)); | 356 CHECK_EQ(0, audio_processing->echo_control_mobile()->Enable(true)); |
| 357 return; | 357 return; |
| 358 #endif | 358 #endif |
| 359 int err = audio_processing->echo_cancellation()->set_suppression_level( | 359 int err = audio_processing->echo_cancellation()->set_suppression_level( |
| 360 webrtc::EchoCancellation::kHighSuppression); | 360 webrtc::EchoCancellation::kHighSuppression); |
| 361 | 361 |
| 362 // Enable the metrics for AEC. | 362 // Enable the metrics for AEC. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 if (audio_processing->StartDebugRecording(stream)) | 401 if (audio_processing->StartDebugRecording(stream)) |
| 402 DLOG(ERROR) << "Fail to start AEC debug recording"; | 402 DLOG(ERROR) << "Fail to start AEC debug recording"; |
| 403 } | 403 } |
| 404 | 404 |
| 405 void StopEchoCancellationDump(AudioProcessing* audio_processing) { | 405 void StopEchoCancellationDump(AudioProcessing* audio_processing) { |
| 406 if (audio_processing->StopDebugRecording()) | 406 if (audio_processing->StopDebugRecording()) |
| 407 DLOG(ERROR) << "Fail to stop AEC debug recording"; | 407 DLOG(ERROR) << "Fail to stop AEC debug recording"; |
| 408 } | 408 } |
| 409 | 409 |
| 410 void EnableAutomaticGainControl(AudioProcessing* audio_processing) { | 410 void EnableAutomaticGainControl(AudioProcessing* audio_processing) { |
| 411 #if defined(OS_ANDROID) || defined(OS_IOS) | 411 #if defined(OS_ANDROID) |
| 412 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; | 412 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; |
| 413 #else | 413 #else |
| 414 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; | 414 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; |
| 415 #endif | 415 #endif |
| 416 int err = audio_processing->gain_control()->set_mode(mode); | 416 int err = audio_processing->gain_control()->set_mode(mode); |
| 417 err |= audio_processing->gain_control()->Enable(true); | 417 err |= audio_processing->gain_control()->Enable(true); |
| 418 CHECK_EQ(err, 0); | 418 CHECK_EQ(err, 0); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void GetAecStats(webrtc::EchoCancellation* echo_cancellation, | 421 void GetAecStats(webrtc::EchoCancellation* echo_cancellation, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 467 |
| 468 // Give preference to the audio constraint over the device-supplied mic | 468 // Give preference to the audio constraint over the device-supplied mic |
| 469 // positions. This is mainly for testing purposes. | 469 // positions. This is mainly for testing purposes. |
| 470 return WebrtcPointsFromMediaPoints( | 470 return WebrtcPointsFromMediaPoints( |
| 471 constraints_geometry.empty() | 471 constraints_geometry.empty() |
| 472 ? input_params.mic_positions | 472 ? input_params.mic_positions |
| 473 : media::ParsePointsFromString(constraints_geometry)); | 473 : media::ParsePointsFromString(constraints_geometry)); |
| 474 } | 474 } |
| 475 | 475 |
| 476 } // namespace content | 476 } // namespace content |
| OLD | NEW |