# Copyright (c) 2025 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("scream_feedback") {
  sources = [
    "scream_feedback.cc",
    "scream_feedback.h",
  ]
  deps = [
    "../../../api/transport:ecn_marking",
    "../../../api/transport:network_control",
    "../../../api/units:data_size",
    "../../../api/units:time_delta",
    "../../../api/units:timestamp",
  ]
}

rtc_library("delay_based_congestion_control") {
  sources = [
    "delay_based_congestion_control.cc",
    "delay_based_congestion_control.h",
  ]
  deps = [
    ":scream_feedback",
    ":scream_v2_parameters",
    "../../../api/transport:network_control",
    "../../../api/units:data_rate",
    "../../../api/units:data_size",
    "../../../api/units:time_delta",
    "../../../api/units:timestamp",
    "../../../rtc_base:checks",
    "../../../rtc_base:windowed_min_filter",
  ]
}

rtc_library("scream_v2_parameters") {
  sources = [
    "scream_v2_parameters.cc",
    "scream_v2_parameters.h",
  ]
  deps = [
    "../../../api:field_trials_view",
    "../../../api/units:data_size",
    "../../../api/units:time_delta",
    "../../../rtc_base/experiments:field_trial_parser",
  ]
}

rtc_library("loss_estimator") {
  sources = [
    "loss_estimator.cc",
    "loss_estimator.h",
  ]
  deps = [
    ":scream_feedback",
    ":scream_v2_parameters",
    "../../../api/transport:network_control",
    "../../../api/units:time_delta",
    "../../../api/units:timestamp",
  ]
}

rtc_library("scream_v2") {
  sources = [
    "scream_v2.cc",
    "scream_v2.h",
  ]
  deps = [
    ":delay_based_congestion_control",
    ":loss_estimator",
    ":scream_feedback",
    ":scream_v2_parameters",
    "../../../api/environment",
    "../../../api/transport:ecn_marking",
    "../../../api/transport:network_control",
    "../../../api/units:data_rate",
    "../../../api/units:data_size",
    "../../../api/units:time_delta",
    "../../../api/units:timestamp",
    "../../../logging:rtc_event_bwe_update_scream",
    "../../../rtc_base:checks",
    "../../../rtc_base:logging",
    "../../../rtc_base/experiments:field_trial_parser",
  ]
}

rtc_library("scream_network_controller") {
  sources = [
    "scream_network_controller.cc",
    "scream_network_controller.h",
  ]
  deps = [
    ":scream_v2",
    ":scream_v2_parameters",
    "../../../api/environment",
    "../../../api/transport:network_control",
    "../../../api/units:data_rate",
    "../../../api/units:data_size",
    "../../../api/units:time_delta",
    "../../../api/units:timestamp",
    "../../../logging:rtc_event_bwe",
    "../../../rtc_base:checks",
    "../../../rtc_base:logging",
  ]
}

if (rtc_include_tests) {
  rtc_library("delay_based_congestion_control_unittest") {
    testonly = true
    sources = [ "delay_based_congestion_control_unittest.cc" ]
    deps = [
      ":delay_based_congestion_control",
      ":scream_feedback",
      ":scream_v2_parameters",
      "../../../api/environment",
      "../../../api/transport:network_control",
      "../../../api/units:data_rate",
      "../../../api/units:data_size",
      "../../../api/units:time_delta",
      "../../../api/units:timestamp",
      "../../../system_wrappers",
      "../../../test:create_test_environment",
      "../../../test:test_support",
      "test:cc_feedback_generator",
    ]
  }

  rtc_library("loss_estimator_unittest") {
    testonly = true
    sources = [ "loss_estimator_unittest.cc" ]
    deps = [
      ":loss_estimator",
      ":scream_feedback",
      ":scream_v2_parameters",
      "../../../api/environment",
      "../../../api/units:data_size",
      "../../../api/units:time_delta",
      "../../../api/units:timestamp",
      "../../../system_wrappers",
      "../../../test:create_test_environment",
      "../../../test:test_support",
    ]
  }

  rtc_library("scream_feedback_unittest") {
    testonly = true
    sources = [ "scream_feedback_unittest.cc" ]
    deps = [
      ":scream_feedback",
      "../../../api/transport:ecn_marking",
      "../../../api/transport:network_control",
      "../../../api/units:data_size",
      "../../../api/units:time_delta",
      "../../../api/units:timestamp",
      "../../../test:test_support",
    ]
  }

  rtc_library("scream_network_controller_unittest") {
    testonly = true
    sources = [ "scream_network_controller_unittest.cc" ]
    deps = [
      ":scream_network_controller",
      "../../../api/environment",
      "../../../api/transport:network_control",
      "../../../api/units:data_rate",
      "../../../api/units:data_size",
      "../../../api/units:time_delta",
      "../../../api/units:timestamp",
      "../../../system_wrappers",
      "../../../test:create_test_environment",
      "../../../test:test_support",
      "test:cc_feedback_generator",
    ]
  }

  rtc_library("scream_v2_unittest") {
    testonly = true
    sources = [ "scream_v2_unittest.cc" ]
    deps = [
      ":scream_v2",
      "../../../api/environment",
      "../../../api/transport:ecn_marking",
      "../../../api/transport:network_control",
      "../../../api/units:data_rate",
      "../../../api/units:data_size",
      "../../../api/units:time_delta",
      "../../../api/units:timestamp",
      "../../../rtc_base:logging",
      "../../../system_wrappers",
      "../../../test:create_test_environment",
      "../../../test:test_support",
      "../../../test/network:simulated_network",
      "test:cc_feedback_generator",
    ]
  }

  rtc_library("scream_unittests") {
    testonly = true
    sources = []
    deps = [
      ":delay_based_congestion_control_unittest",
      ":loss_estimator_unittest",
      ":scream_feedback_unittest",
      ":scream_network_controller_unittest",
      ":scream_v2_unittest",
    ]
  }
}
