Expose APM pipeline parameter to select downmixing method
Bug: b/257289030 Change-Id: I03a666a15752d7a1125af2f8d3edae530493618c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285473 Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38789}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
8754a3c945
commit
504bd59422
@ -442,6 +442,19 @@ const AudioProcessing::Config AdjustConfig(
|
||||
return adjusted_config;
|
||||
}
|
||||
|
||||
using DownmixMethod = AudioProcessing::Config::Pipeline::DownmixMethod;
|
||||
|
||||
void SetDownmixMethod(AudioBuffer& buffer, DownmixMethod method) {
|
||||
switch (method) {
|
||||
case DownmixMethod::kAverageChannels:
|
||||
buffer.set_downmixing_by_averaging();
|
||||
break;
|
||||
case DownmixMethod::kUseFirstChannel:
|
||||
buffer.set_downmixing_to_specific_channel(/*channel=*/0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr int kUnspecifiedDataDumpInputVolume = -100;
|
||||
|
||||
} // namespace
|
||||
@ -689,6 +702,8 @@ void AudioProcessingImpl::InitializeLocked() {
|
||||
formats_.api_format.output_stream().num_channels(),
|
||||
formats_.api_format.output_stream().sample_rate_hz(),
|
||||
formats_.api_format.output_stream().num_channels()));
|
||||
SetDownmixMethod(*capture_.capture_audio,
|
||||
config_.pipeline.capture_downmix_method);
|
||||
|
||||
if (capture_nonlocked_.capture_processing_format.sample_rate_hz() <
|
||||
formats_.api_format.output_stream().sample_rate_hz() &&
|
||||
@ -700,6 +715,8 @@ void AudioProcessingImpl::InitializeLocked() {
|
||||
formats_.api_format.output_stream().num_channels(),
|
||||
formats_.api_format.output_stream().sample_rate_hz(),
|
||||
formats_.api_format.output_stream().num_channels()));
|
||||
SetDownmixMethod(*capture_.capture_fullband_audio,
|
||||
config_.pipeline.capture_downmix_method);
|
||||
} else {
|
||||
capture_.capture_fullband_audio.reset();
|
||||
}
|
||||
@ -821,7 +838,9 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
|
||||
config_.pipeline.multi_channel_capture !=
|
||||
adjusted_config.pipeline.multi_channel_capture ||
|
||||
config_.pipeline.maximum_internal_processing_rate !=
|
||||
adjusted_config.pipeline.maximum_internal_processing_rate;
|
||||
adjusted_config.pipeline.maximum_internal_processing_rate ||
|
||||
config_.pipeline.capture_downmix_method !=
|
||||
adjusted_config.pipeline.capture_downmix_method;
|
||||
|
||||
const bool aec_config_changed =
|
||||
config_.echo_canceller.enabled !=
|
||||
|
@ -146,6 +146,12 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
|
||||
struct RTC_EXPORT Config {
|
||||
// Sets the properties of the audio processing pipeline.
|
||||
struct RTC_EXPORT Pipeline {
|
||||
// Ways to downmix a multi-channel track to mono.
|
||||
enum class DownmixMethod {
|
||||
kAverageChannels, // Average across channels.
|
||||
kUseFirstChannel // Use the first channel.
|
||||
};
|
||||
|
||||
// Maximum allowed processing rate used internally. May only be set to
|
||||
// 32000 or 48000 and any differing values will be treated as 48000.
|
||||
int maximum_internal_processing_rate = 48000;
|
||||
@ -154,6 +160,9 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
|
||||
// Allow multi-channel processing of capture audio when AEC3 is active
|
||||
// or a custom AEC is injected..
|
||||
bool multi_channel_capture = false;
|
||||
// Indicates how to downmix multi-channel capture audio to mono (when
|
||||
// needed).
|
||||
DownmixMethod capture_downmix_method = DownmixMethod::kAverageChannels;
|
||||
} pipeline;
|
||||
|
||||
// Enabled the pre-amplifier. It amplifies the capture signal
|
||||
|
Reference in New Issue
Block a user