From af900f474e8af46eacb588d938b3e2fae45fb495 Mon Sep 17 00:00:00 2001 From: atraczyk <andreastraczyk@gmail.com> Date: Thu, 20 Jul 2017 15:52:03 -0400 Subject: [PATCH] contrib(UWP): revert to pjproject 2.5.5 pjproject 2.6 randomly crashes due to access violations. Until the problem can be fixed, we can use v2.5.5 Change-Id: Icdaf565a0bbf45cab6046ddb3114e29ebedff694 --- contrib/src/pjproject/fetch_and_patch.bat | 2 +- contrib/src/pjproject/pj_uwp.patch | 265 ++++++------ .../pjproject/pj_uwp_fix_turn_fallback.patch | 20 +- contrib/src/pjproject/pj_uwp_gnutls.patch | 376 +++++++++++++++++- 4 files changed, 525 insertions(+), 138 deletions(-) diff --git a/contrib/src/pjproject/fetch_and_patch.bat b/contrib/src/pjproject/fetch_and_patch.bat index 9bfe3a86d0..946d2c99e0 100644 --- a/contrib/src/pjproject/fetch_and_patch.bat +++ b/contrib/src/pjproject/fetch_and_patch.bat @@ -1,6 +1,6 @@ set BUILD=%SRC%..\build -set PJPROJECT_VERSION=2.6 +set PJPROJECT_VERSION=2.5.5 set PJPROJECT_URL=http://www.pjsip.org/release/%PJPROJECT_VERSION%/pjproject-%PJPROJECT_VERSION%.zip mkdir %BUILD% diff --git a/contrib/src/pjproject/pj_uwp.patch b/contrib/src/pjproject/pj_uwp.patch index 2e7f038266..0e47f047f2 100644 --- a/contrib/src/pjproject/pj_uwp.patch +++ b/contrib/src/pjproject/pj_uwp.patch @@ -1,6 +1,75 @@ +--- a/pjsip/build/pjsip_core.vcxproj ++++ b/pjsip/build/pjsip_core.vcxproj +@@ -211,7 +211,7 @@ + </Midl> + <ClCompile> + <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> +- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> ++ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;PJ_HAS_SSL_SOCK;_LIB;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PrecompiledHeaderOutputFile /> + </ClCompile> + <Lib> +--- a/pjsip/build/pjsip_simple.vcxproj ++++ b/pjsip/build/pjsip_simple.vcxproj +@@ -235,7 +235,7 @@ + </Midl> + <ClCompile> + <AdditionalIncludeDirectories>../include;../../pjlib-util/include;../../pjlib/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> +- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> ++ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PrecompiledHeaderOutputFile /> + </ClCompile> + <Lib> +--- a/pjsip/build/pjsip_ua.vcxproj ++++ b/pjsip/build/pjsip_ua.vcxproj +@@ -211,7 +211,7 @@ + </Midl> + <ClCompile> + <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;../../pjmedia/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> +- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> ++ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PrecompiledHeaderOutputFile /> + </ClCompile> + <Lib> +--- a/pjsip/build/pjsua2_lib.vcxproj ++++ b/pjsip/build/pjsua2_lib.vcxproj +@@ -235,7 +235,7 @@ + </Midl> + <ClCompile> + <AdditionalIncludeDirectories>../include;../../pjmedia/include;../../pjlib-util/include;../../pjlib/include;../../pjnath/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> +- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> ++ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PrecompiledHeaderOutputFile /> + </ClCompile> + <Lib> +--- a/pjsip/build/pjsua_lib.vcxproj ++++ b/pjsip/build/pjsua_lib.vcxproj +@@ -235,7 +235,7 @@ + </Midl> + <ClCompile> + <AdditionalIncludeDirectories>../include;../../pjmedia/include;../../pjlib-util/include;../../pjlib/include;../../pjnath/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> +- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> ++ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PrecompiledHeaderOutputFile /> + </ClCompile> + <Lib> +--- a/pjsip/src/pjsip/sip_dialog.c ++++ b/pjsip/src/pjsip/sip_dialog.c +@@ -888,7 +888,11 @@ PJ_DEF(void) pjsip_dlg_inc_lock(pjsip_dialog *dlg) + PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_inc_lock(), sess_count=%d", + dlg->sess_count)); + ++#if _WIN32 && (_WIN32_WINNT >= 0x0400) ++ pj_mutex_trylock(dlg->mutex_); ++#else + pj_mutex_lock(dlg->mutex_); ++#endif + dlg->sess_count++; + + PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_inc_lock(), sess_count=%d", --- a/pjlib-util/build/pjlib_util.vcxproj +++ b/pjlib-util/build/pjlib_util.vcxproj -@@ -327,7 +327,7 @@ +@@ -211,7 +211,7 @@ </Midl> <ClCompile> <AdditionalIncludeDirectories>../include;../../pjlib/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> @@ -11,7 +80,7 @@ <Lib> --- a/pjlib/build/pjlib.vcxproj +++ b/pjlib/build/pjlib.vcxproj -@@ -327,8 +327,8 @@ +@@ -224,8 +224,8 @@ <TargetEnvironment>X64</TargetEnvironment> </Midl> <ClCompile> @@ -22,19 +91,24 @@ <PrecompiledHeaderOutputFile /> </ClCompile> </ItemDefinitionGroup> -@@ -620,6 +620,7 @@ +@@ -424,9 +424,11 @@ + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release-Static|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release-Static|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> ++ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> ++ </ClCompile> ++ <ClCompile Include="..\src\pj\ip_helper_win32.c"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> - <ClCompile Include="..\src\pj\ip_helper_win32.c"> -+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(API_Family)'!='WinDesktop'">true</ExcludedFromBuild> - </ClCompile> - <ClCompile Include="..\src\pj\ip_helper_generic.c"> -@@ -851,6 +852,7 @@ +- <ClCompile Include="..\src\pj\ip_helper_win32.c" /> + <ClCompile Include="..\src\pj\list.c" /> + <ClCompile Include="..\src\pj\lock.c" /> + <ClCompile Include="..\src\pj\log.c" /> +@@ -593,6 +595,7 @@ <ClCompile Include="..\src\pj\sock_select.c" /> <ClCompile Include="..\src\pj\ssl_sock_common.c" /> <ClCompile Include="..\src\pj\ssl_sock_dump.c" /> -+ <ClCompile Include="..\src\pj\ssl_sock_gtls.c" /> ++ <ClCompile Include="..\src\pj\ssl_sock_gtls.c" /> <ClCompile Include="..\src\pj\ssl_sock_ossl.c" /> <ClCompile Include="..\src\pj\string.c" /> <ClCompile Include="..\src\pj\symbols.c"> @@ -63,32 +137,66 @@ \ No newline at end of file --- a/pjlib/src/pj/file_access_win32.c +++ b/pjlib/src/pj/file_access_win32.c -@@ -79,7 +79,7 @@ static HANDLE WINAPI create_file(LPCTSTR filename, DWORD desired_access, - return CreateFile2(filename, desired_access, share_mode, - creation_disposition, NULL); - #else -- return CreateFile(filename, desired_access, share_mode, -+ return CreateFile2(filename, desired_access, share_mode, - security_attributes, creation_disposition, - flags_and_attributes, template_file); - #endif +@@ -44,7 +44,7 @@ PJ_DEF(pj_bool_t) pj_file_exists(const char *filename) + + PJ_ASSERT_RETURN(filename != NULL, 0); + +- hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), ++ hFile = CreateFile2(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), + CONTROL_ACCESS, + FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +@@ -68,14 +68,14 @@ PJ_DEF(pj_off_t) pj_file_size(const char *filename) + + PJ_ASSERT_RETURN(filename != NULL, -1); + +- hFile = CreateFile(PJ_STRING_TO_NATIVE(filename, wfilename,sizeof(wfilename)), ++ hFile = CreateFile2(PJ_STRING_TO_NATIVE(filename, wfilename,sizeof(wfilename)), + CONTROL_ACCESS, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) + return -1; + +- sizeLo = GetFileSize(hFile, &sizeHi); ++ sizeLo = GetFileSizeEx(hFile, &sizeHi); + if (sizeLo == INVALID_FILE_SIZE) { + DWORD dwStatus = GetLastError(); + if (dwStatus != NO_ERROR) { +@@ -177,14 +177,14 @@ PJ_DEF(pj_status_t) pj_file_getstat(const char *filename, pj_file_stat *stat) + + PJ_ASSERT_RETURN(filename!=NULL && stat!=NULL, PJ_EINVAL); + +- hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), ++ hFile = CreateFile2(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), + CONTROL_ACCESS, + FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) + return PJ_RETURN_OS_ERROR(GetLastError()); + +- sizeLo = GetFileSize(hFile, &sizeHi); ++ sizeLo = GetFileSizeEx(hFile, &sizeHi); + if (sizeLo == INVALID_FILE_SIZE) { + DWORD dwStatus = GetLastError(); + if (dwStatus != NO_ERROR) { --- a/pjlib/src/pj/file_io_win32.c +++ b/pjlib/src/pj/file_io_win32.c -@@ -129,7 +129,7 @@ PJ_DEF(pj_status_t) pj_file_open( pj_pool_t *pool, - dwDesiredAccess, dwShareMode, dwCreationDisposition, - NULL); - #else -- hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname, -+ hFile = CreateFile2(PJ_STRING_TO_NATIVE(pathname, - wpathname, sizeof(wpathname)), +@@ -88,7 +88,7 @@ PJ_DEF(pj_status_t) pj_file_open( pj_pool_t *pool, + dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; + +- hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)), ++ hFile = CreateFile2(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)), dwDesiredAccess, dwShareMode, NULL, - dwCreationDisposition, dwFlagsAndAttributes, NULL); + dwCreationDisposition, dwFlagsAndAttributes, NULL); + if (hFile == INVALID_HANDLE_VALUE) { --- a/pjmedia/build/pjmedia.vcxproj +++ b/pjmedia/build/pjmedia.vcxproj -@@ -325,7 +325,7 @@ +@@ -207,7 +207,7 @@ </Midl> <ClCompile> - <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;../../pjnath/include;../../third_party/portaudio/include;../../third_party/speex/include;../../third_party/build/srtp;../../third_party/srtp/include;../../third_party/srtp/crypto/include;../../third_party/yuv/include;../../third_party/webrtc/src;../..;$(DXSDK_DIR)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;../../pjnath/include;../../third_party/portaudio/include;../../third_party/speex/include;../../third_party/build/srtp;../../third_party/srtp/include;../../third_party/srtp/crypto/include;../../third_party/yuv/include;../..;$(DXSDK_DIR)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PrecompiledHeaderOutputFile /> @@ -96,7 +204,7 @@ </ItemDefinitionGroup> --- a/pjnath/build/pjnath.vcxproj +++ b/pjnath/build/pjnath.vcxproj -@@ -410,7 +410,7 @@ +@@ -267,7 +267,7 @@ </Midl> <ClCompile> <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> @@ -105,99 +213,4 @@ <PrecompiledHeaderOutputFile /> </ClCompile> </ItemDefinitionGroup> ---- a/pjsip/build/pjsip_core.vcxproj -+++ b/pjsip/build/pjsip_core.vcxproj -@@ -327,7 +327,7 @@ - </Midl> - <ClCompile> - <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> -- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> -+ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;PJ_HAS_SSL_SOCK;_LIB;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PrecompiledHeaderOutputFile /> - </ClCompile> - <Lib> ---- a/pjsip/build/pjsip_simple.vcxproj -+++ b/pjsip/build/pjsip_simple.vcxproj -@@ -362,7 +362,7 @@ - </Midl> - <ClCompile> - <AdditionalIncludeDirectories>../include;../../pjlib-util/include;../../pjlib/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> -- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> -+ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PrecompiledHeaderOutputFile /> - </ClCompile> - <Lib> ---- a/pjsip/build/pjsip_ua.vcxproj -+++ b/pjsip/build/pjsip_ua.vcxproj -@@ -327,7 +327,7 @@ - </Midl> - <ClCompile> - <AdditionalIncludeDirectories>../include;../../pjlib/include;../../pjlib-util/include;../../pjmedia/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> -- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> -+ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PrecompiledHeaderOutputFile /> - </ClCompile> - <Lib> ---- a/pjsip/build/pjsua2_lib.vcxproj -+++ b/pjsip/build/pjsua2_lib.vcxproj -@@ -364,7 +364,7 @@ - </Midl> - <ClCompile> - <AdditionalIncludeDirectories>../include;../../pjmedia/include;../../pjlib-util/include;../../pjlib/include;../../pjnath/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> -- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> -+ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PrecompiledHeaderOutputFile /> - </ClCompile> - <Lib> ---- a/pjsip/build/pjsua_lib.vcxproj -+++ b/pjsip/build/pjsua_lib.vcxproj -@@ -362,7 +362,7 @@ - </Midl> - <ClCompile> - <AdditionalIncludeDirectories>../include;../../pjmedia/include;../../pjlib-util/include;../../pjlib/include;../../pjnath/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> -- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> -+ <PreprocessorDefinitions>PJ_OS_HAS_CHECK_STACK=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PrecompiledHeaderOutputFile /> - </ClCompile> - <Lib> ---- a/pjsip/src/pjsip/sip_dialog.c -+++ b/pjsip/src/pjsip/sip_dialog.c -@@ -882,7 +882,7 @@ PJ_DEF(void) pjsip_dlg_inc_lock(pjsip_dialog *dlg) - PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_inc_lock(), sess_count=%d", - dlg->sess_count)); - -- pj_mutex_lock(dlg->mutex_); -+ pj_mutex_trylock(dlg->mutex_); - dlg->sess_count++; - - PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_inc_lock(), sess_count=%d", ---- a/pjlib/build/pjlib.vcxproj -+++ b/pjlib/build/pjlib.vcxproj -@@ -617,7 +617,7 @@ - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release-Static|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild> -- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> -+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> - </ClCompile> - <ClCompile Include="..\src\pj\ip_helper_win32.c"> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> ---- a/pjlib/src/pj/os_core_win32.c -+++ b/pjlib/src/pj/os_core_win32.c -@@ -1424,10 +1424,10 @@ PJ_DEF(pj_status_t) pj_event_pulse(pj_event_t *event) - - PJ_LOG(6, (event->obj_name, "Pulsing event")); - -- if (PulseEvent(event->hEvent)) -+ //if (PulseEvent(event->hEvent)) - return PJ_SUCCESS; -- else -- return PJ_RETURN_OS_ERROR(GetLastError()); -+ //else -+ //return PJ_RETURN_OS_ERROR(GetLastError()); - #endif - } - --- -2.10.2.windows.1 - + \ No newline at end of file diff --git a/contrib/src/pjproject/pj_uwp_fix_turn_fallback.patch b/contrib/src/pjproject/pj_uwp_fix_turn_fallback.patch index 5d7b44b9f5..fe386f0248 100644 --- a/contrib/src/pjproject/pj_uwp_fix_turn_fallback.patch +++ b/contrib/src/pjproject/pj_uwp_fix_turn_fallback.patch @@ -1,5 +1,5 @@ ---- a/pjnath/src/pjnath/turn_session.c -+++ b/pjnath/src/pjnath/turn_session.c +--- a/pjnath/src/pjnath/turn_session.c 2016-09-19 18:21:09.073614574 -0400 ++++ b/pjnath/src/pjnath/turn_session.c 2016-09-19 18:21:30.648631620 -0400 @@ -653,3 +653,3 @@ - cnt = PJ_TURN_MAX_DNS_SRV_CNT; @@ -7,11 +7,11 @@ ai = (pj_addrinfo*) --- a/pjnath/src/pjnath/ice_strans.c +++ b/pjnath/src/pjnath/ice_strans.c -@@ -2078,6 +2078,38 @@ static void turn_on_state(pj_turn_sock *turn_sock, pj_turn_state_t old_state, - } - - sess_init_update(comp->ice_st); -+ } else if ((old_state == PJ_TURN_STATE_RESOLVING || old_state == PJ_TURN_STATE_ALLOCATING) && +@@ -1996,6 +1996,38 @@ static void turn_on_state(pj_turn_sock *turn_sock, pj_turn_state_t old_state, + sizeof(ipaddr), 3))); + + sess_init_update(comp->ice_st); ++ } else if ((old_state == PJ_TURN_STATE_RESOLVING || old_state == PJ_TURN_STATE_ALLOCATING) && + new_state >= PJ_TURN_STATE_DEALLOCATING) + { + pj_ice_sess_cand *cand = NULL; @@ -43,9 +43,9 @@ + cand->status = old_state == PJ_TURN_STATE_RESOLVING ? PJ_ERESOLVE : PJ_EINVALIDOP; + + sess_init_update(comp->ice_st); - - } else if (new_state >= PJ_TURN_STATE_DEALLOCATING) { - pj_turn_session_info info; + + } else if (new_state >= PJ_TURN_STATE_DEALLOCATING) { + pj_turn_session_info info; -- 2.8.1.windows.1 diff --git a/contrib/src/pjproject/pj_uwp_gnutls.patch b/contrib/src/pjproject/pj_uwp_gnutls.patch index b50b8644e2..d40e30a3ad 100644 --- a/contrib/src/pjproject/pj_uwp_gnutls.patch +++ b/contrib/src/pjproject/pj_uwp_gnutls.patch @@ -15,6 +15,380 @@ Vittorio Giovara <vittorio.giovara@savoirfairelinux.com> Philippe Proulx <philippe.proulx@savoirfairelinux.com> and Adrien Béraud <adrien.beraud@savoirfairelinux.com> on behalf of Savoir-faire Linux. + + .../aconfigure | 184 +- + .../aconfigure.ac | 101 +- + .../pjlib/build/Makefile | 3 +- + .../pjlib/include/pj/compat/os_auto.h.in | 3 + + .../pjlib/include/pj/config.h | 14 +- + .../pjlib/include/pj/ssl_sock.h | 5 + + .../pjlib/src/pj/ssl_sock_common.c | 5 + + .../pjlib/src/pj/ssl_sock_gtls.c | 2887 ++++++++++++++++++++ + .../pjlib/src/pj/ssl_sock_ossl.c | 6 +- + .../pjmedia/src/pjmedia/transport_srtp.c | 6 +- + 10 files changed, 3147 insertions(+), 67 deletions(-) +--- a/aconfigure ++++ b/aconfigure +@@ -640,6 +640,8 @@ ac_no_opencore_amrnb + libcrypto_present + libssl_present + openssl_h_present ++libgnutls_present ++gnutls_h_present + ac_no_ssl + ac_webrtc_ldflags + ac_webrtc_cflags +@@ -1491,8 +1493,8 @@ Optional Features: + package and samples location using IPPROOT and + IPPSAMPLES env var or with --with-ipp and + --with-ipp-samples options +- --disable-ssl Exclude SSL support the build (default: autodetect) +- ++ --enable-ssl=backend Select 'gnutls' or 'openssl' (default) to provide ++ SSL support (autodetect) + --disable-opencore-amr Exclude OpenCORE AMR support from the build + (default: autodetect) + +@@ -7826,33 +7828,160 @@ fi + + # Check whether --enable-ssl was given. + if test "${enable_ssl+set}" = set; then : +- enableval=$enable_ssl; +- if test "$enable_ssl" = "no"; then +- ac_no_ssl=1 +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if SSL support is disabled... yes" >&5 ++ enableval=$enable_ssl; if test "x$enableval" = "xgnutls"; then ++ ssl_backend="gnutls" ++ else ++ ssl_backend="openssl" ++ ++ fi ++ ++fi ++ ++ ++if test "x$enable_ssl" = "xno"; then ++ ac_no_ssl=1 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if SSL support is disabled... yes" >&5 + $as_echo "Checking if SSL support is disabled... yes" >&6; } +- fi ++else ++ if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then ++ CFLAGS="$CFLAGS -I$with_ssl/include" ++ LDFLAGS="$LDFLAGS -L$with_ssl/lib" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using SSL prefix... $with_ssl" >&5 ++$as_echo "Using SSL prefix... $with_ssl" >&6; } ++ fi ++ if test "x$ssl_backend" = "xgnutls"; then ++ for ac_prog in $host-pkg-config pkg-config "python pkgconfig.py" ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_PKG_CONFIG+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$PKG_CONFIG"; then ++ ac_cv_prog_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_PKG_CONFIG="$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++PKG_CONFIG=$ac_cv_prog_PKG_CONFIG ++if test -n "$PKG_CONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 ++$as_echo "$PKG_CONFIG" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi + ++ ++ test -n "$PKG_CONFIG" && break ++done ++test -n "$PKG_CONFIG" || PKG_CONFIG="none" ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking for GnuTLS installations.." >&5 ++$as_echo "checking for GnuTLS installations.." >&6; } ++ ++ ++ ac_fn_c_check_header_mongrel "$LINENO" "gnutls/gnutls.h" "ac_cv_header_gnutls_gnutls_h" "$ac_includes_default" ++if test "x$ac_cv_header_gnutls_gnutls_h" = xyes; then : ++ gnutls_h_present=1 ++fi ++ ++ ++ ++ if test "$PKG_CONFIG" != "none"; then ++ if $PKG_CONFIG --exists gnutls; then ++ LIBS="$LIBS `$PKG_CONFIG --libs gnutls`" ++ libgnutls_present=1 ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gnutls_certificate_set_x509_system_trust in -lgnutls" >&5 ++$as_echo_n "checking for gnutls_certificate_set_x509_system_trust in -lgnutls... " >&6; } ++if ${ac_cv_lib_gnutls_gnutls_certificate_set_x509_system_trust+:} false; then : ++ $as_echo_n "(cached) " >&6 + else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lgnutls $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ + +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking for OpenSSL installations.." >&5 ++/* 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 gnutls_certificate_set_x509_system_trust (); ++int ++main () ++{ ++return gnutls_certificate_set_x509_system_trust (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_gnutls_gnutls_certificate_set_x509_system_trust=yes ++else ++ ac_cv_lib_gnutls_gnutls_certificate_set_x509_system_trust=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_gnutls_gnutls_certificate_set_x509_system_trust" >&5 ++$as_echo "$ac_cv_lib_gnutls_gnutls_certificate_set_x509_system_trust" >&6; } ++if test "x$ac_cv_lib_gnutls_gnutls_certificate_set_x509_system_trust" = xyes; then : ++ libgnutls_present=1 && ++ LIBS="$LIBS -lgnutls" ++fi ++ ++ fi ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: *** Warning: neither pkg-config nor python is available, disabling gnutls. ***" >&5 ++$as_echo "*** Warning: neither pkg-config nor python is available, disabling gnutls. ***" >&6; } ++ fi ++ ++ if test "x$gnutls_h_present" = "x1" -a "x$libgnutls_present" = "x1"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: GnuTLS library found, SSL support enabled" >&5 ++$as_echo "GnuTLS library found, SSL support enabled" >&6; } ++ # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK ++ #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1) ++ $as_echo "#define PJ_HAS_SSL_SOCK 1" >>confdefs.h ++ ++ $as_echo "#define PJ_HAS_TLS_SOCK 1" >>confdefs.h ++ ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ** No GnuTLS libraries found, disabling SSL support **" >&5 ++$as_echo "** No GnuTLS libraries found, disabling SSL support **" >&6; } ++ fi ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking for OpenSSL installations.." >&5 + $as_echo "checking for OpenSSL installations.." >&6; } +- if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then +- CFLAGS="$CFLAGS -I$with_ssl/include" +- LDFLAGS="$LDFLAGS -L$with_ssl/lib" +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using SSL prefix... $with_ssl" >&5 +-$as_echo "Using SSL prefix... $with_ssl" >&6; } +- fi + + + +- ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" ++ ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" + if test "x$ac_cv_header_openssl_ssl_h" = xyes; then : + openssl_h_present=1 + fi + + +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ERR_load_BIO_strings in -lcrypto" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ERR_load_BIO_strings in -lcrypto" >&5 + $as_echo_n "checking for ERR_load_BIO_strings in -lcrypto... " >&6; } + if ${ac_cv_lib_crypto_ERR_load_BIO_strings+:} false; then : + $as_echo_n "(cached) " >&6 +@@ -7892,7 +8021,7 @@ if test "x$ac_cv_lib_crypto_ERR_load_BIO_strings" = xyes; then : + libcrypto_present=1 && LIBS="-lcrypto $LIBS" + fi + +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5 + $as_echo_n "checking for SSL_library_init in -lssl... " >&6; } + if ${ac_cv_lib_ssl_SSL_library_init+:} false; then : + $as_echo_n "(cached) " >&6 +@@ -7932,22 +8061,23 @@ if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then : + libssl_present=1 && LIBS="-lssl $LIBS" + fi + +- if test "x$openssl_h_present" = "x1" -a "x$libssl_present" = "x1" -a "x$libcrypto_present" = "x1"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenSSL library found, SSL support enabled" >&5 ++ if test "x$openssl_h_present" = "x1" -a "x$libssl_present" = "x1" -a "x$libcrypto_present" = "x1"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenSSL library found, SSL support enabled" >&5 + $as_echo "OpenSSL library found, SSL support enabled" >&6; } +- # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK +- #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1) +- $as_echo "#define PJ_HAS_SSL_SOCK 1" >>confdefs.h ++ # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK ++ #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1) ++ $as_echo "#define PJ_HAS_SSL_SOCK 1" >>confdefs.h + +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: ** OpenSSL libraries not found, disabling SSL support **" >&5 +-$as_echo "** OpenSSL libraries not found, disabling SSL support **" >&6; } +- fi ++ $as_echo "#define PJ_HAS_TLS_SOCK 0" >>confdefs.h + ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ** No OpenSSL libraries found, disabling SSL support **" >&5 ++$as_echo "** No OpenSSL libraries found, disabling SSL support **" >&6; } ++ fi ++ fi + fi + + +- + # Check whether --with-opencore-amrnb was given. + if test "${with_opencore_amrnb+set}" = set; then : + withval=$with_opencore_amrnb; as_fn_error $? "This option is obsolete and replaced by --with-opencore-amr=DIR" "$LINENO" 5 +--- a/aconfigure.ac ++++ b/aconfigure.ac +@@ -1566,38 +1566,77 @@ fi + + dnl # Include SSL support + AC_SUBST(ac_no_ssl) +-AC_ARG_ENABLE(ssl, +- AS_HELP_STRING([--disable-ssl], +- [Exclude SSL support the build (default: autodetect)]) +- , +- [ +- if test "$enable_ssl" = "no"; then +- [ac_no_ssl=1] +- AC_MSG_RESULT([Checking if SSL support is disabled... yes]) +- fi +- ], +- [ +- AC_MSG_RESULT([checking for OpenSSL installations..]) +- if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then +- CFLAGS="$CFLAGS -I$with_ssl/include" +- LDFLAGS="$LDFLAGS -L$with_ssl/lib" +- AC_MSG_RESULT([Using SSL prefix... $with_ssl]) ++AC_ARG_ENABLE([ssl], ++ AS_HELP_STRING([--enable-ssl[=backend]], ++ [Select 'gnutls' or 'openssl' (default) to provide SSL support (autodetect)]), ++ [ if test "x$enableval" = "xgnutls"; then ++ [ssl_backend="gnutls"] ++ else ++ [ssl_backend="openssl"] ++ + fi +- AC_SUBST(openssl_h_present) +- AC_SUBST(libssl_present) +- AC_SUBST(libcrypto_present) +- AC_CHECK_HEADER(openssl/ssl.h,[openssl_h_present=1]) +- AC_CHECK_LIB(crypto,ERR_load_BIO_strings,[libcrypto_present=1 && LIBS="-lcrypto $LIBS"]) +- AC_CHECK_LIB(ssl,SSL_library_init,[libssl_present=1 && LIBS="-lssl $LIBS"]) +- if test "x$openssl_h_present" = "x1" -a "x$libssl_present" = "x1" -a "x$libcrypto_present" = "x1"; then +- AC_MSG_RESULT([OpenSSL library found, SSL support enabled]) +- # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK +- #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1) +- AC_DEFINE(PJ_HAS_SSL_SOCK, 1) +- else +- AC_MSG_RESULT([** OpenSSL libraries not found, disabling SSL support **]) +- fi +- ]) ++ ]) ++ ++if test "x$enable_ssl" = "xno"; then ++ [ac_no_ssl=1] ++ AC_MSG_RESULT([Checking if SSL support is disabled... yes]) ++else ++ if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then ++ CFLAGS="$CFLAGS -I$with_ssl/include" ++ LDFLAGS="$LDFLAGS -L$with_ssl/lib" ++ AC_MSG_RESULT([Using SSL prefix... $with_ssl]) ++ fi ++ if test "x$ssl_backend" = "xgnutls"; then ++ AC_CHECK_PROGS(PKG_CONFIG, ++ $host-pkg-config pkg-config "python pkgconfig.py", ++ none) ++ AC_MSG_RESULT([checking for GnuTLS installations..]) ++ AC_SUBST(gnutls_h_present) ++ AC_SUBST(libgnutls_present) ++ AC_CHECK_HEADER(gnutls/gnutls.h, [gnutls_h_present=1]) ++ ++ if test "$PKG_CONFIG" != "none"; then ++ if $PKG_CONFIG --exists gnutls; then ++ LIBS="$LIBS `$PKG_CONFIG --libs gnutls`" ++ libgnutls_present=1 ++ else ++ AC_CHECK_LIB(gnutls, ++ gnutls_certificate_set_x509_system_trust, ++ [libgnutls_present=1 && ++ LIBS="$LIBS -lgnutls"]) ++ fi ++ else ++ AC_MSG_RESULT([*** Warning: neither pkg-config nor python is available, disabling gnutls. ***]) ++ fi ++ ++ if test "x$gnutls_h_present" = "x1" -a "x$libgnutls_present" = "x1"; then ++ AC_MSG_RESULT([GnuTLS library found, SSL support enabled]) ++ # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK ++ #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1) ++ AC_DEFINE(PJ_HAS_SSL_SOCK, 1) ++ AC_DEFINE(PJ_HAS_TLS_SOCK, 1) ++ else ++ AC_MSG_RESULT([** No GnuTLS libraries found, disabling SSL support **]) ++ fi ++ else ++ AC_MSG_RESULT([checking for OpenSSL installations..]) ++ AC_SUBST(openssl_h_present) ++ AC_SUBST(libssl_present) ++ AC_SUBST(libcrypto_present) ++ AC_CHECK_HEADER(openssl/ssl.h, [openssl_h_present=1]) ++ AC_CHECK_LIB(crypto,ERR_load_BIO_strings,[libcrypto_present=1 && LIBS="-lcrypto $LIBS"]) ++ AC_CHECK_LIB(ssl,SSL_library_init,[libssl_present=1 && LIBS="-lssl $LIBS"]) ++ if test "x$openssl_h_present" = "x1" -a "x$libssl_present" = "x1" -a "x$libcrypto_present" = "x1"; then ++ AC_MSG_RESULT([OpenSSL library found, SSL support enabled]) ++ # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK ++ #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1) ++ AC_DEFINE(PJ_HAS_SSL_SOCK, 1) ++ AC_DEFINE(PJ_HAS_TLS_SOCK, 0) ++ else ++ AC_MSG_RESULT([** No OpenSSL libraries found, disabling SSL support **]) ++ fi ++ fi ++fi + + dnl # Obsolete option --with-opencore-amrnb + AC_ARG_WITH(opencore-amrnb, +--- a/pjlib/build/Makefile ++++ b/pjlib/build/Makefile +@@ -35,7 +35,7 @@ export PJLIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ + guid.o hash.o ip_helper_generic.o list.o lock.o log.o os_time_common.o \ + os_info.o pool.o pool_buf.o pool_caching.o pool_dbg.o rand.o \ + rbtree.o sock_common.o sock_qos_common.o sock_qos_bsd.o \ +- ssl_sock_common.o ssl_sock_ossl.o ssl_sock_dump.o \ ++ ssl_sock_common.o ssl_sock_ossl.o ssl_sock_gtls.o ssl_sock_dump.o \ + string.o timer.o types.o + export PJLIB_CFLAGS += $(_CFLAGS) + export PJLIB_CXXFLAGS += $(_CXXFLAGS) --- a/pjlib/include/pj/compat/os_auto.h.in +++ b/pjlib/include/pj/compat/os_auto.h.in @@ -209,6 +209,9 @@ @@ -80,7 +454,7 @@ on behalf of Savoir-faire Linux. @@ -0,0 +1,2887 @@ +/* $Id$ */ +/* -+ * Copyright (C) 2014-2017 Savoir-faire Linux. (https://www.savoirfairelinux.com) ++ * Copyright (C) 2014-2016 Savoir-faire Linux. (https://www.savoirfairelinux.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by -- GitLab