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

Side by Side Diff: content/renderer/media/media_stream_audio_processor_options.cc

Issue 2527193002: Use the new interface to get APM stats (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « content/renderer/media/media_stream_audio_processor_options.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 auto apm_stats = audio_processing->GetStatistics();
487 stats->echo_return_loss = -100; 487 stats->echo_return_loss = apm_stats.echo_return_loss.instant();
488 stats->echo_return_loss_enhancement = -100; 488 stats->echo_return_loss_enhancement =
489 apm_stats.echo_return_loss_enhancement.instant();
hbos_chromium 2016/11/25 10:04:05 The new stats collector is only concerned with ech
Ivo-OOO until feb 6 2016/11/25 10:40:44 These are in exactly the same units, in fact the a
hbos_chromium 2016/11/25 12:51:39 Acknowledged.
490 stats->aec_divergent_filter_fraction = apm_stats.divergent_filter_fraction;
489 491
490 // The median value can also be negative, but in practice -1 is only used to 492 stats->echo_delay_median_ms = apm_stats.delay_median;
491 // signal insufficient data, since the resolution is limited to multiples 493 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 494
496 // TODO(ajm): Re-enable this metric once we have a reliable implementation. 495 stats->residual_echo_likelihood = apm_stats.residual_echo_likelihood;
497 stats->aec_quality_min = -1.0f;
hbos_chromium 2016/11/25 10:04:05 I think that defaulting values to negative, whethe
Ivo-OOO until feb 6 2016/11/25 10:40:44 I agree that this way of using default values is n
hbos_chromium 2016/11/25 12:51:39 That's fine, add a TODO comment? :)
Ivo-OOO until feb 6 2016/11/25 13:22:19 Done.
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 } 496 }
525 497
526 std::vector<webrtc::Point> GetArrayGeometryPreferringConstraints( 498 std::vector<webrtc::Point> GetArrayGeometryPreferringConstraints(
527 const MediaAudioConstraints& audio_constraints, 499 const MediaAudioConstraints& audio_constraints,
528 const MediaStreamDevice::AudioDeviceParameters& input_params) { 500 const MediaStreamDevice::AudioDeviceParameters& input_params) {
529 const std::string constraints_geometry = 501 const std::string constraints_geometry =
530 audio_constraints.GetGoogArrayGeometry(); 502 audio_constraints.GetGoogArrayGeometry();
531 503
532 // Give preference to the audio constraint over the device-supplied mic 504 // Give preference to the audio constraint over the device-supplied mic
533 // positions. This is mainly for testing purposes. 505 // positions. This is mainly for testing purposes.
534 return WebrtcPointsFromMediaPoints( 506 return WebrtcPointsFromMediaPoints(
535 constraints_geometry.empty() 507 constraints_geometry.empty()
536 ? input_params.mic_positions 508 ? input_params.mic_positions
537 : media::ParsePointsFromString(constraints_geometry)); 509 : media::ParsePointsFromString(constraints_geometry));
538 } 510 }
539 511
540 } // namespace content 512 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_processor_options.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698