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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Configure the update period to 100ms (10 * 10ms) in the typing detector. | 137 // Configure the update period to 100ms (10 * 10ms) in the typing detector. |
138 typing_detector->SetParameters(0, 0, 0, 0, 0, 10); | 138 typing_detector->SetParameters(0, 0, 0, 0, 0, 10); |
139 } | 139 } |
140 | 140 |
141 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { | 141 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { |
142 webrtc::Config config; | 142 webrtc::Config config; |
143 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); | 143 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); |
144 audio_processing->SetExtraOptions(config); | 144 audio_processing->SetExtraOptions(config); |
145 } | 145 } |
146 | 146 |
147 void StartAecDump(AudioProcessing* audio_processing) { | 147 void StartEchoCancellationDump(AudioProcessing* audio_processing, |
148 // TODO(grunell): Figure out a more suitable directory for the audio dump | 148 const base::PlatformFile& aec_dump_file) { |
149 // data. | 149 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); |
150 base::FilePath path; | |
151 #if defined(CHROMEOS) | |
152 PathService::Get(base::DIR_TEMP, &path); | |
153 #elif defined(ANDROID) | |
154 path = base::FilePath(FILE_PATH_LITERAL("sdcard")); | |
155 #else | |
156 PathService::Get(base::DIR_EXE, &path); | |
157 #endif | |
158 base::FilePath file = path.Append(FILE_PATH_LITERAL("audio.aecdump")); | |
159 | 150 |
160 #if defined(OS_WIN) | 151 FILE* stream = base::FdopenPlatformFile(aec_dump_file, "w"); |
161 const std::string file_name = base::WideToUTF8(file.value()); | 152 if (!stream) { |
162 #else | 153 LOG(ERROR) << "Failed to open AEC dump file"; |
163 const std::string file_name = file.value(); | 154 return; |
164 #endif | 155 } |
165 if (audio_processing->StartDebugRecording(file_name.c_str())) | 156 |
| 157 if (audio_processing->StartDebugRecording(stream)) |
166 DLOG(ERROR) << "Fail to start AEC debug recording"; | 158 DLOG(ERROR) << "Fail to start AEC debug recording"; |
167 } | 159 } |
168 | 160 |
169 void StopAecDump(AudioProcessing* audio_processing) { | 161 void StopEchoCancellationDump(AudioProcessing* audio_processing) { |
170 if (audio_processing->StopDebugRecording()) | 162 if (audio_processing->StopDebugRecording()) |
171 DLOG(ERROR) << "Fail to stop AEC debug recording"; | 163 DLOG(ERROR) << "Fail to stop AEC debug recording"; |
172 } | 164 } |
173 | 165 |
174 void EnableAutomaticGainControl(AudioProcessing* audio_processing) { | 166 void EnableAutomaticGainControl(AudioProcessing* audio_processing) { |
175 #if defined(OS_ANDROID) || defined(OS_IOS) | 167 #if defined(OS_ANDROID) || defined(OS_IOS) |
176 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; | 168 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; |
177 #else | 169 #else |
178 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; | 170 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; |
179 #endif | 171 #endif |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 207 } |
216 | 208 |
217 int median = 0, std = 0; | 209 int median = 0, std = 0; |
218 if (!audio_processing->echo_cancellation()->GetDelayMetrics(&median, &std)) { | 210 if (!audio_processing->echo_cancellation()->GetDelayMetrics(&median, &std)) { |
219 stats->echo_delay_median_ms = median; | 211 stats->echo_delay_median_ms = median; |
220 stats->echo_delay_std_ms = std; | 212 stats->echo_delay_std_ms = std; |
221 } | 213 } |
222 } | 214 } |
223 | 215 |
224 } // namespace content | 216 } // namespace content |
OLD | NEW |