Skip to content

Commit 5f99723

Browse files
authored
Add support for WebRTC AEC3 (pjsip#2722)
1 parent 65b2444 commit 5f99723

File tree

542 files changed

+81737
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

542 files changed

+81737
-23
lines changed

aconfigure

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,10 @@ ac_subst_vars='LTLIBOBJS
622622
LIBOBJS
623623
ac_main_obj
624624
ac_host
625+
ac_webrtc_aec3_ldflags
626+
ac_webrtc_aec3_cflags
627+
ac_webrtc_aec3_instset
628+
ac_no_webrtc_aec3
625629
ac_webrtc_ldflags
626630
ac_webrtc_cflags
627631
ac_webrtc_instset
@@ -693,6 +697,7 @@ ac_pa_cflags
693697
ac_external_pa
694698
ac_pjmedia_snd
695699
ac_pjmedia_resample
700+
ac_external_webrtc_aec3
696701
ac_external_webrtc
697702
ac_external_yuv
698703
ac_srtp_shutdown_present
@@ -799,6 +804,7 @@ with_external_gsm
799804
with_external_srtp
800805
with_external_yuv
801806
with_external_webrtc
807+
with_external_webrtc_aec3
802808
enable_resample
803809
enable_sound
804810
with_external_pa
@@ -846,6 +852,7 @@ with_bcg729
846852
enable_bcg729
847853
enable_libyuv
848854
enable_libwebrtc
855+
enable_libwebrtc_aec3
849856
'
850857
ac_precious_vars='build_alias
851858
host_alias
@@ -1521,6 +1528,7 @@ Optional Features:
15211528
--disable-bcg729 Disable bcg729 (default: not disabled)
15221529
--disable-libyuv Exclude libyuv in the build
15231530
--disable-libwebrtc Exclude libwebrtc in the build
1531+
--enable-libwebrtc-aec3 Build libwebrtc-aec3 that's included in PJSIP
15241532
15251533
Optional Packages:
15261534
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1550,6 +1558,12 @@ Optional Packages:
15501558
make sure that webrtc is accessible to use (hint:
15511559
use CFLAGS and LDFLAGS env var to set the
15521560
include/lib paths)
1561+
--with-external-webrtc-aec3
1562+
Use external webrtc AEC3 development files, not the
1563+
one in "third_party" directory. When this option is
1564+
set, make sure that webrtc is accessible to use
1565+
(hint: use CFLAGS and LDFLAGS env var to set the
1566+
include/lib paths)
15531567
--with-external-pa Use external PortAudio development files. When this
15541568
option is set, make sure that PortAudio is
15551569
accessible to use (hint: use CFLAGS and LDFLAGS env
@@ -6354,6 +6368,44 @@ fi
63546368

63556369

63566370

6371+
ac_external_webrtc_aec3=0
6372+
6373+
6374+
# Check whether --with-external-webrtc-aec3 was given.
6375+
if test "${with_external_webrtc_aec3+set}" = set; then :
6376+
withval=$with_external_webrtc_aec3;
6377+
if test "x$with_external_webrtc_aec3" != "xno"; then
6378+
# Test webrtc AEC3 installation
6379+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if external webrtc AEC3 is installed" >&5
6380+
$as_echo_n "checking if external webrtc AEC3 is installed... " >&6; }
6381+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6382+
/* end confdefs.h. */
6383+
#include "modules/audio_processing/aec3/echo_canceller3.h"
6384+
6385+
int
6386+
main ()
6387+
{
6388+
EchoCanceller3 ec(EchoCanceller3Config(), 16000, 1, 1);
6389+
;
6390+
return 0;
6391+
}
6392+
_ACEOF
6393+
if ac_fn_c_try_compile "$LINENO"; then :
6394+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes!!" >&5
6395+
$as_echo "yes!!" >&6; }
6396+
ac_external_webrtc_aec3="1"
6397+
6398+
else
6399+
as_fn_error $? "Unable to use external webrtc AEC3. If webrtc development files are not available in the default locations, use CFLAGS and LDFLAGS env var to set the include/lib paths" "$LINENO" 5
6400+
fi
6401+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6402+
fi
6403+
6404+
6405+
fi
6406+
6407+
6408+
63576409
ac_pjmedia_resample=libresample
63586410

63596411
# Check whether --enable-resample was given.
@@ -9187,6 +9239,141 @@ fi
91879239

91889240

91899241

9242+
9243+
9244+
# Check whether --enable-libwebrtc_aec3 was given.
9245+
if test "${enable_libwebrtc_aec3+set}" = set; then :
9246+
enableval=$enable_libwebrtc_aec3;
9247+
if test "$enable_libwebrtc_aec3" = "yes"; then
9248+
# Test if we can build WebRtc AEC3
9249+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if WebRtc AEC3 can be compiled with C++17" >&5
9250+
$as_echo_n "checking if WebRtc AEC3 can be compiled with C++17... " >&6; }
9251+
9252+
SAVED_CXXFLAGS="$CXXFLAGS"
9253+
CXXFLAGS="$CXXFLAGS -std=c++17"
9254+
9255+
ac_ext=cpp
9256+
ac_cpp='$CXXCPP $CPPFLAGS'
9257+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
9258+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
9259+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
9260+
9261+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9262+
/* end confdefs.h. */
9263+
9264+
int
9265+
main ()
9266+
{
9267+
9268+
;
9269+
return 0;
9270+
}
9271+
_ACEOF
9272+
if ac_fn_cxx_try_link "$LINENO"; then :
9273+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
9274+
$as_echo "yes" >&6; }
9275+
LD="$CXX"
9276+
else
9277+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9278+
$as_echo "no" >&6; }
9279+
CXXFLAGS="$SAVED_CXXFLAGS"
9280+
ac_no_webrtc_aec3=1
9281+
$as_echo "#define PJMEDIA_HAS_LIBWEBRTC_AEC3 0" >>confdefs.h
9282+
9283+
fi
9284+
rm -f core conftest.err conftest.$ac_objext \
9285+
conftest$ac_exeext conftest.$ac_ext
9286+
ac_ext=c
9287+
ac_cpp='$CPP $CPPFLAGS'
9288+
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
9289+
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
9290+
ac_compiler_gnu=$ac_cv_c_compiler_gnu
9291+
9292+
9293+
case $target in
9294+
*-apple-darwin_ios*)
9295+
case $target in
9296+
arm64*)
9297+
ac_webrtc_aec3_instset=neon
9298+
ac_webrtc_aec3_cflags="-DWEBRTC_ARCH_ARM64"
9299+
;;
9300+
*arm*)
9301+
ac_webrtc_aec3_instset=neon
9302+
;;
9303+
*)
9304+
ac_webrtc_aec3_instset=sse2
9305+
;;
9306+
esac
9307+
;;
9308+
*android*)
9309+
case $TARGET_ABI in
9310+
armeabi-v7a)
9311+
ac_webrtc_aec3_instset=neon
9312+
ac_webrtc_aec3_cflags="-mfloat-abi=softfp -mfpu=neon"
9313+
;;
9314+
armeabi)
9315+
ac_webrtc_aec3_instset=neon
9316+
ac_webrtc_aec3_cflags="-mthumb -mfloat-abi=softfp -mfpu=neon -march=armv7"
9317+
;;
9318+
arm64*)
9319+
ac_webrtc_aec3_instset=neon
9320+
ac_webrtc_aec3_cflags="-DWEBRTC_ARCH_ARM64"
9321+
;;
9322+
x86*)
9323+
ac_webrtc_aec3_instset=sse2
9324+
;;
9325+
esac
9326+
;;
9327+
*mingw* | *cygw*)
9328+
ac_webrtc_aec3_instset=sse2
9329+
ac_webrtc_aec3_cflags="-msse2"
9330+
;;
9331+
*win32* | *w32* | *darwin* | *linux*)
9332+
case $target in
9333+
armv7l*gnueabihf)
9334+
ac_webrtc_aec3_instset=neon
9335+
ac_webrtc_aec3_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon"
9336+
;;
9337+
arm-apple-darwin*)
9338+
ac_webrtc_aec3_instset=neon
9339+
ac_webrtc_aec3_cflags="-DWEBRTC_ARCH_ARM64"
9340+
;;
9341+
*)
9342+
ac_webrtc_aec3_instset=sse2
9343+
;;
9344+
esac
9345+
case $target in
9346+
*darwin*)
9347+
ac_webrtc_aec3_cflags+=" -DWEBRTC_MAC=1"
9348+
;;
9349+
esac
9350+
;;
9351+
*)
9352+
;;
9353+
esac
9354+
ac_webrtc_aec3_cflags+=" -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX=1"
9355+
else
9356+
ac_no_webrtc_aec3=1
9357+
$as_echo "#define PJMEDIA_HAS_LIBWEBRTC_AEC3 0" >>confdefs.h
9358+
9359+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if libwebrtc-aec3 is enabled...no" >&5
9360+
$as_echo "Checking if libwebrtc-aec3 is enabled...no" >&6; }
9361+
fi
9362+
9363+
9364+
else
9365+
ac_no_webrtc_aec3=1
9366+
$as_echo "#define PJMEDIA_HAS_LIBWEBRTC_AEC3 0" >>confdefs.h
9367+
9368+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if libwebrtc-aec3 is enabled...no" >&5
9369+
$as_echo "Checking if libwebrtc-aec3 is enabled...no" >&6; }
9370+
9371+
fi
9372+
9373+
9374+
9375+
9376+
91909377
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if select() needs correct nfds" >&5
91919378
$as_echo_n "checking if select() needs correct nfds... " >&6; }
91929379
case $target in

aconfigure.ac

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,27 @@ AC_ARG_WITH(external-webrtc,
673673
)
674674

675675

676+
dnl # Use external webrtc AEC3 installation
677+
AC_SUBST(ac_external_webrtc_aec3,0)
678+
AC_ARG_WITH(external-webrtc-aec3,
679+
AS_HELP_STRING([--with-external-webrtc-aec3],
680+
[Use external webrtc AEC3 development files, not the one in "third_party" directory. When this option is set, make sure that webrtc is accessible to use (hint: use CFLAGS and LDFLAGS env var to set the include/lib paths)]),
681+
[
682+
if test "x$with_external_webrtc_aec3" != "xno"; then
683+
# Test webrtc AEC3 installation
684+
AC_MSG_CHECKING([if external webrtc AEC3 is installed])
685+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "modules/audio_processing/aec3/echo_canceller3.h"
686+
]],
687+
[EchoCanceller3 ec(EchoCanceller3Config(), 16000, 1, 1);])],
688+
[AC_MSG_RESULT(yes!!)
689+
ac_external_webrtc_aec3="1"
690+
],
691+
[AC_MSG_ERROR([Unable to use external webrtc AEC3. If webrtc development files are not available in the default locations, use CFLAGS and LDFLAGS env var to set the include/lib paths])])
692+
fi
693+
]
694+
)
695+
696+
676697
dnl # Resample implementation
677698
AC_SUBST(ac_pjmedia_resample,libresample)
678699
AC_ARG_ENABLE(resample,
@@ -2184,6 +2205,106 @@ AC_ARG_ENABLE(libwebrtc,
21842205
])
21852206

21862207

2208+
dnl # Include webrtc AEC3
2209+
AC_SUBST(ac_no_webrtc_aec3)
2210+
AC_SUBST(ac_webrtc_aec3_instset)
2211+
AC_SUBST(ac_webrtc_aec3_cflags)
2212+
AC_SUBST(ac_webrtc_aec3_ldflags)
2213+
AC_ARG_ENABLE(libwebrtc_aec3,
2214+
AS_HELP_STRING([--enable-libwebrtc-aec3],
2215+
[Build libwebrtc-aec3 that's included in PJSIP]),
2216+
[
2217+
if test "$enable_libwebrtc_aec3" = "yes"; then
2218+
# Test if we can build WebRtc AEC3
2219+
AC_MSG_CHECKING([if WebRtc AEC3 can be compiled with C++17])
2220+
2221+
SAVED_CXXFLAGS="$CXXFLAGS"
2222+
CXXFLAGS="$CXXFLAGS -std=c++17"
2223+
2224+
AC_LANG_PUSH([C++])
2225+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])],
2226+
[AC_MSG_RESULT(yes)
2227+
LD="$CXX"],
2228+
[AC_MSG_RESULT(no)
2229+
CXXFLAGS="$SAVED_CXXFLAGS"
2230+
ac_no_webrtc_aec3=1
2231+
AC_DEFINE(PJMEDIA_HAS_LIBWEBRTC_AEC3,0)])
2232+
AC_LANG_POP([C++])
2233+
2234+
case $target in
2235+
*-apple-darwin_ios*)
2236+
case $target in
2237+
arm64*)
2238+
ac_webrtc_aec3_instset=neon
2239+
ac_webrtc_aec3_cflags="-DWEBRTC_ARCH_ARM64"
2240+
;;
2241+
*arm*)
2242+
ac_webrtc_aec3_instset=neon
2243+
;;
2244+
*)
2245+
ac_webrtc_aec3_instset=sse2
2246+
;;
2247+
esac
2248+
;;
2249+
*android*)
2250+
case $TARGET_ABI in
2251+
armeabi-v7a)
2252+
ac_webrtc_aec3_instset=neon
2253+
ac_webrtc_aec3_cflags="-mfloat-abi=softfp -mfpu=neon"
2254+
;;
2255+
armeabi)
2256+
ac_webrtc_aec3_instset=neon
2257+
ac_webrtc_aec3_cflags="-mthumb -mfloat-abi=softfp -mfpu=neon -march=armv7"
2258+
;;
2259+
arm64*)
2260+
ac_webrtc_aec3_instset=neon
2261+
ac_webrtc_aec3_cflags="-DWEBRTC_ARCH_ARM64"
2262+
;;
2263+
x86*)
2264+
ac_webrtc_aec3_instset=sse2
2265+
;;
2266+
esac
2267+
;;
2268+
*mingw* | *cygw*)
2269+
ac_webrtc_aec3_instset=sse2
2270+
ac_webrtc_aec3_cflags="-msse2"
2271+
;;
2272+
*win32* | *w32* | *darwin* | *linux*)
2273+
case $target in
2274+
armv7l*gnueabihf)
2275+
ac_webrtc_aec3_instset=neon
2276+
ac_webrtc_aec3_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon"
2277+
;;
2278+
arm-apple-darwin*)
2279+
ac_webrtc_aec3_instset=neon
2280+
ac_webrtc_aec3_cflags="-DWEBRTC_ARCH_ARM64"
2281+
;;
2282+
*)
2283+
ac_webrtc_aec3_instset=sse2
2284+
;;
2285+
esac
2286+
case $target in
2287+
*darwin*)
2288+
ac_webrtc_aec3_cflags+=" -DWEBRTC_MAC=1"
2289+
;;
2290+
esac
2291+
;;
2292+
*)
2293+
;;
2294+
esac
2295+
ac_webrtc_aec3_cflags+=" -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX=1"
2296+
else
2297+
ac_no_webrtc_aec3=1
2298+
AC_DEFINE(PJMEDIA_HAS_LIBWEBRTC_AEC3,0)
2299+
AC_MSG_RESULT([Checking if libwebrtc-aec3 is enabled...no])
2300+
fi
2301+
],
2302+
[ac_no_webrtc_aec3=1
2303+
AC_DEFINE(PJMEDIA_HAS_LIBWEBRTC_AEC3,0)
2304+
AC_MSG_RESULT([Checking if libwebrtc-aec3 is enabled...no])
2305+
])
2306+
2307+
21872308
dnl ##########################################
21882309
dnl #
21892310
dnl # MANUAL CONFIG

build.mak.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ endif
152152
endif
153153
endif
154154

155+
ifneq (@ac_no_webrtc_aec3@,1)
156+
ifeq (@ac_external_webrtc_aec3@,1)
157+
APP_THIRD_PARTY_EXT += -lwebrtc-aec3
158+
else
159+
APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libwebrtc-aec3-$(LIB_SUFFIX)
160+
ifeq ($(PJ_SHARED_LIBRARIES),)
161+
APP_THIRD_PARTY_LIBS += -lwebrtc-aec3-$(TARGET_NAME)
162+
else
163+
APP_THIRD_PARTY_LIBS += -lwebrtc-aec3
164+
APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libwebrtc-aec3.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libwebrtc.$(SHLIB_SUFFIX)
165+
endif
166+
endif
167+
endif
168+
155169

156170
# Additional flags
157171
@ac_build_mak_vars@

0 commit comments

Comments
 (0)