Deprecate call_factory and media_engine in PeerConnectionFactoryDependencies

Bug: webrtc:15574
Change-Id: Ia97ad0853196fea5c20fc0c0d58a9305b72c515b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/326001
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41088}
diff --git a/api/call/call_factory_interface.h b/api/call/call_factory_interface.h
index 1c12352..db53d72 100644
--- a/api/call/call_factory_interface.h
+++ b/api/call/call_factory_interface.h
@@ -34,7 +34,9 @@
   virtual std::unique_ptr<Call> CreateCall(const CallConfig& config) = 0;
 };
 
-RTC_EXPORT std::unique_ptr<CallFactoryInterface> CreateCallFactory();
+[[deprecated("bugs.webrtc.org/15574")]]  //
+RTC_EXPORT std::unique_ptr<CallFactoryInterface>
+CreateCallFactory();
 
 }  // namespace webrtc
 
diff --git a/api/peer_connection_interface.cc b/api/peer_connection_interface.cc
index dedfd35..33d9755 100644
--- a/api/peer_connection_interface.cc
+++ b/api/peer_connection_interface.cc
@@ -60,8 +60,13 @@
 PeerConnectionFactoryDependencies::PeerConnectionFactoryDependencies() =
     default;
 
+// TODO(bugs.webrtc.org/15574): Remove pragma once call_factory and media_engine
+// are removed from PeerConnectionFactoryDependencies
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
 PeerConnectionFactoryDependencies::PeerConnectionFactoryDependencies(
     PeerConnectionFactoryDependencies&&) = default;
+#pragma clang diagnostic pop
 
 PeerConnectionFactoryDependencies::~PeerConnectionFactoryDependencies() =
     default;
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index fed5474..8977137 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -1432,10 +1432,10 @@
   // called without a `port_allocator`.
   std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory;
   std::unique_ptr<TaskQueueFactory> task_queue_factory;
-  // TODO(bugs.webrtc.org/15574): Deprecate `media_engine` and `call_factory`
-  // when chromium and webrtc are updated to use `media_factory` instead.
-  std::unique_ptr<cricket::MediaEngineInterface> media_engine;
-  std::unique_ptr<CallFactoryInterface> call_factory;
+  // TODO(bugs.webrtc.org/15574): Delete `media_engine` and `call_factory`
+  // after 2023-12-01
+  [[deprecated]] std::unique_ptr<cricket::MediaEngineInterface> media_engine;
+  [[deprecated]] std::unique_ptr<CallFactoryInterface> call_factory;
   std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory;
   std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
   std::unique_ptr<NetworkStatePredictorFactoryInterface>
diff --git a/media/engine/webrtc_media_engine.h b/media/engine/webrtc_media_engine.h
index fa4046b..0dee7ae 100644
--- a/media/engine/webrtc_media_engine.h
+++ b/media/engine/webrtc_media_engine.h
@@ -63,10 +63,9 @@
 // CreateMediaEngine may be called on any thread, though the engine is
 // only expected to be used on one thread, internally called the "worker
 // thread". This is the thread Init must be called on.
-// TODO(bugs.webrtc.org/15574): Deprecate this helper in favor of creating
-// media engine with `PeerConnectionFactoryDependencies::media_factory`.
-RTC_EXPORT std::unique_ptr<MediaEngineInterface> CreateMediaEngine(
-    MediaEngineDependencies dependencies);
+[[deprecated("bugs.webrtc.org/15574")]]  //
+RTC_EXPORT std::unique_ptr<MediaEngineInterface>
+CreateMediaEngine(MediaEngineDependencies dependencies);
 
 // Verify that extension IDs are within 1-byte extension range and are not
 // overlapping, and that they form a legal change from previously registerd
diff --git a/media/engine/webrtc_media_engine_unittest.cc b/media/engine/webrtc_media_engine_unittest.cc
index 738ce45..b89c98fe 100644
--- a/media/engine/webrtc_media_engine_unittest.cc
+++ b/media/engine/webrtc_media_engine_unittest.cc
@@ -322,6 +322,9 @@
   EXPECT_EQ(RtpExtension::kTimestampOffsetUri, filtered[0].uri);
 }
 
+// Deprecated as part of the bugs.webrtc.org/15574 effort.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
 TEST(WebRtcMediaEngineTest, Create) {
   MediaEngineDependencies deps;
   webrtc::DeprecatedSetMediaEngineDefaults(&deps);
@@ -333,5 +336,6 @@
 
   EXPECT_TRUE(engine);
 }
+#pragma clang diagnostic pop
 
 }  // namespace cricket
diff --git a/pc/connection_context.cc b/pc/connection_context.cc
index 1347008..09d4b4a 100644
--- a/pc/connection_context.cc
+++ b/pc/connection_context.cc
@@ -79,12 +79,17 @@
 // Static
 rtc::scoped_refptr<ConnectionContext> ConnectionContext::Create(
     PeerConnectionFactoryDependencies* dependencies) {
+// TODO(bugs.webrtc.org/15574): Remove when call_factory and media_engine
+// are removed from PeerConnectionFactoryDependencies
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
   if (dependencies->media_factory != nullptr) {
     RTC_CHECK(dependencies->media_engine == nullptr)
         << "media_factory replaces media_engine. Do not set media_engine.";
     RTC_CHECK(dependencies->call_factory == nullptr)
         << "media_factory replaces call_factory. Do not set call_factory.";
   }
+#pragma clang diagnostic pop
 
   return rtc::scoped_refptr<ConnectionContext>(
       new ConnectionContext(dependencies));
@@ -109,13 +114,19 @@
       media_engine_(
           dependencies->media_factory != nullptr
               ? dependencies->media_factory->CreateMediaEngine(*dependencies)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
               : std::move(dependencies->media_engine)),
+#pragma clang diagnostic pop
       network_monitor_factory_(
           std::move(dependencies->network_monitor_factory)),
       default_network_manager_(std::move(dependencies->network_manager)),
       call_factory_(dependencies->media_factory != nullptr
                         ? std::move(dependencies->media_factory)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
                         : std::move(dependencies->call_factory)),
+#pragma clang diagnostic pop
       default_socket_factory_(std::move(dependencies->packet_socket_factory)),
       sctp_factory_(
           MaybeCreateSctpFactory(std::move(dependencies->sctp_factory),