OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "webrtc/base/constructormagic.h" | 25 #include "webrtc/base/constructormagic.h" |
26 #include "webrtc/base/helpers.h" | 26 #include "webrtc/base/helpers.h" |
27 #include "webrtc/base/logging.h" | 27 #include "webrtc/base/logging.h" |
28 #include "webrtc/base/race_checker.h" | 28 #include "webrtc/base/race_checker.h" |
29 #include "webrtc/base/stringencode.h" | 29 #include "webrtc/base/stringencode.h" |
30 #include "webrtc/base/stringutils.h" | 30 #include "webrtc/base/stringutils.h" |
31 #include "webrtc/base/trace_event.h" | 31 #include "webrtc/base/trace_event.h" |
32 #include "webrtc/media/base/audiosource.h" | 32 #include "webrtc/media/base/audiosource.h" |
33 #include "webrtc/media/base/mediaconstants.h" | 33 #include "webrtc/media/base/mediaconstants.h" |
34 #include "webrtc/media/base/streamparams.h" | 34 #include "webrtc/media/base/streamparams.h" |
| 35 #include "webrtc/media/engine/apm_helpers.h" |
35 #include "webrtc/media/engine/payload_type_mapper.h" | 36 #include "webrtc/media/engine/payload_type_mapper.h" |
36 #include "webrtc/media/engine/webrtcmediaengine.h" | 37 #include "webrtc/media/engine/webrtcmediaengine.h" |
37 #include "webrtc/media/engine/webrtcvoe.h" | 38 #include "webrtc/media/engine/webrtcvoe.h" |
38 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" | 39 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
39 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 40 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
40 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 41 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
41 #include "webrtc/system_wrappers/include/field_trial.h" | 42 #include "webrtc/system_wrappers/include/field_trial.h" |
42 #include "webrtc/system_wrappers/include/trace.h" | 43 #include "webrtc/system_wrappers/include/trace.h" |
| 44 #include "webrtc/voice_engine/transmit_mixer.h" |
43 | 45 |
44 namespace cricket { | 46 namespace cricket { |
45 namespace { | 47 namespace { |
46 | 48 |
47 const int kDefaultTraceFilter = webrtc::kTraceNone | webrtc::kTraceTerseInfo | | 49 const int kDefaultTraceFilter = webrtc::kTraceNone | webrtc::kTraceTerseInfo | |
48 webrtc::kTraceWarning | webrtc::kTraceError | | 50 webrtc::kTraceWarning | webrtc::kTraceError | |
49 webrtc::kTraceCritical; | 51 webrtc::kTraceCritical; |
50 const int kElevatedTraceFilter = kDefaultTraceFilter | webrtc::kTraceStateInfo | | 52 const int kElevatedTraceFilter = kDefaultTraceFilter | webrtc::kTraceStateInfo | |
51 webrtc::kTraceInfo; | 53 webrtc::kTraceInfo; |
52 | 54 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // fail. If codec is not multi-rate and |bps| exceeds or equal the fixed | 554 // fail. If codec is not multi-rate and |bps| exceeds or equal the fixed |
553 // bitrate then ignore. | 555 // bitrate then ignore. |
554 LOG(LS_ERROR) << "Failed to set codec " << codec_inst.plname | 556 LOG(LS_ERROR) << "Failed to set codec " << codec_inst.plname |
555 << " to bitrate " << bps << " bps" | 557 << " to bitrate " << bps << " bps" |
556 << ", requires at least " << codec_inst.rate << " bps."; | 558 << ", requires at least " << codec_inst.rate << " bps."; |
557 return rtc::Optional<int>(); | 559 return rtc::Optional<int>(); |
558 } | 560 } |
559 return rtc::Optional<int>(codec_rate); | 561 return rtc::Optional<int>(codec_rate); |
560 } | 562 } |
561 | 563 |
562 } // namespace { | 564 } // namespace |
563 | 565 |
564 bool WebRtcVoiceEngine::ToCodecInst(const AudioCodec& in, | 566 bool WebRtcVoiceEngine::ToCodecInst(const AudioCodec& in, |
565 webrtc::CodecInst* out) { | 567 webrtc::CodecInst* out) { |
566 return WebRtcVoiceCodecs::ToCodecInst(in, out); | 568 return WebRtcVoiceCodecs::ToCodecInst(in, out); |
567 } | 569 } |
568 | 570 |
569 WebRtcVoiceEngine::WebRtcVoiceEngine( | 571 WebRtcVoiceEngine::WebRtcVoiceEngine( |
570 webrtc::AudioDeviceModule* adm, | 572 webrtc::AudioDeviceModule* adm, |
571 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, | 573 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, |
572 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer) | 574 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 | 615 |
614 // No ADM supplied? Get the default one from VoE. | 616 // No ADM supplied? Get the default one from VoE. |
615 if (!adm_) { | 617 if (!adm_) { |
616 adm_ = voe_wrapper_->base()->audio_device_module(); | 618 adm_ = voe_wrapper_->base()->audio_device_module(); |
617 } | 619 } |
618 RTC_DCHECK(adm_); | 620 RTC_DCHECK(adm_); |
619 | 621 |
620 apm_ = voe_wrapper_->base()->audio_processing(); | 622 apm_ = voe_wrapper_->base()->audio_processing(); |
621 RTC_DCHECK(apm_); | 623 RTC_DCHECK(apm_); |
622 | 624 |
| 625 transmit_mixer_ = voe_wrapper_->base()->transmit_mixer(); |
| 626 RTC_DCHECK(transmit_mixer_); |
| 627 |
623 // Save the default AGC configuration settings. This must happen before | 628 // Save the default AGC configuration settings. This must happen before |
624 // calling ApplyOptions or the default will be overwritten. | 629 // calling ApplyOptions or the default will be overwritten. |
625 int error = voe_wrapper_->processing()->GetAgcConfig(default_agc_config_); | 630 default_agc_config_ = webrtc::apm_helpers::GetAgcConfig(apm_); |
626 RTC_DCHECK_EQ(0, error); | |
627 | 631 |
628 // Set default engine options. | 632 // Set default engine options. |
629 { | 633 { |
630 AudioOptions options; | 634 AudioOptions options; |
631 options.echo_cancellation = rtc::Optional<bool>(true); | 635 options.echo_cancellation = rtc::Optional<bool>(true); |
632 options.auto_gain_control = rtc::Optional<bool>(true); | 636 options.auto_gain_control = rtc::Optional<bool>(true); |
633 options.noise_suppression = rtc::Optional<bool>(true); | 637 options.noise_suppression = rtc::Optional<bool>(true); |
634 options.highpass_filter = rtc::Optional<bool>(true); | 638 options.highpass_filter = rtc::Optional<bool>(true); |
635 options.stereo_swapping = rtc::Optional<bool>(false); | 639 options.stereo_swapping = rtc::Optional<bool>(false); |
636 options.audio_jitter_buffer_max_packets = rtc::Optional<int>(50); | 640 options.audio_jitter_buffer_max_packets = rtc::Optional<int>(50); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 return new WebRtcVoiceMediaChannel(this, config, options, call); | 677 return new WebRtcVoiceMediaChannel(this, config, options, call); |
674 } | 678 } |
675 | 679 |
676 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { | 680 bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { |
677 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 681 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
678 LOG(LS_INFO) << "WebRtcVoiceEngine::ApplyOptions: " << options_in.ToString(); | 682 LOG(LS_INFO) << "WebRtcVoiceEngine::ApplyOptions: " << options_in.ToString(); |
679 AudioOptions options = options_in; // The options are modified below. | 683 AudioOptions options = options_in; // The options are modified below. |
680 | 684 |
681 // kEcConference is AEC with high suppression. | 685 // kEcConference is AEC with high suppression. |
682 webrtc::EcModes ec_mode = webrtc::kEcConference; | 686 webrtc::EcModes ec_mode = webrtc::kEcConference; |
683 webrtc::AecmModes aecm_mode = webrtc::kAecmSpeakerphone; | |
684 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; | 687 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; |
685 webrtc::NsModes ns_mode = webrtc::kNsHighSuppression; | |
686 if (options.aecm_generate_comfort_noise) { | 688 if (options.aecm_generate_comfort_noise) { |
687 LOG(LS_VERBOSE) << "Comfort noise explicitly set to " | 689 LOG(LS_VERBOSE) << "Comfort noise explicitly set to " |
688 << *options.aecm_generate_comfort_noise | 690 << *options.aecm_generate_comfort_noise |
689 << " (default is false)."; | 691 << " (default is false)."; |
690 } | 692 } |
691 | 693 |
692 #if defined(WEBRTC_IOS) | 694 #if defined(WEBRTC_IOS) |
693 // On iOS, VPIO provides built-in EC, NS and AGC. | 695 // On iOS, VPIO provides built-in EC, NS and AGC. |
694 options.echo_cancellation = rtc::Optional<bool>(false); | 696 options.echo_cancellation = rtc::Optional<bool>(false); |
695 options.auto_gain_control = rtc::Optional<bool>(false); | 697 options.auto_gain_control = rtc::Optional<bool>(false); |
(...skipping 26 matching lines...) Expand all Loading... |
722 ec_mode = webrtc::kEcConference; | 724 ec_mode = webrtc::kEcConference; |
723 } | 725 } |
724 } | 726 } |
725 #endif | 727 #endif |
726 | 728 |
727 #if (WEBRTC_INTELLIGIBILITY_ENHANCER == 0) | 729 #if (WEBRTC_INTELLIGIBILITY_ENHANCER == 0) |
728 // Hardcode the intelligibility enhancer to be off. | 730 // Hardcode the intelligibility enhancer to be off. |
729 options.intelligibility_enhancer = rtc::Optional<bool>(false); | 731 options.intelligibility_enhancer = rtc::Optional<bool>(false); |
730 #endif | 732 #endif |
731 | 733 |
732 webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); | |
733 | |
734 if (options.echo_cancellation) { | 734 if (options.echo_cancellation) { |
735 // Check if platform supports built-in EC. Currently only supported on | 735 // Check if platform supports built-in EC. Currently only supported on |
736 // Android and in combination with Java based audio layer. | 736 // Android and in combination with Java based audio layer. |
737 // TODO(henrika): investigate possibility to support built-in EC also | 737 // TODO(henrika): investigate possibility to support built-in EC also |
738 // in combination with Open SL ES audio. | 738 // in combination with Open SL ES audio. |
739 const bool built_in_aec = adm()->BuiltInAECIsAvailable(); | 739 const bool built_in_aec = adm()->BuiltInAECIsAvailable(); |
740 if (built_in_aec) { | 740 if (built_in_aec) { |
741 // Built-in EC exists on this device and use_delay_agnostic_aec is not | 741 // Built-in EC exists on this device and use_delay_agnostic_aec is not |
742 // overriding it. Enable/Disable it according to the echo_cancellation | 742 // overriding it. Enable/Disable it according to the echo_cancellation |
743 // audio option. | 743 // audio option. |
744 const bool enable_built_in_aec = | 744 const bool enable_built_in_aec = |
745 *options.echo_cancellation && !use_delay_agnostic_aec; | 745 *options.echo_cancellation && !use_delay_agnostic_aec; |
746 if (adm()->EnableBuiltInAEC(enable_built_in_aec) == 0 && | 746 if (adm()->EnableBuiltInAEC(enable_built_in_aec) == 0 && |
747 enable_built_in_aec) { | 747 enable_built_in_aec) { |
748 // Disable internal software EC if built-in EC is enabled, | 748 // Disable internal software EC if built-in EC is enabled, |
749 // i.e., replace the software EC with the built-in EC. | 749 // i.e., replace the software EC with the built-in EC. |
750 options.echo_cancellation = rtc::Optional<bool>(false); | 750 options.echo_cancellation = rtc::Optional<bool>(false); |
751 LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; | 751 LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; |
752 } | 752 } |
753 } | 753 } |
754 if (voep->SetEcStatus(*options.echo_cancellation, ec_mode) == -1) { | 754 webrtc::apm_helpers::SetEcStatus( |
755 LOG_RTCERR2(SetEcStatus, *options.echo_cancellation, ec_mode); | 755 apm(), *options.echo_cancellation, ec_mode); |
756 return false; | |
757 } else { | |
758 LOG(LS_INFO) << "Echo control set to " << *options.echo_cancellation | |
759 << " with mode " << ec_mode; | |
760 } | |
761 #if !defined(ANDROID) | 756 #if !defined(ANDROID) |
762 // TODO(ajm): Remove the error return on Android from webrtc. | 757 webrtc::apm_helpers::SetEcMetricsStatus(apm(), *options.echo_cancellation); |
763 if (voep->SetEcMetricsStatus(*options.echo_cancellation) == -1) { | |
764 LOG_RTCERR1(SetEcMetricsStatus, *options.echo_cancellation); | |
765 return false; | |
766 } | |
767 #endif | 758 #endif |
768 if (ec_mode == webrtc::kEcAecm) { | 759 if (ec_mode == webrtc::kEcAecm) { |
769 bool cn = options.aecm_generate_comfort_noise.value_or(false); | 760 bool cn = options.aecm_generate_comfort_noise.value_or(false); |
770 if (voep->SetAecmMode(aecm_mode, cn) != 0) { | 761 webrtc::apm_helpers::SetAecmMode(apm(), cn); |
771 LOG_RTCERR2(SetAecmMode, aecm_mode, cn); | |
772 return false; | |
773 } | |
774 } | 762 } |
775 } | 763 } |
776 | 764 |
777 if (options.auto_gain_control) { | 765 if (options.auto_gain_control) { |
778 bool built_in_agc_avaliable = adm()->BuiltInAGCIsAvailable(); | 766 bool built_in_agc_avaliable = adm()->BuiltInAGCIsAvailable(); |
779 if (built_in_agc_avaliable) { | 767 if (built_in_agc_avaliable) { |
780 if (adm()->EnableBuiltInAGC(*options.auto_gain_control) == 0 && | 768 if (adm()->EnableBuiltInAGC(*options.auto_gain_control) == 0 && |
781 *options.auto_gain_control) { | 769 *options.auto_gain_control) { |
782 // Disable internal software AGC if built-in AGC is enabled, | 770 // Disable internal software AGC if built-in AGC is enabled, |
783 // i.e., replace the software AGC with the built-in AGC. | 771 // i.e., replace the software AGC with the built-in AGC. |
784 options.auto_gain_control = rtc::Optional<bool>(false); | 772 options.auto_gain_control = rtc::Optional<bool>(false); |
785 LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead"; | 773 LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead"; |
786 } | 774 } |
787 } | 775 } |
788 if (voep->SetAgcStatus(*options.auto_gain_control, agc_mode) == -1) { | 776 webrtc::apm_helpers::SetAgcStatus( |
789 LOG_RTCERR2(SetAgcStatus, *options.auto_gain_control, agc_mode); | 777 apm(), adm(), *options.auto_gain_control, agc_mode); |
790 return false; | |
791 } else { | |
792 LOG(LS_INFO) << "Auto gain set to " << *options.auto_gain_control | |
793 << " with mode " << agc_mode; | |
794 } | |
795 } | 778 } |
796 | 779 |
797 if (options.tx_agc_target_dbov || options.tx_agc_digital_compression_gain || | 780 if (options.tx_agc_target_dbov || options.tx_agc_digital_compression_gain || |
798 options.tx_agc_limiter) { | 781 options.tx_agc_limiter || options.adjust_agc_delta) { |
799 // Override default_agc_config_. Generally, an unset option means "leave | 782 // Override default_agc_config_. Generally, an unset option means "leave |
800 // the VoE bits alone" in this function, so we want whatever is set to be | 783 // the VoE bits alone" in this function, so we want whatever is set to be |
801 // stored as the new "default". If we didn't, then setting e.g. | 784 // stored as the new "default". If we didn't, then setting e.g. |
802 // tx_agc_target_dbov would reset digital compression gain and limiter | 785 // tx_agc_target_dbov would reset digital compression gain and limiter |
803 // settings. | 786 // settings. |
804 // Also, if we don't update default_agc_config_, then adjust_agc_delta | 787 // Also, if we don't update default_agc_config_, then adjust_agc_delta |
805 // would be an offset from the original values, and not whatever was set | 788 // would be an offset from the original values, and not whatever was set |
806 // explicitly. | 789 // explicitly. |
807 default_agc_config_.targetLeveldBOv = options.tx_agc_target_dbov.value_or( | 790 default_agc_config_.targetLeveldBOv = options.tx_agc_target_dbov.value_or( |
808 default_agc_config_.targetLeveldBOv); | 791 default_agc_config_.targetLeveldBOv); |
809 default_agc_config_.digitalCompressionGaindB = | 792 default_agc_config_.digitalCompressionGaindB = |
810 options.tx_agc_digital_compression_gain.value_or( | 793 options.tx_agc_digital_compression_gain.value_or( |
811 default_agc_config_.digitalCompressionGaindB); | 794 default_agc_config_.digitalCompressionGaindB); |
812 default_agc_config_.limiterEnable = | 795 default_agc_config_.limiterEnable = |
813 options.tx_agc_limiter.value_or(default_agc_config_.limiterEnable); | 796 options.tx_agc_limiter.value_or(default_agc_config_.limiterEnable); |
814 if (voe_wrapper_->processing()->SetAgcConfig(default_agc_config_) == -1) { | 797 |
815 LOG_RTCERR3(SetAgcConfig, | 798 webrtc::AgcConfig config = default_agc_config_; |
816 default_agc_config_.targetLeveldBOv, | 799 if (options.adjust_agc_delta) { |
817 default_agc_config_.digitalCompressionGaindB, | 800 config.targetLeveldBOv -= *options.adjust_agc_delta; |
818 default_agc_config_.limiterEnable); | 801 LOG(LS_INFO) << "Adjusting AGC level from default -" |
819 return false; | 802 << default_agc_config_.targetLeveldBOv << "dB to -" |
| 803 << config.targetLeveldBOv << "dB"; |
820 } | 804 } |
| 805 webrtc::apm_helpers::SetAgcConfig(apm_, config); |
821 } | 806 } |
822 | 807 |
823 if (options.intelligibility_enhancer) { | 808 if (options.intelligibility_enhancer) { |
824 intelligibility_enhancer_ = options.intelligibility_enhancer; | 809 intelligibility_enhancer_ = options.intelligibility_enhancer; |
825 } | 810 } |
826 if (intelligibility_enhancer_ && *intelligibility_enhancer_) { | 811 if (intelligibility_enhancer_ && *intelligibility_enhancer_) { |
827 LOG(LS_INFO) << "Enabling NS when Intelligibility Enhancer is active."; | 812 LOG(LS_INFO) << "Enabling NS when Intelligibility Enhancer is active."; |
828 options.noise_suppression = intelligibility_enhancer_; | 813 options.noise_suppression = intelligibility_enhancer_; |
829 } | 814 } |
830 | 815 |
831 if (options.noise_suppression) { | 816 if (options.noise_suppression) { |
832 if (adm()->BuiltInNSIsAvailable()) { | 817 if (adm()->BuiltInNSIsAvailable()) { |
833 bool builtin_ns = | 818 bool builtin_ns = |
834 *options.noise_suppression && | 819 *options.noise_suppression && |
835 !(intelligibility_enhancer_ && *intelligibility_enhancer_); | 820 !(intelligibility_enhancer_ && *intelligibility_enhancer_); |
836 if (adm()->EnableBuiltInNS(builtin_ns) == 0 && builtin_ns) { | 821 if (adm()->EnableBuiltInNS(builtin_ns) == 0 && builtin_ns) { |
837 // Disable internal software NS if built-in NS is enabled, | 822 // Disable internal software NS if built-in NS is enabled, |
838 // i.e., replace the software NS with the built-in NS. | 823 // i.e., replace the software NS with the built-in NS. |
839 options.noise_suppression = rtc::Optional<bool>(false); | 824 options.noise_suppression = rtc::Optional<bool>(false); |
840 LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead"; | 825 LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead"; |
841 } | 826 } |
842 } | 827 } |
843 if (voep->SetNsStatus(*options.noise_suppression, ns_mode) == -1) { | 828 webrtc::apm_helpers::SetNsStatus(apm(), *options.noise_suppression); |
844 LOG_RTCERR2(SetNsStatus, *options.noise_suppression, ns_mode); | |
845 return false; | |
846 } else { | |
847 LOG(LS_INFO) << "Noise suppression set to " << *options.noise_suppression | |
848 << " with mode " << ns_mode; | |
849 } | |
850 } | 829 } |
851 | 830 |
852 if (options.stereo_swapping) { | 831 if (options.stereo_swapping) { |
853 LOG(LS_INFO) << "Stereo swapping enabled? " << *options.stereo_swapping; | 832 LOG(LS_INFO) << "Stereo swapping enabled? " << *options.stereo_swapping; |
854 voep->EnableStereoChannelSwapping(*options.stereo_swapping); | 833 transmit_mixer()->EnableStereoChannelSwapping(*options.stereo_swapping); |
855 if (voep->IsStereoChannelSwappingEnabled() != *options.stereo_swapping) { | |
856 LOG_RTCERR1(EnableStereoChannelSwapping, *options.stereo_swapping); | |
857 return false; | |
858 } | |
859 } | 834 } |
860 | 835 |
861 if (options.audio_jitter_buffer_max_packets) { | 836 if (options.audio_jitter_buffer_max_packets) { |
862 LOG(LS_INFO) << "NetEq capacity is " | 837 LOG(LS_INFO) << "NetEq capacity is " |
863 << *options.audio_jitter_buffer_max_packets; | 838 << *options.audio_jitter_buffer_max_packets; |
864 channel_config_.acm_config.neteq_config.max_packets_in_buffer = | 839 channel_config_.acm_config.neteq_config.max_packets_in_buffer = |
865 std::max(20, *options.audio_jitter_buffer_max_packets); | 840 std::max(20, *options.audio_jitter_buffer_max_packets); |
866 } | 841 } |
867 if (options.audio_jitter_buffer_fast_accelerate) { | 842 if (options.audio_jitter_buffer_fast_accelerate) { |
868 LOG(LS_INFO) << "NetEq fast mode? " | 843 LOG(LS_INFO) << "NetEq fast mode? " |
869 << *options.audio_jitter_buffer_fast_accelerate; | 844 << *options.audio_jitter_buffer_fast_accelerate; |
870 channel_config_.acm_config.neteq_config.enable_fast_accelerate = | 845 channel_config_.acm_config.neteq_config.enable_fast_accelerate = |
871 *options.audio_jitter_buffer_fast_accelerate; | 846 *options.audio_jitter_buffer_fast_accelerate; |
872 } | 847 } |
873 | 848 |
874 if (options.typing_detection) { | 849 if (options.typing_detection) { |
875 LOG(LS_INFO) << "Typing detection is enabled? " | 850 LOG(LS_INFO) << "Typing detection is enabled? " |
876 << *options.typing_detection; | 851 << *options.typing_detection; |
877 if (voep->SetTypingDetectionStatus(*options.typing_detection) == -1) { | 852 webrtc::apm_helpers::SetTypingDetectionStatus( |
878 // In case of error, log the info and continue | 853 apm(), *options.typing_detection); |
879 LOG_RTCERR1(SetTypingDetectionStatus, *options.typing_detection); | |
880 } | |
881 } | |
882 | |
883 if (options.adjust_agc_delta) { | |
884 LOG(LS_INFO) << "Adjust agc delta is " << *options.adjust_agc_delta; | |
885 if (!AdjustAgcLevel(*options.adjust_agc_delta)) { | |
886 return false; | |
887 } | |
888 } | 854 } |
889 | 855 |
890 webrtc::Config config; | 856 webrtc::Config config; |
891 | 857 |
892 if (options.delay_agnostic_aec) | 858 if (options.delay_agnostic_aec) |
893 delay_agnostic_aec_ = options.delay_agnostic_aec; | 859 delay_agnostic_aec_ = options.delay_agnostic_aec; |
894 if (delay_agnostic_aec_) { | 860 if (delay_agnostic_aec_) { |
895 LOG(LS_INFO) << "Delay agnostic aec is enabled? " << *delay_agnostic_aec_; | 861 LOG(LS_INFO) << "Delay agnostic aec is enabled? " << *delay_agnostic_aec_; |
896 config.Set<webrtc::DelayAgnostic>( | 862 config.Set<webrtc::DelayAgnostic>( |
897 new webrtc::DelayAgnostic(*delay_agnostic_aec_)); | 863 new webrtc::DelayAgnostic(*delay_agnostic_aec_)); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 channels_.push_back(channel); | 1026 channels_.push_back(channel); |
1061 } | 1027 } |
1062 | 1028 |
1063 void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) { | 1029 void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) { |
1064 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1030 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1065 auto it = std::find(channels_.begin(), channels_.end(), channel); | 1031 auto it = std::find(channels_.begin(), channels_.end(), channel); |
1066 RTC_DCHECK(it != channels_.end()); | 1032 RTC_DCHECK(it != channels_.end()); |
1067 channels_.erase(it); | 1033 channels_.erase(it); |
1068 } | 1034 } |
1069 | 1035 |
1070 // Adjusts the default AGC target level by the specified delta. | |
1071 // NB: If we start messing with other config fields, we'll want | |
1072 // to save the current webrtc::AgcConfig as well. | |
1073 bool WebRtcVoiceEngine::AdjustAgcLevel(int delta) { | |
1074 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
1075 webrtc::AgcConfig config = default_agc_config_; | |
1076 config.targetLeveldBOv -= delta; | |
1077 | |
1078 LOG(LS_INFO) << "Adjusting AGC level from default -" | |
1079 << default_agc_config_.targetLeveldBOv << "dB to -" | |
1080 << config.targetLeveldBOv << "dB"; | |
1081 | |
1082 if (voe_wrapper_->processing()->SetAgcConfig(config) == -1) { | |
1083 LOG_RTCERR1(SetAgcConfig, config.targetLeveldBOv); | |
1084 return false; | |
1085 } | |
1086 return true; | |
1087 } | |
1088 | |
1089 bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file, | 1036 bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file, |
1090 int64_t max_size_bytes) { | 1037 int64_t max_size_bytes) { |
1091 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1038 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1092 FILE* aec_dump_file_stream = rtc::FdopenPlatformFileForWriting(file); | 1039 FILE* aec_dump_file_stream = rtc::FdopenPlatformFileForWriting(file); |
1093 if (!aec_dump_file_stream) { | 1040 if (!aec_dump_file_stream) { |
1094 LOG(LS_ERROR) << "Could not open AEC dump file stream."; | 1041 LOG(LS_ERROR) << "Could not open AEC dump file stream."; |
1095 if (!rtc::ClosePlatformFile(file)) | 1042 if (!rtc::ClosePlatformFile(file)) |
1096 LOG(LS_WARNING) << "Could not close file."; | 1043 LOG(LS_WARNING) << "Could not close file."; |
1097 return false; | 1044 return false; |
1098 } | 1045 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 RTC_DCHECK(adm_); | 1088 RTC_DCHECK(adm_); |
1142 return adm_; | 1089 return adm_; |
1143 } | 1090 } |
1144 | 1091 |
1145 webrtc::AudioProcessing* WebRtcVoiceEngine::apm() { | 1092 webrtc::AudioProcessing* WebRtcVoiceEngine::apm() { |
1146 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1093 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1147 RTC_DCHECK(apm_); | 1094 RTC_DCHECK(apm_); |
1148 return apm_; | 1095 return apm_; |
1149 } | 1096 } |
1150 | 1097 |
| 1098 webrtc::voe::TransmitMixer* WebRtcVoiceEngine::transmit_mixer() { |
| 1099 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1100 RTC_DCHECK(transmit_mixer_); |
| 1101 return transmit_mixer_; |
| 1102 } |
| 1103 |
1151 AudioCodecs WebRtcVoiceEngine::CollectRecvCodecs() const { | 1104 AudioCodecs WebRtcVoiceEngine::CollectRecvCodecs() const { |
1152 PayloadTypeMapper mapper; | 1105 PayloadTypeMapper mapper; |
1153 AudioCodecs out; | 1106 AudioCodecs out; |
1154 const std::vector<webrtc::AudioCodecSpec>& specs = | 1107 const std::vector<webrtc::AudioCodecSpec>& specs = |
1155 decoder_factory_->GetSupportedDecoders(); | 1108 decoder_factory_->GetSupportedDecoders(); |
1156 | 1109 |
1157 // Only generate CN payload types for these clockrates: | 1110 // Only generate CN payload types for these clockrates: |
1158 std::map<int, bool, std::greater<int>> generate_cn = {{ 8000, false }, | 1111 std::map<int, bool, std::greater<int>> generate_cn = {{ 8000, false }, |
1159 { 16000, false }, | 1112 { 16000, false }, |
1160 { 32000, false }}; | 1113 { 32000, false }}; |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 "Failed to apply engine options during channel SetOptions."; | 1830 "Failed to apply engine options during channel SetOptions."; |
1878 return false; | 1831 return false; |
1879 } | 1832 } |
1880 | 1833 |
1881 rtc::Optional<std::string> audio_network_adatptor_config = | 1834 rtc::Optional<std::string> audio_network_adatptor_config = |
1882 GetAudioNetworkAdaptorConfig(options_); | 1835 GetAudioNetworkAdaptorConfig(options_); |
1883 for (auto& it : send_streams_) { | 1836 for (auto& it : send_streams_) { |
1884 it.second->RecreateAudioSendStream(audio_network_adatptor_config); | 1837 it.second->RecreateAudioSendStream(audio_network_adatptor_config); |
1885 } | 1838 } |
1886 | 1839 |
1887 LOG(LS_INFO) << "Set voice channel options. Current options: " | 1840 LOG(LS_INFO) << "Set voice channel options. Current options: " |
1888 << options_.ToString(); | 1841 << options_.ToString(); |
1889 return true; | 1842 return true; |
1890 } | 1843 } |
1891 | 1844 |
1892 bool WebRtcVoiceMediaChannel::SetRecvCodecs( | 1845 bool WebRtcVoiceMediaChannel::SetRecvCodecs( |
1893 const std::vector<AudioCodec>& codecs) { | 1846 const std::vector<AudioCodec>& codecs) { |
1894 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1847 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1895 | 1848 |
1896 // Set the payload types to be used for incoming media. | 1849 // Set the payload types to be used for incoming media. |
1897 LOG(LS_INFO) << "Setting receive voice codecs."; | 1850 LOG(LS_INFO) << "Setting receive voice codecs."; |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2662 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2710 const auto it = send_streams_.find(ssrc); | 2663 const auto it = send_streams_.find(ssrc); |
2711 if (it != send_streams_.end()) { | 2664 if (it != send_streams_.end()) { |
2712 return it->second->channel(); | 2665 return it->second->channel(); |
2713 } | 2666 } |
2714 return -1; | 2667 return -1; |
2715 } | 2668 } |
2716 } // namespace cricket | 2669 } // namespace cricket |
2717 | 2670 |
2718 #endif // HAVE_WEBRTC_VOICE | 2671 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |