Adds setAudio[Track/Record]StateCallback interfaces to the Java ADM
Bug: webrtc:10950 Change-Id: Ifa7bd7eb003bf97812ce0dfa5a0192ee8955419c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151648 Reviewed-by: Alex Glaznev <glaznev@webrtc.org> Commit-Queue: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29107}
This commit is contained in:
@ -36,6 +36,8 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
private AudioTrackErrorCallback audioTrackErrorCallback;
|
||||
private AudioRecordErrorCallback audioRecordErrorCallback;
|
||||
private SamplesReadyCallback samplesReadyCallback;
|
||||
private AudioTrackStateCallback audioTrackStateCallback;
|
||||
private AudioRecordStateCallback audioRecordStateCallback;
|
||||
private boolean useHardwareAcousticEchoCanceler = isBuiltInAcousticEchoCancelerSupported();
|
||||
private boolean useHardwareNoiseSuppressor = isBuiltInNoiseSuppressorSupported();
|
||||
private boolean useStereoInput;
|
||||
@ -122,6 +124,22 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback to retrieve information from the AudioTrack on when audio starts and stop.
|
||||
*/
|
||||
public Builder setAudioTrackStateCallback(AudioTrackStateCallback audioTrackStateCallback) {
|
||||
this.audioTrackStateCallback = audioTrackStateCallback;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback to retrieve information from the AudioRecord on when audio starts and stops.
|
||||
*/
|
||||
public Builder setAudioRecordStateCallback(AudioRecordStateCallback audioRecordStateCallback) {
|
||||
this.audioRecordStateCallback = audioRecordStateCallback;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Control if the built-in HW noise suppressor should be used or not. The default is on if it is
|
||||
* supported. It is possible to query support by calling isBuiltInNoiseSuppressorSupported().
|
||||
@ -188,10 +206,10 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
Logging.d(TAG, "HW AEC will not be used.");
|
||||
}
|
||||
final WebRtcAudioRecord audioInput = new WebRtcAudioRecord(context, audioManager, audioSource,
|
||||
audioFormat, audioRecordErrorCallback, samplesReadyCallback,
|
||||
audioFormat, audioRecordErrorCallback, audioRecordStateCallback, samplesReadyCallback,
|
||||
useHardwareAcousticEchoCanceler, useHardwareNoiseSuppressor);
|
||||
final WebRtcAudioTrack audioOutput =
|
||||
new WebRtcAudioTrack(context, audioManager, audioTrackErrorCallback);
|
||||
final WebRtcAudioTrack audioOutput = new WebRtcAudioTrack(
|
||||
context, audioManager, audioTrackErrorCallback, audioTrackStateCallback);
|
||||
return new JavaAudioDeviceModule(context, audioManager, audioInput, audioOutput,
|
||||
inputSampleRate, outputSampleRate, useStereoInput, useStereoOutput);
|
||||
}
|
||||
@ -210,6 +228,12 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
void onWebRtcAudioRecordError(String errorMessage);
|
||||
}
|
||||
|
||||
/** Called when audio recording starts and stops. */
|
||||
public static interface AudioRecordStateCallback {
|
||||
void onWebRtcAudioRecordStart();
|
||||
void onWebRtcAudioRecordStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains audio sample information.
|
||||
*/
|
||||
@ -265,6 +289,12 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
void onWebRtcAudioTrackError(String errorMessage);
|
||||
}
|
||||
|
||||
/** Called when audio playout starts and stops. */
|
||||
public static interface AudioTrackStateCallback {
|
||||
void onWebRtcAudioTrackStart();
|
||||
void onWebRtcAudioTrackStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the device supports built-in HW AEC, and the UUID is approved (some UUIDs can
|
||||
* be excluded).
|
||||
|
||||
Reference in New Issue
Block a user