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 <ctime> | 5 #include <ctime> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // <Monitor of x>, where x is whatever your primary sound device is called. | 70 // <Monitor of x>, where x is whatever your primary sound device is called. |
71 // 6. Try launching chrome as the target user on the target machine, try | 71 // 6. Try launching chrome as the target user on the target machine, try |
72 // playing, say, a YouTube video, and record with # arecord -f dat tmp.dat. | 72 // playing, say, a YouTube video, and record with # arecord -f dat tmp.dat. |
73 // Verify the recording with aplay (should have recorded what you played | 73 // Verify the recording with aplay (should have recorded what you played |
74 // from chrome). | 74 // from chrome). |
75 // | 75 // |
76 // Note: the volume for ALL your input devices will be forced to 100% by | 76 // Note: the volume for ALL your input devices will be forced to 100% by |
77 // running this test on Linux. | 77 // running this test on Linux. |
78 // | 78 // |
79 // On Mac: | 79 // On Mac: |
| 80 // TODO(phoglund): download sox from gs instead. |
80 // 1. Get SoundFlower: http://rogueamoeba.com/freebies/soundflower/download.php | 81 // 1. Get SoundFlower: http://rogueamoeba.com/freebies/soundflower/download.php |
81 // 2. Install it + reboot. | 82 // 2. Install it + reboot. |
82 // 3. Install MacPorts (http://www.macports.org/). | 83 // 3. Install MacPorts (http://www.macports.org/). |
83 // 4. Install sox: sudo port install sox. | 84 // 4. Install sox: sudo port install sox. |
84 // 5. (For Chrome bots) Ensure sox and rec are reachable from the env the test | 85 // 5. (For Chrome bots) Ensure sox and rec are reachable from the env the test |
85 // executes in (sox and rec tends to install in /opt/, which generally isn't | 86 // executes in (sox and rec tends to install in /opt/, which generally isn't |
86 // in the Chrome bots' env). For instance, run | 87 // in the Chrome bots' env). For instance, run |
87 // sudo ln -s /opt/local/bin/rec /usr/local/bin/rec | 88 // sudo ln -s /opt/local/bin/rec /usr/local/bin/rec |
88 // sudo ln -s /opt/local/bin/sox /usr/local/bin/sox | 89 // sudo ln -s /opt/local/bin/sox /usr/local/bin/sox |
89 // 6. In Sound Preferences, set both input and output to Soundflower (2ch). | 90 // 6. In Sound Preferences, set both input and output to Soundflower (2ch). |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 } | 298 } |
298 } | 299 } |
299 #endif | 300 #endif |
300 return true; | 301 return true; |
301 } | 302 } |
302 | 303 |
303 // Sox is the "Swiss army knife" of audio processing. We mainly use it for | 304 // Sox is the "Swiss army knife" of audio processing. We mainly use it for |
304 // silence trimming. See http://sox.sourceforge.net. | 305 // silence trimming. See http://sox.sourceforge.net. |
305 base::CommandLine MakeSoxCommandLine() { | 306 base::CommandLine MakeSoxCommandLine() { |
306 #if defined(OS_WIN) | 307 #if defined(OS_WIN) |
307 base::FilePath sox_path = test::GetReferenceFilesDir().Append( | 308 base::FilePath sox_path = test::GetToolForPlatform("sox"); |
308 FILE_PATH_LITERAL("tools/sox.exe")); | |
309 if (!base::PathExists(sox_path)) { | 309 if (!base::PathExists(sox_path)) { |
310 LOG(ERROR) << "Missing sox.exe binary in " << sox_path.value() | 310 LOG(ERROR) << "Missing sox.exe binary in " << sox_path.value() |
311 << "; you may have to provide this binary yourself."; | 311 << "; you may have to provide this binary yourself."; |
312 return base::CommandLine(base::CommandLine::NO_PROGRAM); | 312 return base::CommandLine(base::CommandLine::NO_PROGRAM); |
313 } | 313 } |
314 base::CommandLine command_line(sox_path); | 314 base::CommandLine command_line(sox_path); |
315 #else | 315 #else |
| 316 // TODO(phoglund): call checked-in sox rather than system sox on mac/linux. |
| 317 // Same for rec invocations on Mac, above. |
316 base::CommandLine command_line(base::FilePath(FILE_PATH_LITERAL("sox"))); | 318 base::CommandLine command_line(base::FilePath(FILE_PATH_LITERAL("sox"))); |
317 #endif | 319 #endif |
318 return command_line; | 320 return command_line; |
319 } | 321 } |
320 | 322 |
321 // Removes silence from beginning and end of the |input_audio_file| and writes | 323 // Removes silence from beginning and end of the |input_audio_file| and writes |
322 // the result to the |output_audio_file|. Returns true on success. | 324 // the result to the |output_audio_file|. Returns true on success. |
323 bool RemoveSilence(const base::FilePath& input_file, | 325 bool RemoveSilence(const base::FilePath& input_file, |
324 const base::FilePath& output_file) { | 326 const base::FilePath& output_file) { |
325 // SOX documentation for silence command: http://sox.sourceforge.net/sox.html | 327 // SOX documentation for silence command: http://sox.sourceforge.net/sox.html |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 // The raw score in MOS is written to |raw_mos|, whereas the MOS-LQO score is | 413 // The raw score in MOS is written to |raw_mos|, whereas the MOS-LQO score is |
412 // written to mos_lqo. The scores are returned as floats in string form (e.g. | 414 // written to mos_lqo. The scores are returned as floats in string form (e.g. |
413 // "3.145", etc). Returns true on success. | 415 // "3.145", etc). Returns true on success. |
414 bool RunPesq(const base::FilePath& reference_file, | 416 bool RunPesq(const base::FilePath& reference_file, |
415 const base::FilePath& actual_file, | 417 const base::FilePath& actual_file, |
416 int sample_rate, std::string* raw_mos, std::string* mos_lqo) { | 418 int sample_rate, std::string* raw_mos, std::string* mos_lqo) { |
417 // PESQ will break if the paths are too long (!). | 419 // PESQ will break if the paths are too long (!). |
418 EXPECT_LT(reference_file.value().length(), 128u); | 420 EXPECT_LT(reference_file.value().length(), 128u); |
419 EXPECT_LT(actual_file.value().length(), 128u); | 421 EXPECT_LT(actual_file.value().length(), 128u); |
420 | 422 |
421 #if defined(OS_WIN) | 423 base::FilePath pesq_path = test::GetToolForPlatform("pesq"); |
422 base::FilePath pesq_path = | |
423 test::GetReferenceFilesDir().Append(FILE_PATH_LITERAL("tools/pesq.exe")); | |
424 #elif defined(OS_MACOSX) | |
425 base::FilePath pesq_path = | |
426 test::GetReferenceFilesDir().Append(FILE_PATH_LITERAL("tools/pesq_mac")); | |
427 #else | |
428 base::FilePath pesq_path = | |
429 test::GetReferenceFilesDir().Append(FILE_PATH_LITERAL("tools/pesq")); | |
430 #endif | |
431 | |
432 if (!base::PathExists(pesq_path)) { | 424 if (!base::PathExists(pesq_path)) { |
433 LOG(ERROR) << "Missing PESQ binary in " << pesq_path.value() | 425 LOG(ERROR) << "Missing PESQ binary in " << pesq_path.value() |
434 << "; you may have to provide this binary yourself."; | 426 << "; you may have to provide this binary yourself."; |
435 return false; | 427 return false; |
436 } | 428 } |
437 | 429 |
438 base::CommandLine command_line(pesq_path); | 430 base::CommandLine command_line(pesq_path); |
439 command_line.AppendArg(base::StringPrintf("+%d", sample_rate)); | 431 command_line.AppendArg(base::StringPrintf("+%d", sample_rate)); |
440 command_line.AppendArgPath(reference_file); | 432 command_line.AppendArgPath(reference_file); |
441 command_line.AppendArgPath(actual_file); | 433 command_line.AppendArgPath(actual_file); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 #endif | 766 #endif |
775 | 767 |
776 // Since the AGC is off here there should be no gain at all. | 768 // Since the AGC is off here there should be no gain at all. |
777 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, | 769 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, |
778 MAYBE_MANUAL_TestAutoGainIsOffWithAudioProcessingOff) { | 770 MAYBE_MANUAL_TestAutoGainIsOffWithAudioProcessingOff) { |
779 const char* kAudioCallWithoutAudioProcessing = | 771 const char* kAudioCallWithoutAudioProcessing = |
780 "{audio: { mandatory: { echoCancellation: false } } }"; | 772 "{audio: { mandatory: { echoCancellation: false } } }"; |
781 ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( | 773 ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( |
782 kReferenceFile, kAudioCallWithoutAudioProcessing, "_no_agc")); | 774 kReferenceFile, kAudioCallWithoutAudioProcessing, "_no_agc")); |
783 } | 775 } |
OLD | NEW |