Android: Add AudioDeviceModule interface and clean up implementation code

This CL introduces sdk/android/api/org/webrtc/audio/AudioDeviceModule.java,
which is the new interface for audio device modules on Android.

This CL also refactors the main AudioDeviceModule implementation, which
is sdk/android/api/org/webrtc/audio/JavaAudioDeviceModule.java and makes
it conform to the new interface. The old code used global static methods
to configure the audio device code. This CL gets rid of all that and uses
a builder pattern in JavaAudioDeviceModule instead. The only two dynamic
methods left in the interface are setSpeakerMute() and setMicrophoneMute().
Removing the global static methods allowed a significant cleanup, and e.g.
the file sdk/android/src/jni/audio_device/audio_manager.cc has been
completely removed.

The PeerConnectionFactory interface is also updated to allow passing in
an external AudioDeviceModule. The current built-in ADM is encapsulated
under LegacyAudioDeviceModule.java, which is the default for now to
ensure backwards compatibility.

Bug: webrtc:7452
Change-Id: I64d5f4dba9a004da001f1acb2bd0c1b1f2b64f21
Reviewed-on: https://webrtc-review.googlesource.com/65360
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Paulina Hensman <phensman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22765}
This commit is contained in:
Magnus Jedvert
2018-04-04 17:16:03 +02:00
committed by Commit Bot
parent 3ab5c40f72
commit 66f1e9eb34
37 changed files with 838 additions and 1248 deletions

View File

@ -14,10 +14,10 @@ import java.nio.ByteBuffer;
/** Class with static JNI helper functions that are used in many places. */
@JNINamespace("webrtc::jni")
class JniCommon {
public class JniCommon {
/** Functions to increment/decrement an rtc::RefCountInterface pointer. */
static native void nativeAddRef(long refCountedPointer);
static native void nativeReleaseRef(long refCountedPointer);
public static native void nativeAddRef(long refCountedPointer);
public static native void nativeReleaseRef(long refCountedPointer);
public static native ByteBuffer nativeAllocateByteBuffer(int size);
public static native void nativeFreeByteBuffer(ByteBuffer buffer);