Commit f34c3f01 authored by Sam Zackrisson's avatar Sam Zackrisson Committed by Commit Bot

Support platform tuning of WebRTC processing in ContentRendererClient

This allows platforms with known OS and hardware capabilities to apply
better tuned audio processing configuration.
The config is to parsed, validated and applied in
MediaStreamAudioProcessor.

The Config is passed as a std::string to keep ContentRendererClient
free from WebRTC dependencies, and make it easy for clients to store
the config. Another possible solution is to collect all related WebRTC
audio settings in a struct and have the function return or accept a
(forward-declared) pointer to said struct.

Bug: 892611
Binary-Size: Added dependency is needed to implement new feature. Binary size is very close to bot warn limit (20 kB vs 16 kB). Compensating for size increase seems possible, although not until next release.
Change-Id: Ib478c75ab42318b83ca4ef900587a964b0ceacbd
Reviewed-on: https://chromium-review.googlesource.com/c/1261437
Commit-Queue: Sam Zackrisson <saza@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarMax Morin <maxmorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598719}
parent 8a4ee5f1
...@@ -236,6 +236,11 @@ bool ContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { ...@@ -236,6 +236,11 @@ bool ContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() {
return true; return true;
} }
base::Optional<std::string>
ContentRendererClient::WebRTCPlatformSpecificAudioProcessingConfiguration() {
return base::Optional<std::string>();
}
GURL ContentRendererClient::OverrideFlashEmbedWithHTML(const GURL& url) { GURL ContentRendererClient::OverrideFlashEmbedWithHTML(const GURL& url) {
return GURL(); return GURL();
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/optional.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/task/task_scheduler/task_scheduler.h" #include "base/task/task_scheduler/task_scheduler.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -378,6 +379,14 @@ class CONTENT_EXPORT ContentRendererClient { ...@@ -378,6 +379,14 @@ class CONTENT_EXPORT ContentRendererClient {
// routing logic, i.e. allowing multiple routes and non-proxied UDP. // routing logic, i.e. allowing multiple routes and non-proxied UDP.
virtual bool ShouldEnforceWebRTCRoutingPreferences(); virtual bool ShouldEnforceWebRTCRoutingPreferences();
// Provides a default configuration of WebRTC audio processing, in JSON format
// with fields corresponding to webrtc::AudioProcessing::Config. Allows for a
// more functional tuning on platforms with known implementation and hardware
// limitations.
// This is currently not supported when running the Chrome audio service.
virtual base::Optional<std::string>
WebRTCPlatformSpecificAudioProcessingConfiguration();
// Notifies that a worker context has been created. This function is called // Notifies that a worker context has been created. This function is called
// from the worker thread. // from the worker thread.
virtual void DidInitializeWorkerContextOnWorkerThread( virtual void DidInitializeWorkerContextOnWorkerThread(
......
...@@ -711,6 +711,8 @@ target(link_target_type, "renderer") { ...@@ -711,6 +711,8 @@ target(link_target_type, "renderer") {
"//third_party/webrtc/api:libjingle_logging_api", "//third_party/webrtc/api:libjingle_logging_api",
"//third_party/webrtc/api:libjingle_peerconnection_api", "//third_party/webrtc/api:libjingle_peerconnection_api",
"//third_party/webrtc/api:rtc_stats_api", "//third_party/webrtc/api:rtc_stats_api",
"//third_party/webrtc/api/audio:aec3_config",
"//third_party/webrtc/api/audio:aec3_config_json",
"//third_party/webrtc/api/audio:aec3_factory", "//third_party/webrtc/api/audio:aec3_factory",
"//third_party/webrtc/api/audio_codecs:audio_codecs_api", "//third_party/webrtc/api/audio_codecs:audio_codecs_api",
"//third_party/webrtc/api/audio_codecs/L16:audio_decoder_L16", "//third_party/webrtc/api/audio_codecs/L16:audio_decoder_L16",
......
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h" #include "content/public/common/content_features.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/media/webrtc/webrtc_audio_device_impl.h" #include "content/renderer/media/webrtc/webrtc_audio_device_impl.h"
#include "media/base/audio_converter.h" #include "media/base/audio_converter.h"
#include "media/base/audio_fifo.h" #include "media/base/audio_fifo.h"
...@@ -30,6 +32,8 @@ ...@@ -30,6 +32,8 @@
#include "media/base/channel_layout.h" #include "media/base/channel_layout.h"
#include "media/webrtc/echo_information.h" #include "media/webrtc/echo_information.h"
#include "media/webrtc/webrtc_switches.h" #include "media/webrtc/webrtc_switches.h"
#include "third_party/webrtc/api/audio/echo_canceller3_config.h"
#include "third_party/webrtc/api/audio/echo_canceller3_config_json.h"
#include "third_party/webrtc/api/audio/echo_canceller3_factory.h" #include "third_party/webrtc/api/audio/echo_canceller3_factory.h"
#include "third_party/webrtc/api/mediaconstraintsinterface.h" #include "third_party/webrtc/api/mediaconstraintsinterface.h"
#include "third_party/webrtc/modules/audio_processing/include/audio_processing_statistics.h" #include "third_party/webrtc/modules/audio_processing/include/audio_processing_statistics.h"
...@@ -598,11 +602,22 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule( ...@@ -598,11 +602,22 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
if (properties.echo_cancellation_type == if (properties.echo_cancellation_type ==
EchoCancellationType::kEchoCancellationAec3) { EchoCancellationType::kEchoCancellationAec3) {
webrtc::EchoCanceller3Config aec3_config; webrtc::EchoCanceller3Config aec3_config;
aec3_config.ep_strength.bounded_erl = base::Optional<std::string> audio_processing_platform_config_json =
GetContentClient()
->renderer()
->WebRTCPlatformSpecificAudioProcessingConfiguration();
if (audio_processing_platform_config_json) {
aec3_config = webrtc::Aec3ConfigFromJsonString(
*audio_processing_platform_config_json);
bool config_parameters_already_valid =
webrtc::EchoCanceller3Config::Validate(&aec3_config);
RTC_DCHECK(config_parameters_already_valid);
}
aec3_config.ep_strength.bounded_erl |=
base::FeatureList::IsEnabled(features::kWebRtcAecBoundedErlSetup); base::FeatureList::IsEnabled(features::kWebRtcAecBoundedErlSetup);
aec3_config.echo_removal_control.has_clock_drift = aec3_config.echo_removal_control.has_clock_drift |=
base::FeatureList::IsEnabled(features::kWebRtcAecClockDriftSetup); base::FeatureList::IsEnabled(features::kWebRtcAecClockDriftSetup);
aec3_config.echo_audibility.use_stationary_properties = aec3_config.echo_audibility.use_stationary_properties |=
base::FeatureList::IsEnabled(features::kWebRtcAecNoiseTransparency); base::FeatureList::IsEnabled(features::kWebRtcAecNoiseTransparency);
ap_builder.SetEchoControlFactory( ap_builder.SetEchoControlFactory(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment