Chromium Code Reviews| 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 "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 webrtc::MediaConstraintsInterface::kValueTrue }, | 32 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 33 #endif | 33 #endif |
| 34 { webrtc::MediaConstraintsInterface::kAutoGainControl, | 34 { webrtc::MediaConstraintsInterface::kAutoGainControl, |
| 35 webrtc::MediaConstraintsInterface::kValueTrue }, | 35 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 36 { webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl, | 36 { webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl, |
| 37 webrtc::MediaConstraintsInterface::kValueTrue }, | 37 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 38 { webrtc::MediaConstraintsInterface::kNoiseSuppression, | 38 { webrtc::MediaConstraintsInterface::kNoiseSuppression, |
| 39 webrtc::MediaConstraintsInterface::kValueTrue }, | 39 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 40 { webrtc::MediaConstraintsInterface::kHighpassFilter, | 40 { webrtc::MediaConstraintsInterface::kHighpassFilter, |
| 41 webrtc::MediaConstraintsInterface::kValueTrue }, | 41 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 42 // TODO(xians): Verify if it is OK to set typing detection to kValueFalse as | |
| 43 // default. | |
| 44 { webrtc::MediaConstraintsInterface::kTypingNoiseDetection, | 42 { webrtc::MediaConstraintsInterface::kTypingNoiseDetection, |
| 45 webrtc::MediaConstraintsInterface::kValueFalse }, | 43 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 } // namespace | 46 } // namespace |
| 49 | 47 |
| 50 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) { | 48 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) { |
| 51 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { | 49 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { |
| 52 bool already_set_value; | 50 bool already_set_value; |
| 53 if (!webrtc::FindConstraint(constraints, kDefaultAudioConstraints[i].key, | 51 if (!webrtc::FindConstraint(constraints, kDefaultAudioConstraints[i].key, |
| 54 &already_set_value, NULL)) { | 52 &already_set_value, NULL)) { |
| 55 constraints->AddMandatory(kDefaultAudioConstraints[i].key, | 53 constraints->AddMandatory(kDefaultAudioConstraints[i].key, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 83 return false; | 81 return false; |
| 84 } | 82 } |
| 85 | 83 |
| 86 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints, | 84 bool GetPropertyFromConstraints(const MediaConstraintsInterface* constraints, |
| 87 const std::string& key) { | 85 const std::string& key) { |
| 88 bool value = false; | 86 bool value = false; |
| 89 return webrtc::FindConstraint(constraints, key, &value, NULL) && value; | 87 return webrtc::FindConstraint(constraints, key, &value, NULL) && value; |
| 90 } | 88 } |
| 91 | 89 |
| 92 void EnableEchoCancellation(AudioProcessing* audio_processing) { | 90 void EnableEchoCancellation(AudioProcessing* audio_processing) { |
| 93 #if defined(OS_IOS) | 91 #if defined(OS_IOS) |
|
ajm
2014/01/22 21:50:55
For echo cancellation you have the disable switch
no longer working on chromium
2014/01/23 12:46:08
Done.
| |
| 94 // On iOS, VPIO provides built-in EC and AGC. | 92 // On iOS, VPIO provides built-in EC and AGC. |
| 95 return; | 93 return; |
| 96 #elif defined(OS_ANDROID) | 94 #elif defined(OS_ANDROID) |
| 97 // Mobile devices are using AECM. | 95 // Mobile devices are using AECM. |
| 98 int err = audio_processing->echo_control_mobile()->Enable(true); | 96 int err = audio_processing->echo_control_mobile()->Enable(true); |
| 99 err |= audio_processing->echo_control_mobile()->set_routing_mode( | 97 err |= audio_processing->echo_control_mobile()->set_routing_mode( |
|
ajm
2014/01/22 21:50:55
nit: it's slightly (though probably unmeasurably)
no longer working on chromium
2014/01/23 12:46:08
Done.
| |
| 100 webrtc::EchoControlMobile::kSpeakerphone); | 98 webrtc::EchoControlMobile::kSpeakerphone); |
| 101 CHECK_EQ(err, 0); | 99 CHECK_EQ(err, 0); |
| 102 #else | 100 #else |
| 103 int err = audio_processing->echo_cancellation()->Enable(true); | 101 int err = audio_processing->echo_cancellation()->Enable(true); |
| 104 err |= audio_processing->echo_cancellation()->set_suppression_level( | 102 err |= audio_processing->echo_cancellation()->set_suppression_level( |
| 105 webrtc::EchoCancellation::kHighSuppression); | 103 webrtc::EchoCancellation::kHighSuppression); |
| 106 | 104 |
| 107 // Enable the metrics for AEC. | 105 // Enable the metrics for AEC. |
| 108 err |= audio_processing->echo_cancellation()->enable_metrics(true); | 106 err |= audio_processing->echo_cancellation()->enable_metrics(true); |
| 109 err |= audio_processing->echo_cancellation()->enable_delay_logging(true); | 107 err |= audio_processing->echo_cancellation()->enable_delay_logging(true); |
| 110 CHECK_EQ(err, 0); | 108 CHECK_EQ(err, 0); |
| 111 #endif | 109 #endif |
| 112 } | 110 } |
| 113 | 111 |
| 114 void EnableNoiseSuppression(AudioProcessing* audio_processing) { | 112 void EnableNoiseSuppression(AudioProcessing* audio_processing) { |
| 115 int err = audio_processing->noise_suppression()->set_level( | 113 int err = audio_processing->noise_suppression()->set_level( |
| 116 webrtc::NoiseSuppression::kHigh); | 114 webrtc::NoiseSuppression::kHigh); |
| 117 err |= audio_processing->noise_suppression()->Enable(true); | 115 err |= audio_processing->noise_suppression()->Enable(true); |
| 118 CHECK_EQ(err, 0); | 116 CHECK_EQ(err, 0); |
| 119 } | 117 } |
| 120 | 118 |
| 121 void EnableHighPassFilter(AudioProcessing* audio_processing) { | 119 void EnableHighPassFilter(AudioProcessing* audio_processing) { |
| 122 CHECK_EQ(audio_processing->high_pass_filter()->Enable(true), 0); | 120 CHECK_EQ(audio_processing->high_pass_filter()->Enable(true), 0); |
| 123 } | 121 } |
| 124 | 122 |
| 125 // TODO(xians): stereo swapping | |
| 126 void EnableTypingDetection(AudioProcessing* audio_processing) { | 123 void EnableTypingDetection(AudioProcessing* audio_processing) { |
| 127 int err = audio_processing->voice_detection()->Enable(true); | 124 int err = audio_processing->voice_detection()->Enable(true); |
| 128 err |= audio_processing->voice_detection()->set_likelihood( | 125 err |= audio_processing->voice_detection()->set_likelihood( |
| 129 webrtc::VoiceDetection::kVeryLowLikelihood); | 126 webrtc::VoiceDetection::kVeryLowLikelihood); |
| 130 CHECK_EQ(err, 0); | 127 CHECK_EQ(err, 0); |
| 131 } | 128 } |
| 132 | 129 |
| 133 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { | 130 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { |
| 134 webrtc::Config config; | 131 webrtc::Config config; |
| 135 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); | 132 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 156 #endif | 153 #endif |
| 157 if (audio_processing->StartDebugRecording(file_name.c_str())) | 154 if (audio_processing->StartDebugRecording(file_name.c_str())) |
| 158 DLOG(ERROR) << "Fail to start AEC debug recording"; | 155 DLOG(ERROR) << "Fail to start AEC debug recording"; |
| 159 } | 156 } |
| 160 | 157 |
| 161 void StopAecDump(AudioProcessing* audio_processing) { | 158 void StopAecDump(AudioProcessing* audio_processing) { |
| 162 if (audio_processing->StopDebugRecording()) | 159 if (audio_processing->StopDebugRecording()) |
| 163 DLOG(ERROR) << "Fail to stop AEC debug recording"; | 160 DLOG(ERROR) << "Fail to stop AEC debug recording"; |
| 164 } | 161 } |
| 165 | 162 |
| 163 void EnableAutomaticGainControl(AudioProcessing* audio_processing) { | |
| 164 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 165 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; | |
| 166 #else | |
| 167 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; | |
| 168 #endif | |
| 169 int err = audio_processing->gain_control()->set_mode(mode); | |
| 170 err |= audio_processing->gain_control()->Enable(true); | |
| 171 CHECK_EQ(err, 0); | |
| 172 } | |
| 173 | |
| 166 } // namespace content | 174 } // namespace content |
| OLD | NEW |