From a82395bf7cd15b7396456df06fe952ede8db0c39 Mon Sep 17 00:00:00 2001 From: michaelt Date: Fri, 18 Nov 2016 00:23:19 -0800 Subject: [PATCH] Move smoothing filter to common audio. This will make the smoothing filter a basic tool that is going to be used by both voice engine and ANA. BUG=webrtc:6443 Review-Url: https://codereview.webrtc.org/2484153002 Cr-Commit-Position: refs/heads/master@{#15146} --- webrtc/BUILD.gn | 1 + webrtc/base/BUILD.gn | 10 ++++++++-- webrtc/common_audio/BUILD.gn | 4 ++++ .../mocks}/mock_smoothing_filter.h | 10 ++++------ .../smoothing_filter.cc | 2 +- .../smoothing_filter.h | 8 ++++---- .../smoothing_filter_unittest.cc | 2 +- webrtc/modules/BUILD.gn | 1 - webrtc/modules/audio_coding/BUILD.gn | 2 -- .../audio_network_adaptor/fec_controller.h | 2 +- .../audio_network_adaptor/fec_controller_unittest.cc | 5 +---- .../aimd_rate_control_unittest.cc | 2 +- 12 files changed, 26 insertions(+), 23 deletions(-) rename webrtc/{modules/audio_coding/audio_network_adaptor/mock => common_audio/mocks}/mock_smoothing_filter.h (60%) rename webrtc/{modules/audio_coding/audio_network_adaptor => common_audio}/smoothing_filter.cc (96%) rename webrtc/{modules/audio_coding/audio_network_adaptor => common_audio}/smoothing_filter.h (83%) rename webrtc/{modules/audio_coding/audio_network_adaptor => common_audio}/smoothing_filter_unittest.cc (97%) diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index 1d14c906f3..200d709e8d 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -536,6 +536,7 @@ if (rtc_include_tests) { deps = [ "base:rtc_base", "base:rtc_base_tests_utils", + "base:rtc_exp_filter", "base:rtc_task_queue", "p2p:libstunprober", "p2p:rtc_p2p", diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index e0f6b8282f..89b5725138 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -22,6 +22,7 @@ group("base") { public_deps = [ ":rtc_base", ":rtc_base_approved", + ":rtc_exp_filter", ":rtc_task_queue", ] if (is_android) { @@ -124,8 +125,6 @@ rtc_static_library("rtc_base_approved") { "event.h", "event_tracer.cc", "event_tracer.h", - "exp_filter.cc", - "exp_filter.h", "file.cc", "file.h", "format_macros.h", @@ -338,6 +337,13 @@ rtc_static_library("rtc_task_queue") { } } +rtc_static_library("rtc_exp_filter") { + sources = [ + "exp_filter.cc", + "exp_filter.h", + ] +} + config("rtc_base_warnings_config") { if (is_win && is_clang) { cflags = [ diff --git a/webrtc/common_audio/BUILD.gn b/webrtc/common_audio/BUILD.gn index bfed73eeeb..bd85e2e5b9 100644 --- a/webrtc/common_audio/BUILD.gn +++ b/webrtc/common_audio/BUILD.gn @@ -86,6 +86,8 @@ rtc_static_library("common_audio") { "signal_processing/splitting_filter.c", "signal_processing/sqrt_of_one_minus_x_squared.c", "signal_processing/vector_scaling_operations.c", + "smoothing_filter.cc", + "smoothing_filter.h", "sparse_fir_filter.cc", "sparse_fir_filter.h", "vad/include/vad.h", @@ -109,6 +111,7 @@ rtc_static_library("common_audio") { ] deps = [ + "../base:rtc_exp_filter", "../system_wrappers", ] @@ -257,6 +260,7 @@ if (rtc_include_tests) { "ring_buffer_unittest.cc", "signal_processing/real_fft_unittest.cc", "signal_processing/signal_processing_unittest.cc", + "smoothing_filter_unittest.cc", "sparse_fir_filter_unittest.cc", "vad/vad_core_unittest.cc", "vad/vad_filterbank_unittest.cc", diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_smoothing_filter.h b/webrtc/common_audio/mocks/mock_smoothing_filter.h similarity index 60% rename from webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_smoothing_filter.h rename to webrtc/common_audio/mocks/mock_smoothing_filter.h index 745ca98ea6..6b2991b22f 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_smoothing_filter.h +++ b/webrtc/common_audio/mocks/mock_smoothing_filter.h @@ -8,22 +8,20 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_MOCK_MOCK_SMOOTHING_FILTER_H_ -#define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_MOCK_MOCK_SMOOTHING_FILTER_H_ +#ifndef WEBRTC_COMMON_AUDIO_MOCKS_MOCK_SMOOTHING_FILTER_H_ +#define WEBRTC_COMMON_AUDIO_MOCKS_MOCK_SMOOTHING_FILTER_H_ -#include "webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h" +#include "webrtc/common_audio/smoothing_filter.h" #include "webrtc/test/gmock.h" namespace webrtc { class MockSmoothingFilter : public SmoothingFilter { public: - virtual ~MockSmoothingFilter() { Die(); } - MOCK_METHOD0(Die, void()); MOCK_METHOD1(AddSample, void(float)); MOCK_CONST_METHOD0(GetAverage, rtc::Optional()); }; } // namespace webrtc -#endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_MOCK_MOCK_SMOOTHING_FILTER_H_ +#endif // WEBRTC_COMMON_AUDIO_MOCKS_MOCK_SMOOTHING_FILTER_H_ diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.cc b/webrtc/common_audio/smoothing_filter.cc similarity index 96% rename from webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.cc rename to webrtc/common_audio/smoothing_filter.cc index 8a8106918a..1cf9580d2a 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.cc +++ b/webrtc/common_audio/smoothing_filter.cc @@ -10,7 +10,7 @@ #include -#include "webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h" +#include "webrtc/common_audio/smoothing_filter.h" namespace webrtc { diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h b/webrtc/common_audio/smoothing_filter.h similarity index 83% rename from webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h rename to webrtc/common_audio/smoothing_filter.h index c4de7b5da5..30d8b7c87d 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h +++ b/webrtc/common_audio/smoothing_filter.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_SMOOTHING_FILTER_H_ -#define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_SMOOTHING_FILTER_H_ +#ifndef WEBRTC_COMMON_AUDIO_SMOOTHING_FILTER_H_ +#define WEBRTC_COMMON_AUDIO_SMOOTHING_FILTER_H_ #include "webrtc/base/constructormagic.h" #include "webrtc/base/exp_filter.h" @@ -46,9 +46,9 @@ class SmoothingFilterImpl final : public SmoothingFilter { int64_t last_sample_time_ms_; rtc::ExpFilter filter_; - RTC_DISALLOW_COPY_AND_ASSIGN(SmoothingFilterImpl); + RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SmoothingFilterImpl); }; } // namespace webrtc -#endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_SMOOTHING_FILTER_H_ +#endif // WEBRTC_COMMON_AUDIO_SMOOTHING_FILTER_H_ diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter_unittest.cc b/webrtc/common_audio/smoothing_filter_unittest.cc similarity index 97% rename from webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter_unittest.cc rename to webrtc/common_audio/smoothing_filter_unittest.cc index af4e8d957b..c80ffb672c 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter_unittest.cc +++ b/webrtc/common_audio/smoothing_filter_unittest.cc @@ -10,7 +10,7 @@ #include -#include "webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h" +#include "webrtc/common_audio/smoothing_filter.h" #include "webrtc/test/gtest.h" namespace webrtc { diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index 9120541041..7c8a49644e 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -264,7 +264,6 @@ if (rtc_include_tests) { "audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc", "audio_coding/audio_network_adaptor/mock/mock_controller.h", "audio_coding/audio_network_adaptor/mock/mock_controller_manager.h", - "audio_coding/audio_network_adaptor/smoothing_filter_unittest.cc", ] deps = [ "audio_coding:audio_network_adaptor", diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn index f6188a0425..da6fdccadd 100644 --- a/webrtc/modules/audio_coding/BUILD.gn +++ b/webrtc/modules/audio_coding/BUILD.gn @@ -757,8 +757,6 @@ rtc_static_library("audio_network_adaptor") { "audio_network_adaptor/frame_length_controller.cc", "audio_network_adaptor/frame_length_controller.h", "audio_network_adaptor/include/audio_network_adaptor.h", - "audio_network_adaptor/smoothing_filter.cc", - "audio_network_adaptor/smoothing_filter.h", ] deps = [ diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.h b/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.h index 0c2388b2c6..62a3533a75 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.h +++ b/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.h @@ -14,8 +14,8 @@ #include #include "webrtc/base/constructormagic.h" +#include "webrtc/common_audio/smoothing_filter.h" #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h" -#include "webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h" namespace webrtc { diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_unittest.cc b/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_unittest.cc index 9bbec26cbe..823763f091 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_unittest.cc +++ b/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_unittest.cc @@ -10,8 +10,8 @@ #include +#include "webrtc/common_audio/mocks/mock_smoothing_filter.h" #include "webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.h" -#include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_smoothing_filter.h" #include "webrtc/test/gtest.h" namespace webrtc { @@ -55,7 +55,6 @@ FecControllerStates CreateFecController(bool initial_fec_enabled) { std::unique_ptr mock_smoothing_filter( new NiceMock()); states.packet_loss_smoothed = mock_smoothing_filter.get(); - EXPECT_CALL(*states.packet_loss_smoothed, Die()); using Threshold = FecController::Config::Threshold; states.controller.reset(new FecController( FecController::Config( @@ -262,7 +261,6 @@ TEST(FecControllerTest, CheckBehaviorOnSpecialCurves) { std::unique_ptr mock_smoothing_filter( new NiceMock()); states.packet_loss_smoothed = mock_smoothing_filter.get(); - EXPECT_CALL(*states.packet_loss_smoothed, Die()); using Threshold = FecController::Config::Threshold; states.controller.reset(new FecController( FecController::Config( @@ -293,7 +291,6 @@ TEST(FecControllerDeathTest, InvalidConfig) { std::unique_ptr mock_smoothing_filter( new NiceMock()); states.packet_loss_smoothed = mock_smoothing_filter.get(); - EXPECT_CALL(*states.packet_loss_smoothed, Die()); using Threshold = FecController::Config::Threshold; EXPECT_DEATH( states.controller.reset(new FecController( diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 2966c29372..b36b16ddbf 100644 --- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -9,8 +9,8 @@ */ #include -#include "webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h" #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" +#include "webrtc/system_wrappers/include/clock.h" #include "webrtc/test/gtest.h" namespace webrtc {