Reland "Make cricket::SctpTransportInternalFactory injectable through PeerConnectionFactory Deps"

This is to allow testing without using the singleton sctp library.
cricket::SctpTransportInternalFactory is renamed to webrtc::SctpTransportFactoryInterface and moved to the API folder to follow the API structure.
Tests can use test/pc/sctp/fake_sctp_transport.h to inject a faked data channel implementation.

patch 1 contain the original cl.
patch 2 modifications

Bug: none
Change-Id: Ic088da3eb7d9aada79e6d601dbf2d1aa2be777f6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/182840
Reviewed-by: Taylor <deadbeef@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32024}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index db0723d..50a9c5a 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -185,6 +185,7 @@
     "transport:bitrate_settings",
     "transport:enums",
     "transport:network_control",
+    "transport:sctp_transport_factory_interface",
     "transport:webrtc_key_value_config",
     "transport/rtp:rtp_source",
     "units:data_rate",
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index 3ada740..6cf6dbb 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -105,6 +105,7 @@
 #include "api/transport/bitrate_settings.h"
 #include "api/transport/enums.h"
 #include "api/transport/network_control.h"
+#include "api/transport/sctp_transport_factory_interface.h"
 #include "api/transport/webrtc_key_value_config.h"
 #include "api/turn_customizer.h"
 #include "media/base/media_config.h"
@@ -1363,6 +1364,7 @@
   // used.
   std::unique_ptr<rtc::NetworkMonitorFactory> network_monitor_factory;
   std::unique_ptr<NetEqFactory> neteq_factory;
+  std::unique_ptr<SctpTransportFactoryInterface> sctp_factory;
   std::unique_ptr<WebRtcKeyValueConfig> trials;
 };
 
diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn
index a4ada07..d2da445 100644
--- a/api/transport/BUILD.gn
+++ b/api/transport/BUILD.gn
@@ -93,6 +93,11 @@
   ]
 }
 
+rtc_source_set("sctp_transport_factory_interface") {
+  visibility = [ "*" ]
+  sources = [ "sctp_transport_factory_interface.h" ]
+}
+
 rtc_source_set("stun_types") {
   visibility = [ "*" ]
   sources = [
diff --git a/api/transport/sctp_transport_factory_interface.h b/api/transport/sctp_transport_factory_interface.h
new file mode 100644
index 0000000..912be3a
--- /dev/null
+++ b/api/transport/sctp_transport_factory_interface.h
@@ -0,0 +1,42 @@
+/*
+ *  Copyright 2020 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_TRANSPORT_SCTP_TRANSPORT_FACTORY_INTERFACE_H_
+#define API_TRANSPORT_SCTP_TRANSPORT_FACTORY_INTERFACE_H_
+
+#include <memory>
+
+// These classes are not part of the API, and are treated as opaque pointers.
+namespace cricket {
+class SctpTransportInternal;
+}  // namespace cricket
+
+namespace rtc {
+class PacketTransportInternal;
+}  // namespace rtc
+
+namespace webrtc {
+
+// Factory class which can be used to allow fake SctpTransports to be injected
+// for testing. An application is not intended to implement this interface nor
+// 'cricket::SctpTransportInternal' because SctpTransportInternal is not
+// guaranteed to remain stable in future WebRTC versions.
+class SctpTransportFactoryInterface {
+ public:
+  virtual ~SctpTransportFactoryInterface() = default;
+
+  // Create an SCTP transport using |channel| for the underlying transport.
+  virtual std::unique_ptr<cricket::SctpTransportInternal> CreateSctpTransport(
+      rtc::PacketTransportInternal* channel) = 0;
+};
+
+}  // namespace webrtc
+
+#endif  // API_TRANSPORT_SCTP_TRANSPORT_FACTORY_INTERFACE_H_