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

Unified Diff: content/renderer/media/media_stream_audio_processor.cc

Issue 2219933003: Use LocalMediaStreamAudioSource for screen-casting use cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments on patch set 1 (mostly rewrote comments). Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
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 9b8eaf35ffc0b438b550a88999166fd3653e47ea..428e12054e0374eeec8f478c63a2fcc1ca0a9b38 100644
--- a/content/renderer/media/media_stream_audio_processor.cc
+++ b/content/renderer/media/media_stream_audio_processor.cc
@@ -449,6 +449,42 @@ void MediaStreamAudioProcessor::OnIpcClosing() {
aec_dump_message_filter_ = NULL;
}
+// static
+bool MediaStreamAudioProcessor::WouldModifyAudio(
+ const blink::WebMediaConstraints& constraints,
+ int effects_flags) {
+ // Note: This method should by kept in-sync with any changes to the logic in
+ // MediaStreamAudioProcessor::InitializeAudioProcessingModule().
+
+ const MediaAudioConstraints audio_constraints(constraints, effects_flags);
+
+ if (audio_constraints.GetGoogAudioMirroring())
+ return true;
+
+#if !defined(OS_IOS)
+ if (audio_constraints.GetEchoCancellationProperty() ||
+ audio_constraints.GetGoogAutoGainControl()) {
+ return true;
+ }
+#endif
+
+#if !defined(OS_IOS) && !defined(OS_ANDROID)
+ if (audio_constraints.GetGoogExperimentalEchoCancellation() ||
+ audio_constraints.GetGoogTypingNoiseDetection()) {
+ return true;
+ }
+#endif
+
+ if (audio_constraints.GetGoogNoiseSuppression() ||
+ audio_constraints.GetGoogExperimentalNoiseSuppression() ||
+ audio_constraints.GetGoogBeamforming() ||
+ audio_constraints.GetGoogHighpassFilter()) {
+ return true;
+ }
+
+ return false;
+}
+
void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus,
int sample_rate,
int audio_delay_milliseconds) {
@@ -511,8 +547,9 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
MediaAudioConstraints audio_constraints(constraints, input_params.effects);
- // Audio mirroring can be enabled even though audio processing is otherwise
- // disabled.
+ // Note: The audio mirroring constraint (i.e., swap left and right channels)
+ // is handled within this MediaStreamAudioProcessor and does not, by itself,
+ // require webrtc::AudioProcessing.
audio_mirroring_ = audio_constraints.GetGoogAudioMirroring();
const bool echo_cancellation =
@@ -534,14 +571,24 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
audio_constraints.GetGoogExperimentalNoiseSuppression();
const bool goog_beamforming = audio_constraints.GetGoogBeamforming();
const bool goog_high_pass_filter = audio_constraints.GetGoogHighpassFilter();
- // Return immediately if no goog constraint is enabled.
+
+ // Return immediately if none of the goog constraints requiring
+ // webrtc::AudioProcessing are enabled.
if (!echo_cancellation && !goog_experimental_aec && !goog_ns &&
!goog_high_pass_filter && !goog_typing_detection &&
!goog_agc && !goog_experimental_ns && !goog_beamforming) {
+ // Sanity-check: WouldModifyAudio() should return true iff
+ // |audio_mirroring_| is true.
+ DCHECK_EQ(audio_mirroring_, WouldModifyAudio(constraints,
+ input_params.effects));
RecordProcessingState(AUDIO_PROCESSING_DISABLED);
return;
}
+ // Sanity-check: WouldModifyAudio() should return true because the above logic
+ // has determined webrtc::AudioProcessing will be used.
+ DCHECK(WouldModifyAudio(constraints, input_params.effects));
+
// Experimental options provided at creation.
webrtc::Config config;
config.Set<webrtc::ExtendedFilter>(

Powered by Google App Engine
This is Rietveld 408576698