# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS.  All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.

import("../webrtc.gni")
if (is_android) {
  import("//build/config/android/config.gni")
  import("//build/config/android/rules.gni")
}

rtc_static_library("audio") {
  sources = [
    "audio_receive_stream.cc",
    "audio_receive_stream.h",
    "audio_send_stream.cc",
    "audio_send_stream.h",
    "audio_state.cc",
    "audio_state.h",
    "audio_transport_proxy.cc",
    "audio_transport_proxy.h",
    "conversion.h",
    "scoped_voe_interface.h",
  ]

  if (!build_with_chromium && is_clang) {
    # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
    suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
  }

  deps = [
    "..:webrtc_common",
    "../api:audio_mixer_api",
    "../api:call_api",
    "../base:rtc_base_approved",
    "../base:rtc_task_queue",
    "../call:call_interfaces",
    "../common_audio",
    "../modules/audio_device",
    "../modules/audio_processing",
    "../modules/bitrate_controller:bitrate_controller",
    "../modules/congestion_controller:congestion_controller",
    "../modules/pacing:pacing",
    "../modules/remote_bitrate_estimator:remote_bitrate_estimator",
    "../modules/rtp_rtcp:rtp_rtcp",
    "../system_wrappers",
    "../voice_engine",
  ]
}
if (rtc_include_tests) {
  rtc_source_set("audio_tests") {
    testonly = true

    # TODO(kjellander): Remove (bugs.webrtc.org/6828)
    # This needs remote_bitrate_estimator to be moved to webrtc/api first.
    check_includes = false

    sources = [
      "audio_receive_stream_unittest.cc",
      "audio_send_stream_unittest.cc",
      "audio_state_unittest.cc",
    ]
    deps = [
      ":audio",
      "../api:mock_audio_mixer",
      "../base:rtc_base_approved",
      "../base:rtc_task_queue",
      "../modules/audio_device:mock_audio_device",
      "../modules/audio_mixer:audio_mixer_impl",
      "../modules/congestion_controller:congestion_controller",
      "../modules/pacing:pacing",
      "../test:test_common",
      "../test:test_support",
      "utility:utility_tests",
      "//testing/gmock",
      "//testing/gtest",
    ]

    if (!build_with_chromium && is_clang) {
      # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
      suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
    }
  }

  if (rtc_enable_protobuf) {
    rtc_test("low_bandwidth_audio_test") {
      testonly = true

      sources = [
        "test/low_bandwidth_audio_test.cc",
        "test/low_bandwidth_audio_test.h",
      ]

      deps = [
        "../common_audio",
        "../system_wrappers",
        "../test:fake_audio_device",
        "../test:test_common",
        "../test:test_main",
      ]
      if (is_android) {
        deps += [ "//testing/android/native_test:native_test_native_code" ]
      }

      data = [
        "//resources/voice_engine/audio_tiny16.wav",
      ]

      if (!build_with_chromium && is_clang) {
        # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163)
        suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
      }
    }
  }
}
