blob: a5951ead1e77508f9c120ab694e1c22a18637e13 [file] [log] [blame]
# Copyright 2016 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//gpu/vulkan/features.gni")
import("//media/gpu/args.gni")
import("//media/media_options.gni")
import("//testing/test.gni")
import("//tools/generate_stubs/rules.gni")
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [
"USE_VAAPI=$use_vaapi",
"USE_VAAPI_IMAGE_CODECS=$use_vaapi_image_codecs",
"USE_V4L2_CODEC=$use_v4l2_codec",
"USE_LIBV4L2=$use_v4lplugin",
"USE_VAAPI_X11=$use_vaapi_x11",
]
}
if (is_android) {
generate_stubs("mediacodec_stubs") {
extra_header = "android/mediacodec.fragment"
sigs = [ "android/mediacodec.sigs" ]
output_name = "android/mediacodec_stubs"
deps = [ "//base" ]
}
}
component("gpu") {
output_name = "media_gpu"
# Only local test code, GPU-related IPC code in the media layer, and
# media-related content code should access //media/gpu.
visibility = [
":*",
"//ash/components/arc/mojom:media",
"//ash/components/arc/mojom:media_mojolpm",
"//ash/components/arc/video_accelerator:common",
"//chrome/gpu",
"//chromecast/*",
"//components/chromeos_camera/*",
"//components/mirroring/service:mirroring_service",
"//components/viz/service/main",
"//content/gpu:*",
"//content/renderer:*",
"//media/audio:unit_tests",
"//media/gpu/ipc/*",
"//media/gpu/test/*",
"//media/gpu/vaapi/*",
"//media/mojo/*",
"//remoting/codec:encoder",
"//third_party/blink/renderer/modules:unit_tests",
"//ui/gl:gl_unittests",
# TODO(crbug.com/1184041): Remove //remoting/host:common when the usage is removed.
"//remoting/host:common",
]
if (is_mac) {
# On Mac, content/common reaches into here to do some pre-sandbox
# initialization.
visibility += [ "//content/common" ]
}
defines = [ "MEDIA_GPU_IMPLEMENTATION" ]
sources = [
"gpu_video_accelerator_util.cc",
"gpu_video_accelerator_util.h",
"gpu_video_decode_accelerator_factory.cc",
"gpu_video_decode_accelerator_factory.h",
"gpu_video_encode_accelerator_factory.cc",
"gpu_video_encode_accelerator_factory.h",
]
public_deps = [
":buildflags",
":command_buffer_helper",
":common",
"//base",
"//gpu",
"//media",
"//third_party/mesa_headers",
"//ui/gfx/geometry",
]
deps = [
"//third_party/libyuv",
"//ui/base",
"//ui/display/types",
"//ui/gl",
"//ui/platform_window",
]
libs = []
ldflags = []
# V4L2 and VAAPI for video acceleration should not be enabled simultaneously.
assert(!(use_v4l2_codec && use_vaapi))
# TODO(crbug.com/1006266): consider using |use_chromeos_video_acceleration|.
if (use_v4l2_codec || use_vaapi) {
public_deps += [
":video_frame_mapper",
"//media/gpu/chromeos",
]
}
if (is_mac) {
public_deps += [ "//media/gpu/mac" ]
}
if (is_android) {
sources += [
"android/android_video_encode_accelerator.cc",
"android/android_video_encode_accelerator.h",
"android/android_video_surface_chooser.cc",
"android/android_video_surface_chooser.h",
"android/android_video_surface_chooser_impl.cc",
"android/android_video_surface_chooser_impl.h",
"android/codec_allocator.cc",
"android/codec_allocator.h",
"android/codec_buffer_wait_coordinator.cc",
"android/codec_buffer_wait_coordinator.h",
"android/codec_image.cc",
"android/codec_image.h",
"android/codec_image_group.cc",
"android/codec_image_group.h",
"android/codec_output_buffer_renderer.cc",
"android/codec_output_buffer_renderer.h",
"android/codec_surface_bundle.cc",
"android/codec_surface_bundle.h",
"android/codec_wrapper.cc",
"android/codec_wrapper.h",
"android/device_info.cc",
"android/device_info.h",
"android/direct_shared_image_video_provider.cc",
"android/direct_shared_image_video_provider.h",
"android/frame_info_helper.cc",
"android/frame_info_helper.h",
"android/maybe_render_early_manager.cc",
"android/maybe_render_early_manager.h",
"android/media_codec_video_decoder.cc",
"android/media_codec_video_decoder.h",
"android/ndk_constants.cc",
"android/ndk_video_encode_accelerator.cc",
"android/ndk_video_encode_accelerator.h",
"android/pooled_shared_image_video_provider.cc",
"android/pooled_shared_image_video_provider.h",
"android/promotion_hint_aggregator.h",
"android/promotion_hint_aggregator_impl.cc",
"android/promotion_hint_aggregator_impl.h",
"android/shared_image_video_provider.cc",
"android/shared_image_video_provider.h",
"android/surface_chooser_helper.cc",
"android/surface_chooser_helper.h",
"android/video_accelerator_util.cc",
"android/video_accelerator_util.h",
"android/video_frame_factory.h",
"android/video_frame_factory_impl.cc",
"android/video_frame_factory_impl.h",
]
defines += [
# We need to reference functions and constants from NDK API levels
# beyond the one Chromium compiles with by default.
# Therefore relax the verification of functions and constants.
"__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__",
]
libs += [ "android" ]
deps += [
":mediacodec_stubs",
# TODO(crbug.com/789435): This can be removed once CdmManager is removed.
"//gpu/ipc/common",
"//media/mojo:buildflags",
"//services/service_manager/public/cpp:cpp",
"//ui/gl:gl_jni_headers",
]
if (enable_vulkan) {
deps += [ "//gpu/vulkan:vulkan" ]
}
}
if (use_v4l2_codec) {
public_deps += [ "//media/gpu/v4l2" ]
}
if (use_vaapi) {
public_deps += [
"//media/gpu/vaapi",
"//media/gpu/vaapi:common",
]
}
if (is_fuchsia) {
public_deps += [ "//media/fuchsia/video" ]
}
if (is_win) {
sources += [
"windows/av1_guids.h",
"windows/d3d11_av1_accelerator.cc",
"windows/d3d11_av1_accelerator.h",
"windows/d3d11_com_defs.h",
"windows/d3d11_copying_texture_wrapper.cc",
"windows/d3d11_copying_texture_wrapper.h",
"windows/d3d11_decoder_configurator.cc",
"windows/d3d11_decoder_configurator.h",
"windows/d3d11_h264_accelerator.cc",
"windows/d3d11_h264_accelerator.h",
"windows/d3d11_picture_buffer.cc",
"windows/d3d11_picture_buffer.h",
"windows/d3d11_status.h",
"windows/d3d11_texture_selector.cc",
"windows/d3d11_texture_selector.h",
"windows/d3d11_texture_wrapper.cc",
"windows/d3d11_texture_wrapper.h",
"windows/d3d11_video_context_wrapper.cc",
"windows/d3d11_video_context_wrapper.h",
"windows/d3d11_video_decoder.cc",
"windows/d3d11_video_decoder.h",
"windows/d3d11_video_decoder_client.h",
"windows/d3d11_video_decoder_impl.cc",
"windows/d3d11_video_decoder_impl.h",
"windows/d3d11_video_device_format_support.cc",
"windows/d3d11_video_device_format_support.h",
"windows/d3d11_video_processor_proxy.cc",
"windows/d3d11_video_processor_proxy.h",
"windows/d3d11_vp9_accelerator.cc",
"windows/d3d11_vp9_accelerator.h",
"windows/d3d11_vp9_picture.cc",
"windows/d3d11_vp9_picture.h",
"windows/dxva_picture_buffer_win.cc",
"windows/dxva_picture_buffer_win.h",
"windows/dxva_video_decode_accelerator_win.cc",
"windows/dxva_video_decode_accelerator_win.h",
"windows/gl_image_egl_stream.cc",
"windows/gl_image_egl_stream.h",
"windows/gl_image_pbuffer.cc",
"windows/gl_image_pbuffer.h",
"windows/init_guid.cc",
"windows/media_foundation_video_encode_accelerator_win.cc",
"windows/media_foundation_video_encode_accelerator_win.h",
"windows/mf_audio_encoder.cc",
"windows/mf_audio_encoder.h",
"windows/supported_profile_helpers.cc",
"windows/supported_profile_helpers.h",
"windows/video_rate_control_wrapper.h",
"windows/vp9_video_rate_control_wrapper.cc",
"windows/vp9_video_rate_control_wrapper.h",
]
if (enable_hevc_parser_and_hw_decoder) {
sources += [
"windows/d3d11_h265_accelerator.cc",
"windows/d3d11_h265_accelerator.h",
]
}
if (enable_libaom) {
sources += [
"windows/av1_video_rate_control_wrapper.cc",
"windows/av1_video_rate_control_wrapper.h",
]
configs += [ "//third_party/libaom:libaom_config" ]
deps += [ "//third_party/libaom:libaomrc" ]
}
configs += [
"//third_party/khronos:khronos_headers",
"//third_party/libvpx:libvpx_config",
]
deps += [
"//gpu/ipc/common:common",
"//media/parsers",
"//third_party/angle:includes",
"//third_party/libvpx:libvpxrc",
"//ui/display",
]
libs += [
"d3d9.lib",
"d3d11.lib",
"dxva2.lib",
"strmiids.lib",
"mf.lib",
"mfplat.lib",
"mfuuid.lib",
]
ldflags += [
"/DELAYLOAD:d3d9.dll",
"/DELAYLOAD:d3d11.dll",
"/DELAYLOAD:dxva2.dll",
"/DELAYLOAD:mf.dll",
"/DELAYLOAD:mfplat.dll",
]
}
if (use_ozone) {
deps += [ "//ui/ozone" ]
}
}
source_set("common") {
defines = [ "MEDIA_GPU_IMPLEMENTATION" ]
sources = [
"accelerated_video_decoder.h",
"codec_picture.cc",
"codec_picture.h",
"gpu_video_decode_accelerator_helpers.cc",
"gpu_video_decode_accelerator_helpers.h",
"gpu_video_encode_accelerator_helpers.cc",
"gpu_video_encode_accelerator_helpers.h",
"h264_decoder.cc",
"h264_decoder.h",
"h264_dpb.cc",
"h264_dpb.h",
"macros.h",
"vp9_decoder.cc",
"vp9_decoder.h",
"vp9_picture.cc",
"vp9_picture.h",
"vp9_reference_frame_vector.cc",
"vp9_reference_frame_vector.h",
]
if (enable_hevc_parser_and_hw_decoder) {
sources += [
"h265_decoder.cc",
"h265_decoder.h",
"h265_dpb.cc",
"h265_dpb.h",
]
}
visibility = [
":gpu",
"//media/gpu/*",
]
# TODO(crbug.com/1006266): consider using |use_chromeos_video_acceleration|.
if (use_v4l2_codec || use_vaapi) {
sources += [
"decode_surface_handler.h",
"vp8_decoder.cc",
"vp8_decoder.h",
"vp8_picture.cc",
"vp8_picture.h",
"vp8_reference_frame_vector.cc",
"vp8_reference_frame_vector.h",
]
}
public_deps = []
deps = [
":buildflags",
"//base",
"//build:chromeos_buildflags",
"//media",
"//media/parsers",
"//ui/gfx:buffer_types",
"//ui/gfx:memory_buffer",
"//ui/gfx/geometry",
]
if (is_win || use_vaapi) {
sources += [
"video_rate_control.cc",
"video_rate_control.h",
"vp9_svc_layers.cc",
"vp9_svc_layers.h",
]
configs += [ "//third_party/libvpx:libvpx_config" ]
deps += [
"//third_party/libaom:libaomrc",
"//third_party/libvpx:libvpxrc",
]
}
if (use_libgav1_parser) {
sources += [
"av1_decoder.cc",
"av1_decoder.h",
"av1_picture.cc",
"av1_picture.h",
]
public_deps += [ "//third_party/libgav1:libgav1_parser" ]
}
}
# The buffer validation functionality is in its own component so that it can be
# depended on without pulling the entire //media/gpu target.
component("buffer_validation") {
defines = [ "IS_MEDIA_GPU_BUFFER_VALIDATION_IMPL" ]
sources = [
"buffer_validation.cc",
"buffer_validation.h",
]
public_deps = [
"//base",
"//media",
]
}
source_set("command_buffer_helper") {
defines = [ "MEDIA_GPU_IMPLEMENTATION" ]
sources = [
"command_buffer_helper.cc",
"command_buffer_helper.h",
]
if (!is_android) {
# This code is used only by the legacy VDA implementation, which is not
# supported on Android.
sources += [
"gles2_decoder_helper.cc",
"gles2_decoder_helper.h",
]
}
public_deps = [
"//base",
"//gpu/command_buffer/common",
"//gpu/command_buffer/common:gles2_utils",
"//gpu/command_buffer/service",
"//gpu/command_buffer/service:gles2",
"//gpu/ipc/service",
"//ui/gl",
]
}
# TODO(crbug.com/1006266): consider using |use_chromeos_video_acceleration|.
if (use_v4l2_codec || use_vaapi) {
source_set("video_frame_mapper") {
defines = [ "MEDIA_GPU_IMPLEMENTATION" ]
sources = [ "video_frame_mapper_factory.cc" ]
public_deps = [ ":video_frame_mapper_common" ]
deps = []
# generic_dmabuf_video_frame_mapper
if (use_v4l2_codec || use_vaapi) {
deps += [ "//media/gpu/chromeos:video_frame_mapper" ]
}
# vaapi_dmabuf_video_frame_mapper
if (use_vaapi) {
deps += [ "//media/gpu/vaapi" ]
}
}
source_set("video_frame_mapper_common") {
defines = [ "MEDIA_GPU_IMPLEMENTATION" ]
sources = [
"video_frame_mapper.h",
"video_frame_mapper_factory.h",
]
public_deps = [
":buildflags",
"//base",
"//media",
]
}
}
# TODO(watk): Run this on bots. http://crbug.com/461437
if (is_android) {
test("video_decode_accelerator_unittest") {
testonly = true
data = [ "//media/test/data/" ]
deps = [
":android_video_decode_accelerator_unittests",
":gpu",
"//base",
"//base/test:test_support",
"//gpu/command_buffer/service:android_texture_owner_unittests",
"//media:test_support",
"//media/base/android:media_java",
"//media/test:run_all_unittests",
"//mojo/core/embedder",
"//testing/gtest",
"//ui/android:ui_java",
"//ui/base",
"//ui/gfx",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
"//ui/gl",
"//ui/gl:test_support",
"//ui/gl/init",
]
configs += [ "//third_party/khronos:khronos_headers" ]
}
}
source_set("android_video_decode_accelerator_unittests") {
if (is_android) {
testonly = true
sources = [
"android/android_video_surface_chooser_impl_unittest.cc",
"android/codec_allocator_unittest.cc",
"android/codec_image_group_unittest.cc",
"android/codec_image_unittest.cc",
"android/codec_wrapper_unittest.cc",
"android/fake_codec_allocator.cc",
"android/fake_codec_allocator.h",
"android/frame_info_helper_unittest.cc",
"android/maybe_render_early_manager_unittest.cc",
"android/media_codec_video_decoder_unittest.cc",
"android/mock_android_video_surface_chooser.cc",
"android/mock_android_video_surface_chooser.h",
"android/mock_codec_buffer_wait_coordinator.cc",
"android/mock_codec_buffer_wait_coordinator.h",
"android/mock_codec_image.cc",
"android/mock_codec_image.h",
"android/mock_device_info.cc",
"android/mock_device_info.h",
"android/mock_promotion_hint_aggregator.cc",
"android/mock_promotion_hint_aggregator.h",
"android/mock_shared_image_video_provider.cc",
"android/mock_shared_image_video_provider.h",
"android/ndk_video_encode_accelerator_tests.cc",
"android/pooled_shared_image_video_provider_unittest.cc",
"android/promotion_hint_aggregator_impl_unittest.cc",
"android/surface_chooser_helper_unittest.cc",
"android/video_frame_factory_impl_unittest.cc",
]
deps = [
":gpu",
"//base/test:test_support",
"//gpu:test_support",
"//gpu/command_buffer/service:android_texture_owner_test_support",
"//media",
"//media:test_support",
"//testing/gmock",
"//testing/gtest",
"//third_party/libyuv:libyuv",
"//ui/gl",
"//ui/gl/init",
]
}
}
static_library("test_support") {
visibility = [ "//media/gpu/*" ]
testonly = true
sources = [
"test/fake_command_buffer_helper.cc",
"test/fake_command_buffer_helper.h",
]
configs += [ "//media:media_config" ]
public_deps = [
":gpu",
"//base",
"//media",
]
}
source_set("unit_tests") {
testonly = true
deps = [
"//base",
"//base/test:test_support",
"//media:test_support",
"//media/gpu",
"//media/gpu:test_support",
"//media/gpu/ipc/service:unit_tests",
"//testing/gmock",
"//testing/gtest",
"//ui/gl:test_support",
]
sources = [ "h264_decoder_unittest.cc" ]
if (enable_hevc_parser_and_hw_decoder) {
sources += [ "h265_decoder_unittest.cc" ]
}
if (is_linux || is_chromeos) {
sources += [ "buffer_validation_unittest.cc" ]
deps += [ ":buffer_validation" ]
}
# TODO(b/219079009): consider running these tests without VA-API or V4L2.
if (is_chromeos && (use_v4l2_codec || use_vaapi)) {
deps += [ "//media/gpu/chromeos:unit_tests" ]
}
if (use_vaapi) {
deps += [ "//media/gpu/vaapi:unit_test" ]
}
if (use_v4l2_codec) {
deps += [ "//media/gpu/v4l2:unit_test" ]
}
# TODO(crbug.com/1006266): consider using |use_chromeos_video_acceleration|.
if (use_v4l2_codec || use_vaapi) {
sources += [ "vp8_decoder_unittest.cc" ]
}
if (use_libgav1_parser && media_use_ffmpeg) {
sources += [ "av1_decoder_unittest.cc" ]
deps += [
"//build:chromeos_buildflags",
"//third_party/ffmpeg",
]
}
if (is_win) {
sources += [
"windows/d3d11_copying_texture_wrapper_unittest.cc",
"windows/d3d11_decoder_configurator_unittest.cc",
"windows/d3d11_picture_buffer_unittest.cc",
"windows/d3d11_texture_selector_unittest.cc",
"windows/d3d11_texture_wrapper_unittest.cc",
"windows/d3d11_video_decoder_unittest.cc",
"windows/d3d11_video_device_format_support_unittest.cc",
"windows/d3d11_video_processor_proxy_unittest.cc",
"windows/supported_profile_helpers_unittest.cc",
]
libs = [ "dxguid.lib" ]
}
if (is_mac) {
deps += [ "//media/gpu/mac:unit_tests" ]
}
if (is_win || use_vaapi) {
sources += [ "vp9_svc_layers_unittest.cc" ]
}
}
if (enable_hevc_parser_and_hw_decoder) {
fuzzer_test("media_h265_decoder_fuzzer") {
sources = [ "h265_decoder_fuzzertest.cc" ]
deps = [
":gpu",
"//base",
"//media",
]
}
}
if (use_libgav1_parser) {
fuzzer_test("media_av1_decoder_fuzzer") {
sources = [ "av1_decoder_fuzzertest.cc" ]
deps = [
":common",
"//base",
"//media",
]
}
}