# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chrome_build.gni")
import("//build/config/chromecast_build.gni")
import("//build/config/features.gni")
import("//build/config/jumbo.gni")
import("//media/gpu/args.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/libaom/options.gni")

# Do not expand this list without double-checking with OWNERS, this is a list of
# all targets which roll up into the //media component. It controls visibility
# of subcomponent targets and public_deps for //media.
media_subcomponent_deps = [
  "//media/audio",
  "//media/base",

  # TODO(crbug.com/583067): These files should not be in //media/base.
  "//media/base/android",
  "//media/capabilities",
  "//media/cdm",
  "//media/device_monitors",
  "//media/filters",
  "//media/formats",
  "//media/muxers",
  "//media/renderers",
  "//media/video",
]

declare_args() {
  # Allows distributions to link pulseaudio directly (DT_NEEDED) instead of
  # using dlopen. This helps with automated detection of ABI mismatches and
  # prevents silent errors.
  link_pulseaudio = false

  # Enable usage of FFmpeg within the media library. Used for most software
  # based decoding, demuxing, and sometimes optimized FFTs. If disabled,
  # implementors must provide their own demuxers and decoders.
  media_use_ffmpeg = true

  # Enable usage of libvpx within the media library. Used for software based
  # decoding of VP9 and VP8A type content.
  media_use_libvpx = true

  # iOS doesn't use ffmpeg, libvpx.
  if (is_ios) {
    media_use_ffmpeg = false
    media_use_libvpx = false
  }

  # Override to dynamically link the cras (ChromeOS audio) library.
  use_cras = false

  # Enables AC3/EAC3 audio demuxing. This is enabled only on Chromecast, since
  # it only provides demuxing, and is only useful for AC3/EAC3 audio
  # pass-through to HDMI sink on Chromecast.
  enable_ac3_eac3_audio_demuxing = proprietary_codecs && is_chromecast

  enable_mpeg_h_audio_demuxing = proprietary_codecs && is_chromecast

  enable_mse_mpeg2ts_stream_parser =
      proprietary_codecs && (is_chromecast || use_fuzzing_engine)

  # Enable parsing for the 'cbcs' encryption scheme added by MPEG Common
  # Encryption 3rd Edition (ISO/IEC 23001-7), published 02/15/2016.
  enable_cbcs_encryption_scheme =
      is_chromecast || is_mac || is_win || is_linux || is_android

  # Enable HEVC/H265 demuxing. Actual decoding must be provided by the
  # platform. Enable by default for Chromecast.
  enable_hevc_demuxing = proprietary_codecs && is_chromecast

  # Enable Dolby Vision demuxing. Enable by default for Chromecast. Actual
  # decoding must be provided by the platform. Note some Dolby Vision profiles
  # which are encoded using HEVC require |enable_hevc_demuxing| to be enabled.
  enable_dolby_vision_demuxing = proprietary_codecs && is_chromecast

  # Enable HLS with SAMPLE-AES decryption.
  enable_hls_sample_aes = proprietary_codecs && is_chromecast

  # Enable logging override, e.g. enable DVLOGs at build time. Must not be
  # enabled when |use_jumbo_build| is true, in which case multiple .cc files
  # are combined and we could override more logging than expected.
  enable_logging_override = !use_jumbo_build && is_chromecast

  enable_dav1d_decoder = !is_android && !is_ios
}

declare_args() {
  enable_av1_decoder = enable_dav1d_decoder || enable_libaom_decoder
}

# enable_hls_sample_aes can only be true if enable_mse_mpeg2ts_stream_parser is.
assert(enable_mse_mpeg2ts_stream_parser || !enable_hls_sample_aes)

# Logging override must not be enabled in jumbo builds.
assert(!use_jumbo_build || !enable_logging_override)

if (media_use_ffmpeg) {
  media_subcomponent_deps += [ "//media/ffmpeg" ]
}

# Use a second declare_args() to pick up possible overrides of |use_cras|.
declare_args() {
  # Enables runtime selection of PulseAudio library.
  use_pulseaudio = false

  # Enables runtime selection of ALSA library for audio.
  use_alsa = false

  # Alsa should be used on non-Android, non-Mac POSIX systems.
  # Alsa should be used on desktop Chromecast and audio-only Chromecast builds.
  if (is_posix && !is_android && !is_mac &&
      (!is_chromecast || is_cast_desktop_build || is_cast_audio_only)) {
    use_alsa = true

    # Pulse is not supported on Chromecast platforms.
    if (!use_cras && !is_chromecast) {
      use_pulseaudio = true
    }
  }
}

# Use another declare_args() to pick up possible overrides of media_use_ffmpeg
# from --args command line flags. See "gn help declare_args".
declare_args() {
  # On Android, FFMpeg is built without video decoders by default.
  # This flag gives the option to override that decision in case there are no
  # hardware decoders. To do so, you will also need to update ffmpeg build files
  # in order to define which decoders to build in.
  enable_ffmpeg_video_decoders = media_use_ffmpeg && !is_android
}

# Enables the use of library CDMs that implements the interface defined at
# media/cdm/api/content_decryption_module.h. If true, the actually library CDM
# will be hosted in the mojo CDM service running in the CDM (utility) process.
# On Fuchsia, this is only enabled to build libclearkeycdm.so, the mojo CDM
# service is not used.
enable_library_cdms =
    (is_linux && !is_chromecast) || is_mac || is_win || is_fuchsia

declare_args() {
  # Experiment to enable mojo media services (e.g. "renderer", "cdm", see
  # |mojo_media_services|). When enabled, selected mojo paths will be enabled in
  # the media pipeline and corresponding services will hosted in the selected
  # remote process (e.g. "utility" process, see |mojo_media_host|).
  # This is explicitly disabled for Fuchsia.
  enable_mojo_media =
      !is_fuchsia &&
      (is_android || is_chromeos || is_mac || is_win || enable_library_cdms ||
       (is_desktop_linux && use_vaapi) || is_chromecast)

  # Enable the TestMojoMediaClient to be used in mojo MediaService. This is for
  # testing only and will override the default platform MojoMediaClient, if any.
  enable_test_mojo_media_client = false

  # When enabled, this feature allows developers to use a runtime flag to
  # choose the implementation of the renderer that is used. On a build which
  # enables the mojo renderer, if --disable-mojo-renderer is passed at start-up,
  # the "default" renderer will be used instead. Both renderer implementations
  # will be linked if this feature is enabled, increasing the binary size. This
  # feature does not make sense if the mojo renderer is not enabled.
  enable_runtime_media_renderer_selection = is_cast_desktop_build

  # Enables host verification for CDMs.
  # Windows and Mac.
  enable_cdm_host_verification =
      enable_library_cdms && (is_mac || is_win) && is_chrome_branded

  # Enable Storage ID which is used by CDMs. This is only available with chrome
  # branding, but may be overridden by other embedders.
  enable_cdm_storage_id = enable_library_cdms && is_chrome_branded &&
                          (is_win || is_mac || is_chromeos)

  # If |enable_cdm_storage_id| is set, then an implementation specific key
  # must also be provided. It can be provided by defining CDM_STORAGE_ID_KEY
  # (which takes precedence), or by setting |alternate_cdm_storage_id_key|.
  # The key must be a string of at least 32 characters.
  alternate_cdm_storage_id_key = ""
}

# This feature can only be enabled when using Mojo media. Furthermore, the
# "renderer" service must be enabled, which is asserted in
# //media/mojo/services/BUILD.gn
assert(
    !enable_runtime_media_renderer_selection || enable_mojo_media,
    "Runtime media renderer selection only applies when mojo media is enabled.")

assert(!enable_cdm_host_verification || is_mac || is_win,
       "CDM host verification is only supported on Mac and Windows.")

_default_mojo_media_services = []
_default_mojo_media_host = "none"

# Default mojo_media_services and mojo_media_host on various platforms.
# Can be overridden by gn build arguments from the --args command line flag
# for local testing.
if (enable_mojo_media) {
  if (is_chromecast) {
    _default_mojo_media_services = cast_mojo_media_services
    _default_mojo_media_host = cast_mojo_media_host
  } else if (is_android) {
    _default_mojo_media_services = [
      "cdm",
      "audio_decoder",
      "video_decoder",
    ]
    _default_mojo_media_host = "gpu"
  } else if (is_chromeos || is_mac || is_win ||
             (is_desktop_linux && use_vaapi)) {
    _default_mojo_media_services = [ "video_decoder" ]
    _default_mojo_media_host = "gpu"
  }

  if (enable_library_cdms) {
    _default_mojo_media_services += [ "cdm" ]

    # Having a CDM running means it could require a CdmProxy running in the GPU
    # process.
    assert(
        _default_mojo_media_host == "none" || _default_mojo_media_host == "gpu",
        "For now, mojo_media_host should not overwrite it with a different " +
            "value if it has been set.")
    _default_mojo_media_host = "gpu"
  }
}

# Use another declare_args() to pick up possible overrides of enable_mojo_media
# from --args command line flags. See "gn help declare_args".
declare_args() {
  # A list of mojo media services that should be used in the media pipeline.
  # Must not be empty if |enable_mojo_media| is true.
  # Valid entries in the list are:
  # - "renderer": Use mojo-based media Renderer service.
  # - "cdm": Use mojo-based Content Decryption Module.
  # - "audio_decoder": Use mojo-based audio decoder in the default media
  #                    Renderer. Cannot be used with the mojo Renderer above.
  # - "video_decoder": Use mojo-based video decoder in the default media
  #                    Renderer. Cannot be used with the mojo Renderer above.
  mojo_media_services = _default_mojo_media_services

  # The process that the mojo MediaService runs in. By default, all services
  # registered in |mojo_media_services| are hosted in the MediaService, with the
  # exception that when |enable_library_cdms| is true, the "cdm" service will
  # run in a separate CdmService in the CDM (utility) process, while other
  # |mojo_media_services| still run in the MediaService in the process specified
  # by "mojo_media_host".
  # Valid options are:
  # - "none": Do not use mojo media service.
  # - "browser": Use mojo media service hosted in the browser process.
  # - "gpu": Use mojo media service hosted in the gpu process.
  # - "utility": Use mojo media service hosted in the utility process.
  mojo_media_host = _default_mojo_media_host
}

declare_args() {
  # This switch defines whether the Media Remoting implementation will be built.
  # When enabled, media is allowed to be renderer and played back on remote
  # devices when the tab is being casted and other conditions are met.
  enable_media_remoting = !is_chromecast && !is_ios
}

declare_args() {
  # Media Remoting RPC is disabled on Android since it's unused but increases
  # the native binary size by ~70Kb.
  enable_media_remoting_rpc = enable_media_remoting && !is_android
}
