diff --git a/configure.ac b/configure.ac index 7ad323be2..a5d6088bd 100644 --- a/configure.ac +++ b/configure.ac @@ -177,9 +177,21 @@ fi AC_CHECK_HEADER(srtp2/srtp.h, found_libsrtp2=yes) if test "$found_libsrtp2" = yes then - AC_CHECK_LIB(srtp2, srtp_init, + AC_CHECK_LIB(srtp2, srtp_init,[ LIBS_SRTP="-lsrtp2" - AC_DEFINE([ENABLE_SRTP2], 1, [Define if you have libsrtp2 library installed])) + # Test program to check if the srtp_protect function accepts size_t* argument + AC_MSG_CHECKING(['srtp_protect()' last argument type]) + original_cflags="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ + #include + #include ], + [srtp_t ctx; void* rtp_hdr; size_t len; return srtp_protect(ctx, rtp_hdr, &len);])], + [srtp_protect_lastarg=size_t], [srtp_protect_lastarg=int]) + CFLAGS="$original_cflags" + AC_MSG_RESULT([$srtp_protect_lastarg]) + AC_DEFINE_UNQUOTED([SRTP_PROTECT_LASTARG], [${srtp_protect_lastarg}], [Type of the last argument of the srtp_protect() API]) + AC_DEFINE([ENABLE_SRTP2], 1, [Define if you have libsrtp2 library installed])]) else # libsrtp AC_CHECK_HEADER(srtp/srtp.h, found_libsrtp=yes) diff --git a/modules/dtls_gw/rtpp_dtls_conn.c b/modules/dtls_gw/rtpp_dtls_conn.c index e5519ba5c..423881273 100644 --- a/modules/dtls_gw/rtpp_dtls_conn.c +++ b/modules/dtls_gw/rtpp_dtls_conn.c @@ -454,7 +454,12 @@ rtpp_dtls_conn_dtls_recv(struct rtpp_dtls_conn *self, static int rtpp_dtls_conn_rtp_send(struct rtpp_dtls_conn *self, struct pkt_proc_ctx *pktxp) { - int status, len; + int status; +#if defined(SRTP_PROTECT_LASTARG) + SRTP_PROTECT_LASTARG len; +#else + size_t len; +#endif struct rtpp_dtls_conn_priv *pvt; PUB2PVT(self, pvt); diff --git a/src/config.h.in b/src/config.h.in index ea7f70a0b..3d1cfff7e 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -211,6 +211,9 @@ /* The number of bytes in type time_t */ #undef SIZEOF_TIME_T +/* Type of the last argument of the srtp_protect() API */ +#undef SRTP_PROTECT_LASTARG + /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime.