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)) | |
492 return; | |
493 | |
494 override_aec3_ = base::Optional<bool>(enable); | |
495 if (has_echo_cancellation_) | |
Henrik Grunell
2017/04/10 12:33:47
I suppose it should be !has_echo_cancellation_
hlundin-chromium
2017/04/10 13:03:17
Holy cow! I'm sloppy today... Good thing you are o
| |
496 return; | |
497 | |
498 auto apm_config = audio_processing_->GetConfig(); | |
499 if (apm_config.echo_canceller3.enabled != enable) { | |
Henrik Grunell
2017/04/10 12:33:47
Here too.
if (apm_config.echo_canceller3.enabled
hlundin-chromium
2017/04/10 13:03:17
Done.
| |
500 apm_config.echo_canceller3.enabled = enable; | |
501 audio_processing_->ApplyConfig(apm_config); | |
502 DCHECK(echo_information_); | |
503 echo_information_.reset(new EchoInformation()); | |
504 } | |
505 } | |
506 | |
489 void MediaStreamAudioProcessor::OnIpcClosing() { | 507 void MediaStreamAudioProcessor::OnIpcClosing() { |
490 DCHECK(main_thread_runner_->BelongsToCurrentThread()); | 508 DCHECK(main_thread_runner_->BelongsToCurrentThread()); |
491 aec_dump_message_filter_ = NULL; | 509 aec_dump_message_filter_ = NULL; |
492 } | 510 } |
493 | 511 |
494 // static | 512 // static |
495 bool MediaStreamAudioProcessor::WouldModifyAudio( | 513 bool MediaStreamAudioProcessor::WouldModifyAudio( |
496 const blink::WebMediaConstraints& constraints, | 514 const blink::WebMediaConstraints& constraints, |
497 int effects_flags) { | 515 int effects_flags) { |
498 // Note: This method should by kept in-sync with any changes to the logic in | 516 // 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 | 607 |
590 MediaAudioConstraints audio_constraints(constraints, input_params.effects); | 608 MediaAudioConstraints audio_constraints(constraints, input_params.effects); |
591 | 609 |
592 // Note: The audio mirroring constraint (i.e., swap left and right channels) | 610 // Note: The audio mirroring constraint (i.e., swap left and right channels) |
593 // is handled within this MediaStreamAudioProcessor and does not, by itself, | 611 // is handled within this MediaStreamAudioProcessor and does not, by itself, |
594 // require webrtc::AudioProcessing. | 612 // require webrtc::AudioProcessing. |
595 audio_mirroring_ = audio_constraints.GetGoogAudioMirroring(); | 613 audio_mirroring_ = audio_constraints.GetGoogAudioMirroring(); |
596 | 614 |
597 const bool echo_cancellation = | 615 const bool echo_cancellation = |
598 audio_constraints.GetEchoCancellationProperty(); | 616 audio_constraints.GetEchoCancellationProperty(); |
617 has_echo_cancellation_ = echo_cancellation; | |
599 const bool goog_agc = audio_constraints.GetGoogAutoGainControl(); | 618 const bool goog_agc = audio_constraints.GetGoogAutoGainControl(); |
600 | 619 |
601 #if defined(OS_ANDROID) | 620 #if defined(OS_ANDROID) |
602 const bool goog_experimental_aec = false; | 621 const bool goog_experimental_aec = false; |
603 const bool goog_typing_detection = false; | 622 const bool goog_typing_detection = false; |
604 #else | 623 #else |
605 const bool goog_experimental_aec = | 624 const bool goog_experimental_aec = |
606 audio_constraints.GetGoogExperimentalEchoCancellation(); | 625 audio_constraints.GetGoogExperimentalEchoCancellation(); |
607 const bool goog_typing_detection = | 626 const bool goog_typing_detection = |
608 audio_constraints.GetGoogTypingNoiseDetection(); | 627 audio_constraints.GetGoogTypingNoiseDetection(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 } | 692 } |
674 | 693 |
675 if (echo_cancellation) { | 694 if (echo_cancellation) { |
676 EnableEchoCancellation(audio_processing_.get()); | 695 EnableEchoCancellation(audio_processing_.get()); |
677 | 696 |
678 // Prepare for logging echo information. If there are data remaining in | 697 // Prepare for logging echo information. If there are data remaining in |
679 // |echo_information_| we simply discard it. | 698 // |echo_information_| we simply discard it. |
680 echo_information_.reset(new EchoInformation()); | 699 echo_information_.reset(new EchoInformation()); |
681 | 700 |
682 apm_config.echo_canceller3.enabled = | 701 apm_config.echo_canceller3.enabled = |
683 base::FeatureList::IsEnabled(features::kWebRtcUseEchoCanceller3); | 702 override_aec3_ |
703 ? *override_aec3_ | |
704 : base::FeatureList::IsEnabled(features::kWebRtcUseEchoCanceller3); | |
684 } else { | 705 } else { |
685 apm_config.echo_canceller3.enabled = false; | 706 apm_config.echo_canceller3.enabled = false; |
686 } | 707 } |
687 | 708 |
688 if (goog_ns) { | 709 if (goog_ns) { |
689 // The beamforming postfilter is effective at suppressing stationary noise, | 710 // The beamforming postfilter is effective at suppressing stationary noise, |
690 // so reduce the single-channel NS aggressiveness when enabled. | 711 // so reduce the single-channel NS aggressiveness when enabled. |
691 const NoiseSuppression::Level ns_level = | 712 const NoiseSuppression::Level ns_level = |
692 config.Get<webrtc::Beamforming>().enabled ? NoiseSuppression::kLow | 713 config.Get<webrtc::Beamforming>().enabled ? NoiseSuppression::kLow |
693 : NoiseSuppression::kHigh; | 714 : NoiseSuppression::kHigh; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
870 0 : agc->stream_analog_level(); | 891 0 : agc->stream_analog_level(); |
871 } | 892 } |
872 | 893 |
873 void MediaStreamAudioProcessor::UpdateAecStats() { | 894 void MediaStreamAudioProcessor::UpdateAecStats() { |
874 DCHECK(main_thread_runner_->BelongsToCurrentThread()); | 895 DCHECK(main_thread_runner_->BelongsToCurrentThread()); |
875 if (echo_information_) | 896 if (echo_information_) |
876 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); | 897 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); |
877 } | 898 } |
878 | 899 |
879 } // namespace content | 900 } // namespace content |
OLD | NEW |