libdvd support, lifted from devel/libdvdread
ok jolan@
This commit is contained in:
parent
1b9187a261
commit
09400fbd38
@ -1,7 +1,8 @@
|
||||
# $OpenBSD: Makefile,v 1.3 2005/11/03 04:25:08 jolan Exp $
|
||||
# $OpenBSD: Makefile,v 1.4 2005/11/03 09:03:37 jakemsr Exp $
|
||||
|
||||
COMMENT= "DVD read/navigation library"
|
||||
DISTNAME= libdvdnav-20051102
|
||||
PKGNAME= ${DISTNAME}p0
|
||||
CATEGORIES= multimedia
|
||||
MASTER_SITES= http://mirrors.protection.cx/~jolan/
|
||||
|
||||
|
297
multimedia/libdvdnav/patches/patch-src_dvdread_dvd_input_c
Normal file
297
multimedia/libdvdnav/patches/patch-src_dvdread_dvd_input_c
Normal file
@ -0,0 +1,297 @@
|
||||
$OpenBSD: patch-src_dvdread_dvd_input_c,v 1.1 2005/11/03 09:03:38 jakemsr Exp $
|
||||
--- src/dvdread/dvd_input.c.orig Fri Apr 9 05:15:26 2004
|
||||
+++ src/dvdread/dvd_input.c Thu Nov 3 00:22:19 2005
|
||||
@@ -37,14 +37,14 @@ int (*dvdinput_read) (dvd_input
|
||||
char * (*dvdinput_error) (dvd_input_t);
|
||||
|
||||
#ifdef HAVE_DVDCSS_DVDCSS_H
|
||||
-/* linking to libdvdcss */
|
||||
-#include <dvdcss/dvdcss.h>
|
||||
-#define DVDcss_open(a) dvdcss_open((char*)(a))
|
||||
-#define DVDcss_close dvdcss_close
|
||||
-#define DVDcss_seek dvdcss_seek
|
||||
-#define DVDcss_title dvdcss_title
|
||||
-#define DVDcss_read dvdcss_read
|
||||
-#define DVDcss_error dvdcss_error
|
||||
+/* linking to dvdcss */
|
||||
+#include <libdvd/libdvd.h>
|
||||
+#define DVD_open(a) libdvd_open((char*)(a))
|
||||
+#define DVD_close libdvd_close
|
||||
+#define DVD_seek libdvd_seek
|
||||
+#define DVD_title libdvd_title
|
||||
+#define DVD_read libdvd_read
|
||||
+#define DVD_error libdvd_error
|
||||
#else
|
||||
|
||||
/* dlopening libdvdcss */
|
||||
@@ -55,19 +55,19 @@ char * (*dvdinput_error) (dvd_input
|
||||
#include "../../msvc/contrib/dlfcn.c"
|
||||
#endif
|
||||
|
||||
-typedef struct dvdcss_s *dvdcss_handle;
|
||||
-static dvdcss_handle (*DVDcss_open) (const char *);
|
||||
-static int (*DVDcss_close) (dvdcss_handle);
|
||||
-static int (*DVDcss_seek) (dvdcss_handle, int, int);
|
||||
-static int (*DVDcss_title) (dvdcss_handle, int);
|
||||
-static int (*DVDcss_read) (dvdcss_handle, void *, int, int);
|
||||
-static char * (*DVDcss_error) (dvdcss_handle);
|
||||
+typedef struct libdvd_s *libdvd_handle;
|
||||
+static libdvd_handle (*DVD_open) (const char *);
|
||||
+static int (*DVD_close) (libdvd_handle);
|
||||
+static int (*DVD_seek) (libdvd_handle, int, int);
|
||||
+static int (*DVD_title) (libdvd_handle, int);
|
||||
+static int (*DVD_read) (libdvd_handle, void *, int, int);
|
||||
+static char * (*DVD_error) (libdvd_handle);
|
||||
#endif
|
||||
|
||||
/* The DVDinput handle, add stuff here for new input methods. */
|
||||
struct dvd_input_s {
|
||||
- /* libdvdcss handle */
|
||||
- dvdcss_handle dvdcss;
|
||||
+ /* dvdcss handle */
|
||||
+ libdvd_handle libdvd;
|
||||
|
||||
/* dummy file input */
|
||||
int fd;
|
||||
@@ -77,7 +77,7 @@ struct dvd_input_s {
|
||||
/**
|
||||
* initialize and open a DVD device or file.
|
||||
*/
|
||||
-static dvd_input_t css_open(const char *target)
|
||||
+static dvd_input_t libdvd_open(const char *target)
|
||||
{
|
||||
dvd_input_t dev;
|
||||
|
||||
@@ -88,10 +88,10 @@ static dvd_input_t css_open(const char *
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- /* Really open it with libdvdcss */
|
||||
- dev->dvdcss = DVDcss_open(target);
|
||||
- if(dev->dvdcss == 0) {
|
||||
- fprintf(stderr, "libdvdread: Could not open %s with libdvdcss.\n", target);
|
||||
+ /* Really open it with dvdcss */
|
||||
+ dev->libdvd = DVD_open(target);
|
||||
+ if(dev->libdvd == 0) {
|
||||
+ fprintf(stderr, "libdvdread: Could not open %s with libdvd.\n", target);
|
||||
free(dev);
|
||||
return NULL;
|
||||
}
|
||||
@@ -102,44 +102,44 @@ static dvd_input_t css_open(const char *
|
||||
/**
|
||||
* return the last error message
|
||||
*/
|
||||
-static char *css_error(dvd_input_t dev)
|
||||
+static char *libdvd_error(dvd_input_t dev)
|
||||
{
|
||||
- return DVDcss_error(dev->dvdcss);
|
||||
+ return DVD_error(dev->libdvd);
|
||||
}
|
||||
|
||||
/**
|
||||
* seek into the device.
|
||||
*/
|
||||
-static int css_seek(dvd_input_t dev, int blocks)
|
||||
+static int libdvd_seek(dvd_input_t dev, int blocks)
|
||||
{
|
||||
/* DVDINPUT_NOFLAGS should match the DVDCSS_NOFLAGS value. */
|
||||
- return DVDcss_seek(dev->dvdcss, blocks, DVDINPUT_NOFLAGS);
|
||||
+ return DVD_seek(dev->libdvd, blocks, DVDINPUT_NOFLAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the block for the begining of a new title (key).
|
||||
*/
|
||||
-static int css_title(dvd_input_t dev, int block)
|
||||
+static int libdvd_title(dvd_input_t dev, int block)
|
||||
{
|
||||
- return DVDcss_title(dev->dvdcss, block);
|
||||
+ return DVD_title(dev->libdvd, block);
|
||||
}
|
||||
|
||||
/**
|
||||
* read data from the device.
|
||||
*/
|
||||
-static int css_read(dvd_input_t dev, void *buffer, int blocks, int flags)
|
||||
+static int libdvd_read(dvd_input_t dev, void *buffer, int blocks, int flags)
|
||||
{
|
||||
- return DVDcss_read(dev->dvdcss, buffer, blocks, flags);
|
||||
+ return DVD_read(dev->libdvd, buffer, blocks, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* close the DVD device and clean up the library.
|
||||
*/
|
||||
-static int css_close(dvd_input_t dev)
|
||||
+static int libdvd_close(dvd_input_t dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
- ret = DVDcss_close(dev->dvdcss);
|
||||
+ ret = DVD_close(dev->libdvd);
|
||||
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
@@ -269,90 +269,121 @@ static int file_close(dvd_input_t dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#ifdef __OpenBSD__
|
||||
+#include <dirent.h>
|
||||
+#include <string.h>
|
||||
+static void *findlibrary(char *base)
|
||||
+{
|
||||
+ DIR *d;
|
||||
+ struct dirent *de;
|
||||
+ size_t len;
|
||||
+ void *lib = NULL;
|
||||
|
||||
+ len = strlen(base);
|
||||
+
|
||||
+ d = opendir(".");
|
||||
+ if (!d)
|
||||
+ return lib;
|
||||
+ while ((de = readdir(d)) != NULL) {
|
||||
+ if (strncmp(de->d_name, base, len) != 0)
|
||||
+ continue;
|
||||
+ lib = dlopen(de->d_name, RTLD_LAZY);
|
||||
+ if (lib)
|
||||
+ break;
|
||||
+ }
|
||||
+ closedir(d);
|
||||
+ return lib;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
/**
|
||||
* Setup read functions with either libdvdcss or minimal DVD access.
|
||||
*/
|
||||
int dvdinput_setup(void)
|
||||
{
|
||||
- void *dvdcss_library = NULL;
|
||||
- char **dvdcss_version = NULL;
|
||||
+ void *libdvd_library = NULL;
|
||||
+ char **libdvd_version = NULL;
|
||||
|
||||
#ifdef HAVE_DVDCSS_DVDCSS_H
|
||||
- /* linking to libdvdcss */
|
||||
- dvdcss_library = &dvdcss_library; /* Give it some value != NULL */
|
||||
- /* the DVDcss_* functions have been #defined at the top */
|
||||
- dvdcss_version = &dvdcss_interface_2;
|
||||
+ /* linking to libdvd */
|
||||
+ libdvd_library = &libdvd_library; /* Give it some value != NULL */
|
||||
+ /* the DVD_* functions have been #defined at the top */
|
||||
+ libdvd_version = &libdvd_interface_2;
|
||||
|
||||
#else
|
||||
- /* dlopening libdvdcss */
|
||||
+ /* dlopening libdvd */
|
||||
|
||||
#ifndef WIN32
|
||||
- dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY);
|
||||
+ libdvd_library = dlopen("libdvd.so.0", RTLD_LAZY);
|
||||
+#if defined(__OpenBSD__)
|
||||
+ if (!libdvd_library)
|
||||
+ libdvd_library = findlibrary("libdvd.so.0.");
|
||||
+#endif
|
||||
#else
|
||||
dvdcss_library = dlopen("libdvdcss.dll", RTLD_LAZY);
|
||||
#endif
|
||||
|
||||
- if(dvdcss_library != NULL) {
|
||||
+ if(libdvd_library != NULL) {
|
||||
#if defined(__OpenBSD__) && !defined(__ELF__)
|
||||
#define U_S "_"
|
||||
#else
|
||||
#define U_S
|
||||
#endif
|
||||
- DVDcss_open = (dvdcss_handle (*)(const char*))
|
||||
- dlsym(dvdcss_library, U_S "dvdcss_open");
|
||||
- DVDcss_close = (int (*)(dvdcss_handle))
|
||||
- dlsym(dvdcss_library, U_S "dvdcss_close");
|
||||
- DVDcss_title = (int (*)(dvdcss_handle, int))
|
||||
- dlsym(dvdcss_library, U_S "dvdcss_title");
|
||||
- DVDcss_seek = (int (*)(dvdcss_handle, int, int))
|
||||
- dlsym(dvdcss_library, U_S "dvdcss_seek");
|
||||
- DVDcss_read = (int (*)(dvdcss_handle, void*, int, int))
|
||||
- dlsym(dvdcss_library, U_S "dvdcss_read");
|
||||
- DVDcss_error = (char* (*)(dvdcss_handle))
|
||||
- dlsym(dvdcss_library, U_S "dvdcss_error");
|
||||
-
|
||||
- dvdcss_version = (char **)dlsym(dvdcss_library, U_S "dvdcss_interface_2");
|
||||
+ DVD_open = (libdvd_handle (*)(const char*))
|
||||
+ dlsym(libdvd_library, U_S "libdvd_open");
|
||||
+ DVD_close = (int (*)(libdvd_handle))
|
||||
+ dlsym(libdvd_library, U_S "libdvd_close");
|
||||
+ DVD_title = (int (*)(libdvd_handle, int))
|
||||
+ dlsym(libdvd_library, U_S "libdvd_title");
|
||||
+ DVD_seek = (int (*)(libdvd_handle, int, int))
|
||||
+ dlsym(libdvd_library, U_S "libdvd_seek");
|
||||
+ DVD_read = (int (*)(libdvd_handle, void*, int, int))
|
||||
+ dlsym(libdvd_library, U_S "libdvd_read");
|
||||
+ DVD_error = (char* (*)(libdvd_handle))
|
||||
+ dlsym(libdvd_library, U_S "libdvd_error");
|
||||
|
||||
- if(dlsym(dvdcss_library, U_S "dvdcss_crack")) {
|
||||
+ libdvd_version = (char **)dlsym(libdvd_library, U_S "libdvd_interface_2");
|
||||
+
|
||||
+ if(dlsym(libdvd_library, U_S "libdvd_crack")) {
|
||||
fprintf(stderr,
|
||||
- "libdvdread: Old (pre-0.0.2) version of libdvdcss found.\n"
|
||||
+ "libdvdread: Old (pre-0.0.2) version of libdvd found.\n"
|
||||
"libdvdread: You should get the latest version from "
|
||||
"http://www.videolan.org/\n" );
|
||||
- dlclose(dvdcss_library);
|
||||
- dvdcss_library = NULL;
|
||||
- } else if(!DVDcss_open || !DVDcss_close || !DVDcss_title || !DVDcss_seek
|
||||
- || !DVDcss_read || !DVDcss_error || !dvdcss_version) {
|
||||
- fprintf(stderr, "libdvdread: Missing symbols in libdvdcss.so.2, "
|
||||
+ dlclose(libdvd_library);
|
||||
+ libdvd_library = NULL;
|
||||
+ } else if(!DVD_open || !DVD_close || !DVD_title || !DVD_seek
|
||||
+ || !DVD_read || !DVD_error || !libdvd_version) {
|
||||
+ fprintf(stderr, "libdvdread: Missing symbols in libdvd.so.0, "
|
||||
"this shouldn't happen !\n");
|
||||
- dlclose(dvdcss_library);
|
||||
+ dlclose(libdvd_library);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_DVDCSS_DVDCSS_H */
|
||||
|
||||
- if(dvdcss_library != NULL) {
|
||||
+ if(libdvd_library != NULL) {
|
||||
/*
|
||||
char *psz_method = getenv( "DVDCSS_METHOD" );
|
||||
char *psz_verbose = getenv( "DVDCSS_VERBOSE" );
|
||||
fprintf(stderr, "DVDCSS_METHOD %s\n", psz_method);
|
||||
fprintf(stderr, "DVDCSS_VERBOSE %s\n", psz_verbose);
|
||||
*/
|
||||
- fprintf(stderr, "libdvdread: Using libdvdcss version %s for DVD access\n",
|
||||
- *dvdcss_version);
|
||||
+ fprintf(stderr, "libdvdread: Using libdvd version %s for DVD access\n",
|
||||
+ *libdvd_version);
|
||||
|
||||
/* libdvdcss wrapper functions */
|
||||
- dvdinput_open = css_open;
|
||||
- dvdinput_close = css_close;
|
||||
- dvdinput_seek = css_seek;
|
||||
- dvdinput_title = css_title;
|
||||
- dvdinput_read = css_read;
|
||||
- dvdinput_error = css_error;
|
||||
+ dvdinput_open = libdvd_open;
|
||||
+ dvdinput_close = libdvd_close;
|
||||
+ dvdinput_seek = libdvd_seek;
|
||||
+ dvdinput_title = libdvd_title;
|
||||
+ dvdinput_read = libdvd_read;
|
||||
+ dvdinput_error = libdvd_error;
|
||||
return 1;
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "libdvdread: Encrypted DVD support unavailable.\n");
|
||||
|
||||
- /* libdvdcss replacement functions */
|
||||
+ /* libdvd replacement functions */
|
||||
dvdinput_open = file_open;
|
||||
dvdinput_close = file_close;
|
||||
dvdinput_seek = file_seek;
|
Loading…
Reference in New Issue
Block a user