Rename Call::Config to CallConfig, keep old name as alias.

We want api/peerconnectioninterface.h (and corresponding build target)
to not depend on call.h, and generally we treat Call as an internal,
non-api, class. But we need CallFactoryInterface in the api in order to
enable use of PeerConnection with or without support for media.

Making CallConfig a top-level class makes it possible to forward declare
it, together with Call, for use in callfactoryinterface.h and
peerconnectioninterface.h.

Delete the peerconnection_and_implicit_call_api target, replaced by
new target callfactory_api, to link between Call and Peerconnection.

Bug: webrtc:7504
Change-Id: I5e3978ef89bcd6705e94536f8676bcf89fc82fe1
Reviewed-on: https://webrtc-review.googlesource.com/46201
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22020}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 3952cab..fcd3497 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -37,6 +37,13 @@
   ]
 }
 
+rtc_source_set("callfactory_api") {
+  visibility = [ "*" ]
+  sources = [
+    "call/callfactoryinterface.h",
+  ]
+}
+
 rtc_static_library("libjingle_peerconnection_api") {
   visibility = [ "*" ]
   cflags = []
@@ -60,6 +67,7 @@
     "mediatypes.h",
     "notifier.h",
     "peerconnectionfactoryproxy.h",
+    "peerconnectioninterface.h",
     "peerconnectionproxy.h",
     "proxy.cc",
     "proxy.h",
@@ -94,8 +102,9 @@
     ":array_view",
     ":audio_mixer_api",
     ":audio_options_api",
+    ":callfactory_api",
+    ":libjingle_logging_api",
     ":optional",
-    ":peerconnection_and_implicit_call_api",
     ":rtc_stats_api",
     ":video_frame_api",
     "audio_codecs:audio_codecs_api",
@@ -105,6 +114,7 @@
     # file, really. All these should arguably go away in time.
     "..:typedefs",
     "..:webrtc_common",
+    "../logging:rtc_event_log_api",
     "../media:rtc_media_config",
     "../modules/audio_processing:audio_processing_statistics",
     "../rtc_base:checks",
@@ -113,24 +123,17 @@
     "../rtc_base:rtc_base_approved",
     "../rtc_base:stringutils",
   ]
+
   if (is_nacl) {
     # This is needed by .h files included from rtc_base.
     deps += [ "//native_client_sdk/src/libraries/nacl_io" ]
   }
 }
 
+# TODO(bugs.webrtc.org/7504): Dummy target, kept temporarily because
+# chromium edpends on it.
 rtc_source_set("peerconnection_and_implicit_call_api") {
   visibility = [ "*" ]
-
-  # 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/8667.
-  check_includes = false
-  sources = [
-    "peerconnectioninterface.h",
-  ]
 }
 
 rtc_source_set("libjingle_logging_api") {
@@ -375,7 +378,6 @@
       "fakemetricsobserver.h",
     ]
     deps = [
-      "../api:peerconnection_and_implicit_call_api",
       "../media:rtc_media_base",
       "../rtc_base:checks",
       "../rtc_base:rtc_base_approved",
diff --git a/api/DEPS b/api/DEPS
index 01a3e73..9ba7245 100644
--- a/api/DEPS
+++ b/api/DEPS
@@ -4,6 +4,7 @@
   "+media",
   "+p2p",
   "+pc",
+  "+logging/rtc_event_log/rtc_event_log_factory_interface.h",
 ]
 
 specific_include_rules = {
diff --git a/api/call/callfactoryinterface.h b/api/call/callfactoryinterface.h
new file mode 100644
index 0000000..a7f3245
--- /dev/null
+++ b/api/call/callfactoryinterface.h
@@ -0,0 +1,36 @@
+/*
+ *  Copyright 2017 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.
+ */
+
+#ifndef API_CALL_CALLFACTORYINTERFACE_H_
+#define API_CALL_CALLFACTORYINTERFACE_H_
+
+#include <memory>
+
+namespace webrtc {
+
+// These classes are not part of the API, and are treated as opaque pointers.
+class Call;
+struct CallConfig;
+
+// This interface exists to allow webrtc to be optionally built without media
+// support (i.e., if only being used for data channels). PeerConnectionFactory
+// is constructed with a CallFactoryInterface, which may or may not be null.
+class CallFactoryInterface {
+ public:
+  virtual ~CallFactoryInterface() {}
+
+  virtual Call* CreateCall(const CallConfig& config) = 0;
+};
+
+std::unique_ptr<CallFactoryInterface> CreateCallFactory();
+
+}  // namespace webrtc
+
+#endif  // API_CALL_CALLFACTORYINTERFACE_H_
diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h
index 22514ac..8b4db9a 100644
--- a/api/peerconnectioninterface.h
+++ b/api/peerconnectioninterface.h
@@ -80,6 +80,7 @@
 #include "api/audio_codecs/audio_decoder_factory.h"
 #include "api/audio_codecs/audio_encoder_factory.h"
 #include "api/audio_options.h"
+#include "api/call/callfactoryinterface.h"
 #include "api/datachannelinterface.h"
 #include "api/dtmfsenderinterface.h"
 #include "api/jsep.h"
@@ -94,12 +95,19 @@
 #include "api/statstypes.h"
 #include "api/turncustomizer.h"
 #include "api/umametrics.h"
-#include "call/callfactoryinterface.h"
 #include "logging/rtc_event_log/rtc_event_log_factory_interface.h"
 #include "media/base/mediaconfig.h"
-#include "media/base/videocapturer.h"
-#include "p2p/base/portallocator.h"
+// TODO(bugs.webrtc.org/6353): cricket::VideoCapturer is deprecated and should
+// be deleted from the PeerConnection api.
+#include "media/base/videocapturer.h"  // nogncheck
+// TODO(bugs.webrtc.org/7447): We plan to provide a way to let applications
+// inject a PacketSocketFactory and/or NetworkManager, and not expose
+// PortAllocator in the PeerConnection api.
+#include "p2p/base/portallocator.h"  // nogncheck
+// TODO(nisse): The interface for bitrate allocation strategy belongs in api/.
+#include "rtc_base/bitrateallocationstrategy.h"
 #include "rtc_base/network.h"
+#include "rtc_base/platform_file.h"
 #include "rtc_base/rtccertificate.h"
 #include "rtc_base/rtccertificategenerator.h"
 #include "rtc_base/socketaddress.h"
@@ -119,7 +127,7 @@
 namespace webrtc {
 class AudioDeviceModule;
 class AudioMixer;
-class CallFactoryInterface;
+class AudioProcessing;
 class MediaConstraintsInterface;
 class VideoDecoderFactory;
 class VideoEncoderFactory;