On Fri,  2 Jun 2017 10:43:58 +0200
Diego Biurrun <[email protected]> wrote:

> 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.
> ---
> 
> Now keeping the global ff_tls_(de)init functions according to wm4's
> preference.
> 
>  configure                 |  8 ++------
>  libavformat/Makefile      |  5 +++--
>  libavformat/network.c     | 12 ++++++++----
>  libavformat/protocols.c   |  3 +--
>  libavformat/tls.h         |  2 --
>  libavformat/tls_gnutls.c  |  2 +-
>  libavformat/tls_openssl.c |  2 +-
>  7 files changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/configure b/configure
> index f86ca15..90760fe 100755
> --- 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"
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 7b1df93..2c1c0f6 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -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
>  
> diff --git a/libavformat/network.c b/libavformat/network.c
> index 2c34b4a..86d7955 100644
> --- a/libavformat/network.c
> +++ b/libavformat/network.c
> @@ -27,22 +27,26 @@
>  
>  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;
> diff --git a/libavformat/protocols.c b/libavformat/protocols.c
> index d254540..8ea5c0e 100644
> --- a/libavformat/protocols.c
> +++ b/libavformat/protocols.c
> @@ -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;
> diff --git a/libavformat/tls.h b/libavformat/tls.h
> index 22cb625..94f30ab 100644
> --- a/libavformat/tls.h
> +++ b/libavformat/tls.h
> @@ -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;
> diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
> index f8a612a..1ae7656 100644
> --- a/libavformat/tls_gnutls.c
> +++ b/libavformat/tls_gnutls.c
> @@ -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,
> diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
> index 0abccf0..71fa968 100644
> --- a/libavformat/tls_openssl.c
> +++ b/libavformat/tls_openssl.c
> @@ -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,

Yes, seems good.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to