Chromium Code Reviews| 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 5c61a055cc47fd2e1bc014e2e385ad4af4710c9d..d704a00aceed404228e6717d3803c0291e8b22d2 100644 |
| --- a/content/renderer/media/media_stream_audio_processor_options.cc |
| +++ b/content/renderer/media/media_stream_audio_processor_options.cc |
| @@ -51,13 +51,13 @@ struct { |
| const char* key; |
| bool value; |
| } const kDefaultAudioConstraints[] = { |
| - { MediaAudioConstraints::kEchoCancellation, true }, |
| - { MediaAudioConstraints::kGoogEchoCancellation, true }, |
| + {MediaAudioConstraints::kEchoCancellation, true}, |
|
tommi (sloooow) - chröme
2015/09/02 07:43:07
would be nice to keep the whitespace and indent co
ajm
2015/09/02 17:00:55
Ah sorry, I forgot to fix this after a rebase. I'd
|
| + {MediaAudioConstraints::kGoogEchoCancellation, true}, |
| #if defined(OS_ANDROID) || defined(OS_IOS) |
| - { MediaAudioConstraints::kGoogExperimentalEchoCancellation, false }, |
| + {MediaAudioConstraints::kGoogExperimentalEchoCancellation, false}, |
| #else |
| - // Enable the extended filter mode AEC on all non-mobile platforms. |
| - { MediaAudioConstraints::kGoogExperimentalEchoCancellation, true }, |
| + // Enable the extended filter mode AEC on all non-mobile platforms. |
| + {MediaAudioConstraints::kGoogExperimentalEchoCancellation, true}, |
| #endif |
| { MediaAudioConstraints::kGoogAutoGainControl, true }, |
| { MediaAudioConstraints::kGoogExperimentalAutoGainControl, true }, |
| @@ -65,7 +65,9 @@ struct { |
| { MediaAudioConstraints::kGoogHighpassFilter, true }, |
| { MediaAudioConstraints::kGoogTypingNoiseDetection, true }, |
| { MediaAudioConstraints::kGoogExperimentalNoiseSuppression, false }, |
| - { MediaAudioConstraints::kGoogBeamforming, false }, |
| + // Beamforming will only be enabled if we are also provided with a |
| + // multi-microphone geometry. |
| + { MediaAudioConstraints::kGoogBeamforming, true }, |
| { kMediaStreamAudioHotword, false }, |
| }; |
| @@ -99,6 +101,20 @@ 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()); |
|
tommi (sloooow) - chröme
2015/09/02 07:43:07
appreciate the attention to detail :)
ajm
2015/09/02 17:00:55
Thanks :)
|
| + for (const auto& point : points) { |
| + webrtc_points.push_back(WebrtcPointFromMediaPoint(point)); |
| + } |
| + return webrtc_points; |
| +} |
| + |
| } // namespace |
| // TODO(xians): Remove this method after the APM in WebRtc is deprecated. |
| @@ -377,36 +393,19 @@ void GetAecStats(webrtc::EchoCancellation* echo_cancellation, |
| } |
| } |
| -CONTENT_EXPORT std::vector<webrtc::Point> ParseArrayGeometry( |
| - const std::string& geometry_string) { |
| - const auto& tokens = |
| - base::SplitString(geometry_string, base::kWhitespaceASCII, |
| - base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| - std::vector<webrtc::Point> geometry; |
| - if (tokens.size() < 3 || tokens.size() % 3 != 0) { |
| - LOG(ERROR) << "Malformed geometry string: " << geometry_string; |
| - return geometry; |
| - } |
| - |
| - std::vector<float> float_tokens; |
| - float_tokens.reserve(tokens.size()); |
| - for (const auto& token : tokens) { |
| - double float_token; |
| - if (!base::StringToDouble(token, &float_token)) { |
| - LOG(ERROR) << "Unable to convert token=" << token |
| - << " to double from geometry string: " << geometry_string; |
| - return geometry; |
| - } |
| - float_tokens.push_back(float_token); |
| - } |
| - |
| - geometry.reserve(float_tokens.size() / 3); |
| - for (size_t i = 0; i < float_tokens.size(); i += 3) { |
| - geometry.push_back(webrtc::Point(float_tokens[i + 0], float_tokens[i + 1], |
| - float_tokens[i + 2])); |
| - } |
| - |
| - return geometry; |
| +std::vector<webrtc::Point> GetArrayGeometryPreferringConstraints( |
| + const MediaAudioConstraints& audio_constraints, |
| + const MediaStreamDevice::AudioDeviceParameters& input_params) { |
| + const std::string& constraints_geometry = |
|
tommi (sloooow) - chröme
2015/09/02 07:43:07
nit: no ref
ajm
2015/09/02 17:00:55
I agree, but would like to get your opinion on the
ajm
2015/09/09 01:01:29
Done.
|
| + audio_constraints.GetPropertyAsString( |
| + MediaAudioConstraints::kGoogArrayGeometry); |
| + |
| + // 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)); |
| } |
| } // namespace content |