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

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

Issue 23562002: Will now force the volume of all input devices in the WebRTC audio test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed win compilation error Created 7 years, 3 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // This test will only work on machines that have been configured to record 65 // This test will only work on machines that have been configured to record
66 // their own input. 66 // their own input.
67 // 67 //
68 // On Linux: 68 // On Linux:
69 // 1. # sudo apt-get install pavucontrol 69 // 1. # sudo apt-get install pavucontrol
70 // 2. For the user who will run the test: # pavucontrol 70 // 2. For the user who will run the test: # pavucontrol
71 // 3. In a separate terminal, # arecord dummy 71 // 3. In a separate terminal, # arecord dummy
72 // 4. In pavucontrol, go to the recording tab. 72 // 4. In pavucontrol, go to the recording tab.
73 // 5. For the ALSA plug-in [aplay]: ALSA Capture from, change from <x> to 73 // 5. For the ALSA plug-in [aplay]: ALSA Capture from, change from <x> to
74 // <Monitor of x>, where x is whatever your primary sound device is called. 74 // <Monitor of x>, where x is whatever your primary sound device is called.
75 // This test expects the device id to be render.monitor - if it's something
76 // else, the microphone level will not get forced to 100% appropriately.
77 // See ForceMicrophoneVolumeTo100% for more details. You can list the
78 // available monitor devices on your system by running the command
79 // pacmd list-sources | grep name | grep monitor.
80 // 6. Try launching chrome as the target user on the target machine, try 75 // 6. Try launching chrome as the target user on the target machine, try
81 // playing, say, a YouTube video, and record with # arecord -f dat tmp.dat. 76 // playing, say, a YouTube video, and record with # arecord -f dat tmp.dat.
82 // Verify the recording with aplay (should have recorded what you played 77 // Verify the recording with aplay (should have recorded what you played
83 // from chrome). 78 // from chrome).
84 // 79 //
80 // Note: the volume for ALL your input devices will be forced to 100% by
81 // running this test on Linux.
82 //
85 // On Windows 7: 83 // On Windows 7:
86 // 1. Control panel > Sound > Manage audio devices. 84 // 1. Control panel > Sound > Manage audio devices.
87 // 2. In the recording tab, right-click in an empty space in the pane with the 85 // 2. In the recording tab, right-click in an empty space in the pane with the
88 // devices. Tick 'show disabled devices'. 86 // devices. Tick 'show disabled devices'.
89 // 3. You should see a 'stero mix' device - this is what your speakers output. 87 // 3. You should see a 'stero mix' device - this is what your speakers output.
90 // Right click > Properties. 88 // Right click > Properties.
91 // 4. In the Listen tab for the mix device, check the 'listen to this device' 89 // 4. In the Listen tab for the mix device, check the 'listen to this device'
92 // checkbox. Ensure the mix device is the default recording device. 90 // checkbox. Ensure the mix device is the default recording device.
93 // 5. Launch chrome and try playing a video with sound. You should see 91 // 5. Launch chrome and try playing a video with sound. You should see
94 // in the volume meter for the mix device. Configure the mix device to have 92 // in the volume meter for the mix device. Configure the mix device to have
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Joins the recording program. Returns true on success. 257 // Joins the recording program. Returns true on success.
260 bool WaitForRecordingToEnd() { 258 bool WaitForRecordingToEnd() {
261 int exit_code = -1; 259 int exit_code = -1;
262 base::WaitForExitCode(recording_application_, &exit_code); 260 base::WaitForExitCode(recording_application_, &exit_code);
263 return exit_code == 0; 261 return exit_code == 0;
264 } 262 }
265 private: 263 private:
266 base::ProcessHandle recording_application_; 264 base::ProcessHandle recording_application_;
267 }; 265 };
268 266
269 void ForceMicrophoneVolumeTo100Percent() { 267 bool ForceMicrophoneVolumeTo100Percent() {
270 #if defined(OS_WIN) 268 #if defined(OS_WIN)
271 CommandLine command_line(GetTestDataDir().Append(kToolsPath).Append( 269 CommandLine command_line(GetTestDataDir().Append(kToolsPath).Append(
272 FILE_PATH_LITERAL("force_mic_volume_max.exe"))); 270 FILE_PATH_LITERAL("force_mic_volume_max.exe")));
273 #else
274 const std::string kRecordingDeviceId = "render.monitor";
275 const std::string kHundredPercentVolume = "65536";
276
277 CommandLine command_line(base::FilePath(FILE_PATH_LITERAL("pacmd")));
278 command_line.AppendArg("set-source-volume");
279 command_line.AppendArg(kRecordingDeviceId);
280 command_line.AppendArg(kHundredPercentVolume);
281 #endif
282
283 LOG(INFO) << "Running " << command_line.GetCommandLineString(); 271 LOG(INFO) << "Running " << command_line.GetCommandLineString();
284 std::string result; 272 std::string result;
285 if (!base::GetAppOutput(command_line, &result)) { 273 if (!base::GetAppOutput(command_line, &result)) {
286 // It's hard to figure out for instance the default PA recording device name 274 LOG(ERROR) << "Failed to set source volume: output was " << result;
287 // for different systems, so just warn here. Users will most often have a 275 return false;
288 // reasonable mic level on their systems.
289 LOG(WARNING) << "Failed to set mic volume to 100% on your system. " <<
290 "The test may fail or have results distorted; please ensure that " <<
291 "your mic level is 100% manually.";
292 } 276 }
277 #else
278 // Just force the volume of, say the first 5 devices. A machine will rarely
279 // have more input sources than that. This is way easier than finding the
280 // input device we happen to be using.
281 for (int device_index = 0; device_index < 5; ++device_index) {
282 std::string result;
283 const std::string kHundredPercentVolume = "65536";
284 CommandLine command_line(base::FilePath(FILE_PATH_LITERAL("pacmd")));
285 command_line.AppendArg("set-source-volume");
286 command_line.AppendArg(base::StringPrintf("%d", device_index));
287 command_line.AppendArg(kHundredPercentVolume);
288 LOG(INFO) << "Running " << command_line.GetCommandLineString();
289 if (!base::GetAppOutput(command_line, &result)) {
290 LOG(ERROR) << "Failed to set source volume: output was " << result;
291 return false;
292 }
293 }
294 #endif
295 return true;
293 } 296 }
294 297
295 // Removes silence from beginning and end of the |input_audio_file| and writes 298 // Removes silence from beginning and end of the |input_audio_file| and writes
296 // the result to the |output_audio_file|. Returns true on success. 299 // the result to the |output_audio_file|. Returns true on success.
297 bool RemoveSilence(const base::FilePath& input_file, 300 bool RemoveSilence(const base::FilePath& input_file,
298 const base::FilePath& output_file) { 301 const base::FilePath& output_file) {
299 // SOX documentation for silence command: http://sox.sourceforge.net/sox.html 302 // SOX documentation for silence command: http://sox.sourceforge.net/sox.html
300 // To remove the silence from both beginning and end of the audio file, we 303 // To remove the silence from both beginning and end of the audio file, we
301 // call sox silence command twice: once on normal file and again on its 304 // call sox silence command twice: once on normal file and again on its
302 // reverse, then we reverse the final output. 305 // reverse, then we reverse the final output.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 #define MAYBE_MANUAL_TestAudioQuality MANUAL_TestAudioQuality 410 #define MAYBE_MANUAL_TestAudioQuality MANUAL_TestAudioQuality
408 #else 411 #else
409 #define MAYBE_MANUAL_TestAudioQuality DISABLED_MANUAL_TestAudioQuality 412 #define MAYBE_MANUAL_TestAudioQuality DISABLED_MANUAL_TestAudioQuality
410 #endif 413 #endif
411 414
412 IN_PROC_BROWSER_TEST_F(WebrtcAudioQualityBrowserTest, 415 IN_PROC_BROWSER_TEST_F(WebrtcAudioQualityBrowserTest,
413 MAYBE_MANUAL_TestAudioQuality) { 416 MAYBE_MANUAL_TestAudioQuality) {
414 #if defined(OS_WIN) 417 #if defined(OS_WIN)
415 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 418 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
416 // It would take work to implement this on XP; not prioritized right now. 419 // It would take work to implement this on XP; not prioritized right now.
417 LOG(INFO) << "This test is not implemented for Windows XP."; 420 LOG(ERROR) << "This test is not implemented for Windows XP.";
418 return; 421 return;
419 } 422 }
420 #endif 423 #endif
421 ASSERT_TRUE(HasAllRequiredResources()); 424 ASSERT_TRUE(HasAllRequiredResources());
422 // TODO(phoglund): make this use embedded_test_server when that test server 425 // TODO(phoglund): make this use embedded_test_server when that test server
423 // can handle files > ~400Kb. 426 // can handle files > ~400Kb.
424 ASSERT_TRUE(test_server()->Start()); 427 ASSERT_TRUE(test_server()->Start());
425 ASSERT_TRUE(peerconnection_server_.Start()); 428 ASSERT_TRUE(peerconnection_server_.Start());
426 429
427 ForceMicrophoneVolumeTo100Percent(); 430 ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent());
428 431
429 ui_test_utils::NavigateToURL( 432 ui_test_utils::NavigateToURL(
430 browser(), test_server()->GetURL(kMainWebrtcTestHtmlPage)); 433 browser(), test_server()->GetURL(kMainWebrtcTestHtmlPage));
431 content::WebContents* left_tab = 434 content::WebContents* left_tab =
432 browser()->tab_strip_model()->GetActiveWebContents(); 435 browser()->tab_strip_model()->GetActiveWebContents();
433 436
434 chrome::AddBlankTabAt(browser(), -1, true); 437 chrome::AddBlankTabAt(browser(), -1, true);
435 content::WebContents* right_tab = 438 content::WebContents* right_tab =
436 browser()->tab_strip_model()->GetActiveWebContents(); 439 browser()->tab_strip_model()->GetActiveWebContents();
437 ui_test_utils::NavigateToURL( 440 ui_test_utils::NavigateToURL(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 &raw_mos, &mos_lqo)); 492 &raw_mos, &mos_lqo));
490 493
491 perf_test::PrintResult("audio_pesq", "", "raw_mos", raw_mos, "score", true); 494 perf_test::PrintResult("audio_pesq", "", "raw_mos", raw_mos, "score", true);
492 perf_test::PrintResult("audio_pesq", "", "mos_lqo", mos_lqo, "score", true); 495 perf_test::PrintResult("audio_pesq", "", "mos_lqo", mos_lqo, "score", true);
493 496
494 EXPECT_TRUE(base::DeleteFile(recording, false)); 497 EXPECT_TRUE(base::DeleteFile(recording, false));
495 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false)); 498 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false));
496 499
497 ASSERT_TRUE(peerconnection_server_.Stop()); 500 ASSERT_TRUE(peerconnection_server_.Stop());
498 } 501 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698