# Copyright (c) 2014 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")

rtc_library("remote_bitrate_estimator") {
  sources = [
    "aimd_rate_control.cc",
    "aimd_rate_control.h",
    "bwe_defines.cc",
    "include/bwe_defines.h",
    "include/remote_bitrate_estimator.h",
    "inter_arrival.cc",
    "inter_arrival.h",
    "overuse_detector.cc",
    "overuse_detector.h",
    "overuse_estimator.cc",
    "overuse_estimator.h",
    "packet_arrival_map.cc",
    "packet_arrival_map.h",
    "remote_bitrate_estimator_abs_send_time.cc",
    "remote_bitrate_estimator_abs_send_time.h",
    "remote_bitrate_estimator_single_stream.cc",
    "remote_bitrate_estimator_single_stream.h",
    "remote_estimator_proxy.cc",
    "remote_estimator_proxy.h",
    "test/bwe_test_logging.h",
  ]

  if (rtc_enable_bwe_test_logging) {
    defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ]

    sources += [ "test/bwe_test_logging.cc" ]
  } else {
    defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ]
  }

  deps = [
    "../../api:field_trials_view",
    "../../api:network_state_predictor_api",
    "../../api:rtp_headers",
    "../../api/transport:field_trial_based_config",
    "../../api/transport:network_control",
    "../../api/units:data_rate",
    "../../api/units:data_size",
    "../../api/units:time_delta",
    "../../api/units:timestamp",
    "../../modules:module_api",
    "../../modules:module_api_public",
    "../../modules/congestion_controller/goog_cc:link_capacity_estimator",
    "../../modules/rtp_rtcp:rtp_rtcp_format",
    "../../rtc_base:checks",
    "../../rtc_base:logging",
    "../../rtc_base:macromagic",
    "../../rtc_base:platform_thread",
    "../../rtc_base:race_checker",
    "../../rtc_base:rate_statistics",
    "../../rtc_base:rtc_numerics",
    "../../rtc_base:safe_minmax",
    "../../rtc_base:stringutils",
    "../../rtc_base/experiments:field_trial_parser",
    "../../rtc_base/synchronization:mutex",
    "../../system_wrappers",
    "../../system_wrappers:field_trial",
    "../../system_wrappers:metrics",
  ]
  absl_deps = [
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/types:optional",
  ]
}

if (!build_with_chromium) {
  rtc_library("bwe_rtp") {
    testonly = true
    sources = [
      "tools/bwe_rtp.cc",
      "tools/bwe_rtp.h",
    ]
    deps = [
      "../../test:rtp_test_utils",
      "../rtp_rtcp:rtp_rtcp_format",
    ]
    absl_deps = [
      "//third_party/abseil-cpp/absl/flags:flag",
      "//third_party/abseil-cpp/absl/flags:parse",
    ]
  }

  rtc_executable("rtp_to_text") {
    testonly = true
    sources = [ "tools/rtp_to_text.cc" ]
    deps = [
      ":bwe_rtp",
      "../../rtc_base:macromagic",
      "../../rtc_base:stringutils",
      "../../test:rtp_test_utils",
      "../rtp_rtcp:rtp_rtcp_format",
    ]
  }
}

if (rtc_include_tests) {
  rtc_library("remote_bitrate_estimator_unittests") {
    testonly = true

    sources = [
      "aimd_rate_control_unittest.cc",
      "inter_arrival_unittest.cc",
      "overuse_detector_unittest.cc",
      "packet_arrival_map_test.cc",
      "remote_bitrate_estimator_abs_send_time_unittest.cc",
      "remote_bitrate_estimator_single_stream_unittest.cc",
      "remote_bitrate_estimator_unittest_helper.cc",
      "remote_bitrate_estimator_unittest_helper.h",
      "remote_estimator_proxy_unittest.cc",
    ]
    deps = [
      ":remote_bitrate_estimator",
      "..:module_api_public",
      "../../api/transport:field_trial_based_config",
      "../../api/transport:mock_network_control",
      "../../api/transport:network_control",
      "../../api/units:data_rate",
      "../../api/units:data_size",
      "../../api/units:time_delta",
      "../../api/units:timestamp",
      "../../rtc_base",
      "../../rtc_base:checks",
      "../../rtc_base:random",
      "../../system_wrappers",
      "../../test:field_trial",
      "../../test:fileutils",
      "../../test:test_support",
      "../pacing",
      "../rtp_rtcp:rtp_rtcp_format",
    ]
  }
}