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.
This commit is contained in:
Seungha Yang 2019-04-09 20:07:05 +09:00
parent 807e311ae8
commit 98b303498a
4 changed files with 73 additions and 55 deletions

View file

@ -2018,19 +2018,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"
])
])
])
@ -2511,4 +2507,3 @@ AC_OUTPUT
AG_GST_OUTPUT_PLUGINS
ORC_OUTPUT

View file

@ -1753,7 +1753,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)
@ -1801,6 +1801,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 *

View file

@ -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

View file

@ -12,57 +12,56 @@ hls_cargs = ['-DGST_USE_UNSTABLE_API']
hls_crypto = get_option('hls-crypto')
hls_option = get_option('hls')
hls_crypto_dep = dependency('', required : false)
# used for unit test
hls_dep = dependency('', required : false)
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
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
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
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 ['auto', 'nettle'].contains(hls_crypto)
hls_crypto_dep = dependency('nettle', required : false)
if hls_crypto_dep.found()
hls_cargs += ['-DHAVE_NETTLE']
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)
plugins += [gsthls]
hls_dep = declare_dependency(include_directories : include_directories('.'))
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 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 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)
plugins += [gsthls]
hls_dep = declare_dependency(include_directories : include_directories('.'))