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

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

Issue 1647773002: MediaStream audio sourcing: Bypass audio processing for non-WebRTC cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NOT FOR REVIEW -- This will be broken-up across multiple CLs. Created 4 years, 10 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 DCHECK(main_thread_checker_.CalledOnValidThread()); 421 DCHECK(main_thread_checker_.CalledOnValidThread());
422 if (audio_processing_) 422 if (audio_processing_)
423 StopEchoCancellationDump(audio_processing_.get()); 423 StopEchoCancellationDump(audio_processing_.get());
424 } 424 }
425 425
426 void MediaStreamAudioProcessor::OnIpcClosing() { 426 void MediaStreamAudioProcessor::OnIpcClosing() {
427 DCHECK(main_thread_checker_.CalledOnValidThread()); 427 DCHECK(main_thread_checker_.CalledOnValidThread());
428 aec_dump_message_filter_ = NULL; 428 aec_dump_message_filter_ = NULL;
429 } 429 }
430 430
431 // static
432 bool MediaStreamAudioProcessor::ShouldRouteAudioThroughProcessor(
433 const blink::WebMediaConstraints& constraints,
434 int effects_flags) {
435 // Note: This method should by kept in-sync with any changes to the logic in
436 // MediaStreamAudioProcessor::InitializeAudioProcessingModule().
437
438 const MediaAudioConstraints audio_constraints(constraints, effects_flags);
439
440 if (audio_constraints.GetProperty(MediaAudioConstraints::kGoogAudioMirroring))
441 return true;
442
443 #if !defined(OS_IOS)
444 if (audio_constraints.GetEchoCancellationProperty() ||
445 audio_constraints.GetProperty(
446 MediaAudioConstraints::kGoogAutoGainControl)) {
447 return true;
448 }
449 #endif
450
451 #if !defined(OS_IOS) && !defined(OS_ANDROID)
452 if (audio_constraints.GetProperty(
453 MediaAudioConstraints::kGoogExperimentalEchoCancellation) ||
454 audio_constraints.GetProperty(
455 MediaAudioConstraints::kGoogTypingNoiseDetection)) {
456 return true;
457 }
458 #endif
459
460 if (audio_constraints.GetProperty(
461 MediaAudioConstraints::kGoogNoiseSuppression) ||
462 audio_constraints.GetProperty(
463 MediaAudioConstraints::kGoogExperimentalNoiseSuppression) ||
464 audio_constraints.GetProperty(MediaAudioConstraints::kGoogBeamforming) ||
465 audio_constraints.GetProperty(
466 MediaAudioConstraints::kGoogHighpassFilter)) {
467 return true;
468 }
469
470 return false;
471 }
472
431 void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus, 473 void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus,
432 int sample_rate, 474 int sample_rate,
433 int audio_delay_milliseconds) { 475 int audio_delay_milliseconds) {
434 DCHECK(render_thread_checker_.CalledOnValidThread()); 476 DCHECK(render_thread_checker_.CalledOnValidThread());
435 #if defined(OS_ANDROID) || defined(OS_IOS) 477 #if defined(OS_ANDROID) || defined(OS_IOS)
436 DCHECK(audio_processing_->echo_control_mobile()->is_enabled()); 478 DCHECK(audio_processing_->echo_control_mobile()->is_enabled());
437 DCHECK(!audio_processing_->echo_cancellation()->is_enabled()); 479 DCHECK(!audio_processing_->echo_cancellation()->is_enabled());
438 #else 480 #else
439 DCHECK(!audio_processing_->echo_control_mobile()->is_enabled()); 481 DCHECK(!audio_processing_->echo_control_mobile()->is_enabled());
440 DCHECK(audio_processing_->echo_cancellation()->is_enabled()); 482 DCHECK(audio_processing_->echo_cancellation()->is_enabled());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 const bool goog_experimental_ns = audio_constraints.GetProperty( 557 const bool goog_experimental_ns = audio_constraints.GetProperty(
516 MediaAudioConstraints::kGoogExperimentalNoiseSuppression); 558 MediaAudioConstraints::kGoogExperimentalNoiseSuppression);
517 const bool goog_beamforming = audio_constraints.GetProperty( 559 const bool goog_beamforming = audio_constraints.GetProperty(
518 MediaAudioConstraints::kGoogBeamforming); 560 MediaAudioConstraints::kGoogBeamforming);
519 const bool goog_high_pass_filter = audio_constraints.GetProperty( 561 const bool goog_high_pass_filter = audio_constraints.GetProperty(
520 MediaAudioConstraints::kGoogHighpassFilter); 562 MediaAudioConstraints::kGoogHighpassFilter);
521 // Return immediately if no goog constraint is enabled. 563 // Return immediately if no goog constraint is enabled.
522 if (!echo_cancellation && !goog_experimental_aec && !goog_ns && 564 if (!echo_cancellation && !goog_experimental_aec && !goog_ns &&
523 !goog_high_pass_filter && !goog_typing_detection && 565 !goog_high_pass_filter && !goog_typing_detection &&
524 !goog_agc && !goog_experimental_ns && !goog_beamforming) { 566 !goog_agc && !goog_experimental_ns && !goog_beamforming) {
567 // Ensure ShouldRouteAudioThroughProcessor() is kept in-sync with all of the
568 // above logic.
569 DCHECK_EQ(audio_mirroring_, ShouldRouteAudioThroughProcessor(
570 constraints, input_params.effects));
525 RecordProcessingState(AUDIO_PROCESSING_DISABLED); 571 RecordProcessingState(AUDIO_PROCESSING_DISABLED);
526 return; 572 return;
573 } else {
574 // Ensure ShouldRouteAudioThroughProcessor() is kept in-sync with all of the
575 // above logic.
576 DCHECK(ShouldRouteAudioThroughProcessor(constraints, input_params.effects));
527 } 577 }
528 578
529 // Experimental options provided at creation. 579 // Experimental options provided at creation.
530 webrtc::Config config; 580 webrtc::Config config;
531 config.Set<webrtc::ExtendedFilter>( 581 config.Set<webrtc::ExtendedFilter>(
532 new webrtc::ExtendedFilter(goog_experimental_aec)); 582 new webrtc::ExtendedFilter(goog_experimental_aec));
533 config.Set<webrtc::ExperimentalNs>( 583 config.Set<webrtc::ExperimentalNs>(
534 new webrtc::ExperimentalNs(goog_experimental_ns)); 584 new webrtc::ExperimentalNs(goog_experimental_ns));
535 if (IsDelayAgnosticAecEnabled()) 585 if (IsDelayAgnosticAecEnabled())
536 config.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(true)); 586 config.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(true));
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 if (echo_information_) { 797 if (echo_information_) {
748 echo_information_.get()->UpdateAecDelayStats(ap->echo_cancellation()); 798 echo_information_.get()->UpdateAecDelayStats(ap->echo_cancellation());
749 } 799 }
750 800
751 // Return 0 if the volume hasn't been changed, and otherwise the new volume. 801 // Return 0 if the volume hasn't been changed, and otherwise the new volume.
752 return (agc->stream_analog_level() == volume) ? 802 return (agc->stream_analog_level() == volume) ?
753 0 : agc->stream_analog_level(); 803 0 : agc->stream_analog_level();
754 } 804 }
755 805
756 } // namespace content 806 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_processor.h ('k') | content/renderer/media/media_stream_audio_sink_owner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698