
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}
51 lines
1.6 KiB
Java
51 lines
1.6 KiB
Java
/*
|
|
* Copyright 2018 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.
|
|
*/
|
|
|
|
package org.webrtc.audio;
|
|
|
|
import org.webrtc.voiceengine.WebRtcAudioRecord;
|
|
import org.webrtc.voiceengine.WebRtcAudioTrack;
|
|
|
|
/**
|
|
* This class represents the legacy AudioDeviceModule that is currently hardcoded into C++ WebRTC.
|
|
* It will return a null native AudioDeviceModule pointer, leading to an internal object being
|
|
* created inside WebRTC that is controlled by static calls to the classes under the voiceengine
|
|
* package. Please use the new JavaAudioDeviceModule instead of this class.
|
|
*/
|
|
@Deprecated
|
|
public class LegacyAudioDeviceModule implements AudioDeviceModule {
|
|
public static AudioDeviceModule Create() {
|
|
return new LegacyAudioDeviceModule();
|
|
}
|
|
|
|
@Override
|
|
public long getNativeAudioDeviceModulePointer() {
|
|
// Returning a null pointer will make WebRTC construct the built-in legacy AudioDeviceModule for
|
|
// Android internally.
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public void release() {
|
|
// All control for this ADM goes through static global methods and the C++ object is owned
|
|
// internally by WebRTC.
|
|
}
|
|
|
|
@Override
|
|
public void setSpeakerMute(boolean mute) {
|
|
WebRtcAudioTrack.setSpeakerMute(mute);
|
|
}
|
|
|
|
@Override
|
|
public void setMicrophoneMute(boolean mute) {
|
|
WebRtcAudioRecord.setMicrophoneMute(mute);
|
|
}
|
|
}
|