# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//media/gpu/args.gni")
import("//media/media_options.gni")
if (is_arkweb) {
import("//arkweb/chromium_ext/chromium_ext.gni")
}
if (media_use_symphonia) {
rust_static_library("symphonia_glue") {
# Needed because CXX generates unsafe code, for example using export_name
# is inherently unsafe.
allow_unsafe = true
crate_root = "symphonia_glue.rs"
sources = [ "symphonia_glue.rs" ]
cxx_bindings = [ "symphonia_glue.rs" ]
visibility = [ ":filters" ]
deps = [ "//third_party/rust/symphonia/v0_5:lib" ]
}
}
source_set("filters") {
# Do not expand the visibility here without double-checking with OWNERS, this
# is a roll-up target which is part of the //media component. Most other DEPs
# should be using //media and not directly DEP this roll-up target.
visibility = [
"//media",
"//media/fuchsia/audio",
"//media/renderers",
]
sources = [
"audio_clock.cc",
"audio_clock.h",
"audio_renderer_algorithm.cc",
"audio_renderer_algorithm.h",
"audio_timestamp_validator.cc",
"audio_timestamp_validator.h",
"chunk_demuxer.cc",
"chunk_demuxer.h",
"decoder_selector.cc",
"decoder_selector.h",
"decoder_stream.cc",
"decoder_stream.h",
"decoder_stream_traits.cc",
"decoder_stream_traits.h",
"decrypting_audio_decoder.cc",
"decrypting_audio_decoder.h",
"decrypting_demuxer_stream.cc",
"decrypting_demuxer_stream.h",
"decrypting_media_resource.cc",
"decrypting_media_resource.h",
"decrypting_video_decoder.cc",
"decrypting_video_decoder.h",
"demuxer_manager.cc",
"demuxer_manager.h",
"file_data_source.cc",
"file_data_source.h",
"frame_processor.cc",
"frame_processor.h",
"memory_data_source.cc",
"memory_data_source.h",
"offloading_video_decoder.cc",
"offloading_video_decoder.h",
"pipeline_controller.cc",
"pipeline_controller.h",
"source_buffer_parse_warnings.h",
"source_buffer_range.cc",
"source_buffer_range.h",
"source_buffer_state.cc",
"source_buffer_state.h",
"source_buffer_stream.cc",
"source_buffer_stream.h",
"stream_parser_factory.cc",
"stream_parser_factory.h",
"video_cadence_estimator.cc",
"video_cadence_estimator.h",
"video_renderer_algorithm.cc",
"video_renderer_algorithm.h",
"wsola_internals.cc",
"wsola_internals.h",
]
if (arkweb_same_layer) {
sources += arkweb_media_filters_sources
}
configs += [ "//media:subcomponent_config" ]
deps = [
"//base",
"//cc/base", # For MathUtil.
"//media:media_buildflags",
"//media/base",
"//media/cdm",
"//media/formats",
"//media/parsers",
"//media/video",
"//net",
"//third_party/libyuv",
"//ui/gfx/geometry",
]
libs = []
if (proprietary_codecs) {
sources += [
"h264_to_annex_b_bitstream_converter.cc",
"h264_to_annex_b_bitstream_converter.h",
]
if (enable_platform_hevc) {
sources += [
"h265_to_annex_b_bitstream_converter.cc",
"h265_to_annex_b_bitstream_converter.h",
]
}
}
if (media_use_ffmpeg) {
deps += [
"//media/ffmpeg",
"//third_party/ffmpeg",
"//third_party/ffmpeg:ffmpeg_features",
"//third_party/opus",
]
sources += [
"audio_file_reader.cc",
"audio_file_reader.h",
"audio_video_metadata_extractor.cc",
"audio_video_metadata_extractor.h",
"blocking_url_protocol.cc",
"blocking_url_protocol.h",
"ffmpeg_audio_decoder.cc",
"ffmpeg_audio_decoder.h",
"ffmpeg_bitstream_converter.h",
"ffmpeg_demuxer.cc",
"ffmpeg_demuxer.h",
"ffmpeg_glue.cc",
"ffmpeg_glue.h",
"in_memory_url_protocol.cc",
"in_memory_url_protocol.h",
"legacy_audio_file_reader.cc",
"legacy_audio_file_reader.h",
"media_file_checker.cc",
"media_file_checker.h",
]
}
if (media_use_symphonia) {
sources += [
"symphonia_audio_decoder.cc",
"symphonia_audio_decoder.h",
]
deps += [ ":symphonia_glue" ]
}
if (media_use_libvpx) {
sources += [
"vpx_video_decoder.cc",
"vpx_video_decoder.h",
]
deps += [ "//third_party/libvpx" ]
}
if (enable_dav1d_decoder) {
sources += [
"dav1d_video_decoder.cc",
"dav1d_video_decoder.h",
]
deps += [ "//third_party/dav1d" ]
}
if (media_use_ffmpeg) {
if (proprietary_codecs) {
sources += [
"ffmpeg_aac_bitstream_converter.cc",
"ffmpeg_aac_bitstream_converter.h",
"ffmpeg_h264_to_annex_b_bitstream_converter.cc",
"ffmpeg_h264_to_annex_b_bitstream_converter.h",
]
if (enable_platform_hevc) {
sources += [
"ffmpeg_h265_to_annex_b_bitstream_converter.cc",
"ffmpeg_h265_to_annex_b_bitstream_converter.h",
]
}
}
if (enable_ffmpeg_video_decoders) {
sources += [
"ffmpeg_video_decoder.cc",
"ffmpeg_video_decoder.h",
]
}
if (is_android) {
sources += [
"android/video_frame_extractor.cc",
"android/video_frame_extractor.h",
]
}
}
if (is_android) {
sources -= [
"decrypting_audio_decoder.cc",
"decrypting_audio_decoder.h",
"decrypting_video_decoder.cc",
"decrypting_video_decoder.h",
]
sources += [
"android/media_codec_audio_decoder.cc",
"android/media_codec_audio_decoder.h",
]
deps += [ "//media/base/android" ]
}
if (is_apple) {
sources += [
"mac/audio_toolbox_audio_decoder.cc",
"mac/audio_toolbox_audio_decoder.h",
"mac/audio_toolbox_audio_encoder.cc",
"mac/audio_toolbox_audio_encoder.h",
]
deps += [ "//media/base/mac" ]
}
if (is_arkweb && arkweb_enable_cdm) {
sources += arkweb_media_filters_ohos_sources
}
if (is_win && enable_platform_dts_audio) {
sources += [
"passthrough_dts_audio_decoder.cc",
"passthrough_dts_audio_decoder.h",
]
}
if (is_win) {
sources += [
"win/media_foundation_audio_decoder.cc",
"win/media_foundation_audio_decoder.h",
]
deps += [ "//media/base/win:media_foundation_util" ]
if (enable_platform_dts_audio) {
ldflags = [
"/DELAYLOAD:packages/Microsoft.VCRTForwarders.140.1.0.6/runtimes/win10-x64/native/release/concrt140_app.dll",
"/DELAYLOAD:packages/Microsoft.VCRTForwarders.140.1.0.6/runtimes/win10-x64/native/release/msvcp140_1_app.dll",
"/DELAYLOAD:packages/Microsoft.VCRTForwarders.140.1.0.6/runtimes/win10-x64/native/release/msvcp140_2_app.dll",
"/DELAYLOAD:packages/Microsoft.VCRTForwarders.140.1.0.6/runtimes/win10-x64/native/release/msvcp140_app.dll",
"/DELAYLOAD:packages/Microsoft.VCRTForwarders.140.1.0.6/runtimes/win10-x64/native/release/vcamp140_app.dll",
"/DELAYLOAD:packages/Microsoft.VCRTForwarders.140.1.0.6/runtimes/win10-x64/native/release/vccorlib140_app.dll",
"/DELAYLOAD:packages/Microsoft.VCRTForwarders.140.1.0.6/runtimes/win10-x64/native/release/vcomp140_app.dll",
"/DELAYLOAD:packages/Microsoft.VCRTForwarders.140.1.0.6/runtimes/win10-x64/native/release/vcruntime140_app.dll",
]
}
}
if (is_win || use_vaapi) {
sources += [
"h26x_annex_b_bitstream_builder.cc",
"h26x_annex_b_bitstream_builder.h",
]
}
if (enable_hls_demuxer) {
sources += [
"hls_data_source_provider.cc",
"hls_data_source_provider.h",
"hls_data_source_provider_impl.cc",
"hls_data_source_provider_impl.h",
"hls_demuxer_status.h",
"hls_manifest_demuxer_engine.cc",
"hls_manifest_demuxer_engine.h",
"hls_network_access.cc",
"hls_network_access.h",
"hls_network_access_impl.cc",
"hls_network_access_impl.h",
"hls_rendition.cc",
"hls_rendition.h",
"hls_rendition_impl.cc",
"hls_rendition_impl.h",
"hls_stats_reporter.cc",
"hls_stats_reporter.h",
"manifest_demuxer.cc",
"manifest_demuxer.h",
]
}
}
source_set("perftests") {
testonly = true
sources = []
if (media_use_ffmpeg) {
sources += [ "demuxer_perftest.cc" ]
}
configs += [ "//media:media_config" ]
deps = [
"//base",
"//base/test:test_support",
"//media:test_support",
"//testing/gmock",
"//testing/gtest",
"//testing/perf",
]
}
static_library("test_support") {
testonly = true
visibility = [ "//media:test_support" ]
sources = [
"fake_video_decoder.cc",
"fake_video_decoder.h",
]
deps = [
"//base/test:test_support",
"//media/base:test_support",
]
}
source_set("unit_tests") {
testonly = true
sources = [
"audio_clock_unittest.cc",
"audio_decoder_stream_unittest.cc",
"audio_renderer_algorithm_unittest.cc",
"audio_timestamp_validator_unittest.cc",
"chunk_demuxer_unittest.cc",
"decoder_selector_unittest.cc",
"decrypting_audio_decoder_unittest.cc",
"decrypting_demuxer_stream_unittest.cc",
"decrypting_media_resource_unittest.cc",
"decrypting_video_decoder_unittest.cc",
"fake_video_decoder_unittest.cc",
"file_data_source_unittest.cc",
"frame_processor_unittest.cc",
"memory_data_source_unittest.cc",
"offloading_video_decoder_unittest.cc",
"pipeline_controller_unittest.cc",
"source_buffer_state_unittest.cc",
"source_buffer_stream_unittest.cc",
"video_cadence_estimator_unittest.cc",
"video_decoder_stream_unittest.cc",
"video_renderer_algorithm_unittest.cc",
]
deps = [
"//base/test:test_support",
"//crypto",
"//media:test_support",
"//testing/gmock",
"//testing/gtest",
"//ui/gfx:test_support",
]
if (is_android) {
sources += [ "android/video_frame_extractor_unittest.cc" ]
sources -= [
"decrypting_audio_decoder_unittest.cc",
"decrypting_video_decoder_unittest.cc",
]
deps += [ "//ui/gl" ]
}
# libvpx for running vpx test on chromecast doesn't support high bit depth.
# This may cause some unit tests failure. See b/65382374 for further context.
if (is_castos) {
defines = [ "LIBVPX_NO_HIGH_BIT_DEPTH" ]
}
if (media_use_ffmpeg) {
sources += [
"audio_decoder_unittest.cc",
"audio_file_reader_unittest.cc",
"blocking_url_protocol_unittest.cc",
"ffmpeg_demuxer_unittest.cc",
"ffmpeg_glue_unittest.cc",
"in_memory_url_protocol_unittest.cc",
"legacy_audio_file_reader_unittest.cc",
]
deps += [
# Direct dependency needed for the config
"//third_party/opus",
]
# Even if FFmpeg is enabled on Android we don't want these.
# TODO(watk): Refactor tests that could be made to run on Android.
if (!is_android) {
sources += [
"audio_video_metadata_extractor_unittest.cc",
"media_file_checker_unittest.cc",
]
}
if (enable_ffmpeg_video_decoders && proprietary_codecs) {
sources += [ "ffmpeg_video_decoder_unittest.cc" ]
}
}
if (media_use_libvpx) {
sources += [ "vpx_video_decoder_unittest.cc" ]
}
if (enable_dav1d_decoder) {
sources += [ "dav1d_video_decoder_unittest.cc" ]
}
if (is_win || use_vaapi) {
sources += [ "h26x_annex_b_bitstream_builder_unittest.cc" ]
}
if (proprietary_codecs) {
sources += [ "h264_to_annex_b_bitstream_converter_unittest.cc" ]
if (enable_platform_hevc) {
sources += [ "h265_to_annex_b_bitstream_converter_unittest.cc" ]
}
if (media_use_ffmpeg) {
sources += [
"ffmpeg_aac_bitstream_converter_unittest.cc",
"ffmpeg_h264_to_annex_b_bitstream_converter_unittest.cc",
]
}
}
if (enable_hls_demuxer) {
sources += [
"hls_data_source_provider_impl_unittest.cc",
"hls_data_source_provider_unittest.cc",
"hls_manifest_demuxer_engine_unittest.cc",
"hls_network_access_impl_unittest.cc",
"hls_rendition_impl_unittest.cc",
"hls_test_helpers.cc",
"hls_test_helpers.h",
"manifest_demuxer_unittest.cc",
"stream_parser_factory_unittest.cc",
]
# TODO(crbug.com/40031409): Fix code that adds exit-time destructors and
# enable the diagnostic by removing this line.
configs += [ "//build/config/compiler:no_exit_time_destructors" ]
}
if (media_use_ffmpeg) {
# Direct dependency required to inherit config.
deps += [ "//third_party/ffmpeg" ]
}
}