From 31317fd66633930b82d51d1c2e65121e24f9df19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 2 Nov 2016 14:04:19 +0200 Subject: [PATCH] dtls: Fix compiler warnings with openssl 1.1 or newer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DTLSv1_method() is deprecated, and since 1.0.2 replaced by DTLS_method(). - CRYPTO_set_locking_callback() and CRYPTO_set_id_callback() are no-ops (empty macros) since 1.1 and are not supposed to be used anymore. gstdtlsagent.c: In function ‘gst_dtls_agent_init’: gstdtlsagent.c:173:3: error: ‘DTLSv1_method’ is deprecated [-Werror=deprecated-declarations] priv->ssl_context = SSL_CTX_new (DTLSv1_method ()); ^~~~ In file included from /usr/include/openssl/ct.h:13:0, from /usr/include/openssl/ssl.h:61, from gstdtlsagent.c:40: /usr/include/openssl/ssl.h:1614:1: note: declared here DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */ ^ At top level: gstdtlsagent.c:103:1: error: ‘ssl_thread_id_function’ defined but not used [-Werror=unused-function] ssl_thread_id_function (void) ^~~~~~~~~~~~~~~~~~~~~~ gstdtlsagent.c:73:1: error: ‘ssl_locking_function’ defined but not used [-Werror=unused-function] ssl_locking_function (gint mode, gint lock_num, const gchar * file, gint line) ^~~~~~~~~~~~~~~~~~~~ --- ext/dtls/gstdtlsagent.c | 26 ++++++++++++++++++-------- ext/dtls/gstdtlssrtpdec.c | 3 +-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ext/dtls/gstdtlsagent.c b/ext/dtls/gstdtlsagent.c index c182123878..6ec39fcbc5 100644 --- a/ext/dtls/gstdtlsagent.c +++ b/ext/dtls/gstdtlsagent.c @@ -67,6 +67,7 @@ static void gst_dtls_agent_set_property (GObject *, guint prop_id, const GValue *, GParamSpec *); const gchar *gst_dtls_agent_peek_id (GstDtlsAgent *); +#if OPENSSL_VERSION_NUMBER < 0x10100000L static GRWLock *ssl_locks; static void @@ -104,13 +105,12 @@ ssl_thread_id_function (void) { return (gulong) g_thread_self (); } +#endif void _gst_dtls_init_openssl (void) { static gsize is_init = 0; - gint i; - gint num_locks; if (g_once_init_enter (&is_init)) { GST_DEBUG_CATEGORY_INIT (gst_dtls_agent_debug, "dtlsagent", 0, @@ -128,13 +128,19 @@ _gst_dtls_init_openssl (void) SSL_load_error_strings (); ERR_load_BIO_strings (); - num_locks = CRYPTO_num_locks (); - ssl_locks = g_new (GRWLock, num_locks); - for (i = 0; i < num_locks; ++i) { - g_rw_lock_init (&ssl_locks[i]); +#if OPENSSL_VERSION_NUMBER < 0x10100000L + { + gint i; + gint num_locks; + num_locks = CRYPTO_num_locks (); + ssl_locks = g_new (GRWLock, num_locks); + for (i = 0; i < num_locks; ++i) { + g_rw_lock_init (&ssl_locks[i]); + } + CRYPTO_set_locking_callback (ssl_locking_function); + CRYPTO_set_id_callback (ssl_thread_id_function); } - CRYPTO_set_locking_callback (ssl_locking_function); - CRYPTO_set_id_callback (ssl_thread_id_function); +#endif g_once_init_leave (&is_init, 1); } @@ -170,7 +176,11 @@ gst_dtls_agent_init (GstDtlsAgent * self) ERR_clear_error (); +#if OPENSSL_VERSION_NUMBER >= 0x1000200fL + priv->ssl_context = SSL_CTX_new (DTLS_method ()); +#else priv->ssl_context = SSL_CTX_new (DTLSv1_method ()); +#endif if (ERR_peek_error () || !priv->ssl_context) { char buf[512]; diff --git a/ext/dtls/gstdtlssrtpdec.c b/ext/dtls/gstdtlssrtpdec.c index 300fb9c8fb..983621001c 100644 --- a/ext/dtls/gstdtlssrtpdec.c +++ b/ext/dtls/gstdtlssrtpdec.c @@ -171,8 +171,7 @@ gst_dtls_srtp_dec_init (GstDtlsSrtpDec * self) "failed to create srtp_dec, is the srtp plugin registered?"); return; } - self->dtls_srtp_demux = - gst_element_factory_make ("dtlssrtpdemux", NULL); + self->dtls_srtp_demux = gst_element_factory_make ("dtlssrtpdemux", NULL); if (!self->dtls_srtp_demux) { GST_ERROR_OBJECT (self, "failed to create dtls_srtp_demux"); return;