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 #if 0 | |
the sun
2017/06/29 10:41:52
Uh-oh!
peah-webrtc
2017/06/29 11:46:32
Done.
| |
12 | |
11 #include <math.h> | 13 #include <math.h> |
12 #include <stdio.h> | 14 #include <stdio.h> |
13 | 15 |
14 #include <algorithm> | 16 #include <algorithm> |
15 #include <limits> | 17 #include <limits> |
16 #include <memory> | 18 #include <memory> |
17 #include <queue> | 19 #include <queue> |
18 | 20 |
19 #include "webrtc/base/arraysize.h" | 21 #include "webrtc/base/arraysize.h" |
20 #include "webrtc/base/checks.h" | 22 #include "webrtc/base/checks.h" |
(...skipping 2777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2798 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); | 2800 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); |
2799 #endif | 2801 #endif |
2800 | 2802 |
2801 } // namespace | 2803 } // namespace |
2802 | 2804 |
2803 TEST(ApmConfiguration, DefaultBehavior) { | 2805 TEST(ApmConfiguration, DefaultBehavior) { |
2804 // Verify that the level controller is default off, it can be activated using | 2806 // Verify that the level controller is default off, it can be activated using |
2805 // the config, and that the default initial level is maintained after the | 2807 // the config, and that the default initial level is maintained after the |
2806 // config has been applied. | 2808 // config has been applied. |
2807 std::unique_ptr<AudioProcessingImpl> apm( | 2809 std::unique_ptr<AudioProcessingImpl> apm( |
2808 new AudioProcessingImpl(webrtc::Config())); | 2810 new rtc::RefCountedObject<AudioProcessingImpl>(webrtc::Config())); |
2809 AudioProcessing::Config config; | 2811 AudioProcessing::Config config; |
2810 EXPECT_FALSE(apm->config_.level_controller.enabled); | 2812 EXPECT_FALSE(apm->config_.level_controller.enabled); |
2811 // TODO(peah): Add test for the existence of the level controller object once | 2813 // TODO(peah): Add test for the existence of the level controller object once |
2812 // that is created only when that is specified in the config. | 2814 // that is created only when that is specified in the config. |
2813 // TODO(peah): Remove the testing for | 2815 // TODO(peah): Remove the testing for |
2814 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | 2816 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
2815 // is instead used to activate the level controller. | 2817 // is instead used to activate the level controller. |
2816 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | 2818 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
2817 EXPECT_NEAR(kTargetLcPeakLeveldBFS, | 2819 EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
2818 apm->config_.level_controller.initial_peak_level_dbfs, | 2820 apm->config_.level_controller.initial_peak_level_dbfs, |
2819 std::numeric_limits<float>::epsilon()); | 2821 std::numeric_limits<float>::epsilon()); |
2820 config.level_controller.enabled = true; | 2822 config.level_controller.enabled = true; |
2821 apm->ApplyConfig(config); | 2823 apm->ApplyConfig(config); |
2822 EXPECT_TRUE(apm->config_.level_controller.enabled); | 2824 EXPECT_TRUE(apm->config_.level_controller.enabled); |
2823 // TODO(peah): Add test for the existence of the level controller object once | 2825 // TODO(peah): Add test for the existence of the level controller object once |
2824 // that is created only when the that is specified in the config. | 2826 // that is created only when the that is specified in the config. |
2825 // TODO(peah): Remove the testing for | 2827 // TODO(peah): Remove the testing for |
2826 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | 2828 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
2827 // is instead used to activate the level controller. | 2829 // is instead used to activate the level controller. |
2828 EXPECT_TRUE(apm->capture_nonlocked_.level_controller_enabled); | 2830 EXPECT_TRUE(apm->capture_nonlocked_.level_controller_enabled); |
2829 EXPECT_NEAR(kTargetLcPeakLeveldBFS, | 2831 EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
2830 apm->config_.level_controller.initial_peak_level_dbfs, | 2832 apm->config_.level_controller.initial_peak_level_dbfs, |
2831 std::numeric_limits<float>::epsilon()); | 2833 std::numeric_limits<float>::epsilon()); |
2832 } | 2834 } |
2833 | 2835 |
2834 TEST(ApmConfiguration, ValidConfigBehavior) { | 2836 TEST(ApmConfiguration, ValidConfigBehavior) { |
2835 // Verify that the initial level can be specified and is retained after the | 2837 // Verify that the initial level can be specified and is retained after the |
2836 // config has been applied. | 2838 // config has been applied. |
2837 std::unique_ptr<AudioProcessingImpl> apm( | 2839 std::unique_ptr<AudioProcessingImpl> apm( |
2838 new AudioProcessingImpl(webrtc::Config())); | 2840 new rtc::RefCountedObject<AudioProcessingImpl>(webrtc::Config())); |
2839 AudioProcessing::Config config; | 2841 AudioProcessing::Config config; |
2840 config.level_controller.initial_peak_level_dbfs = -50.f; | 2842 config.level_controller.initial_peak_level_dbfs = -50.f; |
2841 apm->ApplyConfig(config); | 2843 apm->ApplyConfig(config); |
2842 EXPECT_FALSE(apm->config_.level_controller.enabled); | 2844 EXPECT_FALSE(apm->config_.level_controller.enabled); |
2843 // TODO(peah): Add test for the existence of the level controller object once | 2845 // TODO(peah): Add test for the existence of the level controller object once |
2844 // that is created only when the that is specified in the config. | 2846 // that is created only when the that is specified in the config. |
2845 // TODO(peah): Remove the testing for | 2847 // TODO(peah): Remove the testing for |
2846 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | 2848 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
2847 // is instead used to activate the level controller. | 2849 // is instead used to activate the level controller. |
2848 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | 2850 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
2849 EXPECT_NEAR(-50.f, apm->config_.level_controller.initial_peak_level_dbfs, | 2851 EXPECT_NEAR(-50.f, apm->config_.level_controller.initial_peak_level_dbfs, |
2850 std::numeric_limits<float>::epsilon()); | 2852 std::numeric_limits<float>::epsilon()); |
2851 } | 2853 } |
2852 | 2854 |
2853 TEST(ApmConfiguration, InValidConfigBehavior) { | 2855 TEST(ApmConfiguration, InValidConfigBehavior) { |
2854 // Verify that the config is properly reset when nonproper values are applied | 2856 // Verify that the config is properly reset when nonproper values are applied |
2855 // for the initial level. | 2857 // for the initial level. |
2856 | 2858 |
2857 // Verify that the config is properly reset when the specified initial peak | 2859 // Verify that the config is properly reset when the specified initial peak |
2858 // level is too low. | 2860 // level is too low. |
2859 std::unique_ptr<AudioProcessingImpl> apm( | 2861 std::unique_ptr<AudioProcessingImpl> apm( |
2860 new AudioProcessingImpl(webrtc::Config())); | 2862 new rtc::RefCountedObject<AudioProcessingImpl>(webrtc::Config())); |
2861 AudioProcessing::Config config; | 2863 AudioProcessing::Config config; |
2862 config.level_controller.enabled = true; | 2864 config.level_controller.enabled = true; |
2863 config.level_controller.initial_peak_level_dbfs = -101.f; | 2865 config.level_controller.initial_peak_level_dbfs = -101.f; |
2864 apm->ApplyConfig(config); | 2866 apm->ApplyConfig(config); |
2865 EXPECT_FALSE(apm->config_.level_controller.enabled); | 2867 EXPECT_FALSE(apm->config_.level_controller.enabled); |
2866 // TODO(peah): Add test for the existence of the level controller object once | 2868 // TODO(peah): Add test for the existence of the level controller object once |
2867 // that is created only when the that is specified in the config. | 2869 // that is created only when the that is specified in the config. |
2868 // TODO(peah): Remove the testing for | 2870 // TODO(peah): Remove the testing for |
2869 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | 2871 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
2870 // is instead used to activate the level controller. | 2872 // is instead used to activate the level controller. |
2871 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | 2873 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
2872 EXPECT_NEAR(kTargetLcPeakLeveldBFS, | 2874 EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
2873 apm->config_.level_controller.initial_peak_level_dbfs, | 2875 apm->config_.level_controller.initial_peak_level_dbfs, |
2874 std::numeric_limits<float>::epsilon()); | 2876 std::numeric_limits<float>::epsilon()); |
2875 | 2877 |
2876 // Verify that the config is properly reset when the specified initial peak | 2878 // Verify that the config is properly reset when the specified initial peak |
2877 // level is too high. | 2879 // level is too high. |
2878 apm.reset(new AudioProcessingImpl(webrtc::Config())); | 2880 apm.reset(new rtc::RefCountedObject<AudioProcessingImpl>(webrtc::Config())); |
2879 config = AudioProcessing::Config(); | 2881 config = AudioProcessing::Config(); |
2880 config.level_controller.enabled = true; | 2882 config.level_controller.enabled = true; |
2881 config.level_controller.initial_peak_level_dbfs = 1.f; | 2883 config.level_controller.initial_peak_level_dbfs = 1.f; |
2882 apm->ApplyConfig(config); | 2884 apm->ApplyConfig(config); |
2883 EXPECT_FALSE(apm->config_.level_controller.enabled); | 2885 EXPECT_FALSE(apm->config_.level_controller.enabled); |
2884 // TODO(peah): Add test for the existence of the level controller object once | 2886 // TODO(peah): Add test for the existence of the level controller object once |
2885 // that is created only when that is specified in the config. | 2887 // that is created only when that is specified in the config. |
2886 // TODO(peah): Remove the testing for | 2888 // TODO(peah): Remove the testing for |
2887 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ | 2889 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
2888 // is instead used to activate the level controller. | 2890 // is instead used to activate the level controller. |
2889 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); | 2891 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
2890 EXPECT_NEAR(kTargetLcPeakLeveldBFS, | 2892 EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
2891 apm->config_.level_controller.initial_peak_level_dbfs, | 2893 apm->config_.level_controller.initial_peak_level_dbfs, |
2892 std::numeric_limits<float>::epsilon()); | 2894 std::numeric_limits<float>::epsilon()); |
2893 } | 2895 } |
2894 | 2896 |
2895 } // namespace webrtc | 2897 } // namespace webrtc |
2898 | |
2899 #endif | |
OLD | NEW |