1 From 97903498364ae2596e790cb2c2ce9ac76c04d64a Mon Sep 17 00:00:00 2001
2 From: Danmei Chen <danmei.chen@belledonne-communications.com>
3 Date: Fri, 19 Jan 2018 10:04:07 +0100
4 Subject: [PATCH] add compability with srtp2
7 cmake/FindSRTP.cmake | 24 ++++++++++++++++++++----
8 src/CMakeLists.txt | 1 +
9 src/crypto/ms_srtp.c | 10 ++--------
10 src/utils/srtp_prefix.h | 41 +++++++++++++++++++++++++++++++++++++++++
11 4 files changed, 64 insertions(+), 12 deletions(-)
12 create mode 100644 src/utils/srtp_prefix.h
14 diff --git a/cmake/FindSRTP.cmake b/cmake/FindSRTP.cmake
15 index 988b846a..f720ce7e 100644
16 --- a/cmake/FindSRTP.cmake
17 +++ b/cmake/FindSRTP.cmake
18 @@ -31,20 +31,36 @@ set(_SRTP_ROOT_PATHS
21 find_path(SRTP_INCLUDE_DIRS
24 HINTS _SRTP_ROOT_PATHS
29 set(HAVE_SRTP_SRTP_H 1)
32 -find_library(SRTP_LIBRARIES
34 + find_library(SRTP_LIBRARIES
36 + HINTS ${_SRTP_ROOT_PATHS}
37 + PATH_SUFFIXES bin lib
40 + find_path(SRTP_INCLUDE_DIRS
42 + HINTS _SRTP_ROOT_PATHS
43 + PATH_SUFFIXES include
45 + if(SRTP_INCLUDE_DIRS)
46 + set(HAVE_SRTP_SRTP_H 1)
49 + find_library(SRTP_LIBRARIES
51 HINTS ${_SRTP_ROOT_PATHS}
57 include(FindPackageHandleStandardArgs)
58 find_package_handle_standard_args(SRTP
59 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
60 index da429764..c46faa62 100644
61 --- a/src/CMakeLists.txt
62 +++ b/src/CMakeLists.txt
63 @@ -183,6 +183,7 @@ set(VOIP_SOURCE_FILES_C
66 utils/stream_regulator.c
68 voip/audioconference.c
70 voip/bandwidthcontroller.c
71 diff --git a/src/crypto/ms_srtp.c b/src/crypto/ms_srtp.c
72 index 5a510c99..67810316 100644
73 --- a/src/crypto/ms_srtp.c
74 +++ b/src/crypto/ms_srtp.c
76 #include "mediastreamer2/ms_srtp.h"
77 #include "mediastreamer2/mediastream.h"
82 /*srtp defines all this stuff*/
84 #undef PACKAGE_TARNAME
85 #undef PACKAGE_VERSION
87 -#if defined(MS2_WINDOWS_PHONE)
88 -// Windows phone doesn't use make install
91 -#include <srtp/srtp.h>
94 +#include "srtp_prefix.h"
98 @@ -352,7 +347,6 @@ int ms_srtp_init(void)
101 ms_fatal("Couldn't initialize SRTP library: %d.", st);
102 - err_reporting_init("mediastreamer2");
104 }else srtp_init_done++;
106 diff --git a/src/utils/srtp_prefix.h b/src/utils/srtp_prefix.h
108 index 00000000..68bde496
110 +++ b/src/utils/srtp_prefix.h
113 + mediastreamer2 library - modular sound and video processing and streaming
114 + Copyright (C) 2006-2014 Belledonne Communications, Grenoble
116 + This library is free software; you can redistribute it and/or
117 + modify it under the terms of the GNU Lesser General Public
118 + License as published by the Free Software Foundation; either
119 + version 2.1 of the License, or (at your option) any later version.
121 + This library is distributed in the hope that it will be useful,
122 + but WITHOUT ANY WARRANTY; without even the implied warranty of
123 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
124 + Lesser General Public License for more details.
126 + You should have received a copy of the GNU Lesser General Public
127 + License along with this library; if not, write to the Free Software
128 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
133 +#if defined(MS2_WINDOWS_PHONE)
134 +// Windows phone doesn't use make install
136 +#elif SRTP_VERSION==1
137 +#include <srtp/srtp.h>
139 +#include <srtp2/srtp.h>
140 +#define err_status_t srtp_err_status_t
141 +#define err_status_ok srtp_err_status_ok
142 +#define crypto_policy_t srtp_crypto_policy_t
143 +#define crypto_policy_set_aes_cm_256_hmac_sha1_80 srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80
144 +#define crypto_policy_set_aes_cm_128_hmac_sha1_32 srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32
145 +#define crypto_policy_set_aes_cm_128_null_auth srtp_crypto_policy_set_aes_cm_128_null_auth
146 +#define crypto_policy_set_null_cipher_hmac_sha1_80 srtp_crypto_policy_set_null_cipher_hmac_sha1_80
147 +#define crypto_policy_set_aes_cm_128_hmac_sha1_80 srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80
148 +#define crypto_policy_set_aes_cm_256_hmac_sha1_32 srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32
149 +#define ssrc_t srtp_ssrc_t