| 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/memory_mapped_file.h" | 9 #include "base/files/memory_mapped_file.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/process/process.h" | 12 #include "base/process/process.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" | 16 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" |
| 17 #include "media/base/bind_to_current_loop.h" | 17 #include "media/base/bind_to_current_loop.h" |
| 18 #include "media/base/bitstream_buffer.h" | 18 #include "media/base/bitstream_buffer.h" |
| 19 #include "media/base/test_data_util.h" | 19 #include "media/base/test_data_util.h" |
| 20 #include "media/filters/h264_parser.h" | 20 #include "media/filters/h264_parser.h" |
| 21 #include "media/video/video_encode_accelerator.h" | 21 #include "media/video/video_encode_accelerator.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 #if defined(USE_X11) | 24 #if defined(USE_OZONE) |
| 25 #include "ui/gfx/x/x11_types.h" | 25 #include "ui/ozone/public/ozone_platform.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 28 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 29 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 29 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
| 30 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 30 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 31 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" | 31 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
| 32 #else | 32 #else |
| 33 #error The VideoEncodeAcceleratorUnittest is not supported on this platform. | 33 #error The VideoEncodeAcceleratorUnittest is not supported on this platform. |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 using media::VideoEncodeAccelerator; | 36 using media::VideoEncodeAccelerator; |
| 37 | 37 |
| 38 namespace content { | 38 namespace content { |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 580 |
| 581 VEAClient::~VEAClient() { CHECK(!has_encoder()); } | 581 VEAClient::~VEAClient() { CHECK(!has_encoder()); } |
| 582 | 582 |
| 583 void VEAClient::CreateEncoder() { | 583 void VEAClient::CreateEncoder() { |
| 584 DCHECK(thread_checker_.CalledOnValidThread()); | 584 DCHECK(thread_checker_.CalledOnValidThread()); |
| 585 CHECK(!has_encoder()); | 585 CHECK(!has_encoder()); |
| 586 | 586 |
| 587 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 587 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 588 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); | 588 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
| 589 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); | 589 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); |
| 590 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 590 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 591 encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay())); | 591 encoder_.reset(new VaapiVideoEncodeAccelerator()); |
| 592 #endif | 592 #endif |
| 593 | 593 |
| 594 SetState(CS_ENCODER_SET); | 594 SetState(CS_ENCODER_SET); |
| 595 | 595 |
| 596 DVLOG(1) << "Profile: " << test_stream_.requested_profile | 596 DVLOG(1) << "Profile: " << test_stream_.requested_profile |
| 597 << ", initial bitrate: " << test_stream_.requested_bitrate; | 597 << ", initial bitrate: " << test_stream_.requested_bitrate; |
| 598 if (!encoder_->Initialize(kInputFormat, | 598 if (!encoder_->Initialize(kInputFormat, |
| 599 test_stream_.size, | 599 test_stream_.size, |
| 600 test_stream_.requested_profile, | 600 test_stream_.requested_profile, |
| 601 test_stream_.requested_bitrate, | 601 test_stream_.requested_bitrate, |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 // - multiple encoders + decoders | 1024 // - multiple encoders + decoders |
| 1025 // - mid-stream encoder_->Destroy() | 1025 // - mid-stream encoder_->Destroy() |
| 1026 | 1026 |
| 1027 } // namespace | 1027 } // namespace |
| 1028 } // namespace content | 1028 } // namespace content |
| 1029 | 1029 |
| 1030 int main(int argc, char** argv) { | 1030 int main(int argc, char** argv) { |
| 1031 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. | 1031 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. |
| 1032 base::CommandLine::Init(argc, argv); | 1032 base::CommandLine::Init(argc, argv); |
| 1033 | 1033 |
| 1034 #if defined(USE_OZONE) |
| 1035 ui::OzonePlatform::InitializeForUI(); |
| 1036 ui::OzonePlatform::InitializeForGPU(); |
| 1037 #endif |
| 1038 |
| 1034 base::ShadowingAtExitManager at_exit_manager; | 1039 base::ShadowingAtExitManager at_exit_manager; |
| 1035 scoped_ptr<base::FilePath::StringType> test_stream_data( | 1040 scoped_ptr<base::FilePath::StringType> test_stream_data( |
| 1036 new base::FilePath::StringType( | 1041 new base::FilePath::StringType( |
| 1037 media::GetTestDataFilePath(content::g_default_in_filename).value() + | 1042 media::GetTestDataFilePath(content::g_default_in_filename).value() + |
| 1038 content::g_default_in_parameters)); | 1043 content::g_default_in_parameters)); |
| 1039 content::g_test_stream_data = test_stream_data.get(); | 1044 content::g_test_stream_data = test_stream_data.get(); |
| 1040 | 1045 |
| 1041 // Needed to enable DVLOG through --vmodule. | 1046 // Needed to enable DVLOG through --vmodule. |
| 1042 logging::LoggingSettings settings; | 1047 logging::LoggingSettings settings; |
| 1043 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 1048 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 1044 CHECK(logging::InitLogging(settings)); | 1049 CHECK(logging::InitLogging(settings)); |
| 1045 | 1050 |
| 1046 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1051 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 1047 DCHECK(cmd_line); | 1052 DCHECK(cmd_line); |
| 1048 | 1053 |
| 1049 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); | 1054 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
| 1050 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); | 1055 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); |
| 1051 it != switches.end(); | 1056 it != switches.end(); |
| 1052 ++it) { | 1057 ++it) { |
| 1053 if (it->first == "test_stream_data") { | 1058 if (it->first == "test_stream_data") { |
| 1054 test_stream_data->assign(it->second.c_str()); | 1059 test_stream_data->assign(it->second.c_str()); |
| 1055 continue; | 1060 continue; |
| 1056 } | 1061 } |
| 1057 if (it->first == "v" || it->first == "vmodule") | 1062 if (it->first == "v" || it->first == "vmodule") |
| 1058 continue; | 1063 continue; |
| 1064 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") |
| 1065 continue; |
| 1059 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1066 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 1060 } | 1067 } |
| 1061 | 1068 |
| 1062 return RUN_ALL_TESTS(); | 1069 return RUN_ALL_TESTS(); |
| 1063 } | 1070 } |
| OLD | NEW |