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/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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 | 677 |
678 VEAClient::~VEAClient() { CHECK(!has_encoder()); } | 678 VEAClient::~VEAClient() { CHECK(!has_encoder()); } |
679 | 679 |
680 void VEAClient::CreateEncoder() { | 680 void VEAClient::CreateEncoder() { |
681 DCHECK(thread_checker_.CalledOnValidThread()); | 681 DCHECK(thread_checker_.CalledOnValidThread()); |
682 CHECK(!has_encoder()); | 682 CHECK(!has_encoder()); |
683 | 683 |
684 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 684 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
685 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); | 685 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
686 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); | 686 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); |
687 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 687 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
688 encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay())); | 688 encoder_.reset(new VaapiVideoEncodeAccelerator()); |
689 #endif | 689 #endif |
690 | 690 |
691 SetState(CS_ENCODER_SET); | 691 SetState(CS_ENCODER_SET); |
692 | 692 |
693 DVLOG(1) << "Profile: " << test_stream_->requested_profile | 693 DVLOG(1) << "Profile: " << test_stream_->requested_profile |
694 << ", initial bitrate: " << requested_bitrate_; | 694 << ", initial bitrate: " << requested_bitrate_; |
695 if (!encoder_->Initialize(kInputFormat, | 695 if (!encoder_->Initialize(kInputFormat, |
696 test_stream_->visible_size, | 696 test_stream_->visible_size, |
697 test_stream_->requested_profile, | 697 test_stream_->requested_profile, |
698 requested_bitrate_, | 698 requested_bitrate_, |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 // - multiple encoders + decoders | 1168 // - multiple encoders + decoders |
1169 // - mid-stream encoder_->Destroy() | 1169 // - mid-stream encoder_->Destroy() |
1170 | 1170 |
1171 } // namespace | 1171 } // namespace |
1172 } // namespace content | 1172 } // namespace content |
1173 | 1173 |
1174 int main(int argc, char** argv) { | 1174 int main(int argc, char** argv) { |
1175 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. | 1175 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. |
1176 base::CommandLine::Init(argc, argv); | 1176 base::CommandLine::Init(argc, argv); |
1177 | 1177 |
1178 #if defined(USE_OZONE) | |
1179 ui::OzonePlatform::InitializeForUI(); | |
Pawel Osciak
2014/12/08 10:55:16
Is this needed? This doesn't display anything, is
llandwerlin-old
2014/12/08 16:42:07
We need the OzoneSurfaceFactory to be initialize i
| |
1180 ui::OzonePlatform::InitializeForGPU(); | |
1181 #endif | |
1182 | |
1178 base::ShadowingAtExitManager at_exit_manager; | 1183 base::ShadowingAtExitManager at_exit_manager; |
1179 scoped_ptr<base::FilePath::StringType> test_stream_data( | 1184 scoped_ptr<base::FilePath::StringType> test_stream_data( |
1180 new base::FilePath::StringType( | 1185 new base::FilePath::StringType( |
1181 media::GetTestDataFilePath(content::g_default_in_filename).value() + | 1186 media::GetTestDataFilePath(content::g_default_in_filename).value() + |
1182 content::g_default_in_parameters)); | 1187 content::g_default_in_parameters)); |
1183 | 1188 |
1184 // Needed to enable DVLOG through --vmodule. | 1189 // Needed to enable DVLOG through --vmodule. |
1185 logging::LoggingSettings settings; | 1190 logging::LoggingSettings settings; |
1186 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 1191 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
1187 CHECK(logging::InitLogging(settings)); | 1192 CHECK(logging::InitLogging(settings)); |
1188 | 1193 |
1189 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1194 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
1190 DCHECK(cmd_line); | 1195 DCHECK(cmd_line); |
1191 | 1196 |
1192 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); | 1197 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
1193 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); | 1198 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); |
1194 it != switches.end(); | 1199 it != switches.end(); |
1195 ++it) { | 1200 ++it) { |
1196 if (it->first == "test_stream_data") { | 1201 if (it->first == "test_stream_data") { |
1197 test_stream_data->assign(it->second.c_str()); | 1202 test_stream_data->assign(it->second.c_str()); |
1198 continue; | 1203 continue; |
1199 } | 1204 } |
1200 if (it->first == "v" || it->first == "vmodule") | 1205 if (it->first == "v" || it->first == "vmodule") |
1201 continue; | 1206 continue; |
1207 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") | |
1208 continue; | |
1202 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1209 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
1203 } | 1210 } |
1204 | 1211 |
1205 content::g_env = | 1212 content::g_env = |
1206 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( | 1213 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( |
1207 testing::AddGlobalTestEnvironment( | 1214 testing::AddGlobalTestEnvironment( |
1208 new content::VideoEncodeAcceleratorTestEnvironment( | 1215 new content::VideoEncodeAcceleratorTestEnvironment( |
1209 test_stream_data.Pass()))); | 1216 test_stream_data.Pass()))); |
1210 | 1217 |
1211 return RUN_ALL_TESTS(); | 1218 return RUN_ALL_TESTS(); |
1212 } | 1219 } |
OLD | NEW |