Add gn configs to remove the dependency to audio and video codecs.

Actually, I don't think there is any strong reason to keep these
deps in `webrtc` target except some downstream projects need it.

Making a GN config for now.

Bug: webrtc:10306
Change-Id: Id714faeabf4daaf3cc88d1f6224ae89ca8715e48
Reviewed-on: https://webrtc-review.googlesource.com/c/122420
Commit-Queue: Jiawei Ou <ouj@fb.com>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26653}
diff --git a/BUILD.gn b/BUILD.gn
index 1cb920e..a62bb02 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -406,13 +406,19 @@
       "video",
     ]
 
-    # Include audio and video codecs by default.
-    deps += [
-      "api/audio_codecs:builtin_audio_decoder_factory",
-      "api/audio_codecs:builtin_audio_encoder_factory",
-      "api/video_codecs:builtin_video_decoder_factory",
-      "api/video_codecs:builtin_video_encoder_factory",
-    ]
+    if (rtc_include_builtin_audio_codecs) {
+      deps += [
+        "api/audio_codecs:builtin_audio_decoder_factory",
+        "api/audio_codecs:builtin_audio_encoder_factory",
+      ]
+    }
+
+    if (rtc_include_builtin_video_codecs) {
+      deps += [
+        "api/video_codecs:builtin_video_decoder_factory",
+        "api/video_codecs:builtin_video_encoder_factory",
+      ]
+    }
 
     if (build_with_mozilla) {
       deps += [ "api/video:video_frame" ]
diff --git a/webrtc.gni b/webrtc.gni
index 2239d61..d716d7d 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -180,6 +180,18 @@
 
   # Determines whether Metal is available on iOS/macOS.
   rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
+
+  # When set to false, builtin audio encoder/decoder factories and all the
+  # audio codecs they depend on will not be included in libwebrtc.{a|lib}
+  # (they will still be included in libjingle_peerconnection_so.so and
+  # WebRTC.framework)
+  rtc_include_builtin_audio_codecs = true
+
+  # When set to false, builtin video encoder/decoder factories and all the
+  # video codecs they depends on will not be included in libwebrtc.{a|lib}
+  # (they will still be included in libjingle_peerconnection_so.so and
+  # WebRTC.framework)
+  rtc_include_builtin_video_codecs = true
 }
 
 if (!build_with_mozilla) {