# 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_static_library("video") {
  sources = [
    "call_stats.cc",
    "call_stats.h",
    "encoder_rtcp_feedback.cc",
    "encoder_rtcp_feedback.h",
    "overuse_frame_detector.cc",
    "overuse_frame_detector.h",
    "quality_threshold.cc",
    "quality_threshold.h",
    "receive_statistics_proxy.cc",
    "receive_statistics_proxy.h",
    "report_block_stats.cc",
    "report_block_stats.h",
    "rtp_streams_synchronizer.cc",
    "rtp_streams_synchronizer.h",
    "rtp_video_stream_receiver.cc",
    "rtp_video_stream_receiver.h",
    "send_delay_stats.cc",
    "send_delay_stats.h",
    "send_statistics_proxy.cc",
    "send_statistics_proxy.h",
    "stats_counter.cc",
    "stats_counter.h",
    "stream_synchronization.cc",
    "stream_synchronization.h",
    "transport_adapter.cc",
    "transport_adapter.h",
    "video_quality_observer.cc",
    "video_quality_observer.h",
    "video_receive_stream.cc",
    "video_receive_stream.h",
    "video_send_stream.cc",
    "video_send_stream.h",
    "video_send_stream_impl.cc",
    "video_send_stream_impl.h",
    "video_stream_decoder.cc",
    "video_stream_decoder.h",
    "video_stream_encoder.cc",
    "video_stream_encoder.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",
    "../:typedefs",
    "../api:fec_controller_api",
    "../api:libjingle_peerconnection_api",
    "../api:transport_api",
    "../api/video:video_frame",
    "../api/video:video_frame_i420",
    "../api/video:video_stream_encoder",
    "../api/video_codecs:video_codecs_api",
    "../call:bitrate_allocator",
    "../call:call_interfaces",
    "../call:rtp_interfaces",
    "../call:rtp_sender",
    "../call:video_stream_api",
    "../modules/rtp_rtcp:rtp_rtcp_format",
    "../modules/rtp_rtcp:rtp_video_header",
    "../modules/video_coding:codec_globals_headers",
    "../modules/video_coding:nack_module",
    "../modules/video_coding:packet",
    "../modules/video_coding:video_codec_interface",
    "../rtc_base:checks",
    "../rtc_base:rate_limiter",
    "../rtc_base:stringutils",
    "../rtc_base/experiments:alr_experiment",
    "../rtc_base/experiments:quality_scaling_experiment",
    "../rtc_base/system:fallthrough",
    "../system_wrappers:field_trial_api",
    "../system_wrappers:metrics_api",
    "//third_party/abseil-cpp/absl/memory",
    "//third_party/abseil-cpp/absl/types:optional",

    # For RtxReceiveStream.
    "../call:rtp_receiver",
    "../common_video",
    "../logging:rtc_event_log_api",
    "../modules:module_api",
    "../modules/bitrate_controller",
    "../modules/pacing",
    "../modules/remote_bitrate_estimator",
    "../modules/rtp_rtcp",
    "../modules/utility",
    "../modules/video_coding",
    "../modules/video_coding:video_coding_utility",
    "../modules/video_processing",
    "../rtc_base:rtc_base_approved",
    "../rtc_base:rtc_numerics",
    "../rtc_base:rtc_task_queue",
    "../rtc_base:sequenced_task_checker",
    "../rtc_base:weak_ptr",
    "../rtc_base/time:timestamp_extrapolator",
    "../system_wrappers",
  ]

  if (!build_with_mozilla) {
    deps += [ "../media:rtc_media_base" ]
  }
}

rtc_source_set("video_stream_decoder_impl") {
  visibility = [ "*" ]

  sources = [
    "video_stream_decoder_impl.cc",
    "video_stream_decoder_impl.h",
  ]

  deps = [
    "../api/video:encoded_frame",
    "../api/video:video_frame",
    "../api/video:video_stream_decoder",
    "../api/video_codecs:video_codecs_api",
    "../modules/video_coding:video_coding",
    "../rtc_base:rtc_base_approved",
    "../rtc_base:rtc_task_queue_api",
    "../system_wrappers:system_wrappers",
    "//third_party/abseil-cpp/absl/memory",
    "//third_party/abseil-cpp/absl/types:optional",
  ]
}

