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

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: 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_ != base::Optional<bool>(enable)) {
Henrik Grunell 2017/04/10 08:13:28 Early returns instead in this function, e.g. if (
hlundin-chromium 2017/04/10 10:10:16 Done.
492 override_aec3_ = base::Optional<bool>(enable);
493 if (has_echo_cancellation_) {
494 DCHECK(audio_processing_);
Henrik Grunell 2017/04/10 08:13:28 Remove (redundant). It will crash on the next line
hlundin-chromium 2017/04/10 10:10:16 Done.
495 auto apm_config = audio_processing_->GetConfig();
496 if (apm_config.echo_canceller3.enabled != enable) {
497 apm_config.echo_canceller3.enabled = enable;
Henrik Grunell 2017/04/10 08:13:28 I'm not sure how this is supposed to work. If not
hlundin-chromium 2017/04/10 10:10:16 If not overridden, it will already be at the value
Henrik Grunell 2017/04/10 12:33:47 I realized that it can never be un-overridden. Set
498 audio_processing_->ApplyConfig(apm_config);
499 DCHECK(echo_information_);
500 echo_information_.reset(new EchoInformation());
501 }
502 }
503 }
504 }
505
489 void MediaStreamAudioProcessor::OnIpcClosing() { 506 void MediaStreamAudioProcessor::OnIpcClosing() {
490 DCHECK(main_thread_runner_->BelongsToCurrentThread()); 507 DCHECK(main_thread_runner_->BelongsToCurrentThread());
491 aec_dump_message_filter_ = NULL; 508 aec_dump_message_filter_ = NULL;
492 } 509 }
493 510
494 // static 511 // static
495 bool MediaStreamAudioProcessor::WouldModifyAudio( 512 bool MediaStreamAudioProcessor::WouldModifyAudio(
496 const blink::WebMediaConstraints& constraints, 513 const blink::WebMediaConstraints& constraints,
497 int effects_flags) { 514 int effects_flags) {
498 // Note: This method should by kept in-sync with any changes to the logic in 515 // 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 606
590 MediaAudioConstraints audio_constraints(constraints, input_params.effects); 607 MediaAudioConstraints audio_constraints(constraints, input_params.effects);
591 608
592 // Note: The audio mirroring constraint (i.e., swap left and right channels) 609 // Note: The audio mirroring constraint (i.e., swap left and right channels)
593 // is handled within this MediaStreamAudioProcessor and does not, by itself, 610 // is handled within this MediaStreamAudioProcessor and does not, by itself,
594 // require webrtc::AudioProcessing. 611 // require webrtc::AudioProcessing.
595 audio_mirroring_ = audio_constraints.GetGoogAudioMirroring(); 612 audio_mirroring_ = audio_constraints.GetGoogAudioMirroring();
596 613
597 const bool echo_cancellation = 614 const bool echo_cancellation =
598 audio_constraints.GetEchoCancellationProperty(); 615 audio_constraints.GetEchoCancellationProperty();
616 has_echo_cancellation_ = echo_cancellation;
599 const bool goog_agc = audio_constraints.GetGoogAutoGainControl(); 617 const bool goog_agc = audio_constraints.GetGoogAutoGainControl();
600 618
601 #if defined(OS_ANDROID) 619 #if defined(OS_ANDROID)
602 const bool goog_experimental_aec = false; 620 const bool goog_experimental_aec = false;
603 const bool goog_typing_detection = false; 621 const bool goog_typing_detection = false;
604 #else 622 #else
605 const bool goog_experimental_aec = 623 const bool goog_experimental_aec =
606 audio_constraints.GetGoogExperimentalEchoCancellation(); 624 audio_constraints.GetGoogExperimentalEchoCancellation();
607 const bool goog_typing_detection = 625 const bool goog_typing_detection =
608 audio_constraints.GetGoogTypingNoiseDetection(); 626 audio_constraints.GetGoogTypingNoiseDetection();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 691 }
674 692
675 if (echo_cancellation) { 693 if (echo_cancellation) {
676 EnableEchoCancellation(audio_processing_.get()); 694 EnableEchoCancellation(audio_processing_.get());
677 695
678 // Prepare for logging echo information. If there are data remaining in 696 // Prepare for logging echo information. If there are data remaining in
679 // |echo_information_| we simply discard it. 697 // |echo_information_| we simply discard it.
680 echo_information_.reset(new EchoInformation()); 698 echo_information_.reset(new EchoInformation());
681 699
682 apm_config.echo_canceller3.enabled = 700 apm_config.echo_canceller3.enabled =
683 base::FeatureList::IsEnabled(features::kWebRtcUseEchoCanceller3); 701 override_aec3_
702 ? *override_aec3_
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

Powered by Google App Engine
This is Rietveld 408576698