Android AppRTCMobile: Use new audio device code
This CL contains some follow-up fixes for https://webrtc-review.googlesource.com/c/src/+/60541. It removes all use of the old voiceengine implementation from AppRTCMobile. Bug: webrtc:7452 Change-Id: Iea21a4b3be1f3cbb5062831164fffb2c8051d858 Reviewed-on: https://webrtc-review.googlesource.com/63480 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Paulina Hensman <phensman@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22530}
This commit is contained in:
committed by
Commit Bot
parent
82fad3d513
commit
08006d4133
@ -25,6 +25,7 @@ import org.webrtc.audio.AudioDeviceModule.AudioRecordErrorCallback;
|
||||
import org.webrtc.audio.AudioDeviceModule.AudioRecordStartErrorCode;
|
||||
import org.webrtc.CalledByNative;
|
||||
import org.webrtc.NativeClassQualifiedName;
|
||||
import org.webrtc.audio.AudioDeviceModule.SamplesReadyCallback;
|
||||
|
||||
class WebRtcAudioRecord {
|
||||
private static final boolean DEBUG = false;
|
||||
@ -72,52 +73,9 @@ class WebRtcAudioRecord {
|
||||
WebRtcAudioRecord.errorCallback = errorCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains audio sample information. Object is passed using {@link
|
||||
* WebRtcAudioRecord.WebRtcAudioRecordSamplesReadyCallback}
|
||||
*/
|
||||
public static class AudioSamples {
|
||||
/** See {@link AudioRecord#getAudioFormat()} */
|
||||
private final int audioFormat;
|
||||
/** See {@link AudioRecord#getChannelCount()} */
|
||||
private final int channelCount;
|
||||
/** See {@link AudioRecord#getSampleRate()} */
|
||||
private final int sampleRate;
|
||||
private static SamplesReadyCallback audioSamplesReadyCallback = null;
|
||||
|
||||
private final byte[] data;
|
||||
|
||||
private AudioSamples(AudioRecord audioRecord, byte[] data) {
|
||||
this.audioFormat = audioRecord.getAudioFormat();
|
||||
this.channelCount = audioRecord.getChannelCount();
|
||||
this.sampleRate = audioRecord.getSampleRate();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getAudioFormat() {
|
||||
return audioFormat;
|
||||
}
|
||||
|
||||
public int getChannelCount() {
|
||||
return channelCount;
|
||||
}
|
||||
|
||||
public int getSampleRate() {
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when new audio samples are ready. This should only be set for debug purposes */
|
||||
public static interface WebRtcAudioRecordSamplesReadyCallback {
|
||||
void onWebRtcAudioRecordSamplesReady(AudioSamples samples);
|
||||
}
|
||||
|
||||
private static WebRtcAudioRecordSamplesReadyCallback audioSamplesReadyCallback = null;
|
||||
|
||||
public static void setOnAudioSamplesReady(WebRtcAudioRecordSamplesReadyCallback callback) {
|
||||
public static void setOnAudioSamplesReady(SamplesReadyCallback callback) {
|
||||
audioSamplesReadyCallback = callback;
|
||||
}
|
||||
|
||||
@ -159,7 +117,8 @@ class WebRtcAudioRecord {
|
||||
// at index 0.
|
||||
byte[] data = Arrays.copyOf(byteBuffer.array(), byteBuffer.capacity());
|
||||
audioSamplesReadyCallback.onWebRtcAudioRecordSamplesReady(
|
||||
new AudioSamples(audioRecord, data));
|
||||
new AudioDeviceModule.AudioSamples(audioRecord.getAudioFormat(),
|
||||
audioRecord.getChannelCount(), audioRecord.getSampleRate(), data));
|
||||
}
|
||||
} else {
|
||||
String errorMessage = "AudioRecord.read failed: " + bytesRead;
|
||||
|
||||
@ -37,7 +37,7 @@ enum SdkCode {
|
||||
SDK_CODE_N = 24,
|
||||
};
|
||||
|
||||
// Utility class used to query the Java class (org/webrtc/voiceengine/BuildInfo)
|
||||
// Utility class used to query the Java class (org/webrtc/audio/BuildInfo)
|
||||
// for device and Android build information.
|
||||
// The calling thread is attached to the JVM at construction if needed and a
|
||||
// valid Java environment object is also created.
|
||||
|
||||
Reference in New Issue
Block a user