if (rtc_include_tests) {
  rtc_source_set("video_mocks") {
    testonly = true
    sources = [
      "test/mock_video_stream_encoder.h",
    ]
    deps = [
      ":video",
      "../test:test_support",
    ]
  }
  rtc_source_set("video_quality_test") {
    testonly = true

    # Only targets in this file and api/ can depend on this.
    visibility = [
      ":*",
      "../api:create_video_quality_test_fixture_api",
    ]
    sources = [
      "video_analyzer.cc",
      "video_analyzer.h",
      "video_quality_test.cc",
      "video_quality_test.h",
    ]
    deps = [
      "../api:fec_controller_api",
      "../api:video_quality_test_fixture_api",
      "../call:fake_network",
      "../logging:rtc_event_log_api",
      "../logging:rtc_event_log_impl_output",
      "../media:rtc_audio_video",
      "../media:rtc_internal_video_codecs",
      "../modules/audio_mixer:audio_mixer_impl",
      "../modules/rtp_rtcp",
      "../modules/video_coding:video_coding",
      "../modules/video_coding:webrtc_h264",
      "../modules/video_coding:webrtc_multiplex",
      "../modules/video_coding:webrtc_vp8",
      "../modules/video_coding:webrtc_vp9",
      "../rtc_base:rtc_base_approved",
      "../rtc_base:rtc_base_tests_utils",
      "../system_wrappers",
      "../test:fileutils",
      "../test:perf_test",
      "../test:rtp_test_utils",
      "../test:test_common",
      "../test:test_renderer",
      "../test:test_support",
      "../test:test_support_test_artifacts",
      "../test:video_test_common",
      "../test:video_test_support",
    ]
    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" ]
    }
  }

  rtc_source_set("video_full_stack_tests") {
    testonly = true

    sources = [
      "full_stack_tests.cc",
    ]
    deps = [
      ":video_quality_test",
      "../media:rtc_vp9_profile",
      "../modules/pacing:pacing",
      "../modules/video_coding:webrtc_vp9",
      "../rtc_base:rtc_base_approved",
      "../rtc_base/experiments:alr_experiment",
      "../test:field_trial",
      "../test:test_common",
      "../test:test_support",
      "//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_use_h264) {
      defines = [ "WEBRTC_USE_H264" ]
    }
  }

  rtc_executable("video_loopback") {
    testonly = true
    sources = [
      "video_loopback.cc",
    ]
    deps = [
      ":video_quality_test",
      "../rtc_base:rtc_base_approved",
      "../system_wrappers:field_trial_default",
      "../system_wrappers:metrics_default",
      "../system_wrappers:runtime_enabled_features_default",
      "../test:field_trial",
      "../test:run_test",
      "../test:run_test_interface",
      "../test:test_common",
      "../test:test_renderer",
      "../test:test_support",
      "//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" ]
    }
  }

  rtc_executable("screenshare_loopback") {
    testonly = true
    sources = [
      "screenshare_loopback.cc",
    ]

    deps = [
      ":video_quality_test",
      "../rtc_base:rtc_base_approved",
      "../system_wrappers:field_trial_default",
      "../system_wrappers:metrics_default",
      "../system_wrappers:runtime_enabled_features_default",
      "../test:field_trial",
      "../test:run_test",
      "../test:run_test_interface",
      "../test:test_common",
      "../test:test_renderer",
      "../test:test_support",
    ]
    if (!build_with_chromium && is_clang) {
      # Suppress warnings from Chrome's Clang plugins.
      # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
      suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
    }
  }

  rtc_executable("sv_loopback") {
    testonly = true
    sources = [
      "sv_loopback.cc",
    ]
    deps = [
      ":video_quality_test",
      "../rtc_base:rtc_base_approved",
      "../system_wrappers:field_trial_default",
      "../system_wrappers:metrics_default",
      "../system_wrappers:runtime_enabled_features_default",
      "../test:field_trial",
      "../test:run_test",
      "../test:run_test_interface",
      "../test:test_common",
      "../test:test_renderer",
      "../test:test_support",
      "//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" ]
    }
  }

  rtc_executable("video_replay") {
    testonly = true
    sources = [
      "replay.cc",
    ]
    deps = [
      "..:webrtc_common",
      "../:typedefs",
      "../api/video_codecs:video_codecs_api",
      "../call:call_interfaces",
      "../common_video",
      "../logging:rtc_event_log_api",
      "../modules/rtp_rtcp",
      "../rtc_base:checks",
      "../rtc_base:rtc_base_approved",
      "../system_wrappers",
      "../system_wrappers:metrics_default",
      "../system_wrappers:runtime_enabled_features_default",
      "../test:field_trial",
      "../test:rtp_test_utils",
      "../test:run_test",
      "../test:run_test_interface",
      "../test:test_common",
      "../test:test_renderer",
      "../test:test_support",
      "../test:video_test_common",
      "../test:video_test_support",
    ]
    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" ]
    }
  }

  # TODO(pbos): Rename test suite.
  rtc_source_set("video_tests") {
    testonly = true

    defines = []
    sources = [
      "call_stats_unittest.cc",
      "encoder_rtcp_feedback_unittest.cc",
      "end_to_end_tests/bandwidth_tests.cc",
      "end_to_end_tests/call_operation_tests.cc",
      "end_to_end_tests/codec_tests.cc",
      "end_to_end_tests/config_tests.cc",
      "end_to_end_tests/extended_reports_tests.cc",
      "end_to_end_tests/fec_tests.cc",
      "end_to_end_tests/histogram_tests.cc",
      "end_to_end_tests/log_tests.cc",
      "end_to_end_tests/multi_codec_receive_tests.cc",
      "end_to_end_tests/multi_stream_tester.cc",
      "end_to_end_tests/multi_stream_tester.h",
      "end_to_end_tests/multi_stream_tests.cc",
      "end_to_end_tests/network_state_tests.cc",
      "end_to_end_tests/probing_tests.cc",
      "end_to_end_tests/receive_time_tests.cc",
      "end_to_end_tests/retransmission_tests.cc",
      "end_to_end_tests/rtp_rtcp_tests.cc",
      "end_to_end_tests/ssrc_tests.cc",
      "end_to_end_tests/stats_tests.cc",
      "end_to_end_tests/transport_feedback_tests.cc",
      "overuse_frame_detector_unittest.cc",
      "picture_id_tests.cc",
      "quality_scaling_tests.cc",
      "quality_threshold_unittest.cc",
      "receive_statistics_proxy_unittest.cc",
      "report_block_stats_unittest.cc",
      "rtp_video_stream_receiver_unittest.cc",
      "send_delay_stats_unittest.cc",
      "send_statistics_proxy_unittest.cc",
      "stats_counter_unittest.cc",
      "stream_synchronization_unittest.cc",
      "video_receive_stream_unittest.cc",
      "video_send_stream_impl_unittest.cc",
      "video_send_stream_tests.cc",
      "video_stream_encoder_unittest.cc",
    ]
    deps = [
      ":video",
      ":video_mocks",
      "../api/video:video_frame",
      "../api/video:video_frame_i420",
      "../api/video_codecs:video_codecs_api",
      "../call:call_interfaces",
      "../call:mock_bitrate_allocator",
      "../call:mock_rtp_interfaces",
      "../call:rtp_receiver",
      "../call:rtp_sender",
      "../call:video_stream_api",
      "../common_video",
      "../logging:rtc_event_log_api",
      "../media:rtc_audio_video",
      "../media:rtc_internal_video_codecs",
      "../media:rtc_media",
      "../media:rtc_media_base",
      "../media:rtc_media_tests_utils",
      "../modules:module_api",
      "../modules/pacing",
      "../modules/rtp_rtcp",
      "../modules/rtp_rtcp:mock_rtp_rtcp",
      "../modules/rtp_rtcp:rtp_rtcp_format",
      "../modules/utility",
      "../modules/video_coding",
      "../modules/video_coding:codec_globals_headers",
      "../modules/video_coding:packet",
      "../modules/video_coding:video_codec_interface",
      "../modules/video_coding:video_coding_utility",
      "../modules/video_coding:webrtc_h264",
      "../modules/video_coding:webrtc_multiplex",
      "../modules/video_coding:webrtc_vp8",
      "../modules/video_coding:webrtc_vp9",
      "../rtc_base:checks",
      "../rtc_base:rate_limiter",
      "../rtc_base:rtc_base_approved",
      "../rtc_base:rtc_base_tests_utils",
      "../rtc_base:rtc_numerics",
      "../rtc_base:rtc_task_queue",
      "../rtc_base:rtc_task_queue_for_test",
      "../rtc_base/experiments:alr_experiment",
      "../system_wrappers",
      "../system_wrappers:field_trial_default",
      "../system_wrappers:metrics_api",
      "../system_wrappers:metrics_default",
      "../test:direct_transport",
      "../test:field_trial",
      "../test:fileutils",
      "../test:perf_test",
      "../test:rtp_test_utils",
      "../test:test_common",
      "../test:test_support",
      "../test:video_test_common",
      "//testing/gtest",
      "//third_party/abseil-cpp/absl/memory",
      "//third_party/abseil-cpp/absl/types:optional",
    ]
    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_use_h264) {
      defines += [ "WEBRTC_USE_H264" ]
    }
    if (!build_with_mozilla) {
      deps += [ "../media:rtc_media_base" ]
    }
  }
}
