# Copyright (c) 2016 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("../build/webrtc.gni")

group("p2p") {
  deps = [
    ":rtc_p2p",
  ]
}

config("rtc_p2p_inherited_config") {
  defines = [ "FEATURE_ENABLE_VOICEMAIL" ]
}

source_set("rtc_p2p") {
  sources = [
    "base/asyncstuntcpsocket.cc",
    "base/asyncstuntcpsocket.h",
    "base/basicpacketsocketfactory.cc",
    "base/basicpacketsocketfactory.h",
    "base/candidate.h",
    "base/common.h",
    "base/dtlstransport.h",
    "base/dtlstransportchannel.cc",
    "base/dtlstransportchannel.h",
    "base/p2pconstants.cc",
    "base/p2pconstants.h",
    "base/p2ptransport.cc",
    "base/p2ptransport.h",
    "base/p2ptransportchannel.cc",
    "base/p2ptransportchannel.h",
    "base/packetsocketfactory.h",
    "base/port.cc",
    "base/port.h",
    "base/portallocator.cc",
    "base/portallocator.h",
    "base/portinterface.h",
    "base/pseudotcp.cc",
    "base/pseudotcp.h",
    "base/relayport.cc",
    "base/relayport.h",
    "base/session.cc",
    "base/session.h",
    "base/sessiondescription.cc",
    "base/sessiondescription.h",
    "base/sessionid.h",
    "base/stun.cc",
    "base/stun.h",
    "base/stunport.cc",
    "base/stunport.h",
    "base/stunrequest.cc",
    "base/stunrequest.h",
    "base/tcpport.cc",
    "base/tcpport.h",
    "base/transport.cc",
    "base/transport.h",
    "base/transportchannel.cc",
    "base/transportchannel.h",
    "base/transportchannelimpl.h",
    "base/transportcontroller.cc",
    "base/transportcontroller.h",
    "base/transportdescription.cc",
    "base/transportdescription.h",
    "base/transportdescriptionfactory.cc",
    "base/transportdescriptionfactory.h",
    "base/transportinfo.h",
    "base/turnport.cc",
    "base/turnport.h",
    "base/udpport.h",
    "client/basicportallocator.cc",
    "client/basicportallocator.h",
    "client/httpportallocator.cc",
    "client/httpportallocator.h",
    "client/socketmonitor.cc",
    "client/socketmonitor.h",
  ]

  defines = [ "FEATURE_ENABLE_SSL" ]

  deps = [
    "../base:rtc_base",
    "../libjingle/xmllite",
  ]

  if (rtc_build_expat) {
    deps += [ "//third_party/expat" ]
    public_deps = [
      "//third_party/expat",
    ]
  }

  configs += [ "..:common_config" ]
  public_configs = [
    "..:common_inherited_config",
    ":rtc_p2p_inherited_config",
  ]

  if (build_with_chromium) {
    if (is_nacl) {
      deps += [ "//native_client_sdk/src/libraries/nacl_io" ]
    }
  } else {
    sources += [
      "base/relayserver.cc",
      "base/relayserver.h",
      "base/stunserver.cc",
      "base/stunserver.h",
      "base/turnserver.cc",
      "base/turnserver.h",
    ]
    defines += [
      "FEATURE_ENABLE_VOICEMAIL",
      "FEATURE_ENABLE_PSTN",
    ]

    if (is_clang) {
      # Suppress warnings from Chrome's Clang plugins.
      # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
      configs -= [ "//build/config/clang:find_bad_constructs" ]
    }
  }

  if (rtc_use_quic) {
    deps = [
      "//third_party/libquic",
    ]
    sources += [
      "quic/quicconnectionhelper.cc",
      "quic/quicconnectionhelper.h",
      "quic/quicsession.cc",
      "quic/quicsession.h",
      "quic/quictransport.cc",
      "quic/quictransport.h",
      "quic/quictransportchannel.cc",
      "quic/quictransportchannel.h",
      "quic/reliablequicstream.cc",
      "quic/reliablequicstream.h",
    ]
    public_deps += [ "//third_party/libquic" ]
  }
}

source_set("libstunprober") {
  sources = [
    "stunprober/stunprober.cc",
  ]

  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.
    configs -= [ "//build/config/clang:find_bad_constructs" ]
  }

  deps = [
    "..:webrtc_common",
    "../base:rtc_base",
  ]
}