OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #include <math.h> | 11 #include <math.h> |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <limits> | 15 #include <limits> |
16 #include <memory> | 16 #include <memory> |
17 #include <queue> | 17 #include <queue> |
18 | 18 |
19 #include "webrtc/base/arraysize.h" | 19 #include "webrtc/base/arraysize.h" |
20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
21 #include "webrtc/common_audio/include/audio_util.h" | 21 #include "webrtc/common_audio/include/audio_util.h" |
22 #include "webrtc/common_audio/resampler/include/push_resampler.h" | 22 #include "webrtc/common_audio/resampler/include/push_resampler.h" |
23 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" | 23 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" |
24 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" | 24 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" |
25 #include "webrtc/modules/audio_processing/audio_processing_impl.h" | |
25 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h " | 26 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h " |
26 #include "webrtc/modules/audio_processing/common.h" | 27 #include "webrtc/modules/audio_processing/common.h" |
27 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 28 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
28 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | 29 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
29 #include "webrtc/modules/audio_processing/test/test_utils.h" | 30 #include "webrtc/modules/audio_processing/test/test_utils.h" |
30 #include "webrtc/modules/include/module_common_types.h" | 31 #include "webrtc/modules/include/module_common_types.h" |
31 #include "webrtc/system_wrappers/include/event_wrapper.h" | 32 #include "webrtc/system_wrappers/include/event_wrapper.h" |
32 #include "webrtc/system_wrappers/include/trace.h" | 33 #include "webrtc/system_wrappers/include/trace.h" |
33 #include "webrtc/test/testsupport/fileutils.h" | 34 #include "webrtc/test/testsupport/fileutils.h" |
34 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 35 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2767 std::tr1::make_tuple(16000, 44100, 16000, 44100, 15, 15), | 2768 std::tr1::make_tuple(16000, 44100, 16000, 44100, 15, 15), |
2768 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), | 2769 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), |
2769 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), | 2770 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), |
2770 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), | 2771 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), |
2771 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20), | 2772 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20), |
2772 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20), | 2773 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20), |
2773 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); | 2774 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); |
2774 #endif | 2775 #endif |
2775 | 2776 |
2776 } // namespace | 2777 } // namespace |
2778 | |
2779 TEST(ApmConfiguration, DefaultBehavior) { | |
2780 // Verify that the level controller is default off, it can be activate using | |
2781 // the config, and that the default initial level is maintained after the | |
2782 // config has been appied. | |
2783 const float kTolerance = 0.0001f; | |
2784 std::unique_ptr<AudioProcessingImpl> apm( | |
2785 new AudioProcessingImpl(webrtc::Config())); | |
2786 AudioProcessing::Config config; | |
2787 EXPECT_FALSE(apm->config_.level_controller.enabled); | |
2788 // TODO(peah): Add test for the existence of the level controller object once | |
2789 // that is created only when that is specified in the config. | |
2790 // TODO(peah): Remove the testing for | |
2791 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | |
2792 // is instead used to activate the level controller. | |
2793 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | |
2794 EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level_dbfs, | |
aleloi
2016/09/19 15:06:06
Maybe we should compare with the value in lc_const
peah-webrtc
2016/09/19 16:37:10
Good point!
Done.
| |
2795 kTolerance); | |
2796 config.level_controller.enabled = true; | |
2797 apm->ApplyConfig(config); | |
2798 EXPECT_TRUE(apm->config_.level_controller.enabled); | |
2799 // TODO(peah): Add test for the existence of the level controller object once | |
2800 // that is created only when the that is specified in the config. | |
aleloi
2016/09/19 15:06:06
'the that' - remove 'the'
peah-webrtc
2016/09/19 16:37:10
Done.
| |
2801 // TODO(peah): Remove the testing for | |
2802 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | |
2803 // is instead used to activate the level controller. | |
2804 EXPECT_TRUE(apm->capture_nonlocked_.level_controller_enabled); | |
2805 EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level_dbfs, | |
2806 kTolerance); | |
2807 } | |
2808 | |
2809 TEST(ApmConfiguration, ValidConfigBehavior) { | |
2810 // Verify that the initial level can be specified and is retained after the | |
2811 // config has been applied. | |
2812 const float kTolerance = 0.0001f; | |
2813 std::unique_ptr<AudioProcessingImpl> apm( | |
2814 new AudioProcessingImpl(webrtc::Config())); | |
2815 AudioProcessing::Config config; | |
2816 config = AudioProcessing::Config(); | |
2817 config.level_controller.initial_peak_level_dbfs = -50.f; | |
2818 apm->ApplyConfig(config); | |
2819 EXPECT_FALSE(apm->config_.level_controller.enabled); | |
2820 // TODO(peah): Add test for the existence of the level controller object once | |
2821 // that is created only when the that is specified in the config. | |
2822 // TODO(peah): Remove the testing for | |
2823 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | |
2824 // is instead used to activate the level controller. | |
2825 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | |
2826 EXPECT_NEAR(-50.f, apm->config_.level_controller.initial_peak_level_dbfs, | |
2827 kTolerance); | |
2828 } | |
2829 | |
2830 TEST(ApmConfiguration, NonValidConfigBehavior) { | |
2831 // Verify that the config is properly reset when nonproper values are applied | |
2832 // for the initial level. | |
2833 const float kTolerance = 0.0001f; | |
2834 std::unique_ptr<AudioProcessingImpl> apm( | |
2835 new AudioProcessingImpl(webrtc::Config())); | |
2836 AudioProcessing::Config config; | |
2837 config = AudioProcessing::Config(); | |
2838 config.level_controller.enabled = true; | |
2839 config.level_controller.initial_peak_level_dbfs = -101.f; | |
2840 apm->ApplyConfig(config); | |
2841 EXPECT_FALSE(apm->config_.level_controller.enabled); | |
2842 // TODO(peah): Add test for the existence of the level controller object once | |
2843 // that is created only when the that is specified in the config. | |
2844 // TODO(peah): Remove the testing for | |
2845 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | |
2846 // is instead used to activate the level controller. | |
2847 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | |
2848 EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level_dbfs, | |
2849 kTolerance); | |
2850 | |
2851 apm.reset(new AudioProcessingImpl(webrtc::Config())); | |
2852 config = AudioProcessing::Config(); | |
2853 config.level_controller.enabled = true; | |
2854 config.level_controller.initial_peak_level_dbfs = 1.f; | |
2855 apm->ApplyConfig(config); | |
2856 EXPECT_FALSE(apm->config_.level_controller.enabled); | |
2857 // TODO(peah): Add test for the existence of the level controller object once | |
2858 // that is created only when the that is specified in the config. | |
2859 // TODO(peah): Remove the testing for | |
2860 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | |
2861 // is instead used to activate the level controller. | |
2862 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | |
2863 EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level_dbfs, | |
2864 kTolerance); | |
2865 } | |
2866 | |
2777 } // namespace webrtc | 2867 } // namespace webrtc |
OLD | NEW |