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

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

Issue 1752293003: Add VP9 to chrome_webrtc_video_quality_browsertest.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // The barcode decoder decodes the captured video containing barcodes overlaid 191 // The barcode decoder decodes the captured video containing barcodes overlaid
192 // into every frame of the video (produced by rgba_to_i420_converter). It 192 // into every frame of the video (produced by rgba_to_i420_converter). It
193 // produces a set of PNG images and a |stats_file| that maps each captured 193 // produces a set of PNG images and a |stats_file| that maps each captured
194 // frame to a frame in the reference video. The frames should be of size 194 // frame to a frame in the reference video. The frames should be of size
195 // |width| x |height|. 195 // |width| x |height|.
196 // All measurements calculated are printed as perf parsable numbers to stdout. 196 // All measurements calculated are printed as perf parsable numbers to stdout.
197 bool CompareVideosAndPrintResult( 197 bool CompareVideosAndPrintResult(
198 const char* test_label, 198 const char* test_label,
199 int width, 199 int width,
200 int height, 200 int height,
201 const std::string& video_codec,
phoglund_chromium 2016/03/07 10:57:12 I don't see why this function needs to know about
asapersson2 2016/03/07 13:05:29 Done.
201 const base::FilePath& captured_video_filename, 202 const base::FilePath& captured_video_filename,
202 const base::FilePath& reference_video_filename, 203 const base::FilePath& reference_video_filename,
203 const base::FilePath& stats_file) { 204 const base::FilePath& stats_file) {
204 205
205 base::FilePath path_to_analyzer = base::MakeAbsoluteFilePath( 206 base::FilePath path_to_analyzer = base::MakeAbsoluteFilePath(
206 GetBrowserDir().Append(kFrameAnalyzerExecutable)); 207 GetBrowserDir().Append(kFrameAnalyzerExecutable));
207 base::FilePath path_to_compare_script = GetSourceDir().Append( 208 base::FilePath path_to_compare_script = GetSourceDir().Append(
208 FILE_PATH_LITERAL("third_party/webrtc/tools/compare_videos.py")); 209 FILE_PATH_LITERAL("third_party/webrtc/tools/compare_videos.py"));
209 210
210 if (!base::PathExists(path_to_analyzer)) { 211 if (!base::PathExists(path_to_analyzer)) {
(...skipping 12 matching lines...) Expand all
223 if (!base::PathExists(path_to_zxing)) { 224 if (!base::PathExists(path_to_zxing)) {
224 LOG(ERROR) << "Missing zxing: should be in " << path_to_zxing.value(); 225 LOG(ERROR) << "Missing zxing: should be in " << path_to_zxing.value();
225 return false; 226 return false;
226 } 227 }
227 base::FilePath path_to_ffmpeg = test::GetToolForPlatform("ffmpeg"); 228 base::FilePath path_to_ffmpeg = test::GetToolForPlatform("ffmpeg");
228 if (!base::PathExists(path_to_ffmpeg)) { 229 if (!base::PathExists(path_to_ffmpeg)) {
229 LOG(ERROR) << "Missing ffmpeg: should be in " << path_to_ffmpeg.value(); 230 LOG(ERROR) << "Missing ffmpeg: should be in " << path_to_ffmpeg.value();
230 return false; 231 return false;
231 } 232 }
232 233
234 std::string codec_label =
235 video_codec.empty() ? video_codec : "_" + video_codec;
236
233 // Note: don't append switches to this command since it will mess up the 237 // Note: don't append switches to this command since it will mess up the
234 // -u in the python invocation! 238 // -u in the python invocation!
235 base::CommandLine compare_command(base::CommandLine::NO_PROGRAM); 239 base::CommandLine compare_command(base::CommandLine::NO_PROGRAM);
236 EXPECT_TRUE(GetPythonCommand(&compare_command)); 240 EXPECT_TRUE(GetPythonCommand(&compare_command));
237 241
238 compare_command.AppendArgPath(path_to_compare_script); 242 compare_command.AppendArgPath(path_to_compare_script);
239 compare_command.AppendArg(base::StringPrintf("--label=%s", test_label)); 243 compare_command.AppendArg(base::StringPrintf("--label=%s", test_label) +
244 codec_label);
240 compare_command.AppendArg("--ref_video"); 245 compare_command.AppendArg("--ref_video");
241 compare_command.AppendArgPath(reference_video_filename); 246 compare_command.AppendArgPath(reference_video_filename);
242 compare_command.AppendArg("--test_video"); 247 compare_command.AppendArg("--test_video");
243 compare_command.AppendArgPath(captured_video_filename); 248 compare_command.AppendArgPath(captured_video_filename);
244 compare_command.AppendArg("--frame_analyzer"); 249 compare_command.AppendArg("--frame_analyzer");
245 compare_command.AppendArgPath(path_to_analyzer); 250 compare_command.AppendArgPath(path_to_analyzer);
246 compare_command.AppendArg("--yuv_frame_width"); 251 compare_command.AppendArg("--yuv_frame_width");
247 compare_command.AppendArg(base::IntToString(width)); 252 compare_command.AppendArg(base::IntToString(width));
248 compare_command.AppendArg("--yuv_frame_height"); 253 compare_command.AppendArg("--yuv_frame_height");
249 compare_command.AppendArg(base::IntToString(height)); 254 compare_command.AppendArg(base::IntToString(height));
(...skipping 13 matching lines...) Expand all
263 printf("Output was:\n\n%s\n", output.c_str()); 268 printf("Output was:\n\n%s\n", output.c_str());
264 bool has_result_lines = output.find("RESULT") != std::string::npos; 269 bool has_result_lines = output.find("RESULT") != std::string::npos;
265 if (!ok || !has_result_lines) { 270 if (!ok || !has_result_lines) {
266 LOG(ERROR) << "Failed to compare videos; see output above to see what " 271 LOG(ERROR) << "Failed to compare videos; see output above to see what "
267 << "the error was."; 272 << "the error was.";
268 return false; 273 return false;
269 } 274 }
270 return true; 275 return true;
271 } 276 }
272 277
278 void TestVideoQuality(const std::string& video_codec) {
279 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150)
280 << "This is a long-running test; you must specify "
281 "--ui-test-action-max-timeout to have a value of at least 150000.";
282 ASSERT_TRUE(test::HasReferenceFilesInCheckout());
283 ASSERT_TRUE(embedded_test_server()->Start());
284
285 content::WebContents* left_tab =
286 OpenPageAndGetUserMediaInNewTabWithConstraints(
287 embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage),
288 test_config_.constraints);
289 content::WebContents* right_tab =
290 OpenPageAndGetUserMediaInNewTabWithConstraints(
291 embedded_test_server()->GetURL(kCapturingWebrtcHtmlPage),
292 test_config_.constraints);
293
294 SetupPeerconnectionWithLocalStream(left_tab);
295 SetupPeerconnectionWithLocalStream(right_tab);
296
297 NegotiateCall(left_tab, right_tab, video_codec);
298
299 // Poll slower here to avoid flooding the log with messages: capturing and
300 // sending frames take quite a bit of time.
301 int polling_interval_msec = 1000;
302
303 EXPECT_TRUE(test::PollingWaitUntil("doneFrameCapturing()", "done-capturing",
304 right_tab, polling_interval_msec));
305
306 HangUp(left_tab);
307
308 WriteCapturedFramesToWorkingDir(right_tab);
309
310 // Shut everything down to avoid having the javascript race with the
311 // analysis
phoglund_chromium 2016/03/07 10:57:12 Nit: pull up to previous line
asapersson2 2016/03/07 13:05:29 Done.
312 // tools. For instance, dont have console log printouts interleave with the
313 // RESULT lines from the analysis tools (crbug.com/323200).
314 chrome::CloseWebContents(browser(), left_tab, false);
315 chrome::CloseWebContents(browser(), right_tab, false);
316
317 ASSERT_TRUE(
318 RunARGBtoI420Converter(test_config_.width, test_config_.height,
319 GetWorkingDir().Append(kCapturedYuvFileName)));
phoglund_chromium 2016/03/07 10:57:12 What about: std::string codec_label = video_codec
asapersson2 2016/03/07 13:05:29 Done.
320 ASSERT_TRUE(CompareVideosAndPrintResult(
321 test_config_.test_name, test_config_.width, test_config_.height,
322 video_codec, GetWorkingDir().Append(kCapturedYuvFileName),
323 test::GetReferenceFilesDir()
324 .Append(test_config_.reference_video)
325 .AddExtension(test::kYuvFileExtension),
326 GetWorkingDir().Append(kStatsFileName)));
327 }
328
273 protected: 329 protected:
274 VideoQualityTestConfig test_config_; 330 VideoQualityTestConfig test_config_;
275 331
276 base::FilePath GetWorkingDir() { 332 base::FilePath GetWorkingDir() { return temp_working_dir_.path(); }
277 return temp_working_dir_.path();
278 }
279 333
280 private: 334 private:
281 base::FilePath GetSourceDir() { 335 base::FilePath GetSourceDir() {
282 base::FilePath source_dir; 336 base::FilePath source_dir;
283 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); 337 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir);
284 return source_dir; 338 return source_dir;
285 } 339 }
286 340
287 base::FilePath GetBrowserDir() { 341 base::FilePath GetBrowserDir() {
288 base::FilePath browser_dir; 342 base::FilePath browser_dir;
289 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &browser_dir)); 343 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &browser_dir));
290 return browser_dir; 344 return browser_dir;
291 } 345 }
292 346
293 scoped_ptr<base::Environment> environment_; 347 scoped_ptr<base::Environment> environment_;
294 base::FilePath webrtc_reference_video_y4m_; 348 base::FilePath webrtc_reference_video_y4m_;
295 base::ScopedTempDir temp_working_dir_; 349 base::ScopedTempDir temp_working_dir_;
296 }; 350 };
297 351
298 INSTANTIATE_TEST_CASE_P( 352 INSTANTIATE_TEST_CASE_P(
299 WebRtcVideoQualityBrowserTests, 353 WebRtcVideoQualityBrowserTests,
300 WebRtcVideoQualityBrowserTest, 354 WebRtcVideoQualityBrowserTest,
301 testing::ValuesIn(kVideoConfigurations)); 355 testing::ValuesIn(kVideoConfigurations));
302 356
357 // The video codec name is now appended to the test label (e.g. '720p_VP8').
358 // TODO(asapersson): Keep test below using the default video codec (which do
359 // not have the codec name appended ('720p')) until new tests have been
360 // running for some time.
303 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest, 361 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest,
304 MANUAL_TestVideoQuality) { 362 MANUAL_TestVideoQualityDefault) {
305 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150) << 363 TestVideoQuality("");
306 "This is a long-running test; you must specify " 364 }
307 "--ui-test-action-max-timeout to have a value of at least 150000.";
308 ASSERT_TRUE(test::HasReferenceFilesInCheckout());
309 ASSERT_TRUE(embedded_test_server()->Start());
310 365
311 content::WebContents* left_tab = 366 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest,
312 OpenPageAndGetUserMediaInNewTabWithConstraints( 367 MANUAL_TestVideoQualityVp8) {
313 embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage), 368 TestVideoQuality("VP8");
314 test_config_.constraints); 369 }
315 content::WebContents* right_tab =
316 OpenPageAndGetUserMediaInNewTabWithConstraints(
317 embedded_test_server()->GetURL(kCapturingWebrtcHtmlPage),
318 test_config_.constraints);
319 370
320 SetupPeerconnectionWithLocalStream(left_tab); 371 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest,
321 SetupPeerconnectionWithLocalStream(right_tab); 372 MANUAL_TestVideoQualityVp9) {
322 373 TestVideoQuality("VP9");
323 NegotiateCall(left_tab, right_tab);
324
325 // Poll slower here to avoid flooding the log with messages: capturing and
326 // sending frames take quite a bit of time.
327 int polling_interval_msec = 1000;
328
329 EXPECT_TRUE(test::PollingWaitUntil(
330 "doneFrameCapturing()", "done-capturing", right_tab,
331 polling_interval_msec));
332
333 HangUp(left_tab);
334
335 WriteCapturedFramesToWorkingDir(right_tab);
336
337 // Shut everything down to avoid having the javascript race with the analysis
338 // tools. For instance, dont have console log printouts interleave with the
339 // RESULT lines from the analysis tools (crbug.com/323200).
340 chrome::CloseWebContents(browser(), left_tab, false);
341 chrome::CloseWebContents(browser(), right_tab, false);
342
343 ASSERT_TRUE(RunARGBtoI420Converter(
344 test_config_.width, test_config_.height,
345 GetWorkingDir().Append(kCapturedYuvFileName)));
346 ASSERT_TRUE(CompareVideosAndPrintResult(
347 test_config_.test_name,
348 test_config_.width,
349 test_config_.height,
350 GetWorkingDir().Append(kCapturedYuvFileName),
351 test::GetReferenceFilesDir()
352 .Append(test_config_.reference_video)
353 .AddExtension(test::kYuvFileExtension),
354 GetWorkingDir().Append(kStatsFileName)));
355 } 374 }
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