Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The bulk of this file is support code; sorry about that. Here's an overview | 5 // The bulk of this file is support code; sorry about that. Here's an overview |
| 6 // to hopefully help readers of this code: | 6 // to hopefully help readers of this code: |
| 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or | 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or |
| 8 // Win/EGL. | 8 // Win/EGL. |
| 9 // - ClientState is an enum for the state of the decode client used by the test. | 9 // - ClientState is an enum for the state of the decode client used by the test. |
| 10 // - ClientStateNotification is a barrier abstraction that allows the test code | 10 // - ClientStateNotification is a barrier abstraction that allows the test code |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 // This is http://code.google.com/p/googletest/issues/detail?id=371 | 27 // This is http://code.google.com/p/googletest/issues/detail?id=371 |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 #include "base/at_exit.h" | 30 #include "base/at_exit.h" |
| 31 #include "base/bind.h" | 31 #include "base/bind.h" |
| 32 #include "base/command_line.h" | 32 #include "base/command_line.h" |
| 33 #include "base/files/file.h" | 33 #include "base/files/file.h" |
| 34 #include "base/files/file_util.h" | 34 #include "base/files/file_util.h" |
| 35 #include "base/format_macros.h" | 35 #include "base/format_macros.h" |
| 36 #include "base/md5.h" | 36 #include "base/md5.h" |
| 37 #include "base/message_loop/message_loop.h" | |
| 37 #include "base/message_loop/message_loop_proxy.h" | 38 #include "base/message_loop/message_loop_proxy.h" |
| 39 #include "base/message_loop/message_pump_libevent.h" | |
| 38 #include "base/process/process.h" | 40 #include "base/process/process.h" |
| 39 #include "base/stl_util.h" | 41 #include "base/stl_util.h" |
| 40 #include "base/strings/string_number_conversions.h" | 42 #include "base/strings/string_number_conversions.h" |
| 41 #include "base/strings/string_split.h" | 43 #include "base/strings/string_split.h" |
| 42 #include "base/strings/stringize_macros.h" | 44 #include "base/strings/stringize_macros.h" |
| 43 #include "base/strings/stringprintf.h" | 45 #include "base/strings/stringprintf.h" |
| 44 #include "base/strings/utf_string_conversions.h" | 46 #include "base/strings/utf_string_conversions.h" |
| 45 #include "base/synchronization/condition_variable.h" | 47 #include "base/synchronization/condition_variable.h" |
| 46 #include "base/synchronization/lock.h" | 48 #include "base/synchronization/lock.h" |
| 47 #include "base/synchronization/waitable_event.h" | 49 #include "base/synchronization/waitable_event.h" |
| 48 #include "base/threading/thread.h" | 50 #include "base/threading/thread.h" |
| 49 #include "content/common/gpu/media/rendering_helper.h" | 51 #include "content/common/gpu/media/rendering_helper.h" |
| 50 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" | 52 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" |
| 51 #include "content/public/common/content_switches.h" | 53 #include "content/public/common/content_switches.h" |
| 52 #include "media/filters/h264_parser.h" | 54 #include "media/filters/h264_parser.h" |
| 53 #include "ui/gfx/codec/png_codec.h" | 55 #include "ui/gfx/codec/png_codec.h" |
| 54 | 56 |
| 55 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 56 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 58 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 57 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 59 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 58 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 60 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
| 59 #include "content/common/gpu/media/v4l2_video_device.h" | 61 #include "content/common/gpu/media/v4l2_video_device.h" |
| 60 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 62 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 61 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 63 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
| 62 #include "content/common/gpu/media/vaapi_wrapper.h" | 64 #include "content/common/gpu/media/vaapi_wrapper.h" |
| 63 #if defined(USE_X11) | |
| 64 #include "ui/gl/gl_implementation.h" | |
| 65 #endif // USE_X11 | |
| 66 #else | 65 #else |
| 67 #error The VideoAccelerator tests are not supported on this platform. | 66 #error The VideoAccelerator tests are not supported on this platform. |
| 68 #endif // OS_WIN | 67 #endif // OS_WIN |
| 69 | 68 |
| 70 using media::VideoDecodeAccelerator; | 69 using media::VideoDecodeAccelerator; |
| 71 | 70 |
| 72 namespace content { | 71 namespace content { |
| 73 namespace { | 72 namespace { |
| 74 | 73 |
| 75 // Values optionally filled in from flags; see main() below. | 74 // Values optionally filled in from flags; see main() below. |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue))); | 394 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue))); |
| 396 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 395 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 397 | 396 |
| 398 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 397 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
| 399 if (!device.get()) { | 398 if (!device.get()) { |
| 400 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 399 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 401 return; | 400 return; |
| 402 } | 401 } |
| 403 decoder_.reset(new V4L2VideoDecodeAccelerator( | 402 decoder_.reset(new V4L2VideoDecodeAccelerator( |
| 404 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), | 403 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), |
| 405 static_cast<EGLContext>(rendering_helper_->GetGLContext()), | 404 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()), |
| 406 weak_client, | 405 weak_client, |
| 407 base::Bind(&DoNothingReturnTrue), | 406 base::Bind(&DoNothingReturnTrue), |
| 408 device.Pass(), | 407 device.Pass(), |
| 409 base::MessageLoopProxy::current())); | 408 base::MessageLoopProxy::current())); |
| 410 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 409 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 411 CHECK_EQ(gfx::kGLImplementationDesktopGL, gfx::GetGLImplementation()) | |
| 412 << "Hardware video decode does not work with OSMesa"; | |
| 413 decoder_.reset(new VaapiVideoDecodeAccelerator( | 410 decoder_.reset(new VaapiVideoDecodeAccelerator( |
| 414 static_cast<Display*>(rendering_helper_->GetGLDisplay()), | 411 rendering_helper_->GetGLContext(), base::Bind(&DoNothingReturnTrue))); |
| 415 base::Bind(&DoNothingReturnTrue))); | |
| 416 #endif // OS_WIN | 412 #endif // OS_WIN |
| 417 CHECK(decoder_.get()); | 413 CHECK(decoder_.get()); |
| 418 weak_decoder_factory_.reset( | 414 weak_decoder_factory_.reset( |
| 419 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); | 415 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); |
| 420 SetState(CS_DECODER_SET); | 416 SetState(CS_DECODER_SET); |
| 421 if (decoder_deleted()) | 417 if (decoder_deleted()) |
| 422 return; | 418 return; |
| 423 | 419 |
| 424 CHECK(decoder_->Initialize(profile_, client)); | 420 CHECK(decoder_->Initialize(profile_, client)); |
| 425 FinishInitialization(); | 421 FinishInitialization(); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 863 | 859 |
| 864 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() | 860 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() |
| 865 : rendering_thread_("GLRenderingVDAClientThread") {} | 861 : rendering_thread_("GLRenderingVDAClientThread") {} |
| 866 | 862 |
| 867 void VideoDecodeAcceleratorTest::SetUp() { | 863 void VideoDecodeAcceleratorTest::SetUp() { |
| 868 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | 864 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); |
| 869 | 865 |
| 870 // Initialize the rendering thread. | 866 // Initialize the rendering thread. |
| 871 base::Thread::Options options; | 867 base::Thread::Options options; |
| 872 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 868 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
| 873 #if defined(OS_WIN) | 869 #if defined(OS_WIN) || defined(USE_OZONE) |
| 874 // For windows the decoding thread initializes the media foundation decoder | 870 // For windows the decoding thread initializes the media foundation decoder |
| 875 // which uses COM. We need the thread to be a UI thread. | 871 // which uses COM. We need the thread to be a UI thread. |
| 872 // On Ozone, the backend initialize the event system using a UI | |
|
Pawel Osciak
2014/10/26 13:06:48
s/initialize/initializes/
llandwerlin-old
2014/10/29 13:52:49
Acknowledged.
| |
| 873 // thread. | |
| 876 options.message_loop_type = base::MessageLoop::TYPE_UI; | 874 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 877 #endif // OS_WIN | 875 #endif // OS_WIN || USE_OZONE |
| 878 | 876 |
| 879 rendering_thread_.StartWithOptions(options); | 877 rendering_thread_.StartWithOptions(options); |
| 880 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy(); | 878 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy(); |
| 881 } | 879 } |
| 882 | 880 |
| 883 void VideoDecodeAcceleratorTest::TearDown() { | 881 void VideoDecodeAcceleratorTest::TearDown() { |
| 884 rendering_loop_proxy_->PostTask( | 882 rendering_loop_proxy_->PostTask( |
| 885 FROM_HERE, | 883 FROM_HERE, |
| 886 base::Bind(&STLDeleteElements<std::vector<TestVideoFile*> >, | 884 base::Bind(&STLDeleteElements<std::vector<TestVideoFile*> >, |
| 887 &test_video_files_)); | 885 &test_video_files_)); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1421 CHECK(base::StringToDouble(input, &content::g_rendering_fps)); | 1419 CHECK(base::StringToDouble(input, &content::g_rendering_fps)); |
| 1422 continue; | 1420 continue; |
| 1423 } | 1421 } |
| 1424 // TODO(owenlin): Remove this flag once it is not used in autotest. | 1422 // TODO(owenlin): Remove this flag once it is not used in autotest. |
| 1425 if (it->first == "disable_rendering") { | 1423 if (it->first == "disable_rendering") { |
| 1426 content::g_rendering_fps = 0; | 1424 content::g_rendering_fps = 0; |
| 1427 continue; | 1425 continue; |
| 1428 } | 1426 } |
| 1429 if (it->first == "v" || it->first == "vmodule") | 1427 if (it->first == "v" || it->first == "vmodule") |
| 1430 continue; | 1428 continue; |
| 1429 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") | |
| 1430 continue; | |
| 1431 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1431 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 1432 } | 1432 } |
| 1433 | 1433 |
| 1434 base::ShadowingAtExitManager at_exit_manager; | 1434 base::ShadowingAtExitManager at_exit_manager; |
| 1435 content::RenderingHelper::InitializeOneOff(); | 1435 content::RenderingHelper::InitializeOneOff(); |
| 1436 | 1436 |
| 1437 return RUN_ALL_TESTS(); | 1437 return RUN_ALL_TESTS(); |
| 1438 } | 1438 } |
| OLD | NEW |