From 263ef89954cff2ab1e15e5aac643c0f69c520afd Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Thu, 30 Jan 2014 04:33:27 +0000 Subject: Close #1730: Added srtp_deinit()/shutdown() detection for external SRTP in configure script. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4723 74dad513-b988-da41-8d7b-12977e46ad98 --- aconfigure | 90 ++++++++++++++++++++++++++++++++++++ aconfigure.ac | 9 ++++ pjmedia/build/os-auto.mak.in | 3 ++ pjmedia/src/pjmedia/transport_srtp.c | 12 +++++ 4 files changed, 114 insertions(+) diff --git a/aconfigure b/aconfigure index 39ef5ba8..88f48da1 100755 --- a/aconfigure +++ b/aconfigure @@ -651,6 +651,8 @@ ac_pa_cflags ac_external_pa ac_pjmedia_snd ac_pjmedia_resample +ac_srtp_shutdown_present +ac_srtp_deinit_present ac_external_srtp ac_external_gsm ac_external_speex @@ -5845,6 +5847,94 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi +if test "x$ac_external_srtp" = "x1"; then + ac_srtp_deinit_present=0 + + ac_srtp_shutdown_present=0 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for srtp_deinit in -lsrtp" >&5 +$as_echo_n "checking for srtp_deinit in -lsrtp... " >&6; } +if ${ac_cv_lib_srtp_srtp_deinit+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsrtp $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char srtp_deinit (); +int +main () +{ +return srtp_deinit (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_srtp_srtp_deinit=yes +else + ac_cv_lib_srtp_srtp_deinit=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_srtp_srtp_deinit" >&5 +$as_echo "$ac_cv_lib_srtp_srtp_deinit" >&6; } +if test "x$ac_cv_lib_srtp_srtp_deinit" = xyes; then : + ac_srtp_deinit_present=1 +fi + + if test "x$ac_srtp_deinit_present" != "x1"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for srtp_shutdown in -lsrtp" >&5 +$as_echo_n "checking for srtp_shutdown in -lsrtp... " >&6; } +if ${ac_cv_lib_srtp_srtp_shutdown+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsrtp $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char srtp_shutdown (); +int +main () +{ +return srtp_shutdown (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_srtp_srtp_shutdown=yes +else + ac_cv_lib_srtp_srtp_shutdown=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_srtp_srtp_shutdown" >&5 +$as_echo "$ac_cv_lib_srtp_srtp_shutdown" >&6; } +if test "x$ac_cv_lib_srtp_srtp_shutdown" = xyes; then : + ac_srtp_shutdown_present=1 +fi + + fi +fi ac_pjmedia_resample=libresample diff --git a/aconfigure.ac b/aconfigure.ac index 1a137b6e..c1a6ff8b 100644 --- a/aconfigure.ac +++ b/aconfigure.ac @@ -548,6 +548,15 @@ AC_ARG_WITH(external-srtp, ] ) +dnl # For external SRTP, check availability of srtp_deinit() or srtp_shutdown() +if test "x$ac_external_srtp" = "x1"; then + AC_SUBST(ac_srtp_deinit_present,0) + AC_SUBST(ac_srtp_shutdown_present,0) + AC_CHECK_LIB(srtp,srtp_deinit,[ac_srtp_deinit_present=1]) + if test "x$ac_srtp_deinit_present" != "x1"; then + AC_CHECK_LIB(srtp,srtp_shutdown,[ac_srtp_shutdown_present=1]) + fi +fi dnl # Resample implementation AC_SUBST(ac_pjmedia_resample,libresample) diff --git a/pjmedia/build/os-auto.mak.in b/pjmedia/build/os-auto.mak.in index f451331e..c0642cc8 100644 --- a/pjmedia/build/os-auto.mak.in +++ b/pjmedia/build/os-auto.mak.in @@ -134,6 +134,9 @@ endif ifeq (@ac_external_srtp@,1) # External SRTP export CFLAGS += -DPJMEDIA_EXTERNAL_SRTP=1 +# SRTP srtp_deinit()/srtp_shutdown() API availability settings +export CFLAGS += -DPJMEDIA_SRTP_HAS_DEINIT=@ac_srtp_deinit_present@ \ + -DPJMEDIA_SRTP_HAS_SHUTDOWN=@ac_srtp_shutdown_present@ else # Our SRTP in third_party export CFLAGS += -I$(THIRD_PARTY)/build/srtp \ diff --git a/pjmedia/src/pjmedia/transport_srtp.c b/pjmedia/src/pjmedia/transport_srtp.c index 2e76c506..e82c10a8 100644 --- a/pjmedia/src/pjmedia/transport_srtp.c +++ b/pjmedia/src/pjmedia/transport_srtp.c @@ -323,7 +323,19 @@ static void pjmedia_srtp_deinit_lib(pjmedia_endpt *endpt) PJ_UNUSED_ARG(endpt); +#if defined(PJMEDIA_EXTERNAL_SRTP) && (PJMEDIA_EXTERNAL_SRTP != 0) + +# if defined(PJMEDIA_SRTP_HAS_DEINIT) && PJMEDIA_SRTP_HAS_DEINIT!=0 + err = srtp_deinit(); +# elif defined(PJMEDIA_SRTP_HAS_SHUTDOWN) && PJMEDIA_SRTP_HAS_SHUTDOWN!=0 + err = srtp_shutdown(); +# else + err = err_status_ok; +# endif + +#else err = srtp_deinit(); +#endif if (err != err_status_ok) { PJ_LOG(4, (THIS_FILE, "Failed to deinitialize libsrtp: %s", get_libsrtp_errstr(err))); -- cgit v1.2.3