tls: Hide backend implementation details from users
authorDiego Biurrun <diego@biurrun.de>
Tue, 23 May 2017 08:15:28 +0000 (10:15 +0200)
committerDiego Biurrun <diego@biurrun.de>
Fri, 2 Jun 2017 08:41:52 +0000 (10:41 +0200)
TLS is currently implemented over either OpenSSL or GnuTLS, with more
backends likely to appear in the future. Currently, those backend libraries
are part of the protocol names used during e.g. the configure stage of a
build. Hide those details behind a generically-named declaration for the
TLS protocol to avoid leaking those details into the configuration stage.

configure
libavformat/Makefile
libavformat/network.c
libavformat/protocols.c
libavformat/tls.h
libavformat/tls_gnutls.c
libavformat/tls_openssl.c

index f86ca158c94302eac05ba927da19f087f1e5800f..90760fe39ea1cf065ae9cf65e9ae90fea4a5963a 100755 (executable)
--- a/configure
+++ b/configure
@@ -2468,12 +2468,8 @@ sctp_protocol_deps="struct_sctp_event_subscribe"
 sctp_protocol_select="network"
 srtp_protocol_select="rtp_protocol srtp"
 tcp_protocol_select="network"
-tls_gnutls_protocol_deps="gnutls"
-tls_gnutls_protocol_select="tcp_protocol"
-tls_openssl_protocol_conflict="tls_gnutls_protocol"
-tls_openssl_protocol_deps="openssl"
-tls_openssl_protocol_select="tcp_protocol"
-tls_protocol_deps_any="tls_gnutls_protocol tls_openssl_protocol"
+tls_protocol_deps_any="gnutls openssl"
+tls_protocol_select="tcp_protocol"
 udp_protocol_select="network"
 unix_protocol_deps="sys_un_h"
 unix_protocol_select="network"
index 7b1df9342c72737155ed7bf5f8fedb598d3de08f..2c1c0f6d7fc91f791c3921e6366d9562d32356f1 100644 (file)
@@ -408,8 +408,9 @@ OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
 OBJS-$(CONFIG_SCTP_PROTOCOL)             += sctp.o
 OBJS-$(CONFIG_SRTP_PROTOCOL)             += srtpproto.o srtp.o
 OBJS-$(CONFIG_TCP_PROTOCOL)              += tcp.o
-OBJS-$(CONFIG_TLS_GNUTLS_PROTOCOL)       += tls_gnutls.o tls.o
-OBJS-$(CONFIG_TLS_OPENSSL_PROTOCOL)      += tls_openssl.o tls.o
+TLS-OBJS-$(CONFIG_GNUTLS)                += tls_gnutls.o
+TLS-OBJS-$(CONFIG_OPENSSL)               += tls_openssl.o
+OBJS-$(CONFIG_TLS_PROTOCOL)              += tls.o $(TLS-OBJS-yes)
 OBJS-$(CONFIG_UDP_PROTOCOL)              += udp.o
 OBJS-$(CONFIG_UNIX_PROTOCOL)             += unix.o
 
index 2c34b4a14bfac6fbf3ffcd48bfc964a044688b10..86d79553f7d7769b2a087b27722ee94f1d8b1847 100644 (file)
 
 void ff_tls_init(void)
 {
-#if CONFIG_TLS_OPENSSL_PROTOCOL
+#if CONFIG_TLS_PROTOCOL
+#if CONFIG_OPENSSL
     ff_openssl_init();
 #endif
-#if CONFIG_TLS_GNUTLS_PROTOCOL
+#if CONFIG_GNUTLS
     ff_gnutls_init();
 #endif
+#endif
 }
 
 void ff_tls_deinit(void)
 {
-#if CONFIG_TLS_OPENSSL_PROTOCOL
+#if CONFIG_TLS_PROTOCOL
+#if CONFIG_OPENSSL
     ff_openssl_deinit();
 #endif
-#if CONFIG_TLS_GNUTLS_PROTOCOL
+#if CONFIG_GNUTLS
     ff_gnutls_deinit();
 #endif
+#endif
 }
 
 int ff_network_inited_globally;
index d25454021ff2a3e69e04381d1f015f2c01dab713..8ea5c0e75765a9f220ad6f299269b0bd114e7b8f 100644 (file)
@@ -48,8 +48,7 @@ extern const URLProtocol ff_rtp_protocol;
 extern const URLProtocol ff_sctp_protocol;
 extern const URLProtocol ff_srtp_protocol;
 extern const URLProtocol ff_tcp_protocol;
-extern const URLProtocol ff_tls_gnutls_protocol;
-extern const URLProtocol ff_tls_openssl_protocol;
+extern const URLProtocol ff_tls_protocol;
 extern const URLProtocol ff_udp_protocol;
 extern const URLProtocol ff_unix_protocol;
 extern const URLProtocol ff_librtmp_protocol;
index 22cb6250b4c61044093fb9f224f355160f229a50..94f30ab854bc1baa5bbb1854a6c36ecfff3c4a45 100644 (file)
@@ -26,8 +26,6 @@
 #include "url.h"
 #include "libavutil/opt.h"
 
-#define CONFIG_TLS_PROTOCOL (CONFIG_TLS_GNUTLS_PROTOCOL | CONFIG_TLS_OPENSSL_PROTOCOL)
-
 typedef struct TLSShared {
     char *ca_file;
     int verify;
index f8a612ad9b8c04498f88f99803eb5fa53aa29ef9..1ae7656dcb07188646fc7aee475ad2bb8a38e815 100644 (file)
@@ -233,7 +233,7 @@ static const AVClass tls_class = {
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-const URLProtocol ff_tls_gnutls_protocol = {
+const URLProtocol ff_tls_protocol = {
     .name           = "tls",
     .url_open2      = tls_open,
     .url_read       = tls_read,
index 0abccf00a9dbe7d6b55165754b18227a1ad9564e..71fa96871dfbad81bbb14a2dcabbd4495c801a34 100644 (file)
@@ -323,7 +323,7 @@ static const AVClass tls_class = {
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-const URLProtocol ff_tls_openssl_protocol = {
+const URLProtocol ff_tls_protocol = {
     .name           = "tls",
     .url_open2      = tls_open,
     .url_read       = tls_read,