| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/media_stream_audio_processor_options.h" | 5 #include "content/renderer/media/media_stream_audio_processor_options.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const char MediaAudioConstraints::kGoogAudioMirroring[] = "googAudioMirroring"; | 44 const char MediaAudioConstraints::kGoogAudioMirroring[] = "googAudioMirroring"; |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 // Constant constraint keys which enables default audio constraints on | 48 // Constant constraint keys which enables default audio constraints on |
| 49 // mediastreams with audio. | 49 // mediastreams with audio. |
| 50 struct { | 50 struct { |
| 51 const char* key; | 51 const char* key; |
| 52 bool value; | 52 bool value; |
| 53 } const kDefaultAudioConstraints[] = { | 53 } const kDefaultAudioConstraints[] = { |
| 54 { MediaAudioConstraints::kEchoCancellation, true }, | 54 {MediaAudioConstraints::kEchoCancellation, true}, |
| 55 { MediaAudioConstraints::kGoogEchoCancellation, true }, | 55 {MediaAudioConstraints::kGoogEchoCancellation, true}, |
| 56 #if defined(OS_ANDROID) || defined(OS_IOS) | 56 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 57 { MediaAudioConstraints::kGoogExperimentalEchoCancellation, false }, | 57 {MediaAudioConstraints::kGoogExperimentalEchoCancellation, false}, |
| 58 #else | 58 #else |
| 59 // Enable the extended filter mode AEC on all non-mobile platforms. | 59 // Enable the extended filter mode AEC on all non-mobile platforms. |
| 60 { MediaAudioConstraints::kGoogExperimentalEchoCancellation, true }, | 60 {MediaAudioConstraints::kGoogExperimentalEchoCancellation, true}, |
| 61 #endif | 61 #endif |
| 62 { MediaAudioConstraints::kGoogAutoGainControl, true }, | 62 {MediaAudioConstraints::kGoogAutoGainControl, true}, |
| 63 { MediaAudioConstraints::kGoogExperimentalAutoGainControl, true }, | 63 {MediaAudioConstraints::kGoogExperimentalAutoGainControl, true}, |
| 64 { MediaAudioConstraints::kGoogNoiseSuppression, true }, | 64 {MediaAudioConstraints::kGoogNoiseSuppression, true}, |
| 65 { MediaAudioConstraints::kGoogHighpassFilter, true }, | 65 {MediaAudioConstraints::kGoogHighpassFilter, true}, |
| 66 { MediaAudioConstraints::kGoogTypingNoiseDetection, true }, | 66 {MediaAudioConstraints::kGoogTypingNoiseDetection, true}, |
| 67 { MediaAudioConstraints::kGoogExperimentalNoiseSuppression, false }, | 67 {MediaAudioConstraints::kGoogExperimentalNoiseSuppression, false}, |
| 68 { MediaAudioConstraints::kGoogBeamforming, false }, | 68 // Beamforming will only be enabled if we are also provided with a |
| 69 // multi-microphone geometry. |
| 70 {MediaAudioConstraints::kGoogBeamforming, false}, |
| 69 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
| 70 { kMediaStreamAudioDucking, true }, | 72 {kMediaStreamAudioDucking, true}, |
| 71 #else | 73 #else |
| 72 { kMediaStreamAudioDucking, false }, | 74 {kMediaStreamAudioDucking, false}, |
| 73 #endif | 75 #endif |
| 74 { kMediaStreamAudioHotword, false }, | 76 {kMediaStreamAudioHotword, false}, |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 bool IsAudioProcessingConstraint(const std::string& key) { | 79 bool IsAudioProcessingConstraint(const std::string& key) { |
| 78 // |kMediaStreamAudioDucking| does not require audio processing. | 80 // |kMediaStreamAudioDucking| does not require audio processing. |
| 79 return key != kMediaStreamAudioDucking; | 81 return key != kMediaStreamAudioDucking; |
| 80 } | 82 } |
| 81 | 83 |
| 82 // Used to log echo quality based on delay estimates. | 84 // Used to log echo quality based on delay estimates. |
| 83 enum DelayBasedEchoQuality { | 85 enum DelayBasedEchoQuality { |
| 84 DELAY_BASED_ECHO_QUALITY_GOOD = 0, | 86 DELAY_BASED_ECHO_QUALITY_GOOD = 0, |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 float dummy = 0; | 388 float dummy = 0; |
| 387 if (echo_cancellation->GetDelayMetrics(&median, &std, &dummy) == | 389 if (echo_cancellation->GetDelayMetrics(&median, &std, &dummy) == |
| 388 webrtc::AudioProcessing::kNoError) { | 390 webrtc::AudioProcessing::kNoError) { |
| 389 stats->echo_delay_median_ms = median; | 391 stats->echo_delay_median_ms = median; |
| 390 stats->echo_delay_std_ms = std; | 392 stats->echo_delay_std_ms = std; |
| 391 } | 393 } |
| 392 } | 394 } |
| 393 | 395 |
| 394 CONTENT_EXPORT std::vector<webrtc::Point> ParseArrayGeometry( | 396 CONTENT_EXPORT std::vector<webrtc::Point> ParseArrayGeometry( |
| 395 const std::string& geometry_string) { | 397 const std::string& geometry_string) { |
| 398 std::vector<webrtc::Point> geometry; |
| 399 if (geometry_string.empty()) { |
| 400 return geometry; |
| 401 } |
| 402 |
| 396 const auto& tokens = | 403 const auto& tokens = |
| 397 base::SplitString(geometry_string, base::kWhitespaceASCII, | 404 base::SplitString(geometry_string, base::kWhitespaceASCII, |
| 398 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 405 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 399 std::vector<webrtc::Point> geometry; | |
| 400 if (tokens.size() < 3 || tokens.size() % 3 != 0) { | 406 if (tokens.size() < 3 || tokens.size() % 3 != 0) { |
| 401 LOG(ERROR) << "Malformed geometry string: " << geometry_string; | 407 LOG(ERROR) << "Malformed geometry string: " << geometry_string; |
| 402 return geometry; | 408 return geometry; |
| 403 } | 409 } |
| 404 | 410 |
| 405 std::vector<float> float_tokens; | 411 std::vector<float> float_tokens; |
| 406 float_tokens.reserve(tokens.size()); | 412 float_tokens.reserve(tokens.size()); |
| 407 for (const auto& token : tokens) { | 413 for (const auto& token : tokens) { |
| 408 double float_token; | 414 double float_token; |
| 409 if (!base::StringToDouble(token, &float_token)) { | 415 if (!base::StringToDouble(token, &float_token)) { |
| 410 LOG(ERROR) << "Unable to convert token=" << token | 416 LOG(ERROR) << "Unable to convert token=" << token |
| 411 << " to double from geometry string: " << geometry_string; | 417 << " to double from geometry string: " << geometry_string; |
| 412 return geometry; | 418 return geometry; |
| 413 } | 419 } |
| 414 float_tokens.push_back(float_token); | 420 float_tokens.push_back(float_token); |
| 415 } | 421 } |
| 416 | 422 |
| 417 geometry.reserve(float_tokens.size() / 3); | 423 geometry.reserve(float_tokens.size() / 3); |
| 418 for (size_t i = 0; i < float_tokens.size(); i += 3) { | 424 for (size_t i = 0; i < float_tokens.size(); i += 3) { |
| 419 geometry.push_back(webrtc::Point(float_tokens[i + 0], float_tokens[i + 1], | 425 geometry.push_back(webrtc::Point(float_tokens[i + 0], float_tokens[i + 1], |
| 420 float_tokens[i + 2])); | 426 float_tokens[i + 2])); |
| 421 } | 427 } |
| 422 | 428 |
| 423 return geometry; | 429 return geometry; |
| 424 } | 430 } |
| 425 | 431 |
| 426 } // namespace content | 432 } // namespace content |
| OLD | NEW |