f6d494facbc4fe36b35b65578898c29205dc3742
[jackhill/guix/guix.git] / gnu / packages / patches / mediastreamer2-srtp2.patch
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
5
6 ---
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
13
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
19 )
20
21 find_path(SRTP_INCLUDE_DIRS
22 - NAMES srtp/srtp.h
23 + NAMES srtp2/srtp.h
24 HINTS _SRTP_ROOT_PATHS
25 PATH_SUFFIXES include
26 )
27
28 if(SRTP_INCLUDE_DIRS)
29 set(HAVE_SRTP_SRTP_H 1)
30 -endif()
31 -
32 -find_library(SRTP_LIBRARIES
33 + set(SRTP_VERSION 2)
34 + find_library(SRTP_LIBRARIES
35 + NAMES srtp2
36 + HINTS ${_SRTP_ROOT_PATHS}
37 + PATH_SUFFIXES bin lib
38 + )
39 +else()
40 + find_path(SRTP_INCLUDE_DIRS
41 + NAMES srtp/srtp.h
42 + HINTS _SRTP_ROOT_PATHS
43 + PATH_SUFFIXES include
44 + )
45 + if(SRTP_INCLUDE_DIRS)
46 + set(HAVE_SRTP_SRTP_H 1)
47 + set(SRTP_VERSION 1)
48 + endif()
49 + find_library(SRTP_LIBRARIES
50 NAMES srtp
51 HINTS ${_SRTP_ROOT_PATHS}
52 PATH_SUFFIXES bin lib
53 )
54 +endif()
55 +
56
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
64 utils/pcap_sender.c
65 utils/pcap_sender.h
66 utils/stream_regulator.c
67 + utils/srtp_prefix.h
68 voip/audioconference.c
69 voip/audiostream.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
75 @@ -25,6 +25,7 @@
76 #include "mediastreamer2/ms_srtp.h"
77 #include "mediastreamer2/mediastream.h"
78
79 +
80 #ifdef HAVE_SRTP
81
82 /*srtp defines all this stuff*/
83 @@ -34,13 +35,7 @@
84 #undef PACKAGE_TARNAME
85 #undef PACKAGE_VERSION
86
87 -#if defined(MS2_WINDOWS_PHONE)
88 -// Windows phone doesn't use make install
89 -#include <srtp.h>
90 -#else
91 -#include <srtp/srtp.h>
92 -#endif
93 -
94 +#include "srtp_prefix.h"
95
96 #include "ortp/b64.h"
97
98 @@ -352,7 +347,6 @@ int ms_srtp_init(void)
99 srtp_init_done++;
100 }else{
101 ms_fatal("Couldn't initialize SRTP library: %d.", st);
102 - err_reporting_init("mediastreamer2");
103 }
104 }else srtp_init_done++;
105 return (int)st;
106 diff --git a/src/utils/srtp_prefix.h b/src/utils/srtp_prefix.h
107 new file mode 100644
108 index 00000000..68bde496
109 --- /dev/null
110 +++ b/src/utils/srtp_prefix.h
111 @@ -0,0 +1,41 @@
112 +/*
113 + mediastreamer2 library - modular sound and video processing and streaming
114 + Copyright (C) 2006-2014 Belledonne Communications, Grenoble
115 +
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.
120 +
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.
125 +
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
129 +*/
130 +#ifndef __SRTP2_H__
131 +#define __SRTP2_H__
132 +
133 +#if defined(MS2_WINDOWS_PHONE)
134 +// Windows phone doesn't use make install
135 +#include <srtp.h>
136 +#elif SRTP_VERSION==1
137 +#include <srtp/srtp.h>
138 +#else
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
150 +#endif
151 +
152 +#endif
153 --
154 2.21.0
155