Index: pjproject/trunk/aconfigure
===================================================================
--- pjproject/trunk/aconfigure	(revision 4722)
+++ pjproject/trunk/aconfigure	(revision 4723)
@@ -652,4 +652,6 @@
 ac_pjmedia_snd
 ac_pjmedia_resample
+ac_srtp_shutdown_present
+ac_srtp_deinit_present
 ac_external_srtp
 ac_external_gsm
@@ -5846,4 +5848,92 @@
 
 
+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
Index: pjproject/trunk/aconfigure.ac
===================================================================
--- pjproject/trunk/aconfigure.ac	(revision 4722)
+++ pjproject/trunk/aconfigure.ac	(revision 4723)
@@ -549,4 +549,13 @@
     )
 
+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
Index: pjproject/trunk/pjmedia/build/os-auto.mak.in
===================================================================
--- pjproject/trunk/pjmedia/build/os-auto.mak.in	(revision 4722)
+++ pjproject/trunk/pjmedia/build/os-auto.mak.in	(revision 4723)
@@ -135,4 +135,7 @@
 # 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
Index: pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c	(revision 4722)
+++ pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c	(revision 4723)
@@ -324,5 +324,17 @@
     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", 
