| 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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 } | 648 } |
| 649 #endif | 649 #endif |
| 650 | 650 |
| 651 webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); | 651 webrtc::VoEAudioProcessing* voep = voe_wrapper_->processing(); |
| 652 | 652 |
| 653 if (options.echo_cancellation) { | 653 if (options.echo_cancellation) { |
| 654 // Check if platform supports built-in EC. Currently only supported on | 654 // Check if platform supports built-in EC. Currently only supported on |
| 655 // Android and in combination with Java based audio layer. | 655 // Android and in combination with Java based audio layer. |
| 656 // TODO(henrika): investigate possibility to support built-in EC also | 656 // TODO(henrika): investigate possibility to support built-in EC also |
| 657 // in combination with Open SL ES audio. | 657 // in combination with Open SL ES audio. |
| 658 const bool built_in_aec = voe_wrapper_->hw()->BuiltInAECIsAvailable(); | 658 const bool built_in_aec = adm()->BuiltInAECIsAvailable(); |
| 659 if (built_in_aec) { | 659 if (built_in_aec) { |
| 660 // Built-in EC exists on this device and use_delay_agnostic_aec is not | 660 // Built-in EC exists on this device and use_delay_agnostic_aec is not |
| 661 // overriding it. Enable/Disable it according to the echo_cancellation | 661 // overriding it. Enable/Disable it according to the echo_cancellation |
| 662 // audio option. | 662 // audio option. |
| 663 const bool enable_built_in_aec = | 663 const bool enable_built_in_aec = |
| 664 *options.echo_cancellation && !use_delay_agnostic_aec; | 664 *options.echo_cancellation && !use_delay_agnostic_aec; |
| 665 if (voe_wrapper_->hw()->EnableBuiltInAEC(enable_built_in_aec) == 0 && | 665 if (adm()->EnableBuiltInAEC(enable_built_in_aec) == 0 && |
| 666 enable_built_in_aec) { | 666 enable_built_in_aec) { |
| 667 // Disable internal software EC if built-in EC is enabled, | 667 // Disable internal software EC if built-in EC is enabled, |
| 668 // i.e., replace the software EC with the built-in EC. | 668 // i.e., replace the software EC with the built-in EC. |
| 669 options.echo_cancellation = rtc::Optional<bool>(false); | 669 options.echo_cancellation = rtc::Optional<bool>(false); |
| 670 LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; | 670 LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 if (voep->SetEcStatus(*options.echo_cancellation, ec_mode) == -1) { | 673 if (voep->SetEcStatus(*options.echo_cancellation, ec_mode) == -1) { |
| 674 LOG_RTCERR2(SetEcStatus, *options.echo_cancellation, ec_mode); | 674 LOG_RTCERR2(SetEcStatus, *options.echo_cancellation, ec_mode); |
| 675 return false; | 675 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 687 if (ec_mode == webrtc::kEcAecm) { | 687 if (ec_mode == webrtc::kEcAecm) { |
| 688 bool cn = options.aecm_generate_comfort_noise.value_or(false); | 688 bool cn = options.aecm_generate_comfort_noise.value_or(false); |
| 689 if (voep->SetAecmMode(aecm_mode, cn) != 0) { | 689 if (voep->SetAecmMode(aecm_mode, cn) != 0) { |
| 690 LOG_RTCERR2(SetAecmMode, aecm_mode, cn); | 690 LOG_RTCERR2(SetAecmMode, aecm_mode, cn); |
| 691 return false; | 691 return false; |
| 692 } | 692 } |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 | 695 |
| 696 if (options.auto_gain_control) { | 696 if (options.auto_gain_control) { |
| 697 const bool built_in_agc = voe_wrapper_->hw()->BuiltInAGCIsAvailable(); | 697 const bool built_in_agc = adm()->BuiltInAGCIsAvailable(); |
| 698 if (built_in_agc) { | 698 if (built_in_agc) { |
| 699 if (voe_wrapper_->hw()->EnableBuiltInAGC(*options.auto_gain_control) == | 699 if (adm()->EnableBuiltInAGC(*options.auto_gain_control) == 0 && |
| 700 0 && | |
| 701 *options.auto_gain_control) { | 700 *options.auto_gain_control) { |
| 702 // Disable internal software AGC if built-in AGC is enabled, | 701 // Disable internal software AGC if built-in AGC is enabled, |
| 703 // i.e., replace the software AGC with the built-in AGC. | 702 // i.e., replace the software AGC with the built-in AGC. |
| 704 options.auto_gain_control = rtc::Optional<bool>(false); | 703 options.auto_gain_control = rtc::Optional<bool>(false); |
| 705 LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead"; | 704 LOG(LS_INFO) << "Disabling AGC since built-in AGC will be used instead"; |
| 706 } | 705 } |
| 707 } | 706 } |
| 708 if (voep->SetAgcStatus(*options.auto_gain_control, agc_mode) == -1) { | 707 if (voep->SetAgcStatus(*options.auto_gain_control, agc_mode) == -1) { |
| 709 LOG_RTCERR2(SetAgcStatus, *options.auto_gain_control, agc_mode); | 708 LOG_RTCERR2(SetAgcStatus, *options.auto_gain_control, agc_mode); |
| 710 return false; | 709 return false; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 734 if (voe_wrapper_->processing()->SetAgcConfig(default_agc_config_) == -1) { | 733 if (voe_wrapper_->processing()->SetAgcConfig(default_agc_config_) == -1) { |
| 735 LOG_RTCERR3(SetAgcConfig, | 734 LOG_RTCERR3(SetAgcConfig, |
| 736 default_agc_config_.targetLeveldBOv, | 735 default_agc_config_.targetLeveldBOv, |
| 737 default_agc_config_.digitalCompressionGaindB, | 736 default_agc_config_.digitalCompressionGaindB, |
| 738 default_agc_config_.limiterEnable); | 737 default_agc_config_.limiterEnable); |
| 739 return false; | 738 return false; |
| 740 } | 739 } |
| 741 } | 740 } |
| 742 | 741 |
| 743 if (options.noise_suppression) { | 742 if (options.noise_suppression) { |
| 744 const bool built_in_ns = voe_wrapper_->hw()->BuiltInNSIsAvailable(); | 743 const bool built_in_ns = adm()->BuiltInNSIsAvailable(); |
| 745 if (built_in_ns) { | 744 if (built_in_ns) { |
| 746 if (voe_wrapper_->hw()->EnableBuiltInNS(*options.noise_suppression) == | 745 if (adm()->EnableBuiltInNS(*options.noise_suppression) == 0 && |
| 747 0 && | |
| 748 *options.noise_suppression) { | 746 *options.noise_suppression) { |
| 749 // Disable internal software NS if built-in NS is enabled, | 747 // Disable internal software NS if built-in NS is enabled, |
| 750 // i.e., replace the software NS with the built-in NS. | 748 // i.e., replace the software NS with the built-in NS. |
| 751 options.noise_suppression = rtc::Optional<bool>(false); | 749 options.noise_suppression = rtc::Optional<bool>(false); |
| 752 LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead"; | 750 LOG(LS_INFO) << "Disabling NS since built-in NS will be used instead"; |
| 753 } | 751 } |
| 754 } | 752 } |
| 755 if (voep->SetNsStatus(*options.noise_suppression, ns_mode) == -1) { | 753 if (voep->SetNsStatus(*options.noise_suppression, ns_mode) == -1) { |
| 756 LOG_RTCERR2(SetNsStatus, *options.noise_suppression, ns_mode); | 754 LOG_RTCERR2(SetNsStatus, *options.noise_suppression, ns_mode); |
| 757 return false; | 755 return false; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine | 839 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine |
| 842 // returns NULL on audio_processing(). | 840 // returns NULL on audio_processing(). |
| 843 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); | 841 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); |
| 844 if (audioproc) { | 842 if (audioproc) { |
| 845 audioproc->SetExtraOptions(config); | 843 audioproc->SetExtraOptions(config); |
| 846 } | 844 } |
| 847 | 845 |
| 848 if (options.recording_sample_rate) { | 846 if (options.recording_sample_rate) { |
| 849 LOG(LS_INFO) << "Recording sample rate is " | 847 LOG(LS_INFO) << "Recording sample rate is " |
| 850 << *options.recording_sample_rate; | 848 << *options.recording_sample_rate; |
| 851 if (voe_wrapper_->hw()->SetRecordingSampleRate( | 849 if (adm()->SetRecordingSampleRate(*options.recording_sample_rate)) { |
| 852 *options.recording_sample_rate)) { | |
| 853 LOG_RTCERR1(SetRecordingSampleRate, *options.recording_sample_rate); | 850 LOG_RTCERR1(SetRecordingSampleRate, *options.recording_sample_rate); |
| 854 } | 851 } |
| 855 } | 852 } |
| 856 | 853 |
| 857 if (options.playout_sample_rate) { | 854 if (options.playout_sample_rate) { |
| 858 LOG(LS_INFO) << "Playout sample rate is " << *options.playout_sample_rate; | 855 LOG(LS_INFO) << "Playout sample rate is " << *options.playout_sample_rate; |
| 859 if (voe_wrapper_->hw()->SetPlayoutSampleRate( | 856 if (adm()->SetPlayoutSampleRate(*options.playout_sample_rate)) { |
| 860 *options.playout_sample_rate)) { | |
| 861 LOG_RTCERR1(SetPlayoutSampleRate, *options.playout_sample_rate); | 857 LOG_RTCERR1(SetPlayoutSampleRate, *options.playout_sample_rate); |
| 862 } | 858 } |
| 863 } | 859 } |
| 864 | 860 |
| 865 return true; | 861 return true; |
| 866 } | 862 } |
| 867 | 863 |
| 868 void WebRtcVoiceEngine::SetDefaultDevices() { | 864 void WebRtcVoiceEngine::SetDefaultDevices() { |
| 869 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 865 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 870 #if !defined(WEBRTC_IOS) | 866 #if !defined(WEBRTC_IOS) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 return; | 1067 return; |
| 1072 } | 1068 } |
| 1073 LOG_RTCERR0(StopRtcEventLog); | 1069 LOG_RTCERR0(StopRtcEventLog); |
| 1074 } | 1070 } |
| 1075 | 1071 |
| 1076 int WebRtcVoiceEngine::CreateVoEChannel() { | 1072 int WebRtcVoiceEngine::CreateVoEChannel() { |
| 1077 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1073 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1078 return voe_wrapper_->base()->CreateChannel(voe_config_); | 1074 return voe_wrapper_->base()->CreateChannel(voe_config_); |
| 1079 } | 1075 } |
| 1080 | 1076 |
| 1077 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { |
| 1078 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1079 RTC_DCHECK(adm_); |
| 1080 return adm_; |
| 1081 } |
| 1082 |
| 1081 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream | 1083 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream |
| 1082 : public AudioSource::Sink { | 1084 : public AudioSource::Sink { |
| 1083 public: | 1085 public: |
| 1084 WebRtcAudioSendStream(int ch, | 1086 WebRtcAudioSendStream(int ch, |
| 1085 webrtc::AudioTransport* voe_audio_transport, | 1087 webrtc::AudioTransport* voe_audio_transport, |
| 1086 uint32_t ssrc, | 1088 uint32_t ssrc, |
| 1087 const std::string& c_name, | 1089 const std::string& c_name, |
| 1088 const std::vector<webrtc::RtpExtension>& extensions, | 1090 const std::vector<webrtc::RtpExtension>& extensions, |
| 1089 webrtc::Call* call) | 1091 webrtc::Call* call) |
| 1090 : voe_audio_transport_(voe_audio_transport), | 1092 : voe_audio_transport_(voe_audio_transport), |
| (...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 } | 2562 } |
| 2561 } else { | 2563 } else { |
| 2562 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2564 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
| 2563 engine()->voe()->base()->StopPlayout(channel); | 2565 engine()->voe()->base()->StopPlayout(channel); |
| 2564 } | 2566 } |
| 2565 return true; | 2567 return true; |
| 2566 } | 2568 } |
| 2567 } // namespace cricket | 2569 } // namespace cricket |
| 2568 | 2570 |
| 2569 #endif // HAVE_WEBRTC_VOICE | 2571 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |