Index: content/renderer/media/media_stream_audio_processor.cc |
diff --git a/content/renderer/media/media_stream_audio_processor.cc b/content/renderer/media/media_stream_audio_processor.cc |
index c83ffff7eb408417dd9a641fc3c93f92a032119f..74c3294851780ed053ce28d351273806b899cea1 100644 |
--- a/content/renderer/media/media_stream_audio_processor.cc |
+++ b/content/renderer/media/media_stream_audio_processor.cc |
@@ -24,7 +24,6 @@ namespace content { |
namespace { |
using webrtc::AudioProcessing; |
-using webrtc::MediaConstraintsInterface; |
#if defined(OS_ANDROID) |
const int kAudioProcessingSampleRate = 16000; |
@@ -157,15 +156,14 @@ class MediaStreamAudioProcessor::MediaStreamAudioConverter |
MediaStreamAudioProcessor::MediaStreamAudioProcessor( |
const blink::WebMediaConstraints& constraints, |
int effects, |
- MediaStreamType type, |
WebRtcPlayoutDataSource* playout_data_source) |
: render_delay_ms_(0), |
playout_data_source_(playout_data_source), |
- audio_mirroring_(false), |
- typing_detected_(false) { |
+ goog_audio_mirroring_(false), |
+ goog_typing_detected_(false) { |
capture_thread_checker_.DetachFromThread(); |
render_thread_checker_.DetachFromThread(); |
- InitializeAudioProcessingModule(constraints, effects, type); |
+ InitializeAudioProcessingModule(constraints, effects); |
} |
MediaStreamAudioProcessor::~MediaStreamAudioProcessor() { |
@@ -193,7 +191,7 @@ void MediaStreamAudioProcessor::PushCaptureData(media::AudioBus* audio_source) { |
DCHECK_EQ(audio_source->frames(), |
capture_converter_->source_parameters().frames_per_buffer()); |
- if (audio_mirroring_ && |
+ if (goog_audio_mirroring_ && |
capture_converter_->source_parameters().channel_layout() == |
media::CHANNEL_LAYOUT_STEREO) { |
// Swap the first and second channels. |
@@ -271,73 +269,69 @@ void MediaStreamAudioProcessor::OnPlayoutDataSourceChanged() { |
void MediaStreamAudioProcessor::GetStats(AudioProcessorStats* stats) { |
stats->typing_noise_detected = |
- (base::subtle::Acquire_Load(&typing_detected_) != false); |
+ (base::subtle::Acquire_Load(&goog_typing_detected_) != false); |
GetAecStats(audio_processing_.get(), stats); |
} |
void MediaStreamAudioProcessor::InitializeAudioProcessingModule( |
- const blink::WebMediaConstraints& constraints, int effects, |
- MediaStreamType type) { |
+ const blink::WebMediaConstraints& constraints, int effects) { |
DCHECK(!audio_processing_); |
- RTCMediaConstraints native_constraints(constraints); |
+ MediaAudioConstraints audio_constraints(constraints, effects); |
+ DCHECK(audio_constraints.IsValid()); |
perkj_chrome
2014/04/14 12:15:19
I don't think you should crash if a user user inse
no longer working on chromium
2014/04/14 14:40:50
I was thinking WebRtcAudioCapture::Initialize() wi
|
// Audio mirroring can be enabled even though audio processing is otherwise |
// disabled. |
- audio_mirroring_ = GetPropertyFromConstraints( |
- &native_constraints, webrtc::MediaConstraintsInterface::kAudioMirroring); |
+ goog_audio_mirroring_ = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kGoogAudioMirroring); |
if (!IsAudioTrackProcessingEnabled()) { |
RecordProcessingState(AUDIO_PROCESSING_IN_WEBRTC); |
return; |
} |
- // Only apply the fixed constraints for gUM of MEDIA_DEVICE_AUDIO_CAPTURE. |
- DCHECK(IsAudioMediaType(type)); |
- if (type == MEDIA_DEVICE_AUDIO_CAPTURE) |
- ApplyFixedAudioConstraints(&native_constraints); |
- |
- if (effects & media::AudioParameters::ECHO_CANCELLER) { |
- // If platform echo canceller is enabled, disable the software AEC. |
- native_constraints.AddMandatory( |
- MediaConstraintsInterface::kEchoCancellation, |
- MediaConstraintsInterface::kValueFalse, true); |
+ // |kEchoCancellation| is used as a master control on enabling/disabling |
+ // the audio processing. |
+ const bool echo_cancellation = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kEchoCancellation); |
+ if (!echo_cancellation) { |
+ RecordProcessingState(AUDIO_PROCESSING_DISABLED); |
+ return; |
} |
#if defined(OS_IOS) |
// On iOS, VPIO provides built-in AEC and AGC. |
- const bool enable_aec = false; |
- const bool enable_agc = false; |
+ const bool goog_aec = false; |
+ const bool goog_agc = false; |
#else |
- const bool enable_aec = GetPropertyFromConstraints( |
- &native_constraints, MediaConstraintsInterface::kEchoCancellation); |
- const bool enable_agc = GetPropertyFromConstraints( |
- &native_constraints, webrtc::MediaConstraintsInterface::kAutoGainControl); |
+ // TODO(xians): goog_aec should be just echo_cancellation. |
+ const bool goog_aec = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kGoogEchoCancellation); |
+ const bool goog_agc = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kGoogAutoGainControl); |
#endif |
#if defined(OS_IOS) || defined(OS_ANDROID) |
- const bool enable_experimental_aec = false; |
- const bool enable_typing_detection = false; |
+ const bool goog_experimental_aec = false; |
+ const bool goog_typing_detection = false; |
#else |
- const bool enable_experimental_aec = GetPropertyFromConstraints( |
- &native_constraints, |
- MediaConstraintsInterface::kExperimentalEchoCancellation); |
- const bool enable_typing_detection = GetPropertyFromConstraints( |
- &native_constraints, MediaConstraintsInterface::kTypingNoiseDetection); |
+ const bool goog_experimental_aec = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kGoogExperimentalEchoCancellation); |
+ const bool goog_typing_detection = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kGoogTypingNoiseDetection); |
#endif |
- const bool enable_ns = GetPropertyFromConstraints( |
- &native_constraints, MediaConstraintsInterface::kNoiseSuppression); |
- const bool enable_experimental_ns = GetPropertyFromConstraints( |
- &native_constraints, |
- MediaConstraintsInterface::kExperimentalNoiseSuppression); |
- const bool enable_high_pass_filter = GetPropertyFromConstraints( |
- &native_constraints, MediaConstraintsInterface::kHighpassFilter); |
- |
- // Return immediately if no audio processing component is enabled. |
- if (!enable_aec && !enable_experimental_aec && !enable_ns && |
- !enable_high_pass_filter && !enable_typing_detection && !enable_agc && |
- !enable_experimental_ns) { |
+ const bool goog_ns = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kGoogNoiseSuppression); |
+ const bool goog_experimental_ns = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kGoogExperimentalNoiseSuppression); |
+ const bool goog_high_pass_filter = audio_constraints.GetProperty( |
+ MediaAudioConstraints::kGoogHighpassFilter); |
+ |
+ // Return immediately if no goog constraint is enabled. |
+ if (!goog_aec && !goog_experimental_aec && !goog_ns && |
+ !goog_high_pass_filter && !goog_typing_detection && |
+ !goog_agc && !goog_experimental_ns) { |
RecordProcessingState(AUDIO_PROCESSING_DISABLED); |
return; |
} |
@@ -346,32 +340,33 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule( |
audio_processing_.reset(webrtc::AudioProcessing::Create(0)); |
// Enable the audio processing components. |
- if (enable_aec) { |
+ if (goog_aec) { |
EnableEchoCancellation(audio_processing_.get()); |
- if (enable_experimental_aec) |
+ |
+ if (goog_experimental_aec) |
EnableExperimentalEchoCancellation(audio_processing_.get()); |
if (playout_data_source_) |
playout_data_source_->AddPlayoutSink(this); |
} |
- if (enable_ns) |
+ if (goog_ns) |
EnableNoiseSuppression(audio_processing_.get()); |
- if (enable_experimental_ns) |
+ if (goog_experimental_ns) |
EnableExperimentalNoiseSuppression(audio_processing_.get()); |
- if (enable_high_pass_filter) |
+ if (goog_high_pass_filter) |
EnableHighPassFilter(audio_processing_.get()); |
- if (enable_typing_detection) { |
+ if (goog_typing_detection) { |
// TODO(xians): Remove this |typing_detector_| after the typing suppression |
// is enabled by default. |
typing_detector_.reset(new webrtc::TypingDetection()); |
EnableTypingDetection(audio_processing_.get(), typing_detector_.get()); |
} |
- if (enable_agc) |
+ if (goog_agc) |
EnableAutomaticGainControl(audio_processing_.get()); |
// Configure the audio format the audio processing is running on. This |
@@ -488,7 +483,7 @@ int MediaStreamAudioProcessor::ProcessData(webrtc::AudioFrame* audio_frame, |
bool vad_active = |
(audio_frame->vad_activity_ == webrtc::AudioFrame::kVadActive); |
bool typing_detected = typing_detector_->Process(key_pressed, vad_active); |
- base::subtle::Release_Store(&typing_detected_, typing_detected); |
+ base::subtle::Release_Store(&goog_typing_detected_, typing_detected); |
} |
// Return 0 if the volume has not been changed, otherwise return the new |