[AndroidAudioRecord] Added audio format parameter to configure AudioRecord - JavaAudioDeviceModule
Added audio format field and set method to Builder. - WebRTCAudioRecord. Added audio format field, added to constructor. Default audio format value AudioFormat.ENCODING_PCM_16BIT. initRecord(), added how to calculate bytesPerFrame, depends on audioFormat. First commit and contribution, updated AUTHORS file Bug: None Change-Id: I16f660d42350ec9ce2e329b239bd7f6324e76dfe Reviewed-on: https://webrtc-review.googlesource.com/c/122302 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26775}
This commit is contained in:
committed by
Commit Bot
parent
5341aaccdb
commit
ce27875b83
@ -31,6 +31,7 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
private final AudioManager audioManager;
|
||||
private int sampleRate;
|
||||
private int audioSource = WebRtcAudioRecord.DEFAULT_AUDIO_SOURCE;
|
||||
private int audioFormat = WebRtcAudioRecord.DEFAULT_AUDIO_FORMAT;
|
||||
private AudioTrackErrorCallback audioTrackErrorCallback;
|
||||
private AudioRecordErrorCallback audioRecordErrorCallback;
|
||||
private SamplesReadyCallback samplesReadyCallback;
|
||||
@ -65,6 +66,17 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to change the audio format. The argument should be one of the values from
|
||||
* android.media.AudioFormat ENCODING_PCM_8BIT, ENCODING_PCM_16BIT or ENCODING_PCM_FLOAT.
|
||||
* Default audio data format is PCM 16 bit per sample.
|
||||
* Guaranteed to be supported by all devices.
|
||||
*/
|
||||
public Builder setAudioFormat(int audioFormat) {
|
||||
this.audioFormat = audioFormat;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback to retrieve errors from the AudioTrack.
|
||||
*/
|
||||
@ -154,9 +166,9 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
}
|
||||
Logging.d(TAG, "HW AEC will not be used.");
|
||||
}
|
||||
final WebRtcAudioRecord audioInput =
|
||||
new WebRtcAudioRecord(context, audioManager, audioSource, audioRecordErrorCallback,
|
||||
samplesReadyCallback, useHardwareAcousticEchoCanceler, useHardwareNoiseSuppressor);
|
||||
final WebRtcAudioRecord audioInput = new WebRtcAudioRecord(context, audioManager, audioSource,
|
||||
audioFormat, audioRecordErrorCallback, samplesReadyCallback,
|
||||
useHardwareAcousticEchoCanceler, useHardwareNoiseSuppressor);
|
||||
final WebRtcAudioTrack audioOutput =
|
||||
new WebRtcAudioTrack(context, audioManager, audioTrackErrorCallback);
|
||||
return new JavaAudioDeviceModule(context, audioManager, audioInput, audioOutput, sampleRate,
|
||||
|
||||
Reference in New Issue
Block a user