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

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

Issue 795793003: Added a chrome flag to enable Delay Agnostic AEC in WebRTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « content/public/common/content_switches.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | 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.h" 5 #include "content/renderer/media/media_stream_audio_processor.h"
6 6
7 #include "base/command_line.h"
7 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
8 #if defined(OS_MACOSX)
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #endif
11 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "content/public/common/content_switches.h"
12 #include "content/renderer/media/media_stream_audio_processor_options.h" 12 #include "content/renderer/media/media_stream_audio_processor_options.h"
13 #include "content/renderer/media/rtc_media_constraints.h" 13 #include "content/renderer/media/rtc_media_constraints.h"
14 #include "content/renderer/media/webrtc_audio_device_impl.h" 14 #include "content/renderer/media/webrtc_audio_device_impl.h"
15 #include "media/audio/audio_parameters.h" 15 #include "media/audio/audio_parameters.h"
16 #include "media/base/audio_converter.h" 16 #include "media/base/audio_converter.h"
17 #include "media/base/audio_fifo.h" 17 #include "media/base/audio_fifo.h"
18 #include "media/base/channel_layout.h" 18 #include "media/base/channel_layout.h"
19 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 19 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
20 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h" 20 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h"
21 #include "third_party/webrtc/modules/audio_processing/typing_detection.h" 21 #include "third_party/webrtc/modules/audio_processing/typing_detection.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 AUDIO_PROCESSING_DISABLED, 70 AUDIO_PROCESSING_DISABLED,
71 AUDIO_PROCESSING_IN_WEBRTC, 71 AUDIO_PROCESSING_IN_WEBRTC,
72 AUDIO_PROCESSING_MAX 72 AUDIO_PROCESSING_MAX
73 }; 73 };
74 74
75 void RecordProcessingState(AudioTrackProcessingStates state) { 75 void RecordProcessingState(AudioTrackProcessingStates state) {
76 UMA_HISTOGRAM_ENUMERATION("Media.AudioTrackProcessingStates", 76 UMA_HISTOGRAM_ENUMERATION("Media.AudioTrackProcessingStates",
77 state, AUDIO_PROCESSING_MAX); 77 state, AUDIO_PROCESSING_MAX);
78 } 78 }
79 79
80 bool isDelayAgnosticAecEnabled() {
81 // Note: It's important to query the field trial state first, to ensure that
82 // UMA reports the correct group.
83 const std::string group_name =
84 base::FieldTrialList::FindFullName("NoReportedDelayOnMac");
85 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
86 if (command_line->HasSwitch(switches::kEnableDelayAgnosticAec))
87 return true;
88
89 return (!group_name.empty() && group_name == "Enabled");
90 }
80 } // namespace 91 } // namespace
81 92
82 // Wraps AudioBus to provide access to the array of channel pointers, since this 93 // Wraps AudioBus to provide access to the array of channel pointers, since this
83 // is the type webrtc::AudioProcessing deals in. The array is refreshed on every 94 // is the type webrtc::AudioProcessing deals in. The array is refreshed on every
84 // channel_ptrs() call, and will be valid until the underlying AudioBus pointers 95 // channel_ptrs() call, and will be valid until the underlying AudioBus pointers
85 // are changed, e.g. through calls to SetChannelData() or SwapChannels(). 96 // are changed, e.g. through calls to SetChannelData() or SwapChannels().
86 // 97 //
87 // All methods are called on one of the capture or render audio threads 98 // All methods are called on one of the capture or render audio threads
88 // exclusively. 99 // exclusively.
89 class MediaStreamAudioBus { 100 class MediaStreamAudioBus {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 RecordProcessingState(AUDIO_PROCESSING_DISABLED); 472 RecordProcessingState(AUDIO_PROCESSING_DISABLED);
462 return; 473 return;
463 } 474 }
464 475
465 // Experimental options provided at creation. 476 // Experimental options provided at creation.
466 webrtc::Config config; 477 webrtc::Config config;
467 if (goog_experimental_aec) 478 if (goog_experimental_aec)
468 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); 479 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true));
469 if (goog_experimental_ns) 480 if (goog_experimental_ns)
470 config.Set<webrtc::ExperimentalNs>(new webrtc::ExperimentalNs(true)); 481 config.Set<webrtc::ExperimentalNs>(new webrtc::ExperimentalNs(true));
471 #if defined(OS_MACOSX) 482 if (isDelayAgnosticAecEnabled())
472 if (base::FieldTrialList::FindFullName("NoReportedDelayOnMac") == "Enabled")
473 config.Set<webrtc::ReportedDelay>(new webrtc::ReportedDelay(false)); 483 config.Set<webrtc::ReportedDelay>(new webrtc::ReportedDelay(false));
474 #endif
475 if (goog_beamforming) { 484 if (goog_beamforming) {
476 ConfigureBeamforming(&config); 485 ConfigureBeamforming(&config);
477 } 486 }
478 487
479 // Create and configure the webrtc::AudioProcessing. 488 // Create and configure the webrtc::AudioProcessing.
480 audio_processing_.reset(webrtc::AudioProcessing::Create(config)); 489 audio_processing_.reset(webrtc::AudioProcessing::Create(config));
481 490
482 // Enable the audio processing components. 491 // Enable the audio processing components.
483 if (echo_cancellation) { 492 if (echo_cancellation) {
484 EnableEchoCancellation(audio_processing_.get()); 493 EnableEchoCancellation(audio_processing_.get());
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 vad->stream_has_voice()); 679 vad->stream_has_voice());
671 base::subtle::Release_Store(&typing_detected_, detected); 680 base::subtle::Release_Store(&typing_detected_, detected);
672 } 681 }
673 682
674 // Return 0 if the volume hasn't been changed, and otherwise the new volume. 683 // Return 0 if the volume hasn't been changed, and otherwise the new volume.
675 return (agc->stream_analog_level() == volume) ? 684 return (agc->stream_analog_level() == volume) ?
676 0 : agc->stream_analog_level(); 685 0 : agc->stream_analog_level();
677 } 686 }
678 687
679 } // namespace content 688 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698