Delete android helper to create default AudioProcessing

Users can use BuiltinAudioProcessingBuilder directly instead and thus depend on field trials more explicetly.

Bug: webrtc:369904700
Change-Id: I100e73785ebf9fbfcdd80152b6d094a93498d711
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/367261
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: ZoƩ Lepaul <xalep@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43356}
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index f95c749..bc8d507 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -113,7 +113,6 @@
       "software_video_codecs",  # TODO(bugs.webrtc.org/7925): Remove.
     ]
     public_deps = [  # no-presubmit-check TODO(webrtc:8603)
-      ":audio_jni",
       ":base_jni",
       ":builtin_audio_codecs_jni",
       ":default_video_codec_factory_jni",
@@ -562,7 +561,6 @@
       "src/jni/jni_common.cc",
       "src/jni/jni_helpers.cc",
       "src/jni/jni_helpers.h",
-      "src/jni/pc/audio.h",
       "src/jni/pc/logging.cc",
       "src/jni/pc/video.h",
       "src/jni/scoped_java_ref_counted.cc",
@@ -592,16 +590,12 @@
     ]
   }
 
-  rtc_library("audio_jni") {
+  # TODO: bugs.webrtc.org/369904700 - Delete when downstream dependencies stop
+  # depending on this now empty target.
+  rtc_source_set("audio_jni") {
     visibility = [ "*" ]
-    allow_poison = [ "audio_codecs" ]
-    sources = [ "src/jni/pc/audio.cc" ]
-
-    deps = [
-      ":base_jni",
-      "../../api/audio:audio_processing",
-      "../../modules/audio_processing",
-    ]
+    sources = []
+    deps = []
   }
 
   rtc_library("builtin_audio_codecs_jni") {
@@ -785,6 +779,7 @@
       "../../api:turn_customizer",
       "../../api/audio:audio_device",
       "../../api/audio:audio_processing",
+      "../../api/audio:builtin_audio_processing_builder",
       "../../api/crypto:options",
       "../../api/rtc_event_log:rtc_event_log_factory",
       "../../api/task_queue:default_task_queue_factory",
@@ -1642,7 +1637,6 @@
 
     deps = [
       ":audio_device_module_base",
-      ":audio_jni",
       ":base_jni",
       ":generated_native_unittests_jni",
       ":native_api_audio_device_module",
diff --git a/sdk/android/src/jni/pc/audio.cc b/sdk/android/src/jni/pc/audio.cc
deleted file mode 100644
index bf99203..0000000
--- a/sdk/android/src/jni/pc/audio.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- *  Copyright 2017 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 "sdk/android/src/jni/pc/audio.h"
-
-#include "api/audio/audio_processing.h"
-
-namespace webrtc {
-namespace jni {
-
-rtc::scoped_refptr<AudioProcessing> CreateAudioProcessing() {
-  return AudioProcessingBuilder().Create();
-}
-
-}  // namespace jni
-}  // namespace webrtc
diff --git a/sdk/android/src/jni/pc/audio.h b/sdk/android/src/jni/pc/audio.h
deleted file mode 100644
index 41aaa08..0000000
--- a/sdk/android/src/jni/pc/audio.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  Copyright 2017 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 SDK_ANDROID_SRC_JNI_PC_AUDIO_H_
-#define SDK_ANDROID_SRC_JNI_PC_AUDIO_H_
-
-#include "api/audio/audio_processing.h"
-#include "api/scoped_refptr.h"
-
-namespace webrtc {
-namespace jni {
-
-rtc::scoped_refptr<AudioProcessing> CreateAudioProcessing();
-
-}  // namespace jni
-}  // namespace webrtc
-
-#endif  // SDK_ANDROID_SRC_JNI_PC_AUDIO_H_
diff --git a/sdk/android/src/jni/pc/peer_connection_factory.cc b/sdk/android/src/jni/pc/peer_connection_factory.cc
index 2619140..305fad4 100644
--- a/sdk/android/src/jni/pc/peer_connection_factory.cc
+++ b/sdk/android/src/jni/pc/peer_connection_factory.cc
@@ -16,6 +16,7 @@
 #include "absl/memory/memory.h"
 #include "api/audio/audio_device.h"
 #include "api/audio/audio_processing.h"
+#include "api/audio/builtin_audio_processing_builder.h"
 #include "api/enable_media.h"
 #include "api/rtc_event_log/rtc_event_log_factory.h"
 #include "api/task_queue/default_task_queue_factory.h"
@@ -31,7 +32,6 @@
 #include "sdk/android/src/jni/jni_helpers.h"
 #include "sdk/android/src/jni/logging/log_sink.h"
 #include "sdk/android/src/jni/pc/android_network_monitor.h"
-#include "sdk/android/src/jni/pc/audio.h"
 #include "sdk/android/src/jni/pc/ice_candidate.h"
 #include "sdk/android/src/jni/pc/media_stream_track.h"
 #include "sdk/android/src/jni/pc/owned_factory_and_threads.h"
@@ -287,7 +287,15 @@
   dependencies.adm = std::move(audio_device_module);
   dependencies.audio_encoder_factory = std::move(audio_encoder_factory);
   dependencies.audio_decoder_factory = std::move(audio_decoder_factory);
-  dependencies.audio_processing = std::move(audio_processor);
+  if (audio_processor != nullptr) {
+    dependencies.audio_processing_builder =
+        CustomAudioProcessing(std::move(audio_processor));
+#ifndef WEBRTC_EXCLUDE_AUDIO_PROCESSING_MODULE
+  } else {
+    dependencies.audio_processing_builder =
+        std::make_unique<webrtc::BuiltinAudioProcessingBuilder>();
+#endif
+  }
   dependencies.video_encoder_factory =
       absl::WrapUnique(CreateVideoEncoderFactory(jni, jencoder_factory));
   dependencies.video_decoder_factory =
@@ -332,8 +340,7 @@
           reinterpret_cast<AudioDeviceModule*>(native_audio_device_module)),
       TakeOwnershipOfRefPtr<AudioEncoderFactory>(native_audio_encoder_factory),
       TakeOwnershipOfRefPtr<AudioDecoderFactory>(native_audio_decoder_factory),
-      jencoder_factory, jdecoder_factory,
-      audio_processor ? audio_processor : CreateAudioProcessing(),
+      jencoder_factory, jdecoder_factory, std::move(audio_processor),
       TakeOwnershipOfUniquePtr<FecControllerFactoryInterface>(
           native_fec_controller_factory),
       TakeOwnershipOfUniquePtr<NetworkControllerFactoryInterface>(