diff options
author | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-23 08:08:42 +0000 |
---|---|---|
committer | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-23 08:08:42 +0000 |
commit | 5b2970282b80f36849d822886eb8ad41f78a2056 (patch) | |
tree | a9b6b1a82d7a898fc75ea986096a04dbde7b85ea /content/renderer/media | |
parent | 64194c83b422f3cab5b699221db2e44249b241d8 (diff) | |
download | chromium_src-5b2970282b80f36849d822886eb8ad41f78a2056.zip chromium_src-5b2970282b80f36849d822886eb8ad41f78a2056.tar.gz chromium_src-5b2970282b80f36849d822886eb8ad41f78a2056.tar.bz2 |
Do not provide the input level if the APM is not enabled in Chrome.
NOTRY=true
BUG=365616
TEST=content_unittests --gtest_filter=*GetSignalLevel*"
Review URL: https://codereview.chromium.org/247183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265564 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/media')
5 files changed, 34 insertions, 10 deletions
diff --git a/content/renderer/media/media_stream_audio_processor.cc b/content/renderer/media/media_stream_audio_processor.cc index aaa1138..9532eb3 100644 --- a/content/renderer/media/media_stream_audio_processor.cc +++ b/content/renderer/media/media_stream_audio_processor.cc @@ -155,6 +155,13 @@ class MediaStreamAudioProcessor::MediaStreamAudioConverter scoped_ptr<media::AudioFifo> fifo_; }; +bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() { + const std::string group_name = + base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); + return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableAudioTrackProcessing); +} + MediaStreamAudioProcessor::MediaStreamAudioProcessor( const blink::WebMediaConstraints& constraints, int effects, @@ -508,11 +515,4 @@ void MediaStreamAudioProcessor::StopAudioProcessing() { audio_processing_.reset(); } -bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const { - const std::string group_name = - base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); - return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableAudioTrackProcessing); -} - } // namespace content diff --git a/content/renderer/media/media_stream_audio_processor.h b/content/renderer/media/media_stream_audio_processor.h index 0c80514..73bf234 100644 --- a/content/renderer/media/media_stream_audio_processor.h +++ b/content/renderer/media/media_stream_audio_processor.h @@ -47,6 +47,10 @@ class CONTENT_EXPORT MediaStreamAudioProcessor : NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink), NON_EXPORTED_BASE(public AudioProcessorInterface) { public: + // Returns true if |kEnableAudioTrackProcessing| is on or if the + // |MediaStreamAudioTrackProcessing| finch experiment is enabled. + static bool IsAudioTrackProcessingEnabled(); + // |playout_data_source| is used to register this class as a sink to the // WebRtc playout data for processing AEC. If clients do not enable AEC, // |playout_data_source| won't be used. @@ -85,8 +89,6 @@ class CONTENT_EXPORT MediaStreamAudioProcessor : int* new_volume, int16** out); - bool IsAudioTrackProcessingEnabled() const; - // The audio format of the input to the processor. const media::AudioParameters& InputFormat() const; diff --git a/content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc b/content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc index b1bde99..95958a8 100644 --- a/content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc +++ b/content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc @@ -86,6 +86,14 @@ void WebRtcLocalAudioTrackAdapter::RemoveSink( bool WebRtcLocalAudioTrackAdapter::GetSignalLevel(int* level) { base::AutoLock auto_lock(lock_); + // It is required to provide the signal level after audio processing. In + // case the audio processing is not enabled for the track, we return + // false here in order not to overwrite the value from WebRTC. + // TODO(xians): Remove this after we turn on the APM in Chrome by default. + // http://crbug/365672 . + if (!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) + return false; + *level = signal_level_; return true; } diff --git a/content/renderer/media/webrtc/webrtc_local_audio_track_adapter_unittest.cc b/content/renderer/media/webrtc/webrtc_local_audio_track_adapter_unittest.cc index 4fe1eaf..d798b31 100644 --- a/content/renderer/media/webrtc/webrtc_local_audio_track_adapter_unittest.cc +++ b/content/renderer/media/webrtc/webrtc_local_audio_track_adapter_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/command_line.h" +#include "content/public/common/content_switches.h" #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" #include "content/renderer/media/webrtc_local_audio_track.h" #include "testing/gmock/include/gmock/gmock.h" @@ -79,4 +81,16 @@ TEST_F(WebRtcLocalAudioTrackAdapterTest, AddAndRemoveSink) { track_->Capture(data.get(), base::TimeDelta(), 255, false, false); } +TEST_F(WebRtcLocalAudioTrackAdapterTest, GetSignalLevel) { + webrtc::AudioTrackInterface* webrtc_track = + static_cast<webrtc::AudioTrackInterface*>(adapter_.get()); + int signal_level = 0; + EXPECT_FALSE(webrtc_track->GetSignalLevel(&signal_level)); + + // Enable the audio processing in the audio track. + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableAudioTrackProcessing); + EXPECT_TRUE(webrtc_track->GetSignalLevel(&signal_level)); +} + } // namespace content diff --git a/content/renderer/media/webrtc_audio_capturer.cc b/content/renderer/media/webrtc_audio_capturer.cc index 5169c27..4b14af7 100644 --- a/content/renderer/media/webrtc_audio_capturer.cc +++ b/content/renderer/media/webrtc_audio_capturer.cc @@ -485,7 +485,7 @@ void WebRtcAudioCapturer::Capture(media::AudioBus* audio_source, // Note that, we turn off the audio processing in PeerConnection if the // processor has already processed the data. need_audio_processing = need_audio_processing_ ? - !audio_processor_->IsAudioTrackProcessingEnabled() : false; + !MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() : false; } DCHECK(audio_processor_->InputFormat().IsValid()); |