diff options
author | Seungha Yang <seungha.yang@navercorp.com> | 2019-04-09 20:07:05 +0900 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2019-09-09 09:15:34 -0400 |
commit | b819667f36ef252b6ab184d5c28b2fe28f9452f4 (patch) | |
tree | 2c9626f0ff696176fc24d46281c7e56a74053409 | |
parent | 21ad51f48c651350b543d74e6373773bad54fd93 (diff) | |
download | gstreamer-plugins-bad-b819667f36ef252b6ab184d5c28b2fe28f9452f4.tar.gz |
hls: Make crypto dependency optional when hls-crypto is auto
crypto libraries are not required for hlssink and hlssink2.
Also, hlsdemux with nonencrypted stream can work without crpyto.
Make an error only when users set "hls-crpyto" with non-auto option explicitly,
but no crpyto library was found.
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | ext/hls/gsthlsdemux.c | 26 | ||||
-rw-r--r-- | ext/hls/gsthlsdemux.h | 4 | ||||
-rw-r--r-- | ext/hls/meson.build | 80 |
4 files changed, 68 insertions, 49 deletions
diff --git a/configure.ac b/configure.ac index 536224835..a730e8288 100644 --- a/configure.ac +++ b/configure.ac @@ -2234,19 +2234,15 @@ AG_GST_CHECK_FEATURE(HLS, [http live streaming plugin], hls, [ ], [ dnl Try to find a valid crypto library + HAVE_HLS="yes" PKG_CHECK_MODULES(NETTLE, nettle, [ AC_DEFINE(HAVE_NETTLE, 1, [Define if nettle is available]) - HAVE_HLS="yes" ],[ AM_PATH_LIBGCRYPT([1.2.0], [ AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define if libgcrypt is available]) - HAVE_HLS="yes" ],[ PKG_CHECK_MODULES(OPENSSL, openssl, [ AC_DEFINE(HAVE_OPENSSL, 1, [Define if openssl is available]) - HAVE_HLS="yes" - ],[ - HAVE_HLS="no" ]) ]) ]) @@ -2727,4 +2723,3 @@ AC_OUTPUT AG_GST_OUTPUT_PLUGINS ORC_OUTPUT - diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c index 864b65bf6..efd135eac 100644 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -1738,7 +1738,7 @@ gst_hls_demux_stream_decrypt_end (GstHLSDemuxStream * stream) /* NOP */ } -#else +#elif defined(HAVE_LIBGCRYPT) static gboolean gst_hls_demux_stream_decrypt_start (GstHLSDemuxStream * stream, const guint8 * key_data, const guint8 * iv_data) @@ -1786,6 +1786,30 @@ gst_hls_demux_stream_decrypt_end (GstHLSDemuxStream * stream) stream->aes_ctx = NULL; } } + +#else +/* NO crypto available */ +static gboolean +gst_hls_demux_stream_decrypt_start (GstHLSDemuxStream * stream, + const guint8 * key_data, const guint8 * iv_data) +{ + GST_ERROR ("No crypto available"); + return FALSE; +} + +static gboolean +decrypt_fragment (GstHLSDemuxStream * stream, gsize length, + const guint8 * encrypted_data, guint8 * decrypted_data) +{ + GST_ERROR ("Cannot decrypt fragment, no crypto available"); + return FALSE; +} + +static void +gst_hls_demux_stream_decrypt_end (GstHLSDemuxStream * stream) +{ + return; +} #endif static GstBuffer * diff --git a/ext/hls/gsthlsdemux.h b/ext/hls/gsthlsdemux.h index 0cab19627..529cd1961 100644 --- a/ext/hls/gsthlsdemux.h +++ b/ext/hls/gsthlsdemux.h @@ -34,7 +34,7 @@ #elif defined(HAVE_NETTLE) #include <nettle/aes.h> #include <nettle/cbc.h> -#else +#elif defined(HAVE_LIBGCRYPT) #include <gcrypt.h> #endif @@ -108,7 +108,7 @@ struct _GstHLSDemuxStream # endif #elif defined(HAVE_NETTLE) struct CBC_CTX (struct aes_ctx, AES_BLOCK_SIZE) aes_ctx; -#else +#elif defined(HAVE_LIBGCRYPT) gcry_cipher_hd_t aes_ctx; #endif diff --git a/ext/hls/meson.build b/ext/hls/meson.build index 69597ac28..42291401f 100644 --- a/ext/hls/meson.build +++ b/ext/hls/meson.build @@ -13,52 +13,52 @@ hls_cargs = ['-DGST_USE_UNSTABLE_API'] hls_crypto = get_option('hls-crypto') hls_option = get_option('hls') -have_hls_crypto = false -if not hls_option.disabled() - if ['auto', 'nettle'].contains(hls_crypto) - hls_crypto_dep = dependency('nettle', required : false) - if hls_crypto_dep.found() - have_hls_crypto = true - hls_cargs += ['-DHAVE_NETTLE'] - endif - endif +hls_crypto_dep = dependency('', required : false) + +if hls_option.disabled() + subdir_done() +endif - if not have_hls_crypto and ['auto', 'libgcrypt'].contains(hls_crypto) - hls_crypto_dep = cc.find_library('gcrypt', required : false) - if hls_crypto_dep.found() - have_hls_crypto = true - hls_cargs += ['-DHAVE_LIBGCRYPT'] - endif +if ['auto', 'nettle'].contains(hls_crypto) + hls_crypto_dep = dependency('nettle', required : false) + if hls_crypto_dep.found() + hls_cargs += ['-DHAVE_NETTLE'] endif +endif - if not have_hls_crypto and ['auto', 'openssl'].contains(hls_crypto) - hls_crypto_dep = dependency('openssl', required : false) - if hls_crypto_dep.found() - have_hls_crypto = true - hls_cargs += ['-DHAVE_OPENSSL'] - endif +if not hls_crypto_dep.found() and ['auto', 'libgcrypt'].contains(hls_crypto) + hls_crypto_dep = cc.find_library('gcrypt', required : false) + if hls_crypto_dep.found() + hls_cargs += ['-DHAVE_LIBGCRYPT'] endif +endif - if not have_hls_crypto and hls_option.enabled() - if hls_crypto == 'auto' - error('HLS plugin enabled, but found none of nettle, libgcrypt, or openssl') - else - error('HLS plugin enabled, but crypto library "@0@" not found'.format(hls_crypto)) - endif +if not hls_crypto_dep.found() and ['auto', 'openssl'].contains(hls_crypto) + hls_crypto_dep = dependency('openssl', required : false) + if hls_crypto_dep.found() + hls_cargs += ['-DHAVE_OPENSSL'] endif endif -if have_hls_crypto - gsthls = library('gsthls', - hls_sources, - c_args : gst_plugins_bad_args + hls_cargs, - link_args : noseh_link_args, - include_directories : [configinc], - dependencies : [gstpbutils_dep, gsttag_dep, gstvideo_dep, - gstadaptivedemux_dep, gsturidownloader_dep, - hls_crypto_dep, libm], - install : true, - install_dir : plugins_install_dir, - ) - pkgconfig.generate(gsthls, install_dir : plugins_pkgconfig_install_dir) +if not hls_crypto_dep.found() + if hls_crypto == 'auto' + message('Enable HLS plugin enable without crypto') + elif hls_option.enabled() + error('HLS plugin enabled with crypto, but crypto library "@0@" not found'.format(hls_crypto)) + else + subdir_done() + endif endif + +gsthls = library('gsthls', + hls_sources, + c_args : gst_plugins_bad_args + hls_cargs, + link_args : noseh_link_args, + include_directories : [configinc], + dependencies : [gstpbutils_dep, gsttag_dep, gstvideo_dep, + gstadaptivedemux_dep, gsturidownloader_dep, + hls_crypto_dep, libm], + install : true, + install_dir : plugins_install_dir, +) +pkgconfig.generate(gsthls, install_dir : plugins_pkgconfig_install_dir) |