From 326a6060483542cf6b650f354296056f7d409c35 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 15 Nov 2012 11:40:19 +0100 Subject: [PATCH] Add WebRTC echo canceller. --- .gitmodules | 3 + Makefile | 2 +- jni/Android.mk | 12 +++ jni/Application.mk | 5 + res/raw/linphonerc | 2 - submodules/externals/build/webrtc/Android.mk | 10 ++ .../common_audio/signal_processing/Android.mk | 96 +++++++++++++++++++ .../modules/audio_processing/aecm/Android.mk | 87 +++++++++++++++++ .../aecm/aecm_core_neon_offsets.h | 8 ++ .../audio_processing/utility/Android.mk | 43 +++++++++ .../build/webrtc/system_wrappers/Android.mk | 39 ++++++++ submodules/externals/webrtc | 1 + 12 files changed, 305 insertions(+), 3 deletions(-) create mode 100644 submodules/externals/build/webrtc/Android.mk create mode 100644 submodules/externals/build/webrtc/common_audio/signal_processing/Android.mk create mode 100644 submodules/externals/build/webrtc/modules/audio_processing/aecm/Android.mk create mode 100644 submodules/externals/build/webrtc/modules/audio_processing/aecm/aecm_core_neon_offsets.h create mode 100644 submodules/externals/build/webrtc/modules/audio_processing/utility/Android.mk create mode 100644 submodules/externals/build/webrtc/system_wrappers/Android.mk create mode 160000 submodules/externals/webrtc diff --git a/.gitmodules b/.gitmodules index f488bd83e..e250e561c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -55,3 +55,6 @@ [submodule "submodules/bcg729"] path = submodules/bcg729 url = git://git.linphone.org/bcg729.git +[submodule "submodules/externals/webrtc"] + path = submodules/externals/webrtc + url = gitosis@git.linphone.org:webrtc diff --git a/Makefile b/Makefile index 021137551..91ac19447 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ prepare-mediastreamer2: prepare-sources: prepare-ffmpeg prepare-ilbc prepare-vpx prepare-silk prepare-srtp prepare-mediastreamer2 generate-libs: - $(NDK_PATH)/ndk-build LINPHONE_VERSION=$(LINPHONE_VERSION) BUILD_SILK=1 BUILD_AMRNB=full -j$(NUMCPUS) + $(NDK_PATH)/ndk-build LINPHONE_VERSION=$(LINPHONE_VERSION) BUILD_SILK=1 BUILD_AMRNB=full BUILD_G729=1 BUILD_WEBRTC_AECM=1 -j$(NUMCPUS) update-project: $(SDK_PATH)/android update project --path . diff --git a/jni/Android.mk b/jni/Android.mk index 35e56b068..3c6df768b 100755 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -143,3 +143,15 @@ ifneq ($(BUILD_G729), 0) include $(linphone-root-dir)/submodules/bcg729/Android.mk include $(linphone-root-dir)/submodules/bcg729/msbcg729/Android.mk endif + +ifneq ($(BUILD_WEBRTC_AECM), 0) +ifneq ($(TARGET_ARCH), x86) +ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) +WEBRTC_BUILD_NEON_LIBS=true +endif +include $(linphone-root-dir)/submodules/externals/build/webrtc/system_wrappers/Android.mk +include $(linphone-root-dir)/submodules/externals/build/webrtc/common_audio/signal_processing/Android.mk +include $(linphone-root-dir)/submodules/externals/build/webrtc/modules/audio_processing/utility/Android.mk +include $(linphone-root-dir)/submodules/externals/build/webrtc/modules/audio_processing/aecm/Android.mk +endif +endif diff --git a/jni/Application.mk b/jni/Application.mk index c67dc451a..e6aae1f36 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -48,6 +48,11 @@ ifeq ($(BUILD_G729),1) APP_MODULES +=libbcg729 libmsbcg729 endif +ifneq ($BUILD_WEBRTC_AECM), 0) +APP_MODULES += libwebrtc_system_wrappers libwebrtc_spl libwebrtc_apm_utility libwebrtc_aecm +APP_MODULES += libwebrtc_spl_neon libwebrtc_aecm_neon +endif + ifeq ($(RING),yes) APP_MODULES += libring endif diff --git a/res/raw/linphonerc b/res/raw/linphonerc index 5f3bbe5f0..7b64b4898 100644 --- a/res/raw/linphonerc +++ b/res/raw/linphonerc @@ -34,8 +34,6 @@ ringer_dev_id= capture_dev_id= remote_ring=/data/data/org.linphone/files/ringback.wav local_ring=/data/data/org.linphone/files/oldphone_mono.wav -ec_tail_len=120 -ec_framesize=128 el_type=mic el_thres=0.03 diff --git a/submodules/externals/build/webrtc/Android.mk b/submodules/externals/build/webrtc/Android.mk new file mode 100644 index 000000000..71185c94d --- /dev/null +++ b/submodules/externals/build/webrtc/Android.mk @@ -0,0 +1,10 @@ +MY_WEBRTC_COMMON_DEFS := \ + -DWEBRTC_ANDROID \ + -DWEBRTC_LINUX \ + -DWEBRTC_CLOCK_TYPE_REALTIME \ + -DWEBRTC_ARCH_ARM + +ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) +MY_WEBRTC_COMMON_DEFS += \ + -DWEBRTC_DETECT_ARM_NEON +endif diff --git a/submodules/externals/build/webrtc/common_audio/signal_processing/Android.mk b/submodules/externals/build/webrtc/common_audio/signal_processing/Android.mk new file mode 100644 index 000000000..0c04ebea3 --- /dev/null +++ b/submodules/externals/build/webrtc/common_audio/signal_processing/Android.mk @@ -0,0 +1,96 @@ +# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +MY_WEBRTC_PATH := $(call my-dir)/../../ +LOCAL_PATH := $(MY_WEBRTC_PATH)/../../webrtc/common_audio/signal_processing + +include $(CLEAR_VARS) + +include $(MY_WEBRTC_PATH)/Android.mk + +LOCAL_ARM_MODE := arm +LOCAL_MODULE_CLASS := STATIC_LIBRARIES +LOCAL_MODULE := libwebrtc_spl +LOCAL_MODULE_TAGS := optional +LOCAL_SRC_FILES := \ + complex_fft.c \ + cross_correlation.c \ + division_operations.c \ + downsample_fast.c \ + min_max_operations.c \ + randomization_functions.c \ + real_fft.c \ + spl_init.c \ + vector_scaling_operations.c + +# Flags passed to both C and C++ files. +LOCAL_CFLAGS := \ + $(MY_WEBRTC_COMMON_DEFS) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/../.. + +ifeq ($(TARGET_ARCH),arm) +LOCAL_SRC_FILES += \ + complex_bit_reverse_arm.s \ + spl_sqrt_floor_arm.s +else +LOCAL_SRC_FILES += \ + complex_bit_reverse.c \ + spl_sqrt_floor.c +endif + +LOCAL_SHARED_LIBRARIES := libstlport + +ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) +LOCAL_LDLIBS += -ldl -lpthread +endif + +ifneq ($(TARGET_SIMULATOR),true) +LOCAL_SHARED_LIBRARIES += libdl +endif + +ifndef NDK_ROOT +include external/stlport/libstlport.mk +endif +include $(BUILD_STATIC_LIBRARY) + +######################### +# Build the neon library. +ifeq ($(WEBRTC_BUILD_NEON_LIBS),true) + +include $(CLEAR_VARS) + +include $(MY_WEBRTC_PATH)/Android.mk + +LOCAL_ARM_MODE := arm +LOCAL_MODULE_CLASS := STATIC_LIBRARIES +LOCAL_MODULE := libwebrtc_spl_neon +LOCAL_MODULE_TAGS := optional +LOCAL_SRC_FILES := \ + cross_correlation_neon.s \ + downsample_fast_neon.s \ + min_max_operations_neon.s \ + vector_scaling_operations_neon.s + +# Flags passed to both C and C++ files. +LOCAL_CFLAGS := \ + $(MY_WEBRTC_COMMON_DEFS) \ + $(MY_ARM_CFLAGS_NEON) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/../.. + +ifndef NDK_ROOT +include external/stlport/libstlport.mk +endif +include $(BUILD_STATIC_LIBRARY) + +endif # ifeq ($(WEBRTC_BUILD_NEON_LIBS),true) diff --git a/submodules/externals/build/webrtc/modules/audio_processing/aecm/Android.mk b/submodules/externals/build/webrtc/modules/audio_processing/aecm/Android.mk new file mode 100644 index 000000000..9ef3de3bd --- /dev/null +++ b/submodules/externals/build/webrtc/modules/audio_processing/aecm/Android.mk @@ -0,0 +1,87 @@ +############################# +# Build the non-neon library. + +MY_WEBRTC_PATH := $(call my-dir)/../../../ +LOCAL_PATH := $(MY_WEBRTC_PATH)/../../webrtc/modules/audio_processing/aecm + +include $(CLEAR_VARS) + +include $(MY_WEBRTC_PATH)/Android.mk + +LOCAL_ARM_MODE := arm +LOCAL_MODULE_CLASS := STATIC_LIBRARIES +LOCAL_MODULE := libwebrtc_aecm +LOCAL_MODULE_TAGS := optional +LOCAL_SRC_FILES := \ + echo_control_mobile.c \ + aecm_core.c + +# Flags passed to both C and C++ files. +LOCAL_CFLAGS := $(MY_WEBRTC_COMMON_DEFS) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/../utility \ + $(LOCAL_PATH)/../../.. \ + $(LOCAL_PATH)/../../../common_audio/signal_processing/include \ + $(LOCAL_PATH)/../../../system_wrappers/interface \ + +LOCAL_STATIC_LIBRARIES += libwebrtc_system_wrappers + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + libdl \ + libstlport + +ifndef NDK_ROOT +include external/stlport/libstlport.mk +endif +include $(BUILD_STATIC_LIBRARY) + +######################### +# Build the neon library. +ifeq ($(WEBRTC_BUILD_NEON_LIBS),true) + +include $(CLEAR_VARS) + +include $(MY_WEBRTC_PATH)/Android.mk + +LOCAL_ARM_MODE := arm +LOCAL_MODULE_CLASS := STATIC_LIBRARIES +LOCAL_MODULE := libwebrtc_aecm_neon +LOCAL_MODULE_TAGS := optional + +# Generate a header file aecm_core_neon_offsets.h which will be included in +# assembly file aecm_core_neon.S, from file aecm_core_neon_offsets.c. +#$(LOCAL_PATH)/aecm_core_neon_offsets.h: $(LOCAL_PATH)/aecm_core_neon_offsets.S +# python $(LOCAL_PATH)/../../../build/generate_asm_header.py $^ $@ offset_aecm_ +# +#$(LOCAL_PATH)/aecm_core_neon_offsets.S: $(LOCAL_PATH)/aecm_core_neon_offsets.c +# $(TARGET_CC) $(addprefix -I, $(LOCAL_INCLUDES)) $(addprefix -isystem ,\ +# $(TARGET_C_INCLUDES)) -S -o $@ $^ +# +#$(LOCAL_PATH)/aecm_core_neon.S: $(LOCAL_PATH)/aecm_core_neon_offsets.h + +LOCAL_SRC_FILES := aecm_core_neon.S + +# Flags passed to both C and C++ files. +LOCAL_CFLAGS := \ + $(MY_WEBRTC_COMMON_DEFS) \ + -mfpu=neon \ + -mfloat-abi=softfp \ + -flax-vector-conversions + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/../../.. \ + $(LOCAL_PATH)/../../../common_audio/signal_processing/include \ + $(MY_WEBRTC_PATH)/modules/audio_processing/aecm + +LOCAL_INCLUDES := $(LOCAL_C_INCLUDES) + +ifndef NDK_ROOT +include external/stlport/libstlport.mk +endif +include $(BUILD_STATIC_LIBRARY) + +endif # ifeq ($(WEBRTC_BUILD_NEON_LIBS),true) diff --git a/submodules/externals/build/webrtc/modules/audio_processing/aecm/aecm_core_neon_offsets.h b/submodules/externals/build/webrtc/modules/audio_processing/aecm/aecm_core_neon_offsets.h new file mode 100644 index 000000000..7f24270ec --- /dev/null +++ b/submodules/externals/build/webrtc/modules/audio_processing/aecm/aecm_core_neon_offsets.h @@ -0,0 +1,8 @@ +#define offset_aecm_dfaCleanQDomain 13976 +#define offset_aecm_outBuf 15988 +#define offset_aecm_xBuf 15976 +#define offset_aecm_dBufNoisy 15984 +#define offset_aecm_dBufClean 15980 +#define offset_aecm_channelStored 15964 +#define offset_aecm_channelAdapt16 15968 +#define offset_aecm_channelAdapt32 15972 diff --git a/submodules/externals/build/webrtc/modules/audio_processing/utility/Android.mk b/submodules/externals/build/webrtc/modules/audio_processing/utility/Android.mk new file mode 100644 index 000000000..8f8bb6b8c --- /dev/null +++ b/submodules/externals/build/webrtc/modules/audio_processing/utility/Android.mk @@ -0,0 +1,43 @@ +# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +MY_WEBRTC_PATH := $(call my-dir)/../../../ +LOCAL_PATH := $(MY_WEBRTC_PATH)/../../webrtc/modules/audio_processing/utility + +include $(CLEAR_VARS) + +include $(MY_WEBRTC_PATH)/Android.mk + +LOCAL_ARM_MODE := arm +LOCAL_MODULE_CLASS := STATIC_LIBRARIES +LOCAL_MODULE := libwebrtc_apm_utility +LOCAL_MODULE_TAGS := optional +LOCAL_SRC_FILES := \ + ring_buffer.c \ + delay_estimator.c \ + delay_estimator_wrapper.c + +# Flags passed to both C and C++ files. +LOCAL_CFLAGS := \ + $(MY_WEBRTC_COMMON_DEFS) + +# Include paths placed before CFLAGS/CPPFLAGS +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH) \ + $(LOCAL_PATH)/../../.. \ + $(LOCAL_PATH)/../../../common_audio/signal_processing/include + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + libdl \ + libstlport + +ifndef NDK_ROOT +include external/stlport/libstlport.mk +endif +include $(BUILD_STATIC_LIBRARY) diff --git a/submodules/externals/build/webrtc/system_wrappers/Android.mk b/submodules/externals/build/webrtc/system_wrappers/Android.mk new file mode 100644 index 000000000..fce5e9cdd --- /dev/null +++ b/submodules/externals/build/webrtc/system_wrappers/Android.mk @@ -0,0 +1,39 @@ +# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +MY_WEBRTC_PATH := $(call my-dir)/../ +LOCAL_PATH := $(MY_WEBRTC_PATH)/../../webrtc/system_wrappers/source + +include $(CLEAR_VARS) + +include $(MY_WEBRTC_PATH)/Android.mk + +LOCAL_ARM_MODE := arm +LOCAL_MODULE := libwebrtc_system_wrappers +LOCAL_MODULE_TAGS := optional +LOCAL_CPP_EXTENSION := .cc +LOCAL_SRC_FILES := \ + cpu_features_android.c + +LOCAL_CFLAGS := \ + $(MY_WEBRTC_COMMON_DEFS) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../.. \ + $(LOCAL_PATH)/../interface \ + $(LOCAL_PATH)/spreadsortlib + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + libdl \ + libstlport + +ifndef NDK_ROOT +include external/stlport/libstlport.mk +endif +include $(BUILD_STATIC_LIBRARY) diff --git a/submodules/externals/webrtc b/submodules/externals/webrtc new file mode 160000 index 000000000..2117f353f --- /dev/null +++ b/submodules/externals/webrtc @@ -0,0 +1 @@ +Subproject commit 2117f353f82da43f648b10dc6bd99f55e0d44c3f