# 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")

config("common_video_config") {
  include_dirs = [ "include" ]
}

rtc_static_library("common_video") {
  visibility = [ "*" ]

  sources = [
    "bitrate_adjuster.cc",
    "h264/h264_bitstream_parser.cc",
    "h264/h264_bitstream_parser.h",
    "h264/h264_common.cc",
    "h264/h264_common.h",
    "h264/pps_parser.cc",
    "h264/pps_parser.h",
    "h264/profile_level_id.h",
    "h264/sps_parser.cc",
    "h264/sps_parser.h",
    "h264/sps_vui_rewriter.cc",
    "h264/sps_vui_rewriter.h",
    "i420_buffer_pool.cc",
    "include/bitrate_adjuster.h",
    "include/frame_callback.h",
    "include/i420_buffer_pool.h",
    "include/incoming_video_stream.h",
    "include/video_bitrate_allocator.h",
    "include/video_frame.h",
    "include/video_frame_buffer.h",
    "incoming_video_stream.cc",
    "libyuv/include/webrtc_libyuv.h",
    "libyuv/webrtc_libyuv.cc",
    "video_frame.cc",
    "video_frame_buffer.cc",
    "video_render_frames.cc",
    "video_render_frames.h",
  ]

  include_dirs = [ "../modules/interface" ]

  public_configs = [ ":common_video_config" ]

  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:libjingle_peerconnection_api",
    "../api:optional",
    "../api:video_frame_api",
    "../api:video_frame_api_i420",
    "../media:rtc_h264_profile_id",
    "../modules:module_api",
    "../rtc_base:checks",
    "../rtc_base:rtc_base",
    "../rtc_base:rtc_task_queue",
    "../system_wrappers",
    "//third_party/libyuv",
  ]
}

if (rtc_include_tests) {
  common_video_resources = [ "../resources/foreman_cif.yuv" ]

  if (is_ios) {
    bundle_data("common_video_unittests_bundle_data") {
      testonly = true
      sources = common_video_resources
      outputs = [
        "{{bundle_resources_dir}}/{{source_file_part}}",
      ]
    }
  }

  rtc_test("common_video_unittests") {
    testonly = true

    sources = [
      "bitrate_adjuster_unittest.cc",
      "h264/h264_bitstream_parser_unittest.cc",
      "h264/pps_parser_unittest.cc",
      "h264/profile_level_id_unittest.cc",
      "h264/sps_parser_unittest.cc",
      "h264/sps_vui_rewriter_unittest.cc",
      "i420_buffer_pool_unittest.cc",
      "i420_video_frame_unittest.cc",
      "libyuv/libyuv_unittest.cc",
    ]

    # TODO(jschuh): Bug 1348: fix this warning.
    configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]

    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 = [
      ":common_video",
      "../api:video_frame_api",
      "../api:video_frame_api_i420",
      "../modules/video_capture:video_capture",
      "../rtc_base:rtc_base",
      "../rtc_base:rtc_base_approved",
      "../system_wrappers:system_wrappers",
      "../test:test_main",
      "../test:video_test_common",
      "//testing/gtest",
      "//third_party/libyuv",
    ]

    data = common_video_resources
    if (is_android) {
      deps += [ "//testing/android/native_test:native_test_support" ]
      shard_timeout = 900
    }

    if (is_ios) {
      deps += [ ":common_video_unittests_bundle_data" ]
    }
  }
}
