Commit b45c0111 authored by gates's avatar gates

Support using libaacs and libbdplus without dlopen

parent 4542b6e1
......@@ -8,6 +8,15 @@ AM_CONFIG_HEADER(config.h)
# messages
library_not_found="Could not find required library!"
function_not_found="Could not find required function!"
using_dlopen="Using libaacs and libbdplus via dlopen."
using_normal_linking="Using libaacs and libbdplus via normal linking."
# configure options
AC_ARG_WITH([dlopen],
[AS_HELP_STRING([--with-dlopen],
[use libaacs and libbdplus via dlopen (default is auto)])],
[use_dlopen=$withval],
[use_dlopen=auto])
# required programs
AC_PROG_CC
......@@ -18,7 +27,7 @@ AC_TYPE_SIGNAL
# required headers
AC_CHECK_HEADERS([stdarg.h sys/types.h dirent.h errno.h libgen.h malloc.h])
AC_CHECK_HEADERS([stdlib.h mntent.h linux/cdrom.h dlfcn.h inttypes.h])
AC_CHECK_HEADERS([stdlib.h mntent.h linux/cdrom.h inttypes.h])
AC_CHECK_HEADERS([sys/time.h time.h])
# required structures
......@@ -27,13 +36,26 @@ AC_STRUCT_DIRENT_D_TYPE
# required system services
AC_SYS_LARGEFILE
# required libraries
AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LDFLAGS="-ldl"],
[AC_MSG_ERROR($library_not_found)])
# required functions
AC_CHECK_FUNC([snprintf],, [AC_MSG_ERROR($function_not_found)])
# dlopen check
if [[ $use_dlopen = "auto" ]]; then
AC_CHECK_LIB([dl], [dlopen],
[DLOPEN_LDFLAGS="-ldl"; AC_MSG_NOTICE($using_dlopen)
AC_DEFINE([USING_DLOPEN], [1], ["Define to 1 if using dlopen"])],
[use_dlopen="no"; AC_MSG_NOTICE($using_normal_linking)])
elif [[ $use_dlopen = "yes" ]]; then
AC_CHECK_LIB([dl], [dlopen],
[DLOPEN_LDFLAGS="-ldl"; AC_MSG_NOTICE($using_dlopen)
AC_DEFINE([USING_DLOPEN], [1], ["Define to 1 if using dlopen"])],
[AC_MSG_ERROR($library_not_found)])
else
AC_MSG_NOTICE($using_normal_linking)
fi
AM_CONDITIONAL([USING_DLOPEN],
[test $use_dlopen = "auto" || test $use_dlopen = "yes"])
# libaacs checks
if [[ -d src/libaacs ]]; then
PKG_CHECK_MODULES([OPENSSL], [openssl],
......
......@@ -24,7 +24,13 @@ libbdplus_la_CFLAGS = -I$(top_builddir)/src/libbdplus \
libbdplus_la_LDFLAGS = @OPENSSL_LDFLAGS@
endif
if USING_DLOPEN
LIBBLURAY_LDFLAGS=@DLOPEN_LDFLAGS@
else
LIBBLURAY_LIBADD=$(LIBAACS_LIBADD) $(LIBBDPLUS_LIBADD)
endif
lib_LTLIBRARIES+=libbluray.la
libbluray_la_SOURCES= bluray.c bluray.h file/dl_posix.c
libbluray_la_LIBADD = libbdnav/libbdnav.la
libbluray_la_LDFLAGS= -version-info 0:0:0 @DLOPEN_LDFLAGS@
libbluray_la_LIBADD = libbdnav/libbdnav.la $(LIBBLURAY_LIBADD)
libbluray_la_LDFLAGS= -version-info 0:0:0 $(LIBBLURAY_LDFLAGS)
......@@ -25,6 +25,11 @@
#include "libbdnav/index_parse.h"
#ifndef USING_DLOPEN
#include "libaacs/aacs.h"
#include "libbdplus/bdplus.h"
#endif
static int _open_m2ts(BLURAY *bd)
{
char *f_name;
......@@ -66,32 +71,42 @@ static int _open_m2ts(BLURAY *bd)
static int _libaacs_open(BLURAY *bd, const char *keyfile_path)
{
#ifdef USING_DLOPEN
if ((bd->h_libaacs = dl_dlopen("aacs"))) {
fptr_p_void fptr;
DEBUG(DBG_BLURAY, "Downloaded libaacs (%p)\n", bd->h_libaacs);
fptr = dl_dlsym(bd->h_libaacs, "aacs_open");
fptr_p_void fptr = dl_dlsym(bd->h_libaacs, "aacs_open");
bd->libaacs_decrypt_unit = dl_dlsym(bd->h_libaacs, "aacs_decrypt_unit");
if (fptr && bd->libaacs_decrypt_unit) {
if ((bd->aacs = fptr(bd->device_path, keyfile_path))) {
DEBUG(DBG_BLURAY, "Opened libaacs (%p)\n", bd->aacs);
return 1;
}
DEBUG(DBG_BLURAY, "aacs_open() failed!\n");
} else {
DEBUG(DBG_BLURAY, "libaacs dlsym failed!\n");
}
dl_dlclose(bd->h_libaacs);
} else {
DEBUG(DBG_BLURAY, "libaacs not found!\n");
}
#else
if ((bd->h_libaacs = NULL)) {
DEBUG(DBG_BLURAY, "Using libaacs via normal linking\n");
fptr_p_void fptr = (fptr_p_void)&aacs_open;
bd->libaacs_decrypt_unit = &aacs_decrypt_unit;
if (fptr && bd->libaacs_decrypt_unit) {
if ((bd->aacs = fptr(bd->device_path, keyfile_path))) {
DEBUG(DBG_BLURAY, "Opened libaacs (%p)\n", bd->aacs);
return 1;
}
DEBUG(DBG_BLURAY, "aacs_open() failed!\n");
}
}
#endif
bd->h_libaacs = NULL;
bd->libaacs_decrypt_unit = NULL;
......@@ -145,6 +160,7 @@ BLURAY *bd_open(const char* device_path, const char* keyfile_path)
file_close(fd);
DEBUG(DBG_BDPLUS, "attempting to load libbdplus\n");
#ifdef USING_DLOPEN
if ((bd->h_libbdplus = dl_dlopen("bdplus"))) {
DEBUG(DBG_BLURAY, "Downloaded libbdplus (%p)\n",
bd->h_libbdplus);
......@@ -159,7 +175,23 @@ BLURAY *bd_open(const char* device_path, const char* keyfile_path)
bd->bdplus_seek = dl_dlsym(bd->h_libbdplus, "bdplus_seek");
bd->bdplus_fixup = dl_dlsym(bd->h_libbdplus, "bdplus_fixup");
} // dlopen
}
#else
if ((bd->h_libbdplus = NULL)) {
DEBUG(DBG_BLURAY,"Using libbdplus via normal linking\n");
fptr_p_void fp_bdplus_init = (fptr_p_void)&bdplus_init;
//bdplus_t *bdplus_init(path,configfile_path,*vid );
if (fp_bdplus_init)
bd->bdplus = fp_bdplus_init(device_path, keyfile_path, vid);
// Since we will call these functions a lot, we assign them
// now.
bd->bdplus_seek = &bdplus_seek;
bd->bdplus_fixup = &bdplus_fixup;
}
#endif
} // file_open
X_FREE(tmp);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment