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