| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 #if defined(OS_ANDROID) | 473 #if defined(OS_ANDROID) |
| 474 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; | 474 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; |
| 475 #else | 475 #else |
| 476 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; | 476 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; |
| 477 #endif | 477 #endif |
| 478 int err = audio_processing->gain_control()->set_mode(mode); | 478 int err = audio_processing->gain_control()->set_mode(mode); |
| 479 err |= audio_processing->gain_control()->Enable(true); | 479 err |= audio_processing->gain_control()->Enable(true); |
| 480 CHECK_EQ(err, 0); | 480 CHECK_EQ(err, 0); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void GetAecStats(webrtc::EchoCancellation* echo_cancellation, | 483 void GetAudioProcessingStats( |
| 484 webrtc::AudioProcessorInterface::AudioProcessorStats* stats) { | 484 AudioProcessing* audio_processing, |
| 485 // These values can take on valid negative values, so use the lowest possible | 485 webrtc::AudioProcessorInterface::AudioProcessorStats* stats) { |
| 486 // level as default rather than -1. | 486 // TODO(ivoc): Change the APM stats to use rtc::Optional instead of default |
| 487 stats->echo_return_loss = -100; | 487 // values. |
| 488 stats->echo_return_loss_enhancement = -100; | 488 auto apm_stats = audio_processing->GetStatistics(); |
| 489 stats->echo_return_loss = apm_stats.echo_return_loss.instant(); |
| 490 stats->echo_return_loss_enhancement = |
| 491 apm_stats.echo_return_loss_enhancement.instant(); |
| 492 stats->aec_divergent_filter_fraction = apm_stats.divergent_filter_fraction; |
| 489 | 493 |
| 490 // The median value can also be negative, but in practice -1 is only used to | 494 stats->echo_delay_median_ms = apm_stats.delay_median; |
| 491 // signal insufficient data, since the resolution is limited to multiples | 495 stats->echo_delay_std_ms = apm_stats.delay_standard_deviation; |
| 492 // of 4ms. | |
| 493 stats->echo_delay_median_ms = -1; | |
| 494 stats->echo_delay_std_ms = -1; | |
| 495 | 496 |
| 496 // TODO(ajm): Re-enable this metric once we have a reliable implementation. | 497 stats->residual_echo_likelihood = apm_stats.residual_echo_likelihood; |
| 497 stats->aec_quality_min = -1.0f; | |
| 498 | |
| 499 if (!echo_cancellation->are_metrics_enabled() || | |
| 500 !echo_cancellation->is_delay_logging_enabled() || | |
| 501 !echo_cancellation->is_enabled()) { | |
| 502 return; | |
| 503 } | |
| 504 | |
| 505 // TODO(ajm): we may want to use VoECallReport::GetEchoMetricsSummary | |
| 506 // here, but it appears to be unsuitable currently. Revisit after this is | |
| 507 // investigated: http://b/issue?id=5666755 | |
| 508 webrtc::EchoCancellation::Metrics echo_metrics; | |
| 509 if (!echo_cancellation->GetMetrics(&echo_metrics)) { | |
| 510 stats->echo_return_loss = echo_metrics.echo_return_loss.instant; | |
| 511 stats->echo_return_loss_enhancement = | |
| 512 echo_metrics.echo_return_loss_enhancement.instant; | |
| 513 stats->aec_divergent_filter_fraction = | |
| 514 echo_metrics.divergent_filter_fraction; | |
| 515 } | |
| 516 | |
| 517 int median = 0, std = 0; | |
| 518 float dummy = 0; | |
| 519 if (echo_cancellation->GetDelayMetrics(&median, &std, &dummy) == | |
| 520 webrtc::AudioProcessing::kNoError) { | |
| 521 stats->echo_delay_median_ms = median; | |
| 522 stats->echo_delay_std_ms = std; | |
| 523 } | |
| 524 } | 498 } |
| 525 | 499 |
| 526 std::vector<webrtc::Point> GetArrayGeometryPreferringConstraints( | 500 std::vector<webrtc::Point> GetArrayGeometryPreferringConstraints( |
| 527 const MediaAudioConstraints& audio_constraints, | 501 const MediaAudioConstraints& audio_constraints, |
| 528 const MediaStreamDevice::AudioDeviceParameters& input_params) { | 502 const MediaStreamDevice::AudioDeviceParameters& input_params) { |
| 529 const std::string constraints_geometry = | 503 const std::string constraints_geometry = |
| 530 audio_constraints.GetGoogArrayGeometry(); | 504 audio_constraints.GetGoogArrayGeometry(); |
| 531 | 505 |
| 532 // Give preference to the audio constraint over the device-supplied mic | 506 // Give preference to the audio constraint over the device-supplied mic |
| 533 // positions. This is mainly for testing purposes. | 507 // positions. This is mainly for testing purposes. |
| 534 return WebrtcPointsFromMediaPoints( | 508 return WebrtcPointsFromMediaPoints( |
| 535 constraints_geometry.empty() | 509 constraints_geometry.empty() |
| 536 ? input_params.mic_positions | 510 ? input_params.mic_positions |
| 537 : media::ParsePointsFromString(constraints_geometry)); | 511 : media::ParsePointsFromString(constraints_geometry)); |
| 538 } | 512 } |
| 539 | 513 |
| 540 } // namespace content | 514 } // namespace content |
| OLD | NEW |