diff --git a/aconfigure b/aconfigure index f6584a0e8..7082e13b6 100755 --- a/aconfigure +++ b/aconfigure @@ -690,6 +690,7 @@ ac_external_webrtc ac_external_yuv ac_srtp_shutdown_present ac_srtp_deinit_present +ac_external_srtp_lib ac_external_srtp ac_external_gsm ac_external_speex @@ -757,7 +758,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -882,7 +882,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1135,15 +1134,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1281,7 +1271,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1434,7 +1424,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -6009,6 +5998,7 @@ fi ac_external_srtp=0 + # Check whether --with-external-srtp was given. if test "${with_external_srtp+set}" = set; then : withval=$with_external_srtp; @@ -6018,6 +6008,25 @@ if test "${with_external_srtp+set}" = set; then : $as_echo_n "checking if external SRTP devkit is installed... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include + +int +main () +{ +srtp_init(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: version 2.x" >&5 +$as_echo "yes: version 2.x" >&6; } + ac_external_srtp="2" + ac_external_srtp_lib="srtp2" + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ #include int @@ -6029,13 +6038,16 @@ srtp_init(); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes!!" >&5 -$as_echo "yes!!" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: version 1.x" >&5 +$as_echo "yes: version 1.x" >&6; } ac_external_srtp="1" + ac_external_srtp_lib="srtp" else as_fn_error $? "Unable to use SRTP. If SRTP development files are not available in the default locations, use CFLAGS and LDFLAGS env var to set the include/lib paths" "$LINENO" 5 fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi @@ -6043,18 +6055,19 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -if test "x$ac_external_srtp" = "x1"; then +if test "x$ac_external_srtp" != "x0"; 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_ac_Lib=`$as_echo "ac_cv_lib_$ac_external_srtp_lib''_srtp_deinit" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for srtp_deinit in -l$ac_external_srtp_lib" >&5 +$as_echo_n "checking for srtp_deinit in -l$ac_external_srtp_lib... " >&6; } +if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lsrtp $LIBS" +LIBS="-l$ac_external_srtp_lib $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6074,28 +6087,30 @@ return srtp_deinit (); } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_srtp_srtp_deinit=yes + eval "$as_ac_Lib=yes" else - ac_cv_lib_srtp_srtp_deinit=no + eval "$as_ac_Lib=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 : +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; 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_ac_Lib=`$as_echo "ac_cv_lib_$ac_external_srtp_lib''_srtp_shutdown" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for srtp_shutdown in -l$ac_external_srtp_lib" >&5 +$as_echo_n "checking for srtp_shutdown in -l$ac_external_srtp_lib... " >&6; } +if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lsrtp $LIBS" +LIBS="-l$ac_external_srtp_lib $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6115,17 +6130,18 @@ return srtp_shutdown (); } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_srtp_srtp_shutdown=yes + eval "$as_ac_Lib=yes" else - ac_cv_lib_srtp_srtp_shutdown=no + eval "$as_ac_Lib=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 : +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : ac_srtp_shutdown_present=1 fi diff --git a/aconfigure.ac b/aconfigure.ac index 433696dfb..c3af3e14c 100644 --- a/aconfigure.ac +++ b/aconfigure.ac @@ -566,6 +566,7 @@ AC_ARG_WITH(external-gsm, dnl # Use external SRTP installation AC_SUBST(ac_external_srtp,0) +AC_SUBST(ac_external_srtp_lib) AC_ARG_WITH(external-srtp, AS_HELP_STRING([--with-external-srtp], [Use external SRTP development files, not the one in "third_party" directory. When this option is set, make sure that SRTP is accessible to use (hint: use CFLAGS and LDFLAGS env var to set the include/lib paths)]), @@ -573,24 +574,32 @@ AC_ARG_WITH(external-srtp, if test "x$with_external_srtp" != "xno"; then # Test SRTP installation AC_MSG_CHECKING([if external SRTP devkit is installed]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [srtp_init();])], - [AC_MSG_RESULT(yes!!) + [AC_MSG_RESULT(yes: version 2.x) + ac_external_srtp="2" + ac_external_srtp_lib="srtp2" + ], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + ]], + [srtp_init();])], + [AC_MSG_RESULT(yes: version 1.x) ac_external_srtp="1" + ac_external_srtp_lib="srtp" ], - [AC_MSG_ERROR([Unable to use SRTP. If SRTP development files are not available in the default locations, use CFLAGS and LDFLAGS env var to set the include/lib paths])]) + [AC_MSG_ERROR([Unable to use SRTP. If SRTP development files are not available in the default locations, use CFLAGS and LDFLAGS env var to set the include/lib paths])])]) fi ] ) dnl # For external SRTP, check availability of srtp_deinit() or srtp_shutdown() -if test "x$ac_external_srtp" = "x1"; then +if test "x$ac_external_srtp" != "x0"; 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]) + AC_CHECK_LIB($ac_external_srtp_lib,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]) + AC_CHECK_LIB($ac_external_srtp_lib,srtp_shutdown,[ac_srtp_shutdown_present=1]) fi fi diff --git a/build.mak.in b/build.mak.in index 7ed1206dd..6c263a975 100644 --- a/build.mak.in +++ b/build.mak.in @@ -28,9 +28,9 @@ export APP_THIRD_PARTY_EXT := export APP_THIRD_PARTY_LIBS := export APP_THIRD_PARTY_LIB_FILES := -ifeq (@ac_external_srtp@,1) +ifneq (@ac_external_srtp@,0) # External SRTP library -APP_THIRD_PARTY_EXT += -lsrtp +APP_THIRD_PARTY_EXT += -l@ac_external_srtp_lib@ else APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libsrtp-$(LIB_SUFFIX) ifeq ($(PJ_SHARED_LIBRARIES),) diff --git a/pjmedia/build/os-auto.mak.in b/pjmedia/build/os-auto.mak.in index 8a0ce4cfc..f998f6692 100644 --- a/pjmedia/build/os-auto.mak.in +++ b/pjmedia/build/os-auto.mak.in @@ -148,9 +148,9 @@ endif # # SRTP # -ifeq (@ac_external_srtp@,1) +ifneq (@ac_external_srtp@,0) # External SRTP -export CFLAGS += -DPJMEDIA_EXTERNAL_SRTP=1 +export CFLAGS += -DPJMEDIA_EXTERNAL_SRTP=@ac_external_srtp@ # 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@ diff --git a/pjmedia/src/pjmedia/transport_srtp.c b/pjmedia/src/pjmedia/transport_srtp.c index 0ebc8f51a..6f2d55c43 100644 --- a/pjmedia/src/pjmedia/transport_srtp.c +++ b/pjmedia/src/pjmedia/transport_srtp.c @@ -44,10 +44,36 @@ #endif -#if defined(PJMEDIA_EXTERNAL_SRTP) && (PJMEDIA_EXTERNAL_SRTP != 0) +#if defined(PJMEDIA_EXTERNAL_SRTP) + +#if (PJMEDIA_EXTERNAL_SRTP == 1) /* External SRTP 1.x */ # include # include -#else +#define srtp_crypto_policy_t crypto_policy_t +#define srtp_cipher_type_id_t cipher_type_id_t +#define srtp_cipher_type_t cipher_type_t +#define srtp_auth_type_id_t auth_type_id_t +#define srtp_sec_serv_t sec_serv_t +#define srtp_err_status_t err_status_t +#define srtp_err_status_ok err_status_ok +#define srtp_err_status_replay_old err_status_replay_old +#define srtp_err_status_replay_fail err_status_replay_fail +#define srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32 \ + crypto_policy_set_aes_cm_256_hmac_sha1_32 +#define srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80 \ + crypto_policy_set_aes_cm_256_hmac_sha1_80 +#define SRTP_NULL_CIPHER NULL_CIPHER +#define SRTP_NULL_AUTH NULL_AUTH +#define SRTP_AES_ICM_128 AES_ICM +#define SRTP_AES_ICM_256 AES_ICM +#define SRTP_HMAC_SHA1 HMAC_SHA1 + +#else /* External SRTP 2.x */ +# include +# include +#endif + +#else /* Bundled SRTP */ # include # include #endif diff --git a/third_party/build/os-auto.mak.in b/third_party/build/os-auto.mak.in index bc3e23220..22defec2c 100644 --- a/third_party/build/os-auto.mak.in +++ b/third_party/build/os-auto.mak.in @@ -39,7 +39,7 @@ else endif endif -ifeq (@ac_external_srtp@,1) +ifneq (@ac_external_srtp@,0) # External SRTP else DIRS += srtp