Close #1730: Added srtp_deinit()/shutdown() detection for external SRTP in configure script.

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@4723 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Nanang Izzuddin 2014-01-30 04:33:27 +00:00
parent 30a2f34618
commit 68cb865f25
4 changed files with 114 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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 \

View File

@ -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)));