Revert "Reland "Delete old Android ADM.""

This reverts commit 6e4d7e606c4327eaa9298193e22794fcb9b30218.

Reason for revert: Still breaks downstream build (though in a different way this time)

Original change's description:
> Reland "Delete old Android ADM."
>
> This is a reland of commit 4ec3e9c98873520b3171d40ab0426b2f05edbbd2
>
> Original change's description:
> > Delete old Android ADM.
> >
> > The schedule move Android ADM code to sdk directory have been around
> > for several years, but the old code still not delete.
> >
> > Bug: webrtc:7452
> > Change-Id: I0f75c680f71f0b2ce614de6cbd9f124c2a59d453
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264620
> > Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
> > Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
> > Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#37174}
>
> Bug: webrtc:7452
> Change-Id: Icabad23e72c8258a854b7809a93811161517266c
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265872
> Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
> Commit-Queue: Björn Terelius <terelius@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#37236}

Bug: webrtc:7452
Change-Id: Ide8fbd55fadd7aed9989053afff7c63c04f1320f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266023
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Owners-Override: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37242}
This commit is contained in:
Björn Terelius
2022-06-16 16:06:42 +00:00
committed by WebRTC LUCI CQ
parent 7517fb639b
commit 38a28603fd
53 changed files with 8366 additions and 216 deletions

View File

@ -1,5 +1,4 @@
include_rules = [
"+modules/audio_device/include/audio_device.h",
"+modules/utility/include/jvm_android.h",
"+system_wrappers/include",
]

View File

@ -24,12 +24,10 @@
#include "sdk/android/src/jni/audio_device/aaudio_recorder.h"
#endif
#include "sdk/android/native_api/jni/application_context_provider.h"
#include "sdk/android/src/jni/audio_device/audio_record_jni.h"
#include "sdk/android/src/jni/audio_device/audio_track_jni.h"
#include "sdk/android/src/jni/audio_device/opensles_player.h"
#include "sdk/android/src/jni/audio_device/opensles_recorder.h"
#include "sdk/android/src/jni/jvm.h"
#include "system_wrappers/include/metrics.h"
namespace webrtc {
@ -72,31 +70,6 @@ rtc::scoped_refptr<AudioDeviceModule> CreateAAudioAudioDeviceModule(
std::make_unique<jni::AAudioRecorder>(input_parameters),
std::make_unique<jni::AAudioPlayer>(output_parameters));
}
rtc::scoped_refptr<AudioDeviceModule>
CreateJavaInputAndAAudioOutputAudioDeviceModule(JNIEnv* env,
jobject application_context) {
RTC_DLOG(LS_INFO) << __FUNCTION__;
// Get default audio input/output parameters.
const JavaParamRef<jobject> j_context(application_context);
const ScopedJavaLocalRef<jobject> j_audio_manager =
jni::GetAudioManager(env, j_context);
AudioParameters input_parameters;
AudioParameters output_parameters;
GetDefaultAudioParameters(env, application_context, &input_parameters,
&output_parameters);
// Create ADM from AudioRecord and OpenSLESPlayer.
auto audio_input = std::make_unique<jni::AudioRecordJni>(
env, input_parameters, jni::kLowLatencyModeDelayEstimateInMilliseconds,
jni::AudioRecordJni::CreateJavaWebRtcAudioRecord(env, j_context,
j_audio_manager));
return CreateAudioDeviceModuleFromInputAndOutput(
AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio,
false /* use_stereo_input */, false /* use_stereo_output */,
jni::kLowLatencyModeDelayEstimateInMilliseconds, std::move(audio_input),
std::make_unique<jni::AAudioPlayer>(output_parameters));
}
#endif
rtc::scoped_refptr<AudioDeviceModule> CreateJavaAudioDeviceModule(
@ -179,57 +152,4 @@ CreateJavaInputAndOpenSLESOutputAudioDeviceModule(JNIEnv* env,
std::move(audio_output));
}
rtc::scoped_refptr<AudioDeviceModule> CreateAndroidAudioDeviceModule(
AudioDeviceModule::AudioLayer audio_layer) {
auto env = AttachCurrentThreadIfNeeded();
auto j_context = webrtc::GetAppContext(env);
// Select best possible combination of audio layers.
if (audio_layer == AudioDeviceModule::kPlatformDefaultAudio) {
#if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
// AAudio based audio for both input and output.
audio_layer = AudioDeviceModule::kAndroidAAudioAudio;
#else
if (jni::IsLowLatencyInputSupported(env, j_context) &&
jni::IsLowLatencyOutputSupported(env, j_context)) {
// Use OpenSL ES for both playout and recording.
audio_layer = AudioDeviceModule::kAndroidOpenSLESAudio;
} else if (jni::IsLowLatencyOutputSupported(env, j_context) &&
!jni::IsLowLatencyInputSupported(env, j_context)) {
// Use OpenSL ES for output on devices that only supports the
// low-latency output audio path.
audio_layer = AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio;
} else {
// Use Java-based audio in both directions when low-latency output is
// not supported.
audio_layer = AudioDeviceModule::kAndroidJavaAudio;
}
#endif
}
switch (audio_layer) {
case AudioDeviceModule::kAndroidJavaAudio:
// Java audio for both input and output audio.
return CreateJavaAudioDeviceModule(env, j_context.obj());
case AudioDeviceModule::kAndroidOpenSLESAudio:
// OpenSL ES based audio for both input and output audio.
return CreateOpenSLESAudioDeviceModule(env, j_context.obj());
case AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio:
// Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
// This combination provides low-latency output audio and at the same
// time support for HW AEC using the AudioRecord Java API.
return CreateJavaInputAndOpenSLESOutputAudioDeviceModule(
env, j_context.obj());
#if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
case AudioDeviceModule::kAndroidAAudioAudio:
// AAudio based audio for both input and output.
return CreateAAudioAudioDeviceModule(env, j_context.obj());
case AudioDeviceModule::kAndroidJavaInputAndAAudioOutputAudio:
// Java audio for input and AAudio for output audio (i.e. mixed APIs).
return CreateJavaInputAndAAudioOutputAudioDeviceModule(
env, j_context.obj());
#endif
default:
return nullptr;
}
}
} // namespace webrtc

View File

@ -32,17 +32,8 @@ rtc::scoped_refptr<AudioDeviceModule> CreateOpenSLESAudioDeviceModule(
jobject application_context);
rtc::scoped_refptr<AudioDeviceModule>
CreateJavaInputAndOpenSLESOutputAudioDeviceModule(
JNIEnv* env,
jobject application_context);
rtc::scoped_refptr<AudioDeviceModule>
CreateJavaInputAndAAudioOutputAudioDeviceModule(
JNIEnv* env,
jobject application_context);
rtc::scoped_refptr<AudioDeviceModule> CreateAndroidAudioDeviceModule(
AudioDeviceModule::AudioLayer audio_layer);
CreateJavaInputAndOpenSLESOutputAudioDeviceModule(JNIEnv* env,
jobject application_context);
} // namespace webrtc

View File

@ -1,22 +0,0 @@
/*
* Copyright 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 "sdk/android/native_api/jni/application_context_provider.h"
#include "sdk/android/generated_native_api_jni/ApplicationContextProvider_jni.h"
#include "sdk/android/native_api/jni/scoped_java_ref.h"
namespace webrtc {
ScopedJavaLocalRef<jobject> GetAppContext(JNIEnv* jni) {
return ScopedJavaLocalRef<jobject>(
jni::Java_ApplicationContextProvider_getApplicationContext(jni));
}
} // namespace webrtc

View File

@ -1,21 +0,0 @@
/*
* Copyright 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 SDK_ANDROID_NATIVE_API_JNI_APPLICATION_CONTEXT_PROVIDER_H_
#define SDK_ANDROID_NATIVE_API_JNI_APPLICATION_CONTEXT_PROVIDER_H_
#include "sdk/android/native_api/jni/scoped_java_ref.h"
namespace webrtc {
ScopedJavaLocalRef<jobject> GetAppContext(JNIEnv* jni);
} // namespace webrtc
#endif // SDK_ANDROID_NATIVE_API_JNI_APPLICATION_CONTEXT_PROVIDER_H_