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

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

Issue 2801853005: Create a private API for controlling WebRTC's AEC3 (Closed)
Patch Set: After grunell and devlin Created 3 years, 8 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 else 479 else
480 file.Close(); 480 file.Close();
481 } 481 }
482 482
483 void MediaStreamAudioProcessor::OnDisableAecDump() { 483 void MediaStreamAudioProcessor::OnDisableAecDump() {
484 DCHECK(main_thread_runner_->BelongsToCurrentThread()); 484 DCHECK(main_thread_runner_->BelongsToCurrentThread());
485 if (audio_processing_) 485 if (audio_processing_)
486 StopEchoCancellationDump(audio_processing_.get()); 486 StopEchoCancellationDump(audio_processing_.get());
487 } 487 }
488 488
489 void MediaStreamAudioProcessor::OnAec3Enable(bool enable) {
490 DCHECK(main_thread_runner_->BelongsToCurrentThread());
491 if (override_aec3_ == enable)
492 return;
493
494 override_aec3_ = enable;
495 if (!has_echo_cancellation_)
Henrik Grunell 2017/04/11 10:12:43 |has_echo_cancellation_| is not initialized in the
hlundin-chromium 2017/04/11 12:40:11 Done. It was unconditionally initialized from the
496 return;
497
498 auto apm_config = audio_processing_->GetConfig();
499 if (apm_config.echo_canceller3.enabled == enable)
500 return;
501
502 apm_config.echo_canceller3.enabled = enable;
503 audio_processing_->ApplyConfig(apm_config);
504 DCHECK(echo_information_);
505 echo_information_.reset(new EchoInformation());
506 }
507
489 void MediaStreamAudioProcessor::OnIpcClosing() { 508 void MediaStreamAudioProcessor::OnIpcClosing() {
490 DCHECK(main_thread_runner_->BelongsToCurrentThread()); 509 DCHECK(main_thread_runner_->BelongsToCurrentThread());
491 aec_dump_message_filter_ = NULL; 510 aec_dump_message_filter_ = NULL;
492 } 511 }
493 512
494 // static 513 // static
495 bool MediaStreamAudioProcessor::WouldModifyAudio( 514 bool MediaStreamAudioProcessor::WouldModifyAudio(
496 const blink::WebMediaConstraints& constraints, 515 const blink::WebMediaConstraints& constraints,
497 int effects_flags) { 516 int effects_flags) {
498 // Note: This method should by kept in-sync with any changes to the logic in 517 // Note: This method should by kept in-sync with any changes to the logic in
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 608
590 MediaAudioConstraints audio_constraints(constraints, input_params.effects); 609 MediaAudioConstraints audio_constraints(constraints, input_params.effects);
591 610
592 // Note: The audio mirroring constraint (i.e., swap left and right channels) 611 // Note: The audio mirroring constraint (i.e., swap left and right channels)
593 // is handled within this MediaStreamAudioProcessor and does not, by itself, 612 // is handled within this MediaStreamAudioProcessor and does not, by itself,
594 // require webrtc::AudioProcessing. 613 // require webrtc::AudioProcessing.
595 audio_mirroring_ = audio_constraints.GetGoogAudioMirroring(); 614 audio_mirroring_ = audio_constraints.GetGoogAudioMirroring();
596 615
597 const bool echo_cancellation = 616 const bool echo_cancellation =
598 audio_constraints.GetEchoCancellationProperty(); 617 audio_constraints.GetEchoCancellationProperty();
618 has_echo_cancellation_ = echo_cancellation;
599 const bool goog_agc = audio_constraints.GetGoogAutoGainControl(); 619 const bool goog_agc = audio_constraints.GetGoogAutoGainControl();
600 620
601 #if defined(OS_ANDROID) 621 #if defined(OS_ANDROID)
602 const bool goog_experimental_aec = false; 622 const bool goog_experimental_aec = false;
603 const bool goog_typing_detection = false; 623 const bool goog_typing_detection = false;
604 #else 624 #else
605 const bool goog_experimental_aec = 625 const bool goog_experimental_aec =
606 audio_constraints.GetGoogExperimentalEchoCancellation(); 626 audio_constraints.GetGoogExperimentalEchoCancellation();
607 const bool goog_typing_detection = 627 const bool goog_typing_detection =
608 audio_constraints.GetGoogTypingNoiseDetection(); 628 audio_constraints.GetGoogTypingNoiseDetection();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 playout_data_source_->AddPlayoutSink(this); 692 playout_data_source_->AddPlayoutSink(this);
673 } 693 }
674 694
675 if (echo_cancellation) { 695 if (echo_cancellation) {
676 EnableEchoCancellation(audio_processing_.get()); 696 EnableEchoCancellation(audio_processing_.get());
677 697
678 // Prepare for logging echo information. If there are data remaining in 698 // Prepare for logging echo information. If there are data remaining in
679 // |echo_information_| we simply discard it. 699 // |echo_information_| we simply discard it.
680 echo_information_.reset(new EchoInformation()); 700 echo_information_.reset(new EchoInformation());
681 701
682 apm_config.echo_canceller3.enabled = 702 apm_config.echo_canceller3.enabled = override_aec3_.value_or(
683 base::FeatureList::IsEnabled(features::kWebRtcUseEchoCanceller3); 703 base::FeatureList::IsEnabled(features::kWebRtcUseEchoCanceller3));
684 } else { 704 } else {
685 apm_config.echo_canceller3.enabled = false; 705 apm_config.echo_canceller3.enabled = false;
686 } 706 }
687 707
688 if (goog_ns) { 708 if (goog_ns) {
689 // The beamforming postfilter is effective at suppressing stationary noise, 709 // The beamforming postfilter is effective at suppressing stationary noise,
690 // so reduce the single-channel NS aggressiveness when enabled. 710 // so reduce the single-channel NS aggressiveness when enabled.
691 const NoiseSuppression::Level ns_level = 711 const NoiseSuppression::Level ns_level =
692 config.Get<webrtc::Beamforming>().enabled ? NoiseSuppression::kLow 712 config.Get<webrtc::Beamforming>().enabled ? NoiseSuppression::kLow
693 : NoiseSuppression::kHigh; 713 : NoiseSuppression::kHigh;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 0 : agc->stream_analog_level(); 890 0 : agc->stream_analog_level();
871 } 891 }
872 892
873 void MediaStreamAudioProcessor::UpdateAecStats() { 893 void MediaStreamAudioProcessor::UpdateAecStats() {
874 DCHECK(main_thread_runner_->BelongsToCurrentThread()); 894 DCHECK(main_thread_runner_->BelongsToCurrentThread());
875 if (echo_information_) 895 if (echo_information_)
876 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); 896 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation());
877 } 897 }
878 898
879 } // namespace content 899 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_processor.h ('k') | content/renderer/media/media_stream_audio_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698