| 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 "media/gpu/ipc/service/gpu_video_encode_accelerator.h" | 5 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 14 #include "base/numerics/safe_math.h" | 14 #include "base/numerics/safe_math.h" |
| 15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "gpu/ipc/service/gpu_channel.h" | 17 #include "gpu/ipc/service/gpu_channel.h" |
| 18 #include "gpu/ipc/service/gpu_channel_manager.h" | 18 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 19 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
| 20 #include "media/base/bind_to_current_loop.h" | 20 #include "media/base/bind_to_current_loop.h" |
| 21 #include "media/base/limits.h" | 21 #include "media/base/limits.h" |
| 22 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
| 23 #include "media/gpu/gpu_video_accelerator_util.h" | 23 #include "media/gpu/gpu_video_accelerator_util.h" |
| 24 #include "media/gpu/ipc/common/media_messages.h" | 24 #include "media/gpu/ipc/common/media_messages.h" |
| 25 #include "media/media_features.h" |
| 25 | 26 |
| 26 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
| 27 #if defined(USE_V4L2_CODEC) | 28 #if defined(USE_V4L2_CODEC) |
| 28 #include "media/gpu/v4l2_video_encode_accelerator.h" | 29 #include "media/gpu/v4l2_video_encode_accelerator.h" |
| 29 #endif | 30 #endif |
| 30 #if defined(ARCH_CPU_X86_FAMILY) | 31 #if defined(ARCH_CPU_X86_FAMILY) |
| 31 #include "media/gpu/vaapi_video_encode_accelerator.h" | 32 #include "media/gpu/vaapi_video_encode_accelerator.h" |
| 32 #endif | 33 #endif |
| 33 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 34 #elif defined(OS_ANDROID) && BUILDFLAG(ENABLE_WEBRTC) |
| 34 #include "media/gpu/android_video_encode_accelerator.h" | 35 #include "media/gpu/android_video_encode_accelerator.h" |
| 35 #elif defined(OS_MACOSX) | 36 #elif defined(OS_MACOSX) |
| 36 #include "media/gpu/vt_video_encode_accelerator_mac.h" | 37 #include "media/gpu/vt_video_encode_accelerator_mac.h" |
| 37 #elif defined(OS_WIN) | 38 #elif defined(OS_WIN) |
| 38 #include "base/feature_list.h" | 39 #include "base/feature_list.h" |
| 39 #include "media/base/media_switches.h" | 40 #include "media/base/media_switches.h" |
| 40 #include "media/gpu/media_foundation_video_encode_accelerator_win.h" | 41 #include "media/gpu/media_foundation_video_encode_accelerator_win.h" |
| 41 #endif | 42 #endif |
| 42 | 43 |
| 43 namespace media { | 44 namespace media { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 73 } | 74 } |
| 74 #endif | 75 #endif |
| 75 | 76 |
| 76 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 77 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 77 std::unique_ptr<VideoEncodeAccelerator> CreateVaapiVEA() { | 78 std::unique_ptr<VideoEncodeAccelerator> CreateVaapiVEA() { |
| 78 return base::WrapUnique<VideoEncodeAccelerator>( | 79 return base::WrapUnique<VideoEncodeAccelerator>( |
| 79 new VaapiVideoEncodeAccelerator()); | 80 new VaapiVideoEncodeAccelerator()); |
| 80 } | 81 } |
| 81 #endif | 82 #endif |
| 82 | 83 |
| 83 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 84 #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_WEBRTC) |
| 84 std::unique_ptr<VideoEncodeAccelerator> CreateAndroidVEA() { | 85 std::unique_ptr<VideoEncodeAccelerator> CreateAndroidVEA() { |
| 85 return base::WrapUnique<VideoEncodeAccelerator>( | 86 return base::WrapUnique<VideoEncodeAccelerator>( |
| 86 new AndroidVideoEncodeAccelerator()); | 87 new AndroidVideoEncodeAccelerator()); |
| 87 } | 88 } |
| 88 #endif | 89 #endif |
| 89 | 90 |
| 90 #if defined(OS_MACOSX) | 91 #if defined(OS_MACOSX) |
| 91 std::unique_ptr<VideoEncodeAccelerator> CreateVTVEA() { | 92 std::unique_ptr<VideoEncodeAccelerator> CreateVTVEA() { |
| 92 return base::WrapUnique<VideoEncodeAccelerator>( | 93 return base::WrapUnique<VideoEncodeAccelerator>( |
| 93 new VTVideoEncodeAccelerator()); | 94 new VTVideoEncodeAccelerator()); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 GpuVideoEncodeAccelerator::GetVEAFactoryFunctions( | 353 GpuVideoEncodeAccelerator::GetVEAFactoryFunctions( |
| 353 const gpu::GpuPreferences& gpu_preferences) { | 354 const gpu::GpuPreferences& gpu_preferences) { |
| 354 std::vector<VEAFactoryFunction> vea_factory_functions; | 355 std::vector<VEAFactoryFunction> vea_factory_functions; |
| 355 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | 356 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
| 356 vea_factory_functions.push_back(base::Bind(&CreateV4L2VEA)); | 357 vea_factory_functions.push_back(base::Bind(&CreateV4L2VEA)); |
| 357 #endif | 358 #endif |
| 358 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 359 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 359 if (!gpu_preferences.disable_vaapi_accelerated_video_encode) | 360 if (!gpu_preferences.disable_vaapi_accelerated_video_encode) |
| 360 vea_factory_functions.push_back(base::Bind(&CreateVaapiVEA)); | 361 vea_factory_functions.push_back(base::Bind(&CreateVaapiVEA)); |
| 361 #endif | 362 #endif |
| 362 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 363 #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_WEBRTC) |
| 363 if (!gpu_preferences.disable_web_rtc_hw_encoding) | 364 if (!gpu_preferences.disable_web_rtc_hw_encoding) |
| 364 vea_factory_functions.push_back(base::Bind(&CreateAndroidVEA)); | 365 vea_factory_functions.push_back(base::Bind(&CreateAndroidVEA)); |
| 365 #endif | 366 #endif |
| 366 #if defined(OS_MACOSX) | 367 #if defined(OS_MACOSX) |
| 367 vea_factory_functions.push_back(base::Bind(&CreateVTVEA)); | 368 vea_factory_functions.push_back(base::Bind(&CreateVTVEA)); |
| 368 #endif | 369 #endif |
| 369 #if defined(OS_WIN) | 370 #if defined(OS_WIN) |
| 370 if (base::FeatureList::IsEnabled(kMediaFoundationH264Encoding)) | 371 if (base::FeatureList::IsEnabled(kMediaFoundationH264Encoding)) |
| 371 vea_factory_functions.push_back(base::Bind(&CreateMediaFoundationVEA)); | 372 vea_factory_functions.push_back(base::Bind(&CreateMediaFoundationVEA)); |
| 372 #endif | 373 #endif |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 DLOG(ERROR) << __func__ << " failed."; | 535 DLOG(ERROR) << __func__ << " failed."; |
| 535 } | 536 } |
| 536 } | 537 } |
| 537 | 538 |
| 538 bool GpuVideoEncodeAccelerator::CheckIfCalledOnCorrectThread() { | 539 bool GpuVideoEncodeAccelerator::CheckIfCalledOnCorrectThread() { |
| 539 return (filter_ && io_task_runner_->BelongsToCurrentThread()) || | 540 return (filter_ && io_task_runner_->BelongsToCurrentThread()) || |
| 540 (!filter_ && main_task_runner_->BelongsToCurrentThread()); | 541 (!filter_ && main_task_runner_->BelongsToCurrentThread()); |
| 541 } | 542 } |
| 542 | 543 |
| 543 } // namespace media | 544 } // namespace media |
| OLD | NEW |