# 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("corruption_detection_settings_generator") {
  visibility = [ "*" ]
  sources = [
    "corruption_detection_settings_generator.cc",
    "corruption_detection_settings_generator.h",
  ]
  deps = [
    ":filter_settings",
    "../../../rtc_base:checks",
  ]
}

rtc_source_set("filter_settings") {
  visibility = [ "*" ]
  sources = [ "corruption_detection_filter_settings.h" ]
}

rtc_library("frame_instrumentation_data") {
  visibility = [ "*" ]
  sources = [
    "frame_instrumentation_data.cc",
    "frame_instrumentation_data.h",
  ]

  deps = []
}

rtc_library("frame_instrumentation_data_reader") {
  visibility = [ "*" ]
  sources = [
    "frame_instrumentation_data_reader.cc",
    "frame_instrumentation_data_reader.h",
  ]

  deps = [
    ":frame_instrumentation_data",
    "../../../rtc_base:logging",
    "../../transport/rtp:corruption_detection_message",
  ]
}

rtc_library("frame_instrumentation_evaluation") {
  visibility = [ "*" ]
  sources = [
    "frame_instrumentation_evaluation.cc",
    "frame_instrumentation_evaluation.h",
  ]
  deps = [
    ":frame_instrumentation_data",
    "..:video_frame",
    "..:video_rtp_headers",
    "../../../rtc_base:checks",
    "../../../rtc_base:logging",
    "../../../video/corruption_detection:corruption_classifier",
    "../../../video/corruption_detection:halton_frame_sampler",
  ]
}

rtc_library("frame_instrumentation_generator_factory") {
  visibility = [ "*" ]
  sources = [
    "frame_instrumentation_generator_factory.cc",
    "frame_instrumentation_generator_factory.h",
  ]
  deps = [
    ":frame_instrumentation_generator_header",  # keep
    "..:video_frame",
    "../../../video/corruption_detection:frame_instrumentation_generator_impl",
    "../../environment",
    "../../video_codecs:scalability_mode",
  ]
}

rtc_library("frame_instrumentation_generator_header") {
  visibility = [ "*" ]
  sources = [ "frame_instrumentation_generator.h" ]
  deps = [
    ":frame_instrumentation_data",
    "..:encoded_image",
    "..:video_frame",
  ]
}

# Legacy target including both header and implementation.
# TODO: bugs.webrtc.org/358039777 - Remove once downstream usage is gone.
rtc_library("frame_instrumentation_generator") {
  visibility = [ "*" ]
  sources = [
    "frame_instrumentation_generator.cc",
    "frame_instrumentation_generator.h",
  ]
  deps = [
    ":frame_instrumentation_data",
    ":frame_instrumentation_generator_factory",
    "..:encoded_image",
    "..:video_frame",
  ]
}

if (rtc_include_tests) {
  rtc_library("corruption_detection_unittests") {
    testonly = true
    sources = [ "corruption_detection_settings_generator_unittest.cc" ]
    deps = [
      ":corruption_detection_settings_generator",
      ":filter_settings",
      "../../../test:test_support",
    ]
  }

  rtc_library("frame_instrumentation_data_unittest") {
    testonly = true
    sources = [ "frame_instrumentation_data_unittest.cc" ]

    deps = [
      ":frame_instrumentation_data",
      "../../../test:test_support",
    ]
  }

  rtc_library("frame_instrumentation_data_reader_unittest") {
    testonly = true
    sources = [ "frame_instrumentation_data_reader_unittest.cc" ]

    deps = [
      ":frame_instrumentation_data",
      ":frame_instrumentation_data_reader",
      "../../../test:test_support",
      "../../transport/rtp:corruption_detection_message",
    ]
  }

  rtc_library("frame_instrumentation_evaluation_unittest") {
    testonly = true
    sources = [ "frame_instrumentation_evaluation_unittest.cc" ]
    deps = [
      ":frame_instrumentation_data",
      ":frame_instrumentation_evaluation",
      "..:video_frame",
      "..:video_rtp_headers",
      "../..:scoped_refptr",
      "../../../test:test_support",
      "../../../video/corruption_detection:halton_frame_sampler",
    ]
  }
}
