OLD | NEW |
---|---|
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 Loading... | |
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 17:08:40
Nit: can be written
if (override_aec3_ == enable)
hlundin-chromium
2017/04/11 09:19:37
Done.
| |
492 return; | |
493 | |
494 override_aec3_ = base::Optional<bool>(enable); | |
Henrik Grunell
2017/04/10 17:08:40
Nit: override_aec3_ = enable;
hlundin-chromium
2017/04/11 09:19:37
Done.
| |
495 if (!has_echo_cancellation_) | |
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 Loading... | |
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 = |
683 base::FeatureList::IsEnabled(features::kWebRtcUseEchoCanceller3); | 703 override_aec3_ |
704 ? *override_aec3_ | |
705 : base::FeatureList::IsEnabled(features::kWebRtcUseEchoCanceller3); | |
684 } else { | 706 } else { |
685 apm_config.echo_canceller3.enabled = false; | 707 apm_config.echo_canceller3.enabled = false; |
686 } | 708 } |
687 | 709 |
688 if (goog_ns) { | 710 if (goog_ns) { |
689 // The beamforming postfilter is effective at suppressing stationary noise, | 711 // The beamforming postfilter is effective at suppressing stationary noise, |
690 // so reduce the single-channel NS aggressiveness when enabled. | 712 // so reduce the single-channel NS aggressiveness when enabled. |
691 const NoiseSuppression::Level ns_level = | 713 const NoiseSuppression::Level ns_level = |
692 config.Get<webrtc::Beamforming>().enabled ? NoiseSuppression::kLow | 714 config.Get<webrtc::Beamforming>().enabled ? NoiseSuppression::kLow |
693 : NoiseSuppression::kHigh; | 715 : NoiseSuppression::kHigh; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
870 0 : agc->stream_analog_level(); | 892 0 : agc->stream_analog_level(); |
871 } | 893 } |
872 | 894 |
873 void MediaStreamAudioProcessor::UpdateAecStats() { | 895 void MediaStreamAudioProcessor::UpdateAecStats() { |
874 DCHECK(main_thread_runner_->BelongsToCurrentThread()); | 896 DCHECK(main_thread_runner_->BelongsToCurrentThread()); |
875 if (echo_information_) | 897 if (echo_information_) |
876 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); | 898 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); |
877 } | 899 } |
878 | 900 |
879 } // namespace content | 901 } // namespace content |
OLD | NEW |