# Copyright 2018 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/media_options.gni")
import("//third_party/webrtc/webrtc.gni")

component("webrtc") {
  _configs = configs
  configs = []
  configs = [ "//third_party/tflite:tflite_shim_config" ] + _configs
  output_name = "media_webrtc"

  sources = [
    "audio_delay_stats_reporter.cc",
    "audio_delay_stats_reporter.h",
    "audio_processor.cc",
    "audio_processor.h",
    "constants.cc",
    "constants.h",
    "helpers.cc",
    "helpers.h",
    "ml_model_handle.h",
    "webrtc_features.cc",
    "webrtc_features.h",
  ]

  defines = [ "IS_MEDIA_WEBRTC_IMPL" ]

  deps = [
    "//base",
    "//build:chromecast_buildflags",
    "//media",
    "//third_party/webrtc_overrides:webrtc_component",
  ]

  if (!is_fuchsia) {
    deps += [ "//components/optimization_guide/core/inference:op_resolver" ]
  }

  public_deps = [ "//third_party/tflite" ]

  if (chrome_wide_echo_cancellation_supported) {
    public_deps += [ "//media/webrtc/voice_isolation" ]
  }
}

source_set("unit_tests") {
  testonly = true
  deps = [
    "//base",
    "//base/test:test_support",
    "//build:chromecast_buildflags",
    "//media:test_support",
    "//media/webrtc",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/webrtc_overrides:webrtc_component",
  ]
  if (chrome_wide_echo_cancellation_supported) {
    deps += [ "//media/webrtc/voice_isolation:unit_tests" ]
  }
  sources = [
    "audio_processor_test.cc",
    "helpers_unittest.cc",
  ]
}
