Allow AudioAttributes to be app/client configurable
WebRtcAudioTrack is hardcoded to configure AudioAttributes with 1. usage=USAGE_VOICE_COMMUNICATIOON 2. contentType=CONTENT_TYPE_SPEECH This change allows AudioAttributes to be configured via the JavaAudioDeviceModule. Bug: webrtc:12153 Change-Id: I67c7f6e572c5a9f3a8fde674b6600d2adaf17895 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191941 Commit-Queue: Gaurav Vaish <gvaish@chromium.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Reviewed-by: Paulina Hensman <phensman@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32583}
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
package org.webrtc.audio;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioDeviceInfo;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
@ -47,6 +48,7 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
private boolean useHardwareNoiseSuppressor = isBuiltInNoiseSuppressorSupported();
|
||||
private boolean useStereoInput;
|
||||
private boolean useStereoOutput;
|
||||
private AudioAttributes audioAttributes;
|
||||
|
||||
private Builder(Context context) {
|
||||
this.context = context;
|
||||
@ -193,6 +195,14 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom {@link AudioAttributes} to use.
|
||||
*/
|
||||
public Builder setAudioAttributes(AudioAttributes audioAttributes) {
|
||||
this.audioAttributes = audioAttributes;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an AudioDeviceModule based on the supplied arguments. The caller takes ownership
|
||||
* and is responsible for calling release().
|
||||
@ -223,7 +233,7 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
audioSource, audioFormat, audioRecordErrorCallback, audioRecordStateCallback,
|
||||
samplesReadyCallback, useHardwareAcousticEchoCanceler, useHardwareNoiseSuppressor);
|
||||
final WebRtcAudioTrack audioOutput = new WebRtcAudioTrack(
|
||||
context, audioManager, audioTrackErrorCallback, audioTrackStateCallback);
|
||||
context, audioManager, audioAttributes, audioTrackErrorCallback, audioTrackStateCallback);
|
||||
return new JavaAudioDeviceModule(context, audioManager, audioInput, audioOutput,
|
||||
inputSampleRate, outputSampleRate, useStereoInput, useStereoOutput);
|
||||
}
|
||||
|
Reference in New Issue
Block a user