Reland "Clean up libjingle API dependencies."

This is a reland of 9185aca9ce1f66e983d9a5e797cab77a64cc46b0

> Original change's description:
> > > Clean up libjingle API dependencies.
> > > 
> > > This CL moves candidate.h into the public API, since it has
> > > been implicitly included before.
> > > 
> > > This is a straightforward way of solving the circular
> > > dependencies involving that file. For instance,
> > > libjingle_peerconnection_api includes candidate.h from
> > > jsepicecandidate.h, but _api can't depend on rtc_p2p, which
> > > depends on _api. In fact, _api can't depend on much at all
> > > since it's a very high level abstraction; instead, things
> > > should depend on it.
> > > 
> > > Furthermore, we have the case where deprecated headers
> > > include headers in internal modules. I just have to turn
> > > off include checking for those, but that's not a big deal.
> > > 
> > > This CL punts the problem of callfactoryinterface.h being
> > > implicitly included, and pulling in most of the call
> > > module with it. This should be addressed in a follow-up
> > > CL.
> Bug: webrtc:7504
> Change-Id: Icae0ba1a0488550e2871cc65e66d3661707aa5b6
> Reviewed-on: https://webrtc-review.googlesource.com/6460
> Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20156}

TBR=deadbeef@webrtc.org

Bug: webrtc:7504
Change-Id: Ic6598ac2af9355b60bbd289c86dc75e0ae9fed2e
Reviewed-on: https://webrtc-review.googlesource.com/6801
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20167}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 86a63e4..2b7e612 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -34,12 +34,9 @@
 }
 
 rtc_static_library("libjingle_peerconnection_api") {
-  # Cannot have GN check enabled since that would introduce dependency cycles
-  # TODO(kjellander): Remove (bugs.webrtc.org/7504)
-  check_includes = false
   cflags = []
   sources = [
-    "datachannel.h",
+    "candidate.h",
     "datachannelinterface.h",
     "dtmfsenderinterface.h",
     "jsep.h",
@@ -47,17 +44,13 @@
     "jsepsessiondescription.h",
     "mediaconstraintsinterface.cc",
     "mediaconstraintsinterface.h",
-    "mediastream.h",
     "mediastreaminterface.cc",
-    "mediastreaminterface.h",
     "mediastreamproxy.h",
-    "mediastreamtrack.h",
     "mediastreamtrackproxy.h",
     "mediatypes.cc",
     "mediatypes.h",
     "notifier.h",
     "peerconnectionfactoryproxy.h",
-    "peerconnectioninterface.h",
     "peerconnectionproxy.h",
     "proxy.h",
     "rtcerror.cc",
@@ -65,15 +58,11 @@
     "rtpparameters.cc",
     "rtpparameters.h",
     "rtpreceiverinterface.h",
-    "rtpsender.h",
     "rtpsenderinterface.h",
     "statstypes.cc",
     "statstypes.h",
-    "streamcollection.h",
     "umametrics.h",
     "videosourceproxy.h",
-    "videotracksource.h",
-    "webrtcsdp.h",
   ]
 
   if (!build_with_chromium && is_clang) {
@@ -81,7 +70,17 @@
     suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
   }
 
+  public_deps = [
+    ":libjingle_api_deprecated_headers",
+    ":mediastream_interface_and_implicit_video_frame_api",
+    ":peerconnection_and_implicit_call_api",
+  ]
+
   deps = [
+    # Basically, don't add stuff here. You might break sensitive downstream
+    # targets like pnacl. API should not depend on anything, really. All these
+    # should go away, in time.
+    ":optional",
     ":rtc_stats_api",
     "..:webrtc_common",
     "../rtc_base:rtc_base",
@@ -97,6 +96,44 @@
   }
 }
 
+rtc_source_set("peerconnection_and_implicit_call_api") {
+  # The peerconnectioninterface.h file pulls in call/callfactoryinterface.h
+  # and the entire call module with it. We need to either get rid of this
+  # dependency or pull most of call/ into the API. For now, silence the warnings
+  # this creates since it creates a circular dependency (call very much depends
+  # on API). See bugs.webrtc.org/7504.
+  check_includes = false
+  sources = [
+    "peerconnectioninterface.h",
+  ]
+}
+
+rtc_source_set("mediastream_interface_and_implicit_video_frame_api") {
+  # The mediastreaminterface.h file pulls in in video_frame.h, but the
+  # system_wrappers dependency that comes with that breaks pnacl downstream.
+  # TODO(phoglund): solve this (see bugs.webrtc.org/7504).
+  check_includes = false
+  sources = [
+    "mediastreaminterface.h",
+  ]
+}
+
+rtc_source_set("libjingle_api_deprecated_headers") {
+  # We need to include headers from undeclared targets here, since they cause
+  # circular dependencies. These deprecated headers are going away anyway.
+  # See http://bugs.webrtc.org/5883.
+  check_includes = false
+  sources = [
+    "datachannel.h",
+    "mediastream.h",
+    "mediastreamtrack.h",
+    "rtpsender.h",
+    "streamcollection.h",
+    "videotracksource.h",
+    "webrtcsdp.h",
+  ]
+}
+
 rtc_source_set("ortc_api") {
   check_includes = false  # TODO(deadbeef): Remove (bugs.webrtc.org/6828)
   sources = [