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

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine.cc

Issue 1344563002: Improving support for Android Audio Effects in WebRTC (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Improved comments Created 5 years, 2 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 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 if (!ApplyOptions(options)) { 608 if (!ApplyOptions(options)) {
609 return false; 609 return false;
610 } 610 }
611 option_overrides_ = AudioOptions(); 611 option_overrides_ = AudioOptions();
612 return true; 612 return true;
613 } 613 }
614 614
615 // AudioOptions defaults are set in InitInternal (for options with corresponding 615 // AudioOptions defaults are set in InitInternal (for options with corresponding
616 // MediaEngineInterface flags) and in SetOptions(int) for flagless options. 616 // MediaEngineInterface flags) and in SetOptions(int) for flagless options.
617 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { 617 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
618 LOG(LS_INFO) << "ApplyOptions: " << options_in.ToString();
618 AudioOptions options = options_in; // The options are modified below. 619 AudioOptions options = options_in; // The options are modified below.
619 // kEcConference is AEC with high suppression. 620 // kEcConference is AEC with high suppression.
620 webrtc::EcModes ec_mode = webrtc::kEcConference; 621 webrtc::EcModes ec_mode = webrtc::kEcConference;
621 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone; 622 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone;
622 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; 623 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog;
623 webrtc::NsModes ns_mode = webrtc::kNsHighSuppression; 624 webrtc::NsModes ns_mode = webrtc::kNsHighSuppression;
624 bool aecm_comfort_noise = false; 625 bool aecm_comfort_noise = false;
625 if (options.aecm_generate_comfort_noise.Get(&aecm_comfort_noise)) { 626 if (options.aecm_generate_comfort_noise.Get(&aecm_comfort_noise)) {
626 LOG(LS_VERBOSE) << "Comfort noise explicitly set to " 627 LOG(LS_VERBOSE) << "Comfort noise explicitly set to "
627 << aecm_comfort_noise << " (default is false)."; 628 << aecm_comfort_noise << " (default is false).";
(...skipping 24 matching lines...) Expand all
652 #if !defined(IOS) 653 #if !defined(IOS)
653 if (options.delay_agnostic_aec.Get(&use_delay_agnostic_aec)) { 654 if (options.delay_agnostic_aec.Get(&use_delay_agnostic_aec)) {
654 if (use_delay_agnostic_aec) { 655 if (use_delay_agnostic_aec) {
655 options.echo_cancellation.Set(true); 656 options.echo_cancellation.Set(true);
656 options.extended_filter_aec.Set(true); 657 options.extended_filter_aec.Set(true);
657 ec_mode = webrtc::kEcConference; 658 ec_mode = webrtc::kEcConference;
658 } 659 }
659 } 660 }
660 #endif 661 #endif
661 662
662 LOG(LS_INFO) << "Applying audio options: " << options.ToString();
663
664 webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); 663 webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing();
665 664
666 bool echo_cancellation = false; 665 bool echo_cancellation = false;
667 if (options.echo_cancellation.Get(&echo_cancellation)) { 666 if (options.echo_cancellation.Get(&echo_cancellation)) {
668 // Check if platform supports built-in EC. Currently only supported on 667 // Check if platform supports built-in EC. Currently only supported on
669 // Android and in combination with Java based audio layer. 668 // Android and in combination with Java based audio layer.
670 // TODO(henrika): investigate possibility to support built-in EC also 669 // TODO(henrika): investigate possibility to support built-in EC also
671 // in combination with Open SL ES audio. 670 // in combination with Open SL ES audio.
672 const bool built_in_aec = voe_wrapper_->hw()->BuiltInAECIsAvailable(); 671 const bool built_in_aec = voe_wrapper_->hw()->BuiltInAECIsAvailable();
673 if (built_in_aec) { 672 if (built_in_aec) {
(...skipping 26 matching lines...) Expand all
700 } 699 }
701 #endif 700 #endif
702 if (ec_mode == webrtc::kEcAecm) { 701 if (ec_mode == webrtc::kEcAecm) {
703 if (voep->SetAecmMode(aecm_mode, aecm_comfort_noise) != 0) { 702 if (voep->SetAecmMode(aecm_mode, aecm_comfort_noise) != 0) {
704 LOG_RTCERR2(SetAecmMode, aecm_mode, aecm_comfort_noise); 703 LOG_RTCERR2(SetAecmMode, aecm_mode, aecm_comfort_noise);
705 return false; 704 return false;
706 } 705 }
707 } 706 }
708 } 707 }
709 708
710 bool auto_gain_control; 709 bool auto_gain_control = false;
711 if (options.auto_gain_control.Get(&auto_gain_control)) { 710 if (options.auto_gain_control.Get(&auto_gain_control)) {
711 const bool built_in_agc = voe_wrapper_->hw()->BuiltInAGCIsAvailable();
712 if (built_in_agc) {
713 if (voe_wrapper_->hw()->EnableBuiltInAGC(auto_gain_control) == 0 &&
714 auto_gain_control) {
715 // Disable internal software AGC if built-in AGC is enabled,
716 // i.e., replace the software AGC with the built-in AGC.
717 options.auto_gain_control.Set(false);
718 auto_gain_control = false;
719 LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead";
720 }
721 }
712 if (voep->SetAgcStatus(auto_gain_control, agc_mode) == -1) { 722 if (voep->SetAgcStatus(auto_gain_control, agc_mode) == -1) {
713 LOG_RTCERR2(SetAgcStatus, auto_gain_control, agc_mode); 723 LOG_RTCERR2(SetAgcStatus, auto_gain_control, agc_mode);
714 return false; 724 return false;
715 } else { 725 } else {
716 LOG(LS_INFO) << "Auto gain set to " << auto_gain_control << " with mode " 726 LOG(LS_INFO) << "Auto gain set to " << auto_gain_control << " with mode "
717 << agc_mode; 727 << agc_mode;
718 } 728 }
719 } 729 }
720 730
721 if (options.tx_agc_target_dbov.IsSet() || 731 if (options.tx_agc_target_dbov.IsSet() ||
(...skipping 18 matching lines...) Expand all
740 default_agc_config_.limiterEnable); 750 default_agc_config_.limiterEnable);
741 if (voe_wrapper_->processing()->SetAgcConfig(default_agc_config_) == -1) { 751 if (voe_wrapper_->processing()->SetAgcConfig(default_agc_config_) == -1) {
742 LOG_RTCERR3(SetAgcConfig, 752 LOG_RTCERR3(SetAgcConfig,
743 default_agc_config_.targetLeveldBOv, 753 default_agc_config_.targetLeveldBOv,
744 default_agc_config_.digitalCompressionGaindB, 754 default_agc_config_.digitalCompressionGaindB,
745 default_agc_config_.limiterEnable); 755 default_agc_config_.limiterEnable);
746 return false; 756 return false;
747 } 757 }
748 } 758 }
749 759
750 bool noise_suppression; 760 bool noise_suppression = false;
751 if (options.noise_suppression.Get(&noise_suppression)) { 761 if (options.noise_suppression.Get(&noise_suppression)) {
762 const bool built_in_ns = voe_wrapper_->hw()->BuiltInNSIsAvailable();
763 if (built_in_ns) {
764 if (voe_wrapper_->hw()->EnableBuiltInNS(noise_suppression) == 0 &&
765 noise_suppression) {
766 // Disable internal software NS if built-in NS is enabled,
767 // i.e., replace the software NS with the built-in NS.
768 options.noise_suppression.Set(false);
769 noise_suppression = false;
770 LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead";
771 }
772 }
752 if (voep->SetNsStatus(noise_suppression, ns_mode) == -1) { 773 if (voep->SetNsStatus(noise_suppression, ns_mode) == -1) {
753 LOG_RTCERR2(SetNsStatus, noise_suppression, ns_mode); 774 LOG_RTCERR2(SetNsStatus, noise_suppression, ns_mode);
754 return false; 775 return false;
755 } else { 776 } else {
756 LOG(LS_VERBOSE) << "Noise suppression set to " << noise_suppression 777 LOG(LS_INFO) << "Noise suppression set to " << noise_suppression
757 << " with mode " << ns_mode; 778 << " with mode " << ns_mode;
758 } 779 }
759 } 780 }
760 781
761 bool highpass_filter; 782 bool highpass_filter;
762 if (options.highpass_filter.Get(&highpass_filter)) { 783 if (options.highpass_filter.Get(&highpass_filter)) {
763 LOG(LS_INFO) << "High pass filter enabled? " << highpass_filter; 784 LOG(LS_INFO) << "High pass filter enabled? " << highpass_filter;
764 if (voep->EnableHighPassFilter(highpass_filter) == -1) { 785 if (voep->EnableHighPassFilter(highpass_filter) == -1) {
765 LOG_RTCERR1(SetHighpassFilterStatus, highpass_filter); 786 LOG_RTCERR1(SetHighpassFilterStatus, highpass_filter);
766 return false; 787 return false;
767 } 788 }
(...skipping 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); 3299 LOG(LS_WARNING) << "Unknown codec " << ToString(codec);
3279 return false; 3300 return false;
3280 } 3301 }
3281 } 3302 }
3282 return true; 3303 return true;
3283 } 3304 }
3284 3305
3285 } // namespace cricket 3306 } // namespace cricket
3286 3307
3287 #endif // HAVE_WEBRTC_VOICE 3308 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « talk/media/webrtc/fakewebrtcvoiceengine.h ('k') | webrtc/modules/audio_device/android/audio_device_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698