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.Set(true); | 371 options.echo_cancellation = rtc::Maybe<bool>(true); |
372 options.auto_gain_control.Set(true); | 372 options.auto_gain_control = rtc::Maybe<bool>(true); |
373 options.noise_suppression.Set(true); | 373 options.noise_suppression = rtc::Maybe<bool>(true); |
374 options.highpass_filter.Set(true); | 374 options.highpass_filter = rtc::Maybe<bool>(true); |
375 options.stereo_swapping.Set(false); | 375 options.stereo_swapping = rtc::Maybe<bool>(false); |
376 options.audio_jitter_buffer_max_packets.Set(50); | 376 options.audio_jitter_buffer_max_packets = rtc::Maybe<int>(50); |
377 options.audio_jitter_buffer_fast_accelerate.Set(false); | 377 options.audio_jitter_buffer_fast_accelerate = rtc::Maybe<bool>(false); |
378 options.typing_detection.Set(true); | 378 options.typing_detection = rtc::Maybe<bool>(true); |
379 options.adjust_agc_delta.Set(0); | 379 options.adjust_agc_delta = rtc::Maybe<int>(0); |
380 options.experimental_agc.Set(false); | 380 options.experimental_agc = rtc::Maybe<bool>(false); |
381 options.extended_filter_aec.Set(false); | 381 options.extended_filter_aec = rtc::Maybe<bool>(false); |
382 options.delay_agnostic_aec.Set(false); | 382 options.delay_agnostic_aec = rtc::Maybe<bool>(false); |
383 options.experimental_ns.Set(false); | 383 options.experimental_ns = rtc::Maybe<bool>(false); |
384 options.aec_dump.Set(false); | 384 options.aec_dump = rtc::Maybe<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 } // namespace { | 391 } // namespace { |
392 | 392 |
393 WebRtcVoiceEngine::WebRtcVoiceEngine() | 393 WebRtcVoiceEngine::WebRtcVoiceEngine() |
394 : voe_wrapper_(new VoEWrapper()), | 394 : voe_wrapper_(new VoEWrapper()), |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 // AudioOptions defaults are set in InitInternal (for options with corresponding | 612 // AudioOptions defaults are set in InitInternal (for options with corresponding |
613 // MediaEngineInterface flags) and in SetOptions(int) for flagless options. | 613 // MediaEngineInterface flags) and in SetOptions(int) for flagless options. |
614 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { | 614 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { |
615 LOG(LS_INFO) << "ApplyOptions: " << options_in.ToString(); | 615 LOG(LS_INFO) << "ApplyOptions: " << options_in.ToString(); |
616 AudioOptions options = options_in; // The options are modified below. | 616 AudioOptions options = options_in; // The options are modified below. |
617 // kEcConference is AEC with high suppression. | 617 // kEcConference is AEC with high suppression. |
618 webrtc::EcModes ec_mode = webrtc::kEcConference; | 618 webrtc::EcModes ec_mode = webrtc::kEcConference; |
619 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone; | 619 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone; |
620 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; | 620 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; |
621 webrtc::NsModes ns_mode = webrtc::kNsHighSuppression; | 621 webrtc::NsModes ns_mode = webrtc::kNsHighSuppression; |
622 bool aecm_comfort_noise = false; | 622 if (options.aecm_generate_comfort_noise) { |
623 if (options.aecm_generate_comfort_noise.Get(&aecm_comfort_noise)) { | |
624 LOG(LS_VERBOSE) << "Comfort noise explicitly set to " | 623 LOG(LS_VERBOSE) << "Comfort noise explicitly set to " |
625 << aecm_comfort_noise << " (default is false)."; | 624 << *options.aecm_generate_comfort_noise |
| 625 << " (default is false)."; |
626 } | 626 } |
627 | 627 |
628 #if defined(IOS) | 628 #if defined(IOS) |
629 // On iOS, VPIO provides built-in EC and AGC. | 629 // On iOS, VPIO provides built-in EC and AGC. |
630 options.echo_cancellation.Set(false); | 630 options.echo_cancellation = rtc::Maybe<bool>(false); |
631 options.auto_gain_control.Set(false); | 631 options.auto_gain_control = rtc::Maybe<bool>(false); |
632 LOG(LS_INFO) << "Always disable AEC and AGC on iOS. Use built-in instead."; | 632 LOG(LS_INFO) << "Always disable AEC and AGC on iOS. Use built-in instead."; |
633 #elif defined(ANDROID) | 633 #elif defined(ANDROID) |
634 ec_mode = webrtc::kEcAecm; | 634 ec_mode = webrtc::kEcAecm; |
635 #endif | 635 #endif |
636 | 636 |
637 #if defined(IOS) || defined(ANDROID) | 637 #if defined(IOS) || defined(ANDROID) |
638 // Set the AGC mode for iOS as well despite disabling it above, to avoid | 638 // Set the AGC mode for iOS as well despite disabling it above, to avoid |
639 // unsupported configuration errors from webrtc. | 639 // unsupported configuration errors from webrtc. |
640 agc_mode = webrtc::kAgcFixedDigital; | 640 agc_mode = webrtc::kAgcFixedDigital; |
641 options.typing_detection.Set(false); | 641 options.typing_detection = rtc::Maybe<bool>(false); |
642 options.experimental_agc.Set(false); | 642 options.experimental_agc = rtc::Maybe<bool>(false); |
643 options.extended_filter_aec.Set(false); | 643 options.extended_filter_aec = rtc::Maybe<bool>(false); |
644 options.experimental_ns.Set(false); | 644 options.experimental_ns = rtc::Maybe<bool>(false); |
645 #endif | 645 #endif |
646 | 646 |
647 // Delay Agnostic AEC automatically turns on EC if not set except on iOS | 647 // Delay Agnostic AEC automatically turns on EC if not set except on iOS |
648 // where the feature is not supported. | 648 // where the feature is not supported. |
649 bool use_delay_agnostic_aec = false; | 649 bool use_delay_agnostic_aec = false; |
650 #if !defined(IOS) | 650 #if !defined(IOS) |
651 if (options.delay_agnostic_aec.Get(&use_delay_agnostic_aec)) { | 651 if (options.delay_agnostic_aec) { |
| 652 use_delay_agnostic_aec = *options.delay_agnostic_aec; |
652 if (use_delay_agnostic_aec) { | 653 if (use_delay_agnostic_aec) { |
653 options.echo_cancellation.Set(true); | 654 options.echo_cancellation = rtc::Maybe<bool>(true); |
654 options.extended_filter_aec.Set(true); | 655 options.extended_filter_aec = rtc::Maybe<bool>(true); |
655 ec_mode = webrtc::kEcConference; | 656 ec_mode = webrtc::kEcConference; |
656 } | 657 } |
657 } | 658 } |
658 #endif | 659 #endif |
659 | 660 |
660 webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); | 661 webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); |
661 | 662 |
662 bool echo_cancellation = false; | 663 if (options.echo_cancellation) { |
663 if (options.echo_cancellation.Get(&echo_cancellation)) { | |
664 // Check if platform supports built-in EC. Currently only supported on | 664 // Check if platform supports built-in EC. Currently only supported on |
665 // Android and in combination with Java based audio layer. | 665 // Android and in combination with Java based audio layer. |
666 // TODO(henrika): investigate possibility to support built-in EC also | 666 // TODO(henrika): investigate possibility to support built-in EC also |
667 // in combination with Open SL ES audio. | 667 // in combination with Open SL ES audio. |
668 const bool built_in_aec = voe_wrapper_->hw()->BuiltInAECIsAvailable(); | 668 const bool built_in_aec = voe_wrapper_->hw()->BuiltInAECIsAvailable(); |
669 if (built_in_aec) { | 669 if (built_in_aec) { |
670 // Built-in EC exists on this device and use_delay_agnostic_aec is not | 670 // Built-in EC exists on this device and use_delay_agnostic_aec is not |
671 // overriding it. Enable/Disable it according to the echo_cancellation | 671 // overriding it. Enable/Disable it according to the echo_cancellation |
672 // audio option. | 672 // audio option. |
673 const bool enable_built_in_aec = | 673 const bool enable_built_in_aec = |
674 echo_cancellation && !use_delay_agnostic_aec; | 674 *options.echo_cancellation && !use_delay_agnostic_aec; |
675 if (voe_wrapper_->hw()->EnableBuiltInAEC(enable_built_in_aec) == 0 && | 675 if (voe_wrapper_->hw()->EnableBuiltInAEC(enable_built_in_aec) == 0 && |
676 enable_built_in_aec) { | 676 enable_built_in_aec) { |
677 // Disable internal software EC if built-in EC is enabled, | 677 // Disable internal software EC if built-in EC is enabled, |
678 // i.e., replace the software EC with the built-in EC. | 678 // i.e., replace the software EC with the built-in EC. |
679 options.echo_cancellation.Set(false); | 679 options.echo_cancellation = rtc::Maybe<bool>(false); |
680 echo_cancellation = false; | |
681 LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; | 680 LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; |
682 } | 681 } |
683 } | 682 } |
684 if (voep->SetEcStatus(echo_cancellation, ec_mode) == -1) { | 683 if (voep->SetEcStatus(*options.echo_cancellation, ec_mode) == -1) { |
685 LOG_RTCERR2(SetEcStatus, echo_cancellation, ec_mode); | 684 LOG_RTCERR2(SetEcStatus, *options.echo_cancellation, ec_mode); |
686 return false; | 685 return false; |
687 } else { | 686 } else { |
688 LOG(LS_INFO) << "Echo control set to " << echo_cancellation | 687 LOG(LS_INFO) << "Echo control set to " << *options.echo_cancellation |
689 << " with mode " << ec_mode; | 688 << " with mode " << ec_mode; |
690 } | 689 } |
691 #if !defined(ANDROID) | 690 #if !defined(ANDROID) |
692 // TODO(ajm): Remove the error return on Android from webrtc. | 691 // TODO(ajm): Remove the error return on Android from webrtc. |
693 if (voep->SetEcMetricsStatus(echo_cancellation) == -1) { | 692 if (voep->SetEcMetricsStatus(*options.echo_cancellation) == -1) { |
694 LOG_RTCERR1(SetEcMetricsStatus, echo_cancellation); | 693 LOG_RTCERR1(SetEcMetricsStatus, *options.echo_cancellation); |
695 return false; | 694 return false; |
696 } | 695 } |
697 #endif | 696 #endif |
698 if (ec_mode == webrtc::kEcAecm) { | 697 if (ec_mode == webrtc::kEcAecm) { |
699 if (voep->SetAecmMode(aecm_mode, aecm_comfort_noise) != 0) { | 698 bool cn = options.aecm_generate_comfort_noise.value_or(false); |
700 LOG_RTCERR2(SetAecmMode, aecm_mode, aecm_comfort_noise); | 699 if (voep->SetAecmMode(aecm_mode, cn) != 0) { |
| 700 LOG_RTCERR2(SetAecmMode, aecm_mode, cn); |
701 return false; | 701 return false; |
702 } | 702 } |
703 } | 703 } |
704 } | 704 } |
705 | 705 |
706 bool auto_gain_control = false; | 706 if (options.auto_gain_control) { |
707 if (options.auto_gain_control.Get(&auto_gain_control)) { | |
708 const bool built_in_agc = voe_wrapper_->hw()->BuiltInAGCIsAvailable(); | 707 const bool built_in_agc = voe_wrapper_->hw()->BuiltInAGCIsAvailable(); |
709 if (built_in_agc) { | 708 if (built_in_agc) { |
710 if (voe_wrapper_->hw()->EnableBuiltInAGC(auto_gain_control) == 0 && | 709 if (voe_wrapper_->hw()->EnableBuiltInAGC(*options.auto_gain_control) == |
711 auto_gain_control) { | 710 0 && |
| 711 *options.auto_gain_control) { |
712 // Disable internal software AGC if built-in AGC is enabled, | 712 // Disable internal software AGC if built-in AGC is enabled, |
713 // i.e., replace the software AGC with the built-in AGC. | 713 // i.e., replace the software AGC with the built-in AGC. |
714 options.auto_gain_control.Set(false); | 714 options.auto_gain_control = rtc::Maybe<bool>(false); |
715 auto_gain_control = false; | |
716 LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead"; | 715 LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead"; |
717 } | 716 } |
718 } | 717 } |
719 if (voep->SetAgcStatus(auto_gain_control, agc_mode) == -1) { | 718 if (voep->SetAgcStatus(*options.auto_gain_control, agc_mode) == -1) { |
720 LOG_RTCERR2(SetAgcStatus, auto_gain_control, agc_mode); | 719 LOG_RTCERR2(SetAgcStatus, *options.auto_gain_control, agc_mode); |
721 return false; | 720 return false; |
722 } else { | 721 } else { |
723 LOG(LS_INFO) << "Auto gain set to " << auto_gain_control << " with mode " | 722 LOG(LS_INFO) << "Auto gain set to " << *options.auto_gain_control |
724 << agc_mode; | 723 << " with mode " << agc_mode; |
725 } | 724 } |
726 } | 725 } |
727 | 726 |
728 if (options.tx_agc_target_dbov.IsSet() || | 727 if (options.tx_agc_target_dbov || options.tx_agc_digital_compression_gain || |
729 options.tx_agc_digital_compression_gain.IsSet() || | 728 options.tx_agc_limiter) { |
730 options.tx_agc_limiter.IsSet()) { | |
731 // Override default_agc_config_. Generally, an unset option means "leave | 729 // Override default_agc_config_. Generally, an unset option means "leave |
732 // the VoE bits alone" in this function, so we want whatever is set to be | 730 // the VoE bits alone" in this function, so we want whatever is set to be |
733 // stored as the new "default". If we didn't, then setting e.g. | 731 // stored as the new "default". If we didn't, then setting e.g. |
734 // tx_agc_target_dbov would reset digital compression gain and limiter | 732 // tx_agc_target_dbov would reset digital compression gain and limiter |
735 // settings. | 733 // settings. |
736 // Also, if we don't update default_agc_config_, then adjust_agc_delta | 734 // Also, if we don't update default_agc_config_, then adjust_agc_delta |
737 // would be an offset from the original values, and not whatever was set | 735 // would be an offset from the original values, and not whatever was set |
738 // explicitly. | 736 // explicitly. |
739 default_agc_config_.targetLeveldBOv = | 737 default_agc_config_.targetLeveldBOv = options.tx_agc_target_dbov.value_or( |
740 options.tx_agc_target_dbov.GetWithDefaultIfUnset( | 738 default_agc_config_.targetLeveldBOv); |
741 default_agc_config_.targetLeveldBOv); | |
742 default_agc_config_.digitalCompressionGaindB = | 739 default_agc_config_.digitalCompressionGaindB = |
743 options.tx_agc_digital_compression_gain.GetWithDefaultIfUnset( | 740 options.tx_agc_digital_compression_gain.value_or( |
744 default_agc_config_.digitalCompressionGaindB); | 741 default_agc_config_.digitalCompressionGaindB); |
745 default_agc_config_.limiterEnable = | 742 default_agc_config_.limiterEnable = |
746 options.tx_agc_limiter.GetWithDefaultIfUnset( | 743 options.tx_agc_limiter.value_or(default_agc_config_.limiterEnable); |
747 default_agc_config_.limiterEnable); | |
748 if (voe_wrapper_->processing()->SetAgcConfig(default_agc_config_) == -1) { | 744 if (voe_wrapper_->processing()->SetAgcConfig(default_agc_config_) == -1) { |
749 LOG_RTCERR3(SetAgcConfig, | 745 LOG_RTCERR3(SetAgcConfig, |
750 default_agc_config_.targetLeveldBOv, | 746 default_agc_config_.targetLeveldBOv, |
751 default_agc_config_.digitalCompressionGaindB, | 747 default_agc_config_.digitalCompressionGaindB, |
752 default_agc_config_.limiterEnable); | 748 default_agc_config_.limiterEnable); |
753 return false; | 749 return false; |
754 } | 750 } |
755 } | 751 } |
756 | 752 |
757 bool noise_suppression = false; | 753 if (options.noise_suppression) { |
758 if (options.noise_suppression.Get(&noise_suppression)) { | |
759 const bool built_in_ns = voe_wrapper_->hw()->BuiltInNSIsAvailable(); | 754 const bool built_in_ns = voe_wrapper_->hw()->BuiltInNSIsAvailable(); |
760 if (built_in_ns) { | 755 if (built_in_ns) { |
761 if (voe_wrapper_->hw()->EnableBuiltInNS(noise_suppression) == 0 && | 756 if (voe_wrapper_->hw()->EnableBuiltInNS(*options.noise_suppression) == |
762 noise_suppression) { | 757 0 && |
| 758 *options.noise_suppression) { |
763 // Disable internal software NS if built-in NS is enabled, | 759 // Disable internal software NS if built-in NS is enabled, |
764 // i.e., replace the software NS with the built-in NS. | 760 // i.e., replace the software NS with the built-in NS. |
765 options.noise_suppression.Set(false); | 761 options.noise_suppression = rtc::Maybe<bool>(false); |
766 noise_suppression = false; | |
767 LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead"; | 762 LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead"; |
768 } | 763 } |
769 } | 764 } |
770 if (voep->SetNsStatus(noise_suppression, ns_mode) == -1) { | 765 if (voep->SetNsStatus(*options.noise_suppression, ns_mode) == -1) { |
771 LOG_RTCERR2(SetNsStatus, noise_suppression, ns_mode); | 766 LOG_RTCERR2(SetNsStatus, *options.noise_suppression, ns_mode); |
772 return false; | 767 return false; |
773 } else { | 768 } else { |
774 LOG(LS_INFO) << "Noise suppression set to " << noise_suppression | 769 LOG(LS_INFO) << "Noise suppression set to " << *options.noise_suppression |
775 << " with mode " << ns_mode; | 770 << " with mode " << ns_mode; |
776 } | 771 } |
777 } | 772 } |
778 | 773 |
779 bool highpass_filter; | 774 if (options.highpass_filter) { |
780 if (options.highpass_filter.Get(&highpass_filter)) { | 775 LOG(LS_INFO) << "High pass filter enabled? " << *options.highpass_filter; |
781 LOG(LS_INFO) << "High pass filter enabled? " << highpass_filter; | 776 if (voep->EnableHighPassFilter(*options.highpass_filter) == -1) { |
782 if (voep->EnableHighPassFilter(highpass_filter) == -1) { | 777 LOG_RTCERR1(SetHighpassFilterStatus, *options.highpass_filter); |
783 LOG_RTCERR1(SetHighpassFilterStatus, highpass_filter); | |
784 return false; | 778 return false; |
785 } | 779 } |
786 } | 780 } |
787 | 781 |
788 bool stereo_swapping; | 782 if (options.stereo_swapping) { |
789 if (options.stereo_swapping.Get(&stereo_swapping)) { | 783 LOG(LS_INFO) << "Stereo swapping enabled? " << *options.stereo_swapping; |
790 LOG(LS_INFO) << "Stereo swapping enabled? " << stereo_swapping; | 784 voep->EnableStereoChannelSwapping(*options.stereo_swapping); |
791 voep->EnableStereoChannelSwapping(stereo_swapping); | 785 if (voep->IsStereoChannelSwappingEnabled() != *options.stereo_swapping) { |
792 if (voep->IsStereoChannelSwappingEnabled() != stereo_swapping) { | 786 LOG_RTCERR1(EnableStereoChannelSwapping, *options.stereo_swapping); |
793 LOG_RTCERR1(EnableStereoChannelSwapping, stereo_swapping); | |
794 return false; | 787 return false; |
795 } | 788 } |
796 } | 789 } |
797 | 790 |
798 int audio_jitter_buffer_max_packets; | 791 if (options.audio_jitter_buffer_max_packets) { |
799 if (options.audio_jitter_buffer_max_packets.Get( | 792 LOG(LS_INFO) << "NetEq capacity is " |
800 &audio_jitter_buffer_max_packets)) { | 793 << *options.audio_jitter_buffer_max_packets; |
801 LOG(LS_INFO) << "NetEq capacity is " << audio_jitter_buffer_max_packets; | |
802 voe_config_.Set<webrtc::NetEqCapacityConfig>( | 794 voe_config_.Set<webrtc::NetEqCapacityConfig>( |
803 new webrtc::NetEqCapacityConfig(audio_jitter_buffer_max_packets)); | 795 new webrtc::NetEqCapacityConfig( |
| 796 *options.audio_jitter_buffer_max_packets)); |
804 } | 797 } |
805 | 798 |
806 bool audio_jitter_buffer_fast_accelerate; | 799 if (options.audio_jitter_buffer_fast_accelerate) { |
807 if (options.audio_jitter_buffer_fast_accelerate.Get( | 800 LOG(LS_INFO) << "NetEq fast mode? " |
808 &audio_jitter_buffer_fast_accelerate)) { | 801 << *options.audio_jitter_buffer_fast_accelerate; |
809 LOG(LS_INFO) << "NetEq fast mode? " << audio_jitter_buffer_fast_accelerate; | |
810 voe_config_.Set<webrtc::NetEqFastAccelerate>( | 802 voe_config_.Set<webrtc::NetEqFastAccelerate>( |
811 new webrtc::NetEqFastAccelerate(audio_jitter_buffer_fast_accelerate)); | 803 new webrtc::NetEqFastAccelerate( |
| 804 *options.audio_jitter_buffer_fast_accelerate)); |
812 } | 805 } |
813 | 806 |
814 bool typing_detection; | 807 if (options.typing_detection) { |
815 if (options.typing_detection.Get(&typing_detection)) { | 808 LOG(LS_INFO) << "Typing detection is enabled? " |
816 LOG(LS_INFO) << "Typing detection is enabled? " << typing_detection; | 809 << *options.typing_detection; |
817 if (voep->SetTypingDetectionStatus(typing_detection) == -1) { | 810 if (voep->SetTypingDetectionStatus(*options.typing_detection) == -1) { |
818 // In case of error, log the info and continue | 811 // In case of error, log the info and continue |
819 LOG_RTCERR1(SetTypingDetectionStatus, typing_detection); | 812 LOG_RTCERR1(SetTypingDetectionStatus, *options.typing_detection); |
820 } | 813 } |
821 } | 814 } |
822 | 815 |
823 int adjust_agc_delta; | 816 if (options.adjust_agc_delta) { |
824 if (options.adjust_agc_delta.Get(&adjust_agc_delta)) { | 817 LOG(LS_INFO) << "Adjust agc delta is " << *options.adjust_agc_delta; |
825 LOG(LS_INFO) << "Adjust agc delta is " << adjust_agc_delta; | 818 if (!AdjustAgcLevel(*options.adjust_agc_delta)) { |
826 if (!AdjustAgcLevel(adjust_agc_delta)) { | |
827 return false; | 819 return false; |
828 } | 820 } |
829 } | 821 } |
830 | 822 |
831 bool aec_dump; | 823 if (options.aec_dump) { |
832 if (options.aec_dump.Get(&aec_dump)) { | 824 LOG(LS_INFO) << "Aec dump is enabled? " << *options.aec_dump; |
833 LOG(LS_INFO) << "Aec dump is enabled? " << aec_dump; | 825 if (*options.aec_dump) |
834 if (aec_dump) | |
835 StartAecDump(kAecDumpByAudioOptionFilename); | 826 StartAecDump(kAecDumpByAudioOptionFilename); |
836 else | 827 else |
837 StopAecDump(); | 828 StopAecDump(); |
838 } | 829 } |
839 | 830 |
840 webrtc::Config config; | 831 webrtc::Config config; |
841 | 832 |
842 delay_agnostic_aec_.SetFrom(options.delay_agnostic_aec); | 833 if (options.delay_agnostic_aec) |
843 bool delay_agnostic_aec; | 834 delay_agnostic_aec_ = options.delay_agnostic_aec; |
844 if (delay_agnostic_aec_.Get(&delay_agnostic_aec)) { | 835 if (delay_agnostic_aec_) { |
845 LOG(LS_INFO) << "Delay agnostic aec is enabled? " << delay_agnostic_aec; | 836 LOG(LS_INFO) << "Delay agnostic aec is enabled? " << *delay_agnostic_aec_; |
846 config.Set<webrtc::DelayAgnostic>( | 837 config.Set<webrtc::DelayAgnostic>( |
847 new webrtc::DelayAgnostic(delay_agnostic_aec)); | 838 new webrtc::DelayAgnostic(*delay_agnostic_aec_)); |
848 } | 839 } |
849 | 840 |
850 extended_filter_aec_.SetFrom(options.extended_filter_aec); | 841 if (options.extended_filter_aec) { |
851 bool extended_filter; | 842 extended_filter_aec_ = options.extended_filter_aec; |
852 if (extended_filter_aec_.Get(&extended_filter)) { | 843 } |
853 LOG(LS_INFO) << "Extended filter aec is enabled? " << extended_filter; | 844 if (extended_filter_aec_) { |
| 845 LOG(LS_INFO) << "Extended filter aec is enabled? " << *extended_filter_aec_; |
854 config.Set<webrtc::ExtendedFilter>( | 846 config.Set<webrtc::ExtendedFilter>( |
855 new webrtc::ExtendedFilter(extended_filter)); | 847 new webrtc::ExtendedFilter(*extended_filter_aec_)); |
856 } | 848 } |
857 | 849 |
858 experimental_ns_.SetFrom(options.experimental_ns); | 850 if (options.experimental_ns) { |
859 bool experimental_ns; | 851 experimental_ns_ = options.experimental_ns; |
860 if (experimental_ns_.Get(&experimental_ns)) { | 852 } |
861 LOG(LS_INFO) << "Experimental ns is enabled? " << experimental_ns; | 853 if (experimental_ns_) { |
| 854 LOG(LS_INFO) << "Experimental ns is enabled? " << *experimental_ns_; |
862 config.Set<webrtc::ExperimentalNs>( | 855 config.Set<webrtc::ExperimentalNs>( |
863 new webrtc::ExperimentalNs(experimental_ns)); | 856 new webrtc::ExperimentalNs(*experimental_ns_)); |
864 } | 857 } |
865 | 858 |
866 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine | 859 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine |
867 // returns NULL on audio_processing(). | 860 // returns NULL on audio_processing(). |
868 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); | 861 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); |
869 if (audioproc) { | 862 if (audioproc) { |
870 audioproc->SetExtraOptions(config); | 863 audioproc->SetExtraOptions(config); |
871 } | 864 } |
872 | 865 |
873 uint32_t recording_sample_rate; | 866 if (options.recording_sample_rate) { |
874 if (options.recording_sample_rate.Get(&recording_sample_rate)) { | 867 LOG(LS_INFO) << "Recording sample rate is " |
875 LOG(LS_INFO) << "Recording sample rate is " << recording_sample_rate; | 868 << *options.recording_sample_rate; |
876 if (voe_wrapper_->hw()->SetRecordingSampleRate(recording_sample_rate)) { | 869 if (voe_wrapper_->hw()->SetRecordingSampleRate( |
877 LOG_RTCERR1(SetRecordingSampleRate, recording_sample_rate); | 870 *options.recording_sample_rate)) { |
| 871 LOG_RTCERR1(SetRecordingSampleRate, *options.recording_sample_rate); |
878 } | 872 } |
879 } | 873 } |
880 | 874 |
881 uint32_t playout_sample_rate; | 875 if (options.playout_sample_rate) { |
882 if (options.playout_sample_rate.Get(&playout_sample_rate)) { | 876 LOG(LS_INFO) << "Playout sample rate is " << *options.playout_sample_rate; |
883 LOG(LS_INFO) << "Playout sample rate is " << playout_sample_rate; | 877 if (voe_wrapper_->hw()->SetPlayoutSampleRate( |
884 if (voe_wrapper_->hw()->SetPlayoutSampleRate(playout_sample_rate)) { | 878 *options.playout_sample_rate)) { |
885 LOG_RTCERR1(SetPlayoutSampleRate, playout_sample_rate); | 879 LOG_RTCERR1(SetPlayoutSampleRate, *options.playout_sample_rate); |
886 } | 880 } |
887 } | 881 } |
888 | 882 |
889 return true; | 883 return true; |
890 } | 884 } |
891 | 885 |
892 // TODO(juberti): Refactor this so that the core logic can be used to set the | 886 // TODO(juberti): Refactor this so that the core logic can be used to set the |
893 // soundclip device. At that time, reinstate the soundclip pause/resume code. | 887 // soundclip device. At that time, reinstate the soundclip pause/resume code. |
894 bool WebRtcVoiceEngine::SetDevices(const Device* in_device, | 888 bool WebRtcVoiceEngine::SetDevices(const Device* in_device, |
895 const Device* out_device) { | 889 const Device* out_device) { |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 if (send_ != SEND_NOTHING) { | 1501 if (send_ != SEND_NOTHING) { |
1508 if (!engine()->ApplyOptions(options_)) { | 1502 if (!engine()->ApplyOptions(options_)) { |
1509 LOG(LS_WARNING) << | 1503 LOG(LS_WARNING) << |
1510 "Failed to apply engine options during channel SetOptions."; | 1504 "Failed to apply engine options during channel SetOptions."; |
1511 return false; | 1505 return false; |
1512 } | 1506 } |
1513 } | 1507 } |
1514 | 1508 |
1515 if (dscp_option_changed) { | 1509 if (dscp_option_changed) { |
1516 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT; | 1510 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT; |
1517 if (options_.dscp.GetWithDefaultIfUnset(false)) | 1511 if (options_.dscp.value_or(false)) |
1518 dscp = kAudioDscpValue; | 1512 dscp = kAudioDscpValue; |
1519 if (MediaChannel::SetDscp(dscp) != 0) { | 1513 if (MediaChannel::SetDscp(dscp) != 0) { |
1520 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel"; | 1514 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel"; |
1521 } | 1515 } |
1522 } | 1516 } |
1523 | 1517 |
1524 // TODO(solenberg): Don't recreate unless options changed. | 1518 // TODO(solenberg): Don't recreate unless options changed. |
1525 RecreateAudioReceiveStreams(); | 1519 RecreateAudioReceiveStreams(); |
1526 | 1520 |
1527 LOG(LS_INFO) << "Set voice channel options. Current options: " | 1521 LOG(LS_INFO) << "Set voice channel options. Current options: " |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2850 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32_t ssrc) { | 2844 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32_t ssrc) { |
2851 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2845 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
2852 WebRtcAudioReceiveStream* stream = receive_channels_[ssrc]; | 2846 WebRtcAudioReceiveStream* stream = receive_channels_[ssrc]; |
2853 RTC_DCHECK(stream != nullptr); | 2847 RTC_DCHECK(stream != nullptr); |
2854 RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); | 2848 RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); |
2855 webrtc::AudioReceiveStream::Config config; | 2849 webrtc::AudioReceiveStream::Config config; |
2856 config.rtp.remote_ssrc = ssrc; | 2850 config.rtp.remote_ssrc = ssrc; |
2857 // Only add RTP extensions if we support combined A/V BWE. | 2851 // Only add RTP extensions if we support combined A/V BWE. |
2858 config.rtp.extensions = recv_rtp_extensions_; | 2852 config.rtp.extensions = recv_rtp_extensions_; |
2859 config.combined_audio_video_bwe = | 2853 config.combined_audio_video_bwe = |
2860 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); | 2854 options_.combined_audio_video_bwe.value_or(false); |
2861 config.voe_channel_id = stream->channel(); | 2855 config.voe_channel_id = stream->channel(); |
2862 config.sync_group = receive_stream_params_[ssrc].sync_label; | 2856 config.sync_group = receive_stream_params_[ssrc].sync_label; |
2863 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); | 2857 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); |
2864 receive_streams_.insert(std::make_pair(ssrc, s)); | 2858 receive_streams_.insert(std::make_pair(ssrc, s)); |
2865 } | 2859 } |
2866 | 2860 |
2867 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32_t ssrc) { | 2861 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32_t ssrc) { |
2868 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2862 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
2869 auto stream_it = receive_streams_.find(ssrc); | 2863 auto stream_it = receive_streams_.find(ssrc); |
2870 if (stream_it != receive_streams_.end()) { | 2864 if (stream_it != receive_streams_.end()) { |
(...skipping 22 matching lines...) Expand all Loading... |
2893 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 2887 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
2894 return false; | 2888 return false; |
2895 } | 2889 } |
2896 } | 2890 } |
2897 return true; | 2891 return true; |
2898 } | 2892 } |
2899 | 2893 |
2900 } // namespace cricket | 2894 } // namespace cricket |
2901 | 2895 |
2902 #endif // HAVE_WEBRTC_VOICE | 2896 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |