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

Side by Side Diff: chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc

Issue 83413006: Replace LOG(INFO) with VLOG(0), throughout *media* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase2 Created 7 years 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 | Annotate | Revision Log
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 <ctime> 5 #include <ctime>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/process/launch.h" 10 #include "base/process/launch.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 command_line.SetProgram(base::FilePath("arecord")); 215 command_line.SetProgram(base::FilePath("arecord"));
216 command_line.AppendArg("-d"); 216 command_line.AppendArg("-d");
217 command_line.AppendArg(base::StringPrintf("%d", duration_sec)); 217 command_line.AppendArg(base::StringPrintf("%d", duration_sec));
218 command_line.AppendArg("-f"); 218 command_line.AppendArg("-f");
219 command_line.AppendArg("dat"); 219 command_line.AppendArg("dat");
220 command_line.AppendArg("-c"); 220 command_line.AppendArg("-c");
221 command_line.AppendArg(base::StringPrintf("%d", num_channels)); 221 command_line.AppendArg(base::StringPrintf("%d", num_channels));
222 command_line.AppendArgPath(output_file); 222 command_line.AppendArgPath(output_file);
223 #endif 223 #endif
224 224
225 LOG(INFO) << "Running " << command_line.GetCommandLineString(); 225 VLOG(0) << "Running " << command_line.GetCommandLineString();
226 return base::LaunchProcess(command_line, base::LaunchOptions(), 226 return base::LaunchProcess(command_line, base::LaunchOptions(),
227 &recording_application_); 227 &recording_application_);
228 } 228 }
229 229
230 // Joins the recording program. Returns true on success. 230 // Joins the recording program. Returns true on success.
231 bool WaitForRecordingToEnd() { 231 bool WaitForRecordingToEnd() {
232 int exit_code = -1; 232 int exit_code = -1;
233 base::WaitForExitCode(recording_application_, &exit_code); 233 base::WaitForExitCode(recording_application_, &exit_code);
234 return exit_code == 0; 234 return exit_code == 0;
235 } 235 }
236 private: 236 private:
237 base::ProcessHandle recording_application_; 237 base::ProcessHandle recording_application_;
238 }; 238 };
239 239
240 bool ForceMicrophoneVolumeTo100Percent() { 240 bool ForceMicrophoneVolumeTo100Percent() {
241 #if defined(OS_WIN) 241 #if defined(OS_WIN)
242 CommandLine command_line(GetTestDataDir().Append(kToolsPath).Append( 242 CommandLine command_line(GetTestDataDir().Append(kToolsPath).Append(
243 FILE_PATH_LITERAL("force_mic_volume_max.exe"))); 243 FILE_PATH_LITERAL("force_mic_volume_max.exe")));
244 LOG(INFO) << "Running " << command_line.GetCommandLineString(); 244 VLOG(0) << "Running " << command_line.GetCommandLineString();
245 std::string result; 245 std::string result;
246 if (!base::GetAppOutput(command_line, &result)) { 246 if (!base::GetAppOutput(command_line, &result)) {
247 LOG(ERROR) << "Failed to set source volume: output was " << result; 247 LOG(ERROR) << "Failed to set source volume: output was " << result;
248 return false; 248 return false;
249 } 249 }
250 #else 250 #else
251 // Just force the volume of, say the first 5 devices. A machine will rarely 251 // Just force the volume of, say the first 5 devices. A machine will rarely
252 // have more input sources than that. This is way easier than finding the 252 // have more input sources than that. This is way easier than finding the
253 // input device we happen to be using. 253 // input device we happen to be using.
254 for (int device_index = 0; device_index < 5; ++device_index) { 254 for (int device_index = 0; device_index < 5; ++device_index) {
255 std::string result; 255 std::string result;
256 const std::string kHundredPercentVolume = "65536"; 256 const std::string kHundredPercentVolume = "65536";
257 CommandLine command_line(base::FilePath(FILE_PATH_LITERAL("pacmd"))); 257 CommandLine command_line(base::FilePath(FILE_PATH_LITERAL("pacmd")));
258 command_line.AppendArg("set-source-volume"); 258 command_line.AppendArg("set-source-volume");
259 command_line.AppendArg(base::StringPrintf("%d", device_index)); 259 command_line.AppendArg(base::StringPrintf("%d", device_index));
260 command_line.AppendArg(kHundredPercentVolume); 260 command_line.AppendArg(kHundredPercentVolume);
261 LOG(INFO) << "Running " << command_line.GetCommandLineString(); 261 VLOG(0) << "Running " << command_line.GetCommandLineString();
262 if (!base::GetAppOutput(command_line, &result)) { 262 if (!base::GetAppOutput(command_line, &result)) {
263 LOG(ERROR) << "Failed to set source volume: output was " << result; 263 LOG(ERROR) << "Failed to set source volume: output was " << result;
264 return false; 264 return false;
265 } 265 }
266 } 266 }
267 #endif 267 #endif
268 return true; 268 return true;
269 } 269 }
270 270
271 // Removes silence from beginning and end of the |input_audio_file| and writes 271 // Removes silence from beginning and end of the |input_audio_file| and writes
(...skipping 26 matching lines...) Expand all
298 command_line.AppendArg(kAbovePeriods); 298 command_line.AppendArg(kAbovePeriods);
299 command_line.AppendArg(kDuration); 299 command_line.AppendArg(kDuration);
300 command_line.AppendArg(kTreshold); 300 command_line.AppendArg(kTreshold);
301 command_line.AppendArg("reverse"); 301 command_line.AppendArg("reverse");
302 command_line.AppendArg("silence"); 302 command_line.AppendArg("silence");
303 command_line.AppendArg(kAbovePeriods); 303 command_line.AppendArg(kAbovePeriods);
304 command_line.AppendArg(kDuration); 304 command_line.AppendArg(kDuration);
305 command_line.AppendArg(kTreshold); 305 command_line.AppendArg(kTreshold);
306 command_line.AppendArg("reverse"); 306 command_line.AppendArg("reverse");
307 307
308 LOG(INFO) << "Running " << command_line.GetCommandLineString(); 308 VLOG(0) << "Running " << command_line.GetCommandLineString();
309 std::string result; 309 std::string result;
310 bool ok = base::GetAppOutput(command_line, &result); 310 bool ok = base::GetAppOutput(command_line, &result);
311 LOG(INFO) << "Output was:\n\n" << result; 311 VLOG(0) << "Output was:\n\n" << result;
312 return ok; 312 return ok;
313 } 313 }
314 314
315 bool CanParseAsFloat(const std::string& value) { 315 bool CanParseAsFloat(const std::string& value) {
316 return atof(value.c_str()) != 0 || value == "0"; 316 return atof(value.c_str()) != 0 || value == "0";
317 } 317 }
318 318
319 // Runs PESQ to compare |reference_file| to a |actual_file|. The |sample_rate| 319 // Runs PESQ to compare |reference_file| to a |actual_file|. The |sample_rate|
320 // can be either 16000 or 8000. 320 // can be either 16000 or 8000.
321 // 321 //
(...skipping 23 matching lines...) Expand all
345 if (!base::PathExists(pesq_path)) { 345 if (!base::PathExists(pesq_path)) {
346 LOG(ERROR) << "Missing PESQ binary in " << pesq_path.value(); 346 LOG(ERROR) << "Missing PESQ binary in " << pesq_path.value();
347 return false; 347 return false;
348 } 348 }
349 349
350 CommandLine command_line(pesq_path); 350 CommandLine command_line(pesq_path);
351 command_line.AppendArg(base::StringPrintf("+%d", sample_rate)); 351 command_line.AppendArg(base::StringPrintf("+%d", sample_rate));
352 command_line.AppendArgPath(reference_file); 352 command_line.AppendArgPath(reference_file);
353 command_line.AppendArgPath(actual_file); 353 command_line.AppendArgPath(actual_file);
354 354
355 LOG(INFO) << "Running " << command_line.GetCommandLineString(); 355 VLOG(0) << "Running " << command_line.GetCommandLineString();
356 std::string result; 356 std::string result;
357 if (!base::GetAppOutput(command_line, &result)) { 357 if (!base::GetAppOutput(command_line, &result)) {
358 LOG(ERROR) << "Failed to run PESQ."; 358 LOG(ERROR) << "Failed to run PESQ.";
359 return false; 359 return false;
360 } 360 }
361 LOG(INFO) << "Output was:\n\n" << result; 361 VLOG(0) << "Output was:\n\n" << result;
362 362
363 const std::string result_anchor = "Prediction (Raw MOS, MOS-LQO): = "; 363 const std::string result_anchor = "Prediction (Raw MOS, MOS-LQO): = ";
364 std::size_t anchor_pos = result.find(result_anchor); 364 std::size_t anchor_pos = result.find(result_anchor);
365 if (anchor_pos == std::string::npos) { 365 if (anchor_pos == std::string::npos) {
366 LOG(ERROR) << "PESQ was not able to compute a score; we probably recorded " 366 LOG(ERROR) << "PESQ was not able to compute a score; we probably recorded "
367 << "only silence."; 367 << "only silence.";
368 return false; 368 return false;
369 } 369 }
370 370
371 // There are two tab-separated numbers on the format x.xxx, e.g. 5 chars each. 371 // There are two tab-separated numbers on the format x.xxx, e.g. 5 chars each.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 // Note: the sound clip is about 10 seconds: record for 15 seconds to get some 432 // Note: the sound clip is about 10 seconds: record for 15 seconds to get some
433 // safety margins on each side. 433 // safety margins on each side.
434 AudioRecorder recorder; 434 AudioRecorder recorder;
435 static int kRecordingTimeSeconds = 15; 435 static int kRecordingTimeSeconds = 15;
436 ASSERT_TRUE(recorder.StartRecording(kRecordingTimeSeconds, recording, true)); 436 ASSERT_TRUE(recorder.StartRecording(kRecordingTimeSeconds, recording, true));
437 437
438 PlayAudioFile(left_tab); 438 PlayAudioFile(left_tab);
439 439
440 ASSERT_TRUE(recorder.WaitForRecordingToEnd()); 440 ASSERT_TRUE(recorder.WaitForRecordingToEnd());
441 LOG(INFO) << "Done recording to " << recording.value() << std::endl; 441 VLOG(0) << "Done recording to " << recording.value() << std::endl;
442 442
443 AssertNoAsynchronousErrors(left_tab); 443 AssertNoAsynchronousErrors(left_tab);
444 AssertNoAsynchronousErrors(right_tab); 444 AssertNoAsynchronousErrors(right_tab);
445 445
446 HangUp(left_tab); 446 HangUp(left_tab);
447 WaitUntilHangupVerified(left_tab); 447 WaitUntilHangupVerified(left_tab);
448 WaitUntilHangupVerified(right_tab); 448 WaitUntilHangupVerified(right_tab);
449 449
450 AssertNoAsynchronousErrors(left_tab); 450 AssertNoAsynchronousErrors(left_tab);
451 AssertNoAsynchronousErrors(right_tab); 451 AssertNoAsynchronousErrors(right_tab);
452 452
453 base::FilePath trimmed_recording = CreateTemporaryWaveFile(); 453 base::FilePath trimmed_recording = CreateTemporaryWaveFile();
454 454
455 ASSERT_TRUE(RemoveSilence(recording, trimmed_recording)); 455 ASSERT_TRUE(RemoveSilence(recording, trimmed_recording));
456 LOG(INFO) << "Trimmed silence: " << trimmed_recording.value() << std::endl; 456 VLOG(0) << "Trimmed silence: " << trimmed_recording.value() << std::endl;
457 457
458 std::string raw_mos; 458 std::string raw_mos;
459 std::string mos_lqo; 459 std::string mos_lqo;
460 base::FilePath reference_file_in_test_dir = 460 base::FilePath reference_file_in_test_dir =
461 GetTestDataDir().Append(kReferenceFile); 461 GetTestDataDir().Append(kReferenceFile);
462 ASSERT_TRUE(RunPesq(reference_file_in_test_dir, trimmed_recording, 16000, 462 ASSERT_TRUE(RunPesq(reference_file_in_test_dir, trimmed_recording, 16000,
463 &raw_mos, &mos_lqo)); 463 &raw_mos, &mos_lqo));
464 464
465 perf_test::PrintResult("audio_pesq", "", "raw_mos", raw_mos, "score", true); 465 perf_test::PrintResult("audio_pesq", "", "raw_mos", raw_mos, "score", true);
466 perf_test::PrintResult("audio_pesq", "", "mos_lqo", mos_lqo, "score", true); 466 perf_test::PrintResult("audio_pesq", "", "mos_lqo", mos_lqo, "score", true);
467 467
468 EXPECT_TRUE(base::DeleteFile(recording, false)); 468 EXPECT_TRUE(base::DeleteFile(recording, false));
469 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false)); 469 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false));
470 470
471 ASSERT_TRUE(peerconnection_server_.Stop()); 471 ASSERT_TRUE(peerconnection_server_.Stop());
472 } 472 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698