Continue breakup of media/rtc_media_base

Left in target are just .cc files with .h files used externally.

Bug: webrtc:14775
Change-Id: I264f69bb29147fc0f8db877e3def8b21ed42181d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/341420
Reviewed-by: Jeremy Leconte <jleconte@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41835}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index bee98fe..cf86d54 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -335,6 +335,7 @@
     ":sequence_checker",
     ":turn_customizer",
     "../call:rtp_interfaces",
+    "../media:media_engine",
     "../p2p:connection",
     "../p2p:port_allocator",
     "../p2p:rtc_p2p",
diff --git a/media/BUILD.gn b/media/BUILD.gn
index ab1999a..1b470c6 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -52,6 +52,16 @@
   visibility = [ "*" ]
   defines = []
   libs = []
+  sources = [
+    "base/adapted_video_track_source.cc",
+    "base/adapted_video_track_source.h",  # Used downstream
+    "base/video_adapter.cc",
+    "base/video_adapter.h",  # Used once downstream
+    "base/video_broadcaster.cc",
+    "base/video_broadcaster.h",  # Used downstream
+    "base/video_common.cc",
+    "base/video_common.h",  # Used downstream
+  ]
   deps = [
     ":codec",
     ":media_channel",
@@ -60,6 +70,7 @@
     ":rtc_media_config",
     ":rtp_utils",
     ":stream_params",
+    ":video_source_base",
     "../api:array_view",
     "../api:audio_options_api",
     "../api:call_api",
@@ -127,21 +138,50 @@
     "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/types:optional",
   ]
+}
+
+rtc_source_set("audio_source") {
+  sources = [ "base/audio_source.h" ]
+  absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
+}
+
+rtc_library("video_source_base") {
   sources = [
-    "base/adapted_video_track_source.cc",
-    "base/adapted_video_track_source.h",
-    "base/audio_source.h",
-    "base/media_engine.cc",
-    "base/media_engine.h",
-    "base/video_adapter.cc",
-    "base/video_adapter.h",
-    "base/video_broadcaster.cc",
-    "base/video_broadcaster.h",
-    "base/video_common.cc",
-    "base/video_common.h",
     "base/video_source_base.cc",
     "base/video_source_base.h",
   ]
+  deps = [
+    "../api:sequence_checker",
+    "../api/video:video_frame",
+    "../rtc_base:checks",
+    "../rtc_base/system:no_unique_address",
+  ]
+  absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ]
+}
+
+rtc_library("media_engine") {
+  sources = [
+    "base/media_engine.cc",
+    "base/media_engine.h",
+  ]
+  deps = [
+    ":codec",
+    ":media_channel",
+    ":media_channel_impl",
+    ":rtc_media_base",
+    ":rtc_media_config",
+    "../api:field_trials_view",
+    "../api:rtp_parameters",
+    "../api/audio_codecs:audio_codecs_api",
+    "../api/crypto:options",
+    "../api/video:video_bitrate_allocation",
+    "../api/video:video_bitrate_allocator_factory",
+    "../call:call_interfaces",
+    "../rtc_base:checks",
+    "../rtc_base:stringutils",
+    "../rtc_base/system:file_wrapper",
+  ]
+  absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ]
 }
 
 rtc_library("media_channel_impl") {
@@ -434,10 +474,12 @@
   defines = []
   libs = []
   deps = [
+    ":audio_source",
     ":codec",
     ":media_channel",
     ":media_channel_impl",
     ":media_constants",
+    ":media_engine",
     ":rid_description",
     ":rtc_media_base",
     ":rtc_media_config",
@@ -671,10 +713,12 @@
 
     defines = []
     deps = [
+      ":audio_source",
       ":codec",
       ":media_channel",
       ":media_channel_impl",
       ":media_constants",
+      ":media_engine",
       ":rtc_audio_video",
       ":rtc_internal_video_codecs",
       ":rtc_media",
@@ -777,6 +821,7 @@
         ":codec",
         ":media_channel",
         ":media_constants",
+        ":media_engine",
         ":rtc_audio_video",
         ":rtc_internal_video_codecs",
         ":rtc_media",
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 9ff92b4..c684c2f 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -342,6 +342,7 @@
   deps = [
     "../api/environment",
     "../call:call_interfaces",
+    "../media:media_engine",
     "../media:rtc_media_base",
   ]
 }
@@ -366,6 +367,7 @@
     "../api/crypto:options",
     "../media:codec",
     "../media:media_constants",
+    "../media:media_engine",
     "../media:rid_description",
     "../media:rtc_data_sctp_transport_internal",
     "../media:rtc_media_base",
@@ -797,6 +799,7 @@
   ]
   deps = [
     "../api:libjingle_peerconnection_api",
+    "../media:media_engine",
     "../media:rtc_media_base",
     "../rtc_base:checks",
   ]
@@ -818,6 +821,7 @@
     "../api/environment",
     "../api/neteq:neteq_api",
     "../api/transport:sctp_transport_factory_interface",
+    "../media:media_engine",
     "../media:rtc_data_sctp_transport_factory",
     "../media:rtc_media_base",
     "../p2p:basic_packet_socket_factory",
@@ -1137,6 +1141,7 @@
     "../api/video:video_codec_constants",
     "../call:call_interfaces",
     "../media:media_channel",
+    "../media:media_engine",
     "../media:rid_description",
     "../media:rtc_media_base",
     "../media:rtc_media_config",
@@ -1459,6 +1464,7 @@
     "../call:call_interfaces",
     "../call:rtp_interfaces",
     "../call:rtp_sender",
+    "../media:media_engine",
     "../media:rtc_media_base",
     "../p2p:basic_packet_socket_factory",
     "../p2p:basic_port_allocator",
@@ -1555,6 +1561,7 @@
     "../media:media_channel",
     "../media:media_channel_impl",
     "../media:media_constants",
+    "../media:media_engine",
     "../media:rtc_media_base",
     "../media:rtc_media_config",
     "../rtc_base:checks",
@@ -1788,6 +1795,7 @@
     "../api:sequence_checker",
     "../api/video:video_frame",
     "../media:rtc_media_base",
+    "../media:video_source_base",
     "../rtc_base:checks",
     "../rtc_base:macromagic",
     "../rtc_base:threading",
@@ -1870,7 +1878,9 @@
     "../api:scoped_refptr",
     "../api:sequence_checker",
     "../api/crypto:frame_encryptor_interface",
+    "../media:audio_source",
     "../media:media_channel",
+    "../media:media_engine",
     "../media:rtc_media_base",
     "../rtc_base:checks",
     "../rtc_base:event_tracer",
@@ -2419,6 +2429,7 @@
       "../media:codec",
       "../media:media_channel",
       "../media:media_constants",
+      "../media:media_engine",
       "../media:rid_description",
       "../media:rtc_data_sctp_transport_internal",
       "../media:rtc_media_config",
@@ -2637,6 +2648,7 @@
       "../call:call_interfaces",
       "../call/adaptation:resource_adaptation_test_utilities",
       "../logging:fake_rtc_event_log",
+      "../media:media_engine",
       "../media:rtc_media_base",
       "../media:rtc_media_config",
       "../media:rtc_media_tests_utils",
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index 89a78b5..61af49f 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -1650,6 +1650,7 @@
       "../../api/video:video_frame",
       "../../api/video:video_rtp_headers",
       "../../media:media_constants",
+      "../../media:media_engine",
       "../../media:rtc_audio_video",
       "../../media:rtc_internal_video_codecs",
       "../../media:rtc_media_base",