| 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_handle.h" | 12 #include "base/process/process_handle.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/sys_byteorder.h" | 15 #include "base/sys_byteorder.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" | 17 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" |
| 18 #include "media/base/bind_to_current_loop.h" | 18 #include "media/base/bind_to_current_loop.h" |
| 19 #include "media/base/bitstream_buffer.h" | 19 #include "media/base/bitstream_buffer.h" |
| 20 #include "media/base/test_data_util.h" | 20 #include "media/base/test_data_util.h" |
| 21 #include "media/filters/h264_parser.h" | 21 #include "media/filters/h264_parser.h" |
| 22 #include "media/video/video_encode_accelerator.h" | 22 #include "media/video/video_encode_accelerator.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 #if defined(USE_X11) | 25 #if defined(USE_OZONE) |
| 26 #include "ui/gfx/x/x11_types.h" | 26 #include "ui/ozone/public/ozone_platform.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 29 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 30 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 30 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
| 31 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 31 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 32 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" | 32 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
| 33 #else | 33 #else |
| 34 #error The VideoEncodeAcceleratorUnittest is not supported on this platform. | 34 #error The VideoEncodeAcceleratorUnittest is not supported on this platform. |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 using media::VideoEncodeAccelerator; | 37 using media::VideoEncodeAccelerator; |
| 38 | 38 |
| 39 namespace content { | 39 namespace content { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 | 709 |
| 710 VEAClient::~VEAClient() { CHECK(!has_encoder()); } | 710 VEAClient::~VEAClient() { CHECK(!has_encoder()); } |
| 711 | 711 |
| 712 void VEAClient::CreateEncoder() { | 712 void VEAClient::CreateEncoder() { |
| 713 DCHECK(thread_checker_.CalledOnValidThread()); | 713 DCHECK(thread_checker_.CalledOnValidThread()); |
| 714 CHECK(!has_encoder()); | 714 CHECK(!has_encoder()); |
| 715 | 715 |
| 716 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 716 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 717 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); | 717 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
| 718 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); | 718 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); |
| 719 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 719 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 720 encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay())); | 720 encoder_.reset(new VaapiVideoEncodeAccelerator()); |
| 721 #endif | 721 #endif |
| 722 | 722 |
| 723 SetState(CS_ENCODER_SET); | 723 SetState(CS_ENCODER_SET); |
| 724 | 724 |
| 725 DVLOG(1) << "Profile: " << test_stream_->requested_profile | 725 DVLOG(1) << "Profile: " << test_stream_->requested_profile |
| 726 << ", initial bitrate: " << requested_bitrate_; | 726 << ", initial bitrate: " << requested_bitrate_; |
| 727 if (!encoder_->Initialize(kInputFormat, | 727 if (!encoder_->Initialize(kInputFormat, |
| 728 test_stream_->visible_size, | 728 test_stream_->visible_size, |
| 729 test_stream_->requested_profile, | 729 test_stream_->requested_profile, |
| 730 requested_bitrate_, | 730 requested_bitrate_, |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 // - multiple encoders + decoders | 1240 // - multiple encoders + decoders |
| 1241 // - mid-stream encoder_->Destroy() | 1241 // - mid-stream encoder_->Destroy() |
| 1242 | 1242 |
| 1243 } // namespace | 1243 } // namespace |
| 1244 } // namespace content | 1244 } // namespace content |
| 1245 | 1245 |
| 1246 int main(int argc, char** argv) { | 1246 int main(int argc, char** argv) { |
| 1247 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. | 1247 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. |
| 1248 base::CommandLine::Init(argc, argv); | 1248 base::CommandLine::Init(argc, argv); |
| 1249 | 1249 |
| 1250 #if defined(USE_OZONE) |
| 1251 ui::OzonePlatform::InitializeForUI(); |
| 1252 ui::OzonePlatform::InitializeForGPU(); |
| 1253 #endif |
| 1254 |
| 1250 base::ShadowingAtExitManager at_exit_manager; | 1255 base::ShadowingAtExitManager at_exit_manager; |
| 1251 scoped_ptr<base::FilePath::StringType> test_stream_data( | 1256 scoped_ptr<base::FilePath::StringType> test_stream_data( |
| 1252 new base::FilePath::StringType( | 1257 new base::FilePath::StringType( |
| 1253 media::GetTestDataFilePath(content::g_default_in_filename).value() + | 1258 media::GetTestDataFilePath(content::g_default_in_filename).value() + |
| 1254 content::g_default_in_parameters)); | 1259 content::g_default_in_parameters)); |
| 1255 | 1260 |
| 1256 // Needed to enable DVLOG through --vmodule. | 1261 // Needed to enable DVLOG through --vmodule. |
| 1257 logging::LoggingSettings settings; | 1262 logging::LoggingSettings settings; |
| 1258 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 1263 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 1259 CHECK(logging::InitLogging(settings)); | 1264 CHECK(logging::InitLogging(settings)); |
| 1260 | 1265 |
| 1261 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1266 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 1262 DCHECK(cmd_line); | 1267 DCHECK(cmd_line); |
| 1263 | 1268 |
| 1264 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); | 1269 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
| 1265 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); | 1270 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); |
| 1266 it != switches.end(); | 1271 it != switches.end(); |
| 1267 ++it) { | 1272 ++it) { |
| 1268 if (it->first == "test_stream_data") { | 1273 if (it->first == "test_stream_data") { |
| 1269 test_stream_data->assign(it->second.c_str()); | 1274 test_stream_data->assign(it->second.c_str()); |
| 1270 continue; | 1275 continue; |
| 1271 } | 1276 } |
| 1272 if (it->first == "v" || it->first == "vmodule") | 1277 if (it->first == "v" || it->first == "vmodule") |
| 1273 continue; | 1278 continue; |
| 1279 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") |
| 1280 continue; |
| 1274 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1281 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 1275 } | 1282 } |
| 1276 | 1283 |
| 1277 content::g_env = | 1284 content::g_env = |
| 1278 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( | 1285 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( |
| 1279 testing::AddGlobalTestEnvironment( | 1286 testing::AddGlobalTestEnvironment( |
| 1280 new content::VideoEncodeAcceleratorTestEnvironment( | 1287 new content::VideoEncodeAcceleratorTestEnvironment( |
| 1281 test_stream_data.Pass()))); | 1288 test_stream_data.Pass()))); |
| 1282 | 1289 |
| 1283 return RUN_ALL_TESTS(); | 1290 return RUN_ALL_TESTS(); |
| 1284 } | 1291 } |
| OLD | NEW |