Revert "Delete deprecated SetMediaEngineDefaults"

This reverts commit 1682a7f41135d9529917c0f8e5b6a57fbb47220a.

Reason for revert: Breaks chromium import: https://chromium-review.googlesource.com/c/chromium/src/+/5083877?tab=checks

Original change's description:
> Delete deprecated SetMediaEngineDefaults
>
> Bug: webrtc:15574
> Change-Id: Ie60973e020ca91ca93ca46159d53d4a89d1757fe
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/326004
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#41304}

Bug: webrtc:15574
Change-Id: Id09c8e1682831032e84a83187c6905a84e68d736
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/329842
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Owners-Override: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41312}
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 295a748..3f18a79 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -576,6 +576,33 @@
   }
 }
 
+# Heavy but optional helper for unittests and webrtc users who prefer to use
+# defaults factories or do not worry about extra dependencies and binary size.
+rtc_library("rtc_media_engine_defaults") {
+  visibility = [ "*" ]
+  allow_poison = [
+    "audio_codecs",
+    "environment_construction",
+    "software_video_codecs",
+  ]
+  sources = [
+    "engine/webrtc_media_engine_defaults.cc",
+    "engine/webrtc_media_engine_defaults.h",
+  ]
+  deps = [
+    ":rtc_audio_video",
+    "../api/audio_codecs:builtin_audio_decoder_factory",
+    "../api/audio_codecs:builtin_audio_encoder_factory",
+    "../api/task_queue:default_task_queue_factory",
+    "../api/video:builtin_video_bitrate_allocator_factory",
+    "../api/video_codecs:builtin_video_decoder_factory",
+    "../api/video_codecs:builtin_video_encoder_factory",
+    "../modules/audio_processing:api",
+    "../rtc_base:checks",
+    "../rtc_base/system:rtc_export",
+  ]
+}
+
 rtc_source_set("rtc_data_sctp_transport_internal") {
   sources = [ "sctp/sctp_transport_internal.h" ]
   deps = [
@@ -778,6 +805,7 @@
         ":rtc_internal_video_codecs",
         ":rtc_media",
         ":rtc_media_base",
+        ":rtc_media_engine_defaults",
         ":rtc_media_tests_utils",
         ":rtc_sdp_video_format_utils",
         ":rtc_simulcast_encoder_adapter",
diff --git a/media/engine/webrtc_media_engine_defaults.cc b/media/engine/webrtc_media_engine_defaults.cc
new file mode 100644
index 0000000..fed6466
--- /dev/null
+++ b/media/engine/webrtc_media_engine_defaults.cc
@@ -0,0 +1,43 @@
+/*
+ *  Copyright (c) 2019 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 "media/engine/webrtc_media_engine_defaults.h"
+
+#include "api/audio_codecs/builtin_audio_decoder_factory.h"
+#include "api/audio_codecs/builtin_audio_encoder_factory.h"
+#include "api/task_queue/default_task_queue_factory.h"
+#include "api/video/builtin_video_bitrate_allocator_factory.h"
+#include "api/video_codecs/builtin_video_decoder_factory.h"
+#include "api/video_codecs/builtin_video_encoder_factory.h"
+#include "modules/audio_processing/include/audio_processing.h"
+#include "rtc_base/checks.h"
+
+namespace webrtc {
+
+void DeprecatedSetMediaEngineDefaults(cricket::MediaEngineDependencies* deps) {
+  RTC_DCHECK(deps);
+  if (deps->task_queue_factory == nullptr) {
+    static TaskQueueFactory* const task_queue_factory =
+        CreateDefaultTaskQueueFactory().release();
+    deps->task_queue_factory = task_queue_factory;
+  }
+  if (deps->audio_encoder_factory == nullptr)
+    deps->audio_encoder_factory = CreateBuiltinAudioEncoderFactory();
+  if (deps->audio_decoder_factory == nullptr)
+    deps->audio_decoder_factory = CreateBuiltinAudioDecoderFactory();
+  if (deps->audio_processing == nullptr)
+    deps->audio_processing = AudioProcessingBuilder().Create();
+
+  if (deps->video_encoder_factory == nullptr)
+    deps->video_encoder_factory = CreateBuiltinVideoEncoderFactory();
+  if (deps->video_decoder_factory == nullptr)
+    deps->video_decoder_factory = CreateBuiltinVideoDecoderFactory();
+}
+
+}  // namespace webrtc
diff --git a/media/engine/webrtc_media_engine_defaults.h b/media/engine/webrtc_media_engine_defaults.h
new file mode 100644
index 0000000..a0ed059
--- /dev/null
+++ b/media/engine/webrtc_media_engine_defaults.h
@@ -0,0 +1,30 @@
+/*
+ *  Copyright (c) 2019 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 MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_DEFAULTS_H_
+#define MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_DEFAULTS_H_
+
+#include "media/engine/webrtc_media_engine.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// Sets required but null dependencies with default factories.
+// Deprecated in favor of EnableMediaWithDefaults.
+RTC_EXPORT void DeprecatedSetMediaEngineDefaults(
+    cricket::MediaEngineDependencies* deps);
+[[deprecated("bugs.webrc.org/15574")]] inline void SetMediaEngineDefaults(
+    cricket::MediaEngineDependencies* deps) {
+  DeprecatedSetMediaEngineDefaults(deps);
+}
+
+}  // namespace webrtc
+
+#endif  // MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_DEFAULTS_H_
diff --git a/media/engine/webrtc_media_engine_unittest.cc b/media/engine/webrtc_media_engine_unittest.cc
index 40cad75..b89c98fe 100644
--- a/media/engine/webrtc_media_engine_unittest.cc
+++ b/media/engine/webrtc_media_engine_unittest.cc
@@ -14,6 +14,7 @@
 #include <string>
 #include <utility>
 
+#include "media/engine/webrtc_media_engine_defaults.h"
 #include "test/gtest.h"
 #include "test/scoped_key_value_config.h"
 
@@ -321,4 +322,20 @@
   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);
+  webrtc::test::ScopedKeyValueConfig trials;
+  deps.trials = &trials;
+
+  std::unique_ptr<MediaEngineInterface> engine =
+      CreateMediaEngine(std::move(deps));
+
+  EXPECT_TRUE(engine);
+}
+#pragma clang diagnostic pop
+
 }  // namespace cricket
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index e9549cd..e4cff6a 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -2479,6 +2479,7 @@
       "../media:rid_description",
       "../media:rtc_data_sctp_transport_internal",
       "../media:rtc_media_config",
+      "../media:rtc_media_engine_defaults",
       "../media:stream_params",
       "../modules/audio_device:audio_device_api",
       "../modules/audio_processing:audio_processing_statistics",