Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2696)

Unified Diff: content/renderer/media/media_stream_audio_processor_options.cc

Issue 2941563002: Enable new getUserMedia audio constraints algorithm behind a flag. (Closed)
Patch Set: remove vertical space from DEPS Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_audio_processor_options.cc
diff --git a/content/renderer/media/media_stream_audio_processor_options.cc b/content/renderer/media/media_stream_audio_processor_options.cc
index 401350e860614d36970e9176c7a29087bb922db5..2da09963ed26d0359a17bfeda76d9a53132ee0f2 100644
--- a/content/renderer/media/media_stream_audio_processor_options.cc
+++ b/content/renderer/media/media_stream_audio_processor_options.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <utility>
+#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
@@ -18,6 +19,7 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "content/common/media/media_stream_options.h"
+#include "content/public/common/content_features.h"
#include "content/renderer/media/media_stream_constraints_util.h"
#include "content/renderer/media/media_stream_source.h"
#include "media/base/audio_parameters.h"
@@ -107,19 +109,6 @@ DelayBasedEchoQuality EchoDelayFrequencyToQuality(float delay_frequency) {
return DELAY_BASED_ECHO_QUALITY_BAD;
}
-webrtc::Point WebrtcPointFromMediaPoint(const media::Point& point) {
- return webrtc::Point(point.x(), point.y(), point.z());
-}
-
-std::vector<webrtc::Point> WebrtcPointsFromMediaPoints(
- const std::vector<media::Point>& points) {
- std::vector<webrtc::Point> webrtc_points;
- webrtc_points.reserve(webrtc_points.size());
- for (const auto& point : points)
- webrtc_points.push_back(WebrtcPointFromMediaPoint(point));
- return webrtc_points;
-}
-
// Scan the basic and advanced constraints until a value is found.
// If nothing is found, the default is returned.
// Argument 2 is a pointer to class data member.
@@ -141,6 +130,7 @@ MediaAudioConstraints::MediaAudioConstraints(
: constraints_(constraints),
effects_(effects),
default_audio_processing_constraint_value_(true) {
+ DCHECK(IsOldAudioConstraints());
// The default audio processing constraints are turned off when
// - gUM has a specific kMediaStreamSource, which is used by tab capture
// and screen capture.
@@ -286,6 +276,50 @@ AudioProcessingProperties& AudioProcessingProperties::operator=(
AudioProcessingProperties&& other) = default;
AudioProcessingProperties::~AudioProcessingProperties() = default;
+void AudioProcessingProperties::DisableDefaultPropertiesForTesting() {
+ enable_sw_echo_cancellation = false;
+ goog_auto_gain_control = false;
+ goog_experimental_echo_cancellation = false;
+ goog_typing_noise_detection = false;
+ goog_noise_suppression = false;
+ goog_experimental_noise_suppression = false;
+ goog_beamforming = false;
+ goog_highpass_filter = false;
+ goog_experimental_auto_gain_control = false;
+}
+
+// static
+AudioProcessingProperties AudioProcessingProperties::FromConstraints(
+ const blink::WebMediaConstraints& constraints,
+ const MediaStreamDevice::AudioDeviceParameters& input_params) {
+ DCHECK(IsOldAudioConstraints());
+ MediaAudioConstraints audio_constraints(constraints, input_params.effects);
+ AudioProcessingProperties properties;
+ properties.enable_sw_echo_cancellation =
+ audio_constraints.GetEchoCancellationProperty();
+ // |properties.disable_hw_echo_cancellation| is not used when
+ // IsOldAudioConstraints() is true.
+ properties.goog_audio_mirroring = audio_constraints.GetGoogAudioMirroring();
+ properties.goog_auto_gain_control =
+ audio_constraints.GetGoogAutoGainControl();
+ properties.goog_experimental_echo_cancellation =
+ audio_constraints.GetGoogExperimentalEchoCancellation();
+ properties.goog_typing_noise_detection =
+ audio_constraints.GetGoogTypingNoiseDetection();
+ properties.goog_noise_suppression =
+ audio_constraints.GetGoogNoiseSuppression();
+ properties.goog_experimental_noise_suppression =
+ audio_constraints.GetGoogExperimentalNoiseSuppression();
+ properties.goog_beamforming = audio_constraints.GetGoogBeamforming();
+ properties.goog_highpass_filter = audio_constraints.GetGoogHighpassFilter();
+ properties.goog_experimental_auto_gain_control =
+ audio_constraints.GetGoogExperimentalAutoGainControl();
+ properties.goog_array_geometry =
+ GetArrayGeometryPreferringConstraints(audio_constraints, input_params);
+
+ return properties;
+}
+
EchoInformation::EchoInformation()
: delay_stats_time_ms_(0),
echo_frames_received_(false),
@@ -482,7 +516,7 @@ void GetAudioProcessingStats(
apm_stats.residual_echo_likelihood_recent_max;
}
-std::vector<webrtc::Point> GetArrayGeometryPreferringConstraints(
+std::vector<media::Point> GetArrayGeometryPreferringConstraints(
const MediaAudioConstraints& audio_constraints,
const MediaStreamDevice::AudioDeviceParameters& input_params) {
const std::string constraints_geometry =
@@ -490,10 +524,14 @@ std::vector<webrtc::Point> GetArrayGeometryPreferringConstraints(
// Give preference to the audio constraint over the device-supplied mic
// positions. This is mainly for testing purposes.
- return WebrtcPointsFromMediaPoints(
- constraints_geometry.empty()
- ? input_params.mic_positions
- : media::ParsePointsFromString(constraints_geometry));
+ return constraints_geometry.empty()
+ ? input_params.mic_positions
+ : media::ParsePointsFromString(constraints_geometry);
+}
+
+bool IsOldAudioConstraints() {
+ return base::FeatureList::IsEnabled(
+ features::kMediaStreamOldAudioConstraints);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698