| OLD | NEW | 
|---|
| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 361     RTC_DCHECK(voe_codec->plfreq != new_plfreq); | 361     RTC_DCHECK(voe_codec->plfreq != new_plfreq); | 
| 362     voe_codec->plfreq = new_plfreq; | 362     voe_codec->plfreq = new_plfreq; | 
| 363   } | 363   } | 
| 364 } | 364 } | 
| 365 | 365 | 
| 366 // Gets the default set of options applied to the engine. Historically, these | 366 // Gets the default set of options applied to the engine. Historically, these | 
| 367 // were supplied as a combination of flags from the channel manager (ec, agc, | 367 // were supplied as a combination of flags from the channel manager (ec, agc, | 
| 368 // ns, and highpass) and the rest hardcoded in InitInternal. | 368 // ns, and highpass) and the rest hardcoded in InitInternal. | 
| 369 AudioOptions GetDefaultEngineOptions() { | 369 AudioOptions GetDefaultEngineOptions() { | 
| 370   AudioOptions options; | 370   AudioOptions options; | 
| 371   options.echo_cancellation = rtc::Maybe<bool>(true); | 371   options.echo_cancellation = rtc::Optional<bool>(true); | 
| 372   options.auto_gain_control = rtc::Maybe<bool>(true); | 372   options.auto_gain_control = rtc::Optional<bool>(true); | 
| 373   options.noise_suppression = rtc::Maybe<bool>(true); | 373   options.noise_suppression = rtc::Optional<bool>(true); | 
| 374   options.highpass_filter = rtc::Maybe<bool>(true); | 374   options.highpass_filter = rtc::Optional<bool>(true); | 
| 375   options.stereo_swapping = rtc::Maybe<bool>(false); | 375   options.stereo_swapping = rtc::Optional<bool>(false); | 
| 376   options.audio_jitter_buffer_max_packets = rtc::Maybe<int>(50); | 376   options.audio_jitter_buffer_max_packets = rtc::Optional<int>(50); | 
| 377   options.audio_jitter_buffer_fast_accelerate = rtc::Maybe<bool>(false); | 377   options.audio_jitter_buffer_fast_accelerate = rtc::Optional<bool>(false); | 
| 378   options.typing_detection = rtc::Maybe<bool>(true); | 378   options.typing_detection = rtc::Optional<bool>(true); | 
| 379   options.adjust_agc_delta = rtc::Maybe<int>(0); | 379   options.adjust_agc_delta = rtc::Optional<int>(0); | 
| 380   options.experimental_agc = rtc::Maybe<bool>(false); | 380   options.experimental_agc = rtc::Optional<bool>(false); | 
| 381   options.extended_filter_aec = rtc::Maybe<bool>(false); | 381   options.extended_filter_aec = rtc::Optional<bool>(false); | 
| 382   options.delay_agnostic_aec = rtc::Maybe<bool>(false); | 382   options.delay_agnostic_aec = rtc::Optional<bool>(false); | 
| 383   options.experimental_ns = rtc::Maybe<bool>(false); | 383   options.experimental_ns = rtc::Optional<bool>(false); | 
| 384   options.aec_dump = rtc::Maybe<bool>(false); | 384   options.aec_dump = rtc::Optional<bool>(false); | 
| 385   return options; | 385   return options; | 
| 386 } | 386 } | 
| 387 | 387 | 
| 388 std::string GetEnableString(bool enable) { | 388 std::string GetEnableString(bool enable) { | 
| 389   return enable ? "enable" : "disable"; | 389   return enable ? "enable" : "disable"; | 
| 390 } | 390 } | 
| 391 | 391 | 
| 392 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) { | 392 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) { | 
| 393   webrtc::AudioState::Config config; | 393   webrtc::AudioState::Config config; | 
| 394   config.voice_engine = voe_wrapper->engine(); | 394   config.voice_engine = voe_wrapper->engine(); | 
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 633   webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; | 633   webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; | 
| 634   webrtc::NsModes ns_mode = webrtc::kNsHighSuppression; | 634   webrtc::NsModes ns_mode = webrtc::kNsHighSuppression; | 
| 635   if (options.aecm_generate_comfort_noise) { | 635   if (options.aecm_generate_comfort_noise) { | 
| 636     LOG(LS_VERBOSE) << "Comfort noise explicitly set to " | 636     LOG(LS_VERBOSE) << "Comfort noise explicitly set to " | 
| 637                     << *options.aecm_generate_comfort_noise | 637                     << *options.aecm_generate_comfort_noise | 
| 638                     << " (default is false)."; | 638                     << " (default is false)."; | 
| 639   } | 639   } | 
| 640 | 640 | 
| 641 #if defined(IOS) | 641 #if defined(IOS) | 
| 642   // On iOS, VPIO provides built-in EC and AGC. | 642   // On iOS, VPIO provides built-in EC and AGC. | 
| 643   options.echo_cancellation = rtc::Maybe<bool>(false); | 643   options.echo_cancellation = rtc::Optional<bool>(false); | 
| 644   options.auto_gain_control = rtc::Maybe<bool>(false); | 644   options.auto_gain_control = rtc::Optional<bool>(false); | 
| 645   LOG(LS_INFO) << "Always disable AEC and AGC on iOS. Use built-in instead."; | 645   LOG(LS_INFO) << "Always disable AEC and AGC on iOS. Use built-in instead."; | 
| 646 #elif defined(ANDROID) | 646 #elif defined(ANDROID) | 
| 647   ec_mode = webrtc::kEcAecm; | 647   ec_mode = webrtc::kEcAecm; | 
| 648 #endif | 648 #endif | 
| 649 | 649 | 
| 650 #if defined(IOS) || defined(ANDROID) | 650 #if defined(IOS) || defined(ANDROID) | 
| 651   // Set the AGC mode for iOS as well despite disabling it above, to avoid | 651   // Set the AGC mode for iOS as well despite disabling it above, to avoid | 
| 652   // unsupported configuration errors from webrtc. | 652   // unsupported configuration errors from webrtc. | 
| 653   agc_mode = webrtc::kAgcFixedDigital; | 653   agc_mode = webrtc::kAgcFixedDigital; | 
| 654   options.typing_detection = rtc::Maybe<bool>(false); | 654   options.typing_detection = rtc::Optional<bool>(false); | 
| 655   options.experimental_agc = rtc::Maybe<bool>(false); | 655   options.experimental_agc = rtc::Optional<bool>(false); | 
| 656   options.extended_filter_aec = rtc::Maybe<bool>(false); | 656   options.extended_filter_aec = rtc::Optional<bool>(false); | 
| 657   options.experimental_ns = rtc::Maybe<bool>(false); | 657   options.experimental_ns = rtc::Optional<bool>(false); | 
| 658 #endif | 658 #endif | 
| 659 | 659 | 
| 660   // Delay Agnostic AEC automatically turns on EC if not set except on iOS | 660   // Delay Agnostic AEC automatically turns on EC if not set except on iOS | 
| 661   // where the feature is not supported. | 661   // where the feature is not supported. | 
| 662   bool use_delay_agnostic_aec = false; | 662   bool use_delay_agnostic_aec = false; | 
| 663 #if !defined(IOS) | 663 #if !defined(IOS) | 
| 664   if (options.delay_agnostic_aec) { | 664   if (options.delay_agnostic_aec) { | 
| 665     use_delay_agnostic_aec = *options.delay_agnostic_aec; | 665     use_delay_agnostic_aec = *options.delay_agnostic_aec; | 
| 666     if (use_delay_agnostic_aec) { | 666     if (use_delay_agnostic_aec) { | 
| 667       options.echo_cancellation = rtc::Maybe<bool>(true); | 667       options.echo_cancellation = rtc::Optional<bool>(true); | 
| 668       options.extended_filter_aec = rtc::Maybe<bool>(true); | 668       options.extended_filter_aec = rtc::Optional<bool>(true); | 
| 669       ec_mode = webrtc::kEcConference; | 669       ec_mode = webrtc::kEcConference; | 
| 670     } | 670     } | 
| 671   } | 671   } | 
| 672 #endif | 672 #endif | 
| 673 | 673 | 
| 674   webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); | 674   webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); | 
| 675 | 675 | 
| 676   if (options.echo_cancellation) { | 676   if (options.echo_cancellation) { | 
| 677     // Check if platform supports built-in EC. Currently only supported on | 677     // Check if platform supports built-in EC. Currently only supported on | 
| 678     // Android and in combination with Java based audio layer. | 678     // Android and in combination with Java based audio layer. | 
| 679     // TODO(henrika): investigate possibility to support built-in EC also | 679     // TODO(henrika): investigate possibility to support built-in EC also | 
| 680     // in combination with Open SL ES audio. | 680     // in combination with Open SL ES audio. | 
| 681     const bool built_in_aec = voe_wrapper_->hw()->BuiltInAECIsAvailable(); | 681     const bool built_in_aec = voe_wrapper_->hw()->BuiltInAECIsAvailable(); | 
| 682     if (built_in_aec) { | 682     if (built_in_aec) { | 
| 683       // Built-in EC exists on this device and use_delay_agnostic_aec is not | 683       // Built-in EC exists on this device and use_delay_agnostic_aec is not | 
| 684       // overriding it. Enable/Disable it according to the echo_cancellation | 684       // overriding it. Enable/Disable it according to the echo_cancellation | 
| 685       // audio option. | 685       // audio option. | 
| 686       const bool enable_built_in_aec = | 686       const bool enable_built_in_aec = | 
| 687           *options.echo_cancellation && !use_delay_agnostic_aec; | 687           *options.echo_cancellation && !use_delay_agnostic_aec; | 
| 688       if (voe_wrapper_->hw()->EnableBuiltInAEC(enable_built_in_aec) == 0 && | 688       if (voe_wrapper_->hw()->EnableBuiltInAEC(enable_built_in_aec) == 0 && | 
| 689           enable_built_in_aec) { | 689           enable_built_in_aec) { | 
| 690         // Disable internal software EC if built-in EC is enabled, | 690         // Disable internal software EC if built-in EC is enabled, | 
| 691         // i.e., replace the software EC with the built-in EC. | 691         // i.e., replace the software EC with the built-in EC. | 
| 692         options.echo_cancellation = rtc::Maybe<bool>(false); | 692         options.echo_cancellation = rtc::Optional<bool>(false); | 
| 693         LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; | 693         LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; | 
| 694       } | 694       } | 
| 695     } | 695     } | 
| 696     if (voep->SetEcStatus(*options.echo_cancellation, ec_mode) == -1) { | 696     if (voep->SetEcStatus(*options.echo_cancellation, ec_mode) == -1) { | 
| 697       LOG_RTCERR2(SetEcStatus, *options.echo_cancellation, ec_mode); | 697       LOG_RTCERR2(SetEcStatus, *options.echo_cancellation, ec_mode); | 
| 698       return false; | 698       return false; | 
| 699     } else { | 699     } else { | 
| 700       LOG(LS_INFO) << "Echo control set to " << *options.echo_cancellation | 700       LOG(LS_INFO) << "Echo control set to " << *options.echo_cancellation | 
| 701                    << " with mode " << ec_mode; | 701                    << " with mode " << ec_mode; | 
| 702     } | 702     } | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 717   } | 717   } | 
| 718 | 718 | 
| 719   if (options.auto_gain_control) { | 719   if (options.auto_gain_control) { | 
| 720     const bool built_in_agc = voe_wrapper_->hw()->BuiltInAGCIsAvailable(); | 720     const bool built_in_agc = voe_wrapper_->hw()->BuiltInAGCIsAvailable(); | 
| 721     if (built_in_agc) { | 721     if (built_in_agc) { | 
| 722       if (voe_wrapper_->hw()->EnableBuiltInAGC(*options.auto_gain_control) == | 722       if (voe_wrapper_->hw()->EnableBuiltInAGC(*options.auto_gain_control) == | 
| 723               0 && | 723               0 && | 
| 724           *options.auto_gain_control) { | 724           *options.auto_gain_control) { | 
| 725         // Disable internal software AGC if built-in AGC is enabled, | 725         // Disable internal software AGC if built-in AGC is enabled, | 
| 726         // i.e., replace the software AGC with the built-in AGC. | 726         // i.e., replace the software AGC with the built-in AGC. | 
| 727         options.auto_gain_control = rtc::Maybe<bool>(false); | 727         options.auto_gain_control = rtc::Optional<bool>(false); | 
| 728         LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead"; | 728         LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead"; | 
| 729       } | 729       } | 
| 730     } | 730     } | 
| 731     if (voep->SetAgcStatus(*options.auto_gain_control, agc_mode) == -1) { | 731     if (voep->SetAgcStatus(*options.auto_gain_control, agc_mode) == -1) { | 
| 732       LOG_RTCERR2(SetAgcStatus, *options.auto_gain_control, agc_mode); | 732       LOG_RTCERR2(SetAgcStatus, *options.auto_gain_control, agc_mode); | 
| 733       return false; | 733       return false; | 
| 734     } else { | 734     } else { | 
| 735       LOG(LS_INFO) << "Auto gain set to " << *options.auto_gain_control | 735       LOG(LS_INFO) << "Auto gain set to " << *options.auto_gain_control | 
| 736                    << " with mode " << agc_mode; | 736                    << " with mode " << agc_mode; | 
| 737     } | 737     } | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 764   } | 764   } | 
| 765 | 765 | 
| 766   if (options.noise_suppression) { | 766   if (options.noise_suppression) { | 
| 767     const bool built_in_ns = voe_wrapper_->hw()->BuiltInNSIsAvailable(); | 767     const bool built_in_ns = voe_wrapper_->hw()->BuiltInNSIsAvailable(); | 
| 768     if (built_in_ns) { | 768     if (built_in_ns) { | 
| 769       if (voe_wrapper_->hw()->EnableBuiltInNS(*options.noise_suppression) == | 769       if (voe_wrapper_->hw()->EnableBuiltInNS(*options.noise_suppression) == | 
| 770               0 && | 770               0 && | 
| 771           *options.noise_suppression) { | 771           *options.noise_suppression) { | 
| 772         // Disable internal software NS if built-in NS is enabled, | 772         // Disable internal software NS if built-in NS is enabled, | 
| 773         // i.e., replace the software NS with the built-in NS. | 773         // i.e., replace the software NS with the built-in NS. | 
| 774         options.noise_suppression = rtc::Maybe<bool>(false); | 774         options.noise_suppression = rtc::Optional<bool>(false); | 
| 775         LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead"; | 775         LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead"; | 
| 776       } | 776       } | 
| 777     } | 777     } | 
| 778     if (voep->SetNsStatus(*options.noise_suppression, ns_mode) == -1) { | 778     if (voep->SetNsStatus(*options.noise_suppression, ns_mode) == -1) { | 
| 779       LOG_RTCERR2(SetNsStatus, *options.noise_suppression, ns_mode); | 779       LOG_RTCERR2(SetNsStatus, *options.noise_suppression, ns_mode); | 
| 780       return false; | 780       return false; | 
| 781     } else { | 781     } else { | 
| 782       LOG(LS_INFO) << "Noise suppression set to " << *options.noise_suppression | 782       LOG(LS_INFO) << "Noise suppression set to " << *options.noise_suppression | 
| 783                    << " with mode " << ns_mode; | 783                    << " with mode " << ns_mode; | 
| 784     } | 784     } | 
| (...skipping 2071 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2856       LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 2856       LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 
| 2857       return false; | 2857       return false; | 
| 2858     } | 2858     } | 
| 2859   } | 2859   } | 
| 2860   return true; | 2860   return true; | 
| 2861 } | 2861 } | 
| 2862 | 2862 | 
| 2863 }  // namespace cricket | 2863 }  // namespace cricket | 
| 2864 | 2864 | 
| 2865 #endif  // HAVE_WEBRTC_VOICE | 2865 #endif  // HAVE_WEBRTC_VOICE | 
| OLD | NEW | 
|---|