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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 options.stereo_swapping = rtc::Optional<bool>(false); | 553 options.stereo_swapping = rtc::Optional<bool>(false); |
554 options.audio_jitter_buffer_max_packets = rtc::Optional<int>(50); | 554 options.audio_jitter_buffer_max_packets = rtc::Optional<int>(50); |
555 options.audio_jitter_buffer_fast_accelerate = rtc::Optional<bool>(false); | 555 options.audio_jitter_buffer_fast_accelerate = rtc::Optional<bool>(false); |
556 options.typing_detection = rtc::Optional<bool>(true); | 556 options.typing_detection = rtc::Optional<bool>(true); |
557 options.adjust_agc_delta = rtc::Optional<int>(0); | 557 options.adjust_agc_delta = rtc::Optional<int>(0); |
558 options.experimental_agc = rtc::Optional<bool>(false); | 558 options.experimental_agc = rtc::Optional<bool>(false); |
559 options.extended_filter_aec = rtc::Optional<bool>(false); | 559 options.extended_filter_aec = rtc::Optional<bool>(false); |
560 options.delay_agnostic_aec = rtc::Optional<bool>(false); | 560 options.delay_agnostic_aec = rtc::Optional<bool>(false); |
561 options.experimental_ns = rtc::Optional<bool>(false); | 561 options.experimental_ns = rtc::Optional<bool>(false); |
562 options.intelligibility_enhancer = rtc::Optional<bool>(false); | 562 options.intelligibility_enhancer = rtc::Optional<bool>(false); |
| 563 options.level_control = rtc::Optional<bool>(false); |
563 bool error = ApplyOptions(options); | 564 bool error = ApplyOptions(options); |
564 RTC_DCHECK(error); | 565 RTC_DCHECK(error); |
565 } | 566 } |
566 | 567 |
567 SetDefaultDevices(); | 568 SetDefaultDevices(); |
568 } | 569 } |
569 | 570 |
570 WebRtcVoiceEngine::~WebRtcVoiceEngine() { | 571 WebRtcVoiceEngine::~WebRtcVoiceEngine() { |
571 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 572 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
572 LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; | 573 LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 #endif | 677 #endif |
677 if (ec_mode == webrtc::kEcAecm) { | 678 if (ec_mode == webrtc::kEcAecm) { |
678 bool cn = options.aecm_generate_comfort_noise.value_or(false); | 679 bool cn = options.aecm_generate_comfort_noise.value_or(false); |
679 if (voep->SetAecmMode(aecm_mode, cn) != 0) { | 680 if (voep->SetAecmMode(aecm_mode, cn) != 0) { |
680 LOG_RTCERR2(SetAecmMode, aecm_mode, cn); | 681 LOG_RTCERR2(SetAecmMode, aecm_mode, cn); |
681 return false; | 682 return false; |
682 } | 683 } |
683 } | 684 } |
684 } | 685 } |
685 | 686 |
| 687 // Use optional to avoid uneccessary calls to BuiltInAGCIsAvailable while |
| 688 // complying with the unittest requirements of only 1 call per test. |
| 689 rtc::Optional<bool> built_in_agc_avaliable; |
| 690 if (options.level_control) { |
| 691 if (!built_in_agc_avaliable) { |
| 692 built_in_agc_avaliable = |
| 693 rtc::Optional<bool>(adm()->BuiltInAGCIsAvailable()); |
| 694 } |
| 695 RTC_DCHECK(built_in_agc_avaliable); |
| 696 if (*built_in_agc_avaliable) { |
| 697 // Disable internal software level control if built-in AGC is enabled, |
| 698 // i.e., replace the software AGC with the built-in AGC. |
| 699 options.level_control = rtc::Optional<bool>(false); |
| 700 } |
| 701 } |
| 702 |
686 if (options.auto_gain_control) { | 703 if (options.auto_gain_control) { |
687 const bool built_in_agc = adm()->BuiltInAGCIsAvailable(); | 704 if (!built_in_agc_avaliable) { |
688 if (built_in_agc) { | 705 built_in_agc_avaliable = |
| 706 rtc::Optional<bool>(adm()->BuiltInAGCIsAvailable()); |
| 707 } |
| 708 RTC_DCHECK(built_in_agc_avaliable); |
| 709 if (*built_in_agc_avaliable) { |
689 if (adm()->EnableBuiltInAGC(*options.auto_gain_control) == 0 && | 710 if (adm()->EnableBuiltInAGC(*options.auto_gain_control) == 0 && |
690 *options.auto_gain_control) { | 711 *options.auto_gain_control) { |
691 // Disable internal software AGC if built-in AGC is enabled, | 712 // Disable internal software AGC if built-in AGC is enabled, |
692 // i.e., replace the software AGC with the built-in AGC. | 713 // i.e., replace the software AGC with the built-in AGC. |
693 options.auto_gain_control = rtc::Optional<bool>(false); | 714 options.auto_gain_control = rtc::Optional<bool>(false); |
694 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"; |
695 } | 716 } |
696 } | 717 } |
697 if (voep->SetAgcStatus(*options.auto_gain_control, agc_mode) == -1) { | 718 if (voep->SetAgcStatus(*options.auto_gain_control, agc_mode) == -1) { |
698 LOG_RTCERR2(SetAgcStatus, *options.auto_gain_control, agc_mode); | 719 LOG_RTCERR2(SetAgcStatus, *options.auto_gain_control, agc_mode); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 new webrtc::ExperimentalNs(*experimental_ns_)); | 856 new webrtc::ExperimentalNs(*experimental_ns_)); |
836 } | 857 } |
837 | 858 |
838 if (intelligibility_enhancer_) { | 859 if (intelligibility_enhancer_) { |
839 LOG(LS_INFO) << "Intelligibility Enhancer is enabled? " | 860 LOG(LS_INFO) << "Intelligibility Enhancer is enabled? " |
840 << *intelligibility_enhancer_; | 861 << *intelligibility_enhancer_; |
841 config.Set<webrtc::Intelligibility>( | 862 config.Set<webrtc::Intelligibility>( |
842 new webrtc::Intelligibility(*intelligibility_enhancer_)); | 863 new webrtc::Intelligibility(*intelligibility_enhancer_)); |
843 } | 864 } |
844 | 865 |
| 866 if (options.level_control) { |
| 867 level_control_ = options.level_control; |
| 868 } |
| 869 |
| 870 LOG(LS_INFO) << "Level control: " |
| 871 << (!!level_control_ ? *level_control_ : -1); |
| 872 if (level_control_) { |
| 873 config.Set<webrtc::LevelControl>(new webrtc::LevelControl(*level_control_)); |
| 874 } |
| 875 |
845 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine | 876 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine |
846 // returns NULL on audio_processing(). | 877 // returns NULL on audio_processing(). |
847 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); | 878 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); |
848 if (audioproc) { | 879 if (audioproc) { |
849 audioproc->SetExtraOptions(config); | 880 audioproc->SetExtraOptions(config); |
850 } | 881 } |
851 | 882 |
852 if (options.recording_sample_rate) { | 883 if (options.recording_sample_rate) { |
853 LOG(LS_INFO) << "Recording sample rate is " | 884 LOG(LS_INFO) << "Recording sample rate is " |
854 << *options.recording_sample_rate; | 885 << *options.recording_sample_rate; |
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2607 } | 2638 } |
2608 } else { | 2639 } else { |
2609 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2640 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2610 engine()->voe()->base()->StopPlayout(channel); | 2641 engine()->voe()->base()->StopPlayout(channel); |
2611 } | 2642 } |
2612 return true; | 2643 return true; |
2613 } | 2644 } |
2614 } // namespace cricket | 2645 } // namespace cricket |
2615 | 2646 |
2616 #endif // HAVE_WEBRTC_VOICE | 2647 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |