Revert "Remove CreateModularPeerConnectionFactory from peer_connection_interface.h"

This reverts commit a680f2910081769e299614a18695a85e3df3af2d.

Reason for revert: missed some downstream usage

Bug: webrtc:42220069
Original change's description:
> Remove CreateModularPeerConnectionFactory from peer_connection_interface.h
>
> build target with peer_connection_interface.h doesn't have definition
> of that symbols, which is confusing.
>
> Users are updated to depend on create_modular_peer_connection_factory
> instead that does include the definition.
>
> Bug: webrtc:42220069
> Change-Id: I881c0ceb71afe2fec70dbe68b2392e42d9ad6cbd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/400520
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#45418}

Bug: webrtc:42220069
Change-Id: Ia3cf6169a6140ad849af724343b78ecec5ee1229
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/406061
Owners-Override: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45419}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index fa772e5..5b25a93 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -70,20 +70,14 @@
   ]
 }
 
-rtc_library("create_modular_peer_connection_factory") {
+rtc_source_set("create_modular_peer_connection_factory") {
   visibility = [ "*" ]
   allow_poison = [ "environment_construction" ]
-  sources = [
-    "create_modular_peer_connection_factory.cc",
-    "create_modular_peer_connection_factory.h",
-  ]
+  sources = [ "create_modular_peer_connection_factory.h" ]
   deps = [
     ":libjingle_peerconnection_api",
     ":scoped_refptr",
-    ":sequence_checker",
     "../pc:peer_connection_factory",
-    "../pc:peer_connection_factory_proxy",
-    "../rtc_base:threading",
     "../rtc_base/system:rtc_export",
     "../stats:rtc_stats",
   ]
@@ -295,6 +289,17 @@
   ]
 }
 
+# TODO: bugs.webrtc.org/42220069 - Remove when downstream has been updated
+# to depend on `create_modular_peer_connection_factory` instead.
+rtc_source_set("create_modular_peer_connection_factory_internal") {
+  visibility = [ ":libjingle_peerconnection_api" ]
+  sources = [ "create_modular_peer_connection_factory_internal.h" ]
+  deps = [
+    ":scoped_refptr",
+    "../rtc_base/system:rtc_export",
+  ]
+}
+
 rtc_library("libjingle_peerconnection_api") {
   visibility = [ "*" ]
   cflags = []
@@ -335,6 +340,7 @@
     ":async_dns_resolver",
     ":audio_options_api",
     ":candidate",
+    ":create_modular_peer_connection_factory_internal",
     ":data_channel_event_observer_interface",
     ":dtls_transport_interface",
     ":fec_controller_api",
diff --git a/api/create_modular_peer_connection_factory.cc b/api/create_modular_peer_connection_factory.cc
deleted file mode 100644
index 1b43eae..0000000
--- a/api/create_modular_peer_connection_factory.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *  Copyright 2025 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.
- */
-
-#include "api/create_modular_peer_connection_factory.h"
-
-#include <utility>
-
-#include "api/peer_connection_interface.h"
-#include "api/scoped_refptr.h"
-#include "api/sequence_checker.h"
-#include "pc/peer_connection_factory.h"
-#include "pc/peer_connection_factory_proxy.h"
-#include "rtc_base/thread.h"
-
-namespace webrtc {
-
-scoped_refptr<PeerConnectionFactoryInterface>
-CreateModularPeerConnectionFactory(
-    PeerConnectionFactoryDependencies dependencies) {
-  // The PeerConnectionFactory must be created on the signaling thread.
-  if (dependencies.signaling_thread &&
-      !dependencies.signaling_thread->IsCurrent()) {
-    return dependencies.signaling_thread->BlockingCall([&dependencies] {
-      return CreateModularPeerConnectionFactory(std::move(dependencies));
-    });
-  }
-
-  auto pc_factory = PeerConnectionFactory::Create(std::move(dependencies));
-  if (!pc_factory) {
-    return nullptr;
-  }
-  // Verify that the invocation and the initialization ended up agreeing on the
-  // thread.
-  RTC_DCHECK_RUN_ON(pc_factory->signaling_thread());
-  return PeerConnectionFactoryProxy::Create(
-      pc_factory->signaling_thread(), pc_factory->worker_thread(), pc_factory);
-}
-
-}  // namespace webrtc
diff --git a/api/create_modular_peer_connection_factory_internal.h b/api/create_modular_peer_connection_factory_internal.h
new file mode 100644
index 0000000..370c148
--- /dev/null
+++ b/api/create_modular_peer_connection_factory_internal.h
@@ -0,0 +1,39 @@
+/*
+ *  Copyright 2025 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.
+ */
+
+// This temporary header is here to steer users of the
+// CreateModularPeerConnectionFactory to include
+// `create_modular_peer_connection_factory.h` and thus depend on
+// `create_modular_peer_connection_factory` build target. Once users are
+// migrated this file can be deleted.
+
+// IWYU pragma: private, include "api/create_modular_peer_connection_factory.h"
+
+#ifndef API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_
+#define API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_
+
+#include "api/scoped_refptr.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// Forward declare to avoid circular dependencies with
+// `api/peer_connection_interface.h`. This file exists to be included from that
+// header, and same time requires classes defined in that header.
+class PeerConnectionFactoryInterface;
+struct PeerConnectionFactoryDependencies;
+
+RTC_EXPORT scoped_refptr<PeerConnectionFactoryInterface>
+CreateModularPeerConnectionFactory(
+    PeerConnectionFactoryDependencies dependencies);
+
+}  // namespace webrtc
+
+#endif  // API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index d80f545..032320a 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -148,6 +148,10 @@
 #include "rtc_base/system/rtc_export.h"
 #include "rtc_base/thread.h"
 
+// TODO: bugs.webrtc.org/42220069 - Remove this include when users of this
+// function include "create_modular_peer_connection_factory.h" instead.
+#include "api/create_modular_peer_connection_factory_internal.h"  // IWYU pragma: keep
+
 namespace webrtc {
 // IWYU pragma: begin_keep
 // MediaFactory class definition is not part of the api.
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index a197ff8..f48ba6e 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -476,7 +476,7 @@
 }
 
 rtc_source_set("peer_connection_factory_proxy") {
-  visibility = [ "../api:create_modular_peer_connection_factory" ]
+  visibility = [ ":*" ]
   sources = [ "peer_connection_factory_proxy.h" ]
   deps = [
     ":proxy",
@@ -1550,6 +1550,7 @@
     ":media_stream_proxy",
     ":media_stream_track_proxy",
     ":peer_connection",
+    ":peer_connection_factory_proxy",
     ":peer_connection_proxy",
     ":rtp_parameters_conversion",
     ":video_track",
@@ -2439,6 +2440,7 @@
       ":pc_test_utils",
       ":peer_connection",
       ":peer_connection_factory",
+      ":peer_connection_factory_proxy",
       ":peer_connection_internal",
       ":peer_connection_proxy",
       ":peerconnection_wrapper",
diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc
index df3a417..39038d5 100644
--- a/pc/peer_connection_factory.cc
+++ b/pc/peer_connection_factory.cc
@@ -54,6 +54,7 @@
 #include "pc/media_stream_proxy.h"
 #include "pc/media_stream_track_proxy.h"
 #include "pc/peer_connection.h"
+#include "pc/peer_connection_factory_proxy.h"
 #include "pc/peer_connection_proxy.h"
 #include "pc/rtp_parameters_conversion.h"
 #include "pc/video_track.h"
@@ -85,6 +86,31 @@
 
 }  // namespace
 
+// TODO: bugs.webrtc.org/42220069 - Move this function to
+// 'create_modular_peer_connection_factory' build target when all users of this
+// function would depend on that build target.
+scoped_refptr<PeerConnectionFactoryInterface>
+CreateModularPeerConnectionFactory(
+    PeerConnectionFactoryDependencies dependencies) {
+  // The PeerConnectionFactory must be created on the signaling thread.
+  if (dependencies.signaling_thread &&
+      !dependencies.signaling_thread->IsCurrent()) {
+    return dependencies.signaling_thread->BlockingCall([&dependencies] {
+      return CreateModularPeerConnectionFactory(std::move(dependencies));
+    });
+  }
+
+  auto pc_factory = PeerConnectionFactory::Create(std::move(dependencies));
+  if (!pc_factory) {
+    return nullptr;
+  }
+  // Verify that the invocation and the initialization ended up agreeing on the
+  // thread.
+  RTC_DCHECK_RUN_ON(pc_factory->signaling_thread());
+  return PeerConnectionFactoryProxy::Create(
+      pc_factory->signaling_thread(), pc_factory->worker_thread(), pc_factory);
+}
+
 // Static
 scoped_refptr<PeerConnectionFactory> PeerConnectionFactory::Create(
     PeerConnectionFactoryDependencies dependencies) {