Browse code

tls: Hide backend implementation details from users

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.

Diego Biurrun authored on 2017/05/23 17:15:28
Showing 7 changed files
... ...
@@ -2468,12 +2468,8 @@ sctp_protocol_deps="struct_sctp_event_subscribe"
2468 2468
 sctp_protocol_select="network"
2469 2469
 srtp_protocol_select="rtp_protocol srtp"
2470 2470
 tcp_protocol_select="network"
2471
-tls_gnutls_protocol_deps="gnutls"
2472
-tls_gnutls_protocol_select="tcp_protocol"
2473
-tls_openssl_protocol_conflict="tls_gnutls_protocol"
2474
-tls_openssl_protocol_deps="openssl"
2475
-tls_openssl_protocol_select="tcp_protocol"
2476
-tls_protocol_deps_any="tls_gnutls_protocol tls_openssl_protocol"
2471
+tls_protocol_deps_any="gnutls openssl"
2472
+tls_protocol_select="tcp_protocol"
2477 2473
 udp_protocol_select="network"
2478 2474
 unix_protocol_deps="sys_un_h"
2479 2475
 unix_protocol_select="network"
... ...
@@ -408,8 +408,9 @@ OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
408 408
 OBJS-$(CONFIG_SCTP_PROTOCOL)             += sctp.o
409 409
 OBJS-$(CONFIG_SRTP_PROTOCOL)             += srtpproto.o srtp.o
410 410
 OBJS-$(CONFIG_TCP_PROTOCOL)              += tcp.o
411
-OBJS-$(CONFIG_TLS_GNUTLS_PROTOCOL)       += tls_gnutls.o tls.o
412
-OBJS-$(CONFIG_TLS_OPENSSL_PROTOCOL)      += tls_openssl.o tls.o
411
+TLS-OBJS-$(CONFIG_GNUTLS)                += tls_gnutls.o
412
+TLS-OBJS-$(CONFIG_OPENSSL)               += tls_openssl.o
413
+OBJS-$(CONFIG_TLS_PROTOCOL)              += tls.o $(TLS-OBJS-yes)
413 414
 OBJS-$(CONFIG_UDP_PROTOCOL)              += udp.o
414 415
 OBJS-$(CONFIG_UNIX_PROTOCOL)             += unix.o
415 416
 
... ...
@@ -27,22 +27,26 @@
27 27
 
28 28
 void ff_tls_init(void)
29 29
 {
30
-#if CONFIG_TLS_OPENSSL_PROTOCOL
30
+#if CONFIG_TLS_PROTOCOL
31
+#if CONFIG_OPENSSL
31 32
     ff_openssl_init();
32 33
 #endif
33
-#if CONFIG_TLS_GNUTLS_PROTOCOL
34
+#if CONFIG_GNUTLS
34 35
     ff_gnutls_init();
35 36
 #endif
37
+#endif
36 38
 }
37 39
 
38 40
 void ff_tls_deinit(void)
39 41
 {
40
-#if CONFIG_TLS_OPENSSL_PROTOCOL
42
+#if CONFIG_TLS_PROTOCOL
43
+#if CONFIG_OPENSSL
41 44
     ff_openssl_deinit();
42 45
 #endif
43
-#if CONFIG_TLS_GNUTLS_PROTOCOL
46
+#if CONFIG_GNUTLS
44 47
     ff_gnutls_deinit();
45 48
 #endif
49
+#endif
46 50
 }
47 51
 
48 52
 int ff_network_inited_globally;
... ...
@@ -48,8 +48,7 @@ extern const URLProtocol ff_rtp_protocol;
48 48
 extern const URLProtocol ff_sctp_protocol;
49 49
 extern const URLProtocol ff_srtp_protocol;
50 50
 extern const URLProtocol ff_tcp_protocol;
51
-extern const URLProtocol ff_tls_gnutls_protocol;
52
-extern const URLProtocol ff_tls_openssl_protocol;
51
+extern const URLProtocol ff_tls_protocol;
53 52
 extern const URLProtocol ff_udp_protocol;
54 53
 extern const URLProtocol ff_unix_protocol;
55 54
 extern const URLProtocol ff_librtmp_protocol;
... ...
@@ -26,8 +26,6 @@
26 26
 #include "url.h"
27 27
 #include "libavutil/opt.h"
28 28
 
29
-#define CONFIG_TLS_PROTOCOL (CONFIG_TLS_GNUTLS_PROTOCOL | CONFIG_TLS_OPENSSL_PROTOCOL)
30
-
31 29
 typedef struct TLSShared {
32 30
     char *ca_file;
33 31
     int verify;
... ...
@@ -233,7 +233,7 @@ static const AVClass tls_class = {
233 233
     .version    = LIBAVUTIL_VERSION_INT,
234 234
 };
235 235
 
236
-const URLProtocol ff_tls_gnutls_protocol = {
236
+const URLProtocol ff_tls_protocol = {
237 237
     .name           = "tls",
238 238
     .url_open2      = tls_open,
239 239
     .url_read       = tls_read,
... ...
@@ -323,7 +323,7 @@ static const AVClass tls_class = {
323 323
     .version    = LIBAVUTIL_VERSION_INT,
324 324
 };
325 325
 
326
-const URLProtocol ff_tls_openssl_protocol = {
326
+const URLProtocol ff_tls_protocol = {
327 327
     .name           = "tls",
328 328
     .url_open2      = tls_open,
329 329
     .url_read       = tls_read,