mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-24 20:48:52 +02:00
* Exported the CSS part of the dvd plugin into a library.
This commit is contained in:
parent
106079bcac
commit
495436e7e1
9
Makefile
9
Makefile
@ -249,6 +249,9 @@ snapshot: Makefile.opts
|
||||
cp share/$$icon.xpm share/$$icon.png \
|
||||
/tmp/vlc-${PROGRAM_VERSION}/share/ ; done
|
||||
|
||||
# make distclean
|
||||
(cd /tmp/vlc-${PROGRAM_VERSION} ; ./configure ; make distclean )
|
||||
|
||||
# build css-enabled archives
|
||||
(cd /tmp ; tar cf vlc-${PROGRAM_VERSION}.tar vlc-${PROGRAM_VERSION} ; \
|
||||
bzip2 -f -9 < vlc-${PROGRAM_VERSION}.tar \
|
||||
@ -348,3 +351,9 @@ builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
|
||||
$(BUILTIN_OBJ): FORCE
|
||||
cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:lib/%.a=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:%=../../%)
|
||||
|
||||
#
|
||||
# libdvdcss target
|
||||
#
|
||||
libdvdcss:
|
||||
cd extras/libdvdcss && $(MAKE)
|
||||
|
||||
|
@ -62,6 +62,7 @@ libdir = @libdir@
|
||||
LIB_ALSA = @LIB_ALSA@
|
||||
LIB_BEOS = @LIB_BEOS@
|
||||
LIB_DARWIN = @LIB_DARWIN@
|
||||
LIB_DVD = @LIB_DVD@
|
||||
LIB_ESD = @LIB_ESD@
|
||||
LIB_GGI = @LIB_GGI@
|
||||
LIB_GLIDE = @LIB_GLIDE@
|
||||
@ -81,6 +82,7 @@ LIB_YUV = @LIB_YUV@
|
||||
#
|
||||
# CFLAGS for special cases
|
||||
#
|
||||
CFLAGS_DVD = @CFLAGS_DVD@
|
||||
CFLAGS_GTK = @CFLAGS_GTK@
|
||||
CFLAGS_SDL = @CFLAGS_SDL@
|
||||
CFLAGS_X11 = @CFLAGS_X11@
|
||||
|
93
configure
vendored
93
configure
vendored
@ -3357,21 +3357,23 @@ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
|
||||
EOF
|
||||
|
||||
BUILTINS="${BUILTINS} dvd"
|
||||
LIB_DVD="${LIB_DVD} -Llib -L../../lib -ldvdcss"
|
||||
CFLAGS_DVD="${CFLAGS_DVD} -I../../extras/libdvdcss"
|
||||
for ac_hdr in sys/cdio.h sys/dvdio.h linux/cdrom.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:3365: checking for $ac_hdr" >&5
|
||||
echo "configure:3367: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3370 "configure"
|
||||
#line 3372 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:3375: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:3377: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -3399,7 +3401,7 @@ done
|
||||
|
||||
BSD_DVD_STRUCT=0
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3403 "configure"
|
||||
#line 3405 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/dvdio.h>
|
||||
EOF
|
||||
@ -3417,7 +3419,7 @@ fi
|
||||
rm -f conftest*
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3421 "configure"
|
||||
#line 3423 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/cdio.h>
|
||||
EOF
|
||||
@ -3441,7 +3443,7 @@ EOF
|
||||
|
||||
fi
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3445 "configure"
|
||||
#line 3447 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <linux/cdrom.h>
|
||||
EOF
|
||||
@ -3593,7 +3595,7 @@ if test "${enable_esd+set}" = set; then
|
||||
# Extract the first word of "esd-config", so it can be a program name with args.
|
||||
set dummy esd-config; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:3597: checking for $ac_word" >&5
|
||||
echo "configure:3599: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_path_ESD_CONFIG'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -3658,17 +3660,17 @@ else
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:3662: checking for $ac_hdr" >&5
|
||||
echo "configure:3664: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3667 "configure"
|
||||
#line 3669 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:3672: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:3674: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -3739,17 +3741,17 @@ if test "${with_sdl+set}" = set; then
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:3743: checking for $ac_hdr" >&5
|
||||
echo "configure:3745: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3748 "configure"
|
||||
#line 3750 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:3753: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:3755: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -3787,17 +3789,17 @@ fi
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:3791: checking for $ac_hdr" >&5
|
||||
echo "configure:3793: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3796 "configure"
|
||||
#line 3798 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:3801: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:3803: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -3841,17 +3843,17 @@ if test "${with_directx+set}" = set; then
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:3845: checking for $ac_hdr" >&5
|
||||
echo "configure:3847: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3850 "configure"
|
||||
#line 3852 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:3855: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:3857: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -3889,17 +3891,17 @@ fi
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:3893: checking for $ac_hdr" >&5
|
||||
echo "configure:3895: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3898 "configure"
|
||||
#line 3900 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:3903: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:3905: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -3999,7 +4001,7 @@ if test x$enable_gtk != xno; then
|
||||
# Extract the first word of "gtk-config", so it can be a program name with args.
|
||||
set dummy gtk-config; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:4003: checking for $ac_word" >&5
|
||||
echo "configure:4005: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -4059,17 +4061,17 @@ if test x$enable_x11 != xno; then
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:4063: checking for $ac_hdr" >&5
|
||||
echo "configure:4065: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 4068 "configure"
|
||||
#line 4070 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:4073: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:4075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -4121,17 +4123,17 @@ if test x$enable_xvideo != xno; then
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:4125: checking for $ac_hdr" >&5
|
||||
echo "configure:4127: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 4130 "configure"
|
||||
#line 4132 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:4135: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:4137: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -4169,17 +4171,17 @@ if test "${enable_alsa+set}" = set; then
|
||||
enableval="$enable_alsa"
|
||||
if test x$enable_alsa = xyes; then ac_safe=`echo "sys/asoundlib.h" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for sys/asoundlib.h""... $ac_c" 1>&6
|
||||
echo "configure:4173: checking for sys/asoundlib.h" >&5
|
||||
echo "configure:4175: checking for sys/asoundlib.h" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 4178 "configure"
|
||||
#line 4180 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/asoundlib.h>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:4183: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:4185: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -4196,7 +4198,7 @@ fi
|
||||
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
|
||||
echo "$ac_t""yes" 1>&6
|
||||
echo $ac_n "checking for main in -lasound""... $ac_c" 1>&6
|
||||
echo "configure:4200: checking for main in -lasound" >&5
|
||||
echo "configure:4202: checking for main in -lasound" >&5
|
||||
ac_lib_var=`echo asound'_'main | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@ -4204,14 +4206,14 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lasound $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 4208 "configure"
|
||||
#line 4210 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
main()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:4215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:4217: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
@ -4284,6 +4286,8 @@ fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -4456,6 +4460,7 @@ s%@LIB@%$LIB%g
|
||||
s%@LIB_ALSA@%$LIB_ALSA%g
|
||||
s%@LIB_BEOS@%$LIB_BEOS%g
|
||||
s%@LIB_DARWIN@%$LIB_DARWIN%g
|
||||
s%@LIB_DVD@%$LIB_DVD%g
|
||||
s%@LIB_ESD@%$LIB_ESD%g
|
||||
s%@LIB_GGI@%$LIB_GGI%g
|
||||
s%@LIB_GLIDE@%$LIB_GLIDE%g
|
||||
@ -4472,6 +4477,7 @@ s%@LIB_X11@%$LIB_X11%g
|
||||
s%@LIB_XVIDEO@%$LIB_XVIDEO%g
|
||||
s%@LIB_YUV@%$LIB_YUV%g
|
||||
s%@CFLAGS_VLC@%$CFLAGS_VLC%g
|
||||
s%@CFLAGS_DVD@%$CFLAGS_DVD%g
|
||||
s%@CFLAGS_GTK@%$CFLAGS_GTK%g
|
||||
s%@CFLAGS_SDL@%$CFLAGS_SDL%g
|
||||
s%@CFLAGS_X11@%$CFLAGS_X11%g
|
||||
@ -4696,20 +4702,27 @@ test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
|
||||
|
||||
|
||||
echo "
|
||||
global configuration
|
||||
--------------------
|
||||
system : ${SYS}
|
||||
architecture : ${ARCH}
|
||||
optimizations : ${OPTIMS}
|
||||
|
||||
vlc configuration
|
||||
-----------------
|
||||
vlc version : ${VLC_VERSION}
|
||||
system : ${SYS}
|
||||
architecture : ${ARCH}
|
||||
debug mode : ${DEBUG}
|
||||
statistics : ${STATS}
|
||||
trace mode : ${TRACE}
|
||||
optimizations : ${OPTIMS}
|
||||
CSS decryption : ${CSS}
|
||||
need builtin getopt : ${GETOPT}
|
||||
built-in modules :${BUILTINS}
|
||||
plugin modules :${PLUGINS}
|
||||
vlc aliases :${ALIASES}
|
||||
|
||||
You may now tune Makefile.opts at your convenience."
|
||||
libdvdcss configuration
|
||||
-----------------------
|
||||
CSS decryption : ${CSS}
|
||||
|
||||
You may now tune Makefile.opts at your convenience. To build vlc, type
|
||||
\`make vlc'. To build libdvdcss only, type \`make libdvdcss'."
|
||||
|
||||
|
21
configure.in
21
configure.in
@ -180,6 +180,8 @@ dnl DVD module: check for DVD ioctls
|
||||
dnl
|
||||
AC_CHECK_HEADERS(sys/ioctl.h,[
|
||||
BUILTINS="${BUILTINS} dvd"
|
||||
LIB_DVD="${LIB_DVD} -Llib -L../../lib -ldvdcss"
|
||||
CFLAGS_DVD="${CFLAGS_DVD} -I../../extras/libdvdcss"
|
||||
AC_CHECK_HEADERS(sys/cdio.h sys/dvdio.h linux/cdrom.h)
|
||||
BSD_DVD_STRUCT=0
|
||||
dnl
|
||||
@ -592,6 +594,7 @@ AC_SUBST(LIB)
|
||||
AC_SUBST(LIB_ALSA)
|
||||
AC_SUBST(LIB_BEOS)
|
||||
AC_SUBST(LIB_DARWIN)
|
||||
AC_SUBST(LIB_DVD)
|
||||
AC_SUBST(LIB_ESD)
|
||||
AC_SUBST(LIB_GGI)
|
||||
AC_SUBST(LIB_GLIDE)
|
||||
@ -609,6 +612,7 @@ AC_SUBST(LIB_XVIDEO)
|
||||
AC_SUBST(LIB_YUV)
|
||||
|
||||
AC_SUBST(CFLAGS_VLC)
|
||||
AC_SUBST(CFLAGS_DVD)
|
||||
AC_SUBST(CFLAGS_GTK)
|
||||
AC_SUBST(CFLAGS_SDL)
|
||||
AC_SUBST(CFLAGS_X11)
|
||||
@ -616,20 +620,27 @@ AC_SUBST(CFLAGS_X11)
|
||||
AC_OUTPUT([Makefile.opts include/config.h])
|
||||
|
||||
echo "
|
||||
global configuration
|
||||
--------------------
|
||||
system : ${SYS}
|
||||
architecture : ${ARCH}
|
||||
optimizations : ${OPTIMS}
|
||||
|
||||
vlc configuration
|
||||
-----------------
|
||||
vlc version : ${VLC_VERSION}
|
||||
system : ${SYS}
|
||||
architecture : ${ARCH}
|
||||
debug mode : ${DEBUG}
|
||||
statistics : ${STATS}
|
||||
trace mode : ${TRACE}
|
||||
optimizations : ${OPTIMS}
|
||||
CSS decryption : ${CSS}
|
||||
need builtin getopt : ${GETOPT}
|
||||
built-in modules :${BUILTINS}
|
||||
plugin modules :${PLUGINS}
|
||||
vlc aliases :${ALIASES}
|
||||
|
||||
You may now tune Makefile.opts at your convenience."
|
||||
libdvdcss configuration
|
||||
-----------------------
|
||||
CSS decryption : ${CSS}
|
||||
|
||||
You may now tune Makefile.opts at your convenience. To build vlc, type
|
||||
\`make vlc'. To build libdvdcss only, type \`make libdvdcss'."
|
||||
|
||||
|
1
extras/libdvdcss/.cvsignore
Normal file
1
extras/libdvdcss/.cvsignore
Normal file
@ -0,0 +1 @@
|
||||
.dep
|
30
extras/libdvdcss/Makefile
Normal file
30
extras/libdvdcss/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
###############################################################################
|
||||
# vlc (VideoLAN Client) dvd module Makefile
|
||||
# (c)2001 VideoLAN
|
||||
###############################################################################
|
||||
|
||||
include ../../Makefile.opts
|
||||
|
||||
#
|
||||
# Objects
|
||||
#
|
||||
|
||||
LIBDVDCSS_O = libdvdcss.o css.o ioctl.o
|
||||
ALL_OBJ = $(LIBDVDCSS_O)
|
||||
|
||||
include ../../Makefile.modules
|
||||
|
||||
$(LIBDVDCSS_O): %.o: .dep/%.d
|
||||
$(LIBDVDCSS_O): %.o: %.c
|
||||
$(CC) $(CFLAGS) $(PCFLAGS) -c -o $@ $<
|
||||
|
||||
../../lib/libdvdcss.so: $(LIBDVDCSS_O)
|
||||
$(CC) $(PCFLAGS) -o $@ $^ $(PLCFLAGS)
|
||||
|
||||
../../lib/libdvdcss.a: $(LIBDVDCSS_O)
|
||||
ar r $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
#all: ../../lib/libdvdcss.so ../../lib/libdvdcss.a
|
||||
all: ../../lib/libdvdcss.a
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*****************************************************************************
|
||||
* dvd_css.c: Functions for DVD authentification and unscrambling
|
||||
* css.c: Functions for DVD authentification and unscrambling
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_css.c,v 1.33 2001/06/07 22:25:42 sam Exp $
|
||||
* $Id: css.c,v 1.1 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -47,27 +47,20 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "threads.h"
|
||||
#include "mtime.h"
|
||||
|
||||
#include "intf_msg.h"
|
||||
#include "videolan/dvdcss.h"
|
||||
#include "libdvdcss.h"
|
||||
|
||||
#include "input_dvd.h"
|
||||
|
||||
#include "dvd_css.h"
|
||||
#ifdef HAVE_CSS
|
||||
# include "dvd_csstables.h"
|
||||
# include "csstables.h"
|
||||
#endif /* HAVE_CSS */
|
||||
#include "dvd_ioctl.h"
|
||||
|
||||
#include "modules.h"
|
||||
#include "modules_export.h"
|
||||
#include "ioctl.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*****************************************************************************/
|
||||
#ifdef HAVE_CSS
|
||||
static int CSSGetASF ( int i_fd );
|
||||
static int CSSGetASF ( dvdcss_handle dvdcss );
|
||||
static void CSSCryptKey ( int i_key_type, int i_varient,
|
||||
u8 const * pi_challenge, u8* pi_key );
|
||||
static int CSSCracker ( int i_start, unsigned char * p_crypted,
|
||||
@ -78,17 +71,17 @@ static int CSSCracker ( int i_start, unsigned char * p_crypted,
|
||||
/*****************************************************************************
|
||||
* CSSTest : check if the disc is encrypted or not
|
||||
*****************************************************************************/
|
||||
int CSSTest( int i_fd )
|
||||
int CSSTest( dvdcss_handle dvdcss )
|
||||
{
|
||||
int i_ret, i_copyright;
|
||||
|
||||
i_ret = ioctl_ReadCopyright( i_fd, 0 /* i_layer */, &i_copyright );
|
||||
i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright );
|
||||
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
/* Since it's the first ioctl we try to issue, we add a notice */
|
||||
intf_ErrMsg( "css error: ioctl_ReadCopyright failed, "
|
||||
"make sure DVD ioctls were compiled in" );
|
||||
_dvdcss_error( dvdcss, "css error: ioctl_ReadCopyright failed, "
|
||||
"make sure DVD ioctls were compiled in" );
|
||||
|
||||
return i_ret;
|
||||
}
|
||||
@ -103,35 +96,37 @@ int CSSTest( int i_fd )
|
||||
* Since we don't need the disc key to find the title key, we just run the
|
||||
* basic unavoidable commands to authenticate device and disc.
|
||||
*****************************************************************************/
|
||||
int CSSInit( int i_fd, css_t * p_css )
|
||||
int CSSInit( dvdcss_handle dvdcss )
|
||||
{
|
||||
#ifdef HAVE_CSS
|
||||
/* structures defined in cdrom.h or dvdio.h */
|
||||
char p_buffer[2048 + 4 + 1];
|
||||
char psz_warning[32];
|
||||
int i_agid = 0;
|
||||
int i_ret = -1;
|
||||
int i;
|
||||
|
||||
/* Test authentication success */
|
||||
switch( CSSGetASF( i_fd ) )
|
||||
switch( CSSGetASF( dvdcss ) )
|
||||
{
|
||||
case -1:
|
||||
return -1;
|
||||
|
||||
case 1:
|
||||
intf_WarnMsg( 2, "css info: already authenticated" );
|
||||
_dvdcss_debug( dvdcss, "already authenticated" );
|
||||
return 0;
|
||||
|
||||
case 0:
|
||||
intf_WarnMsg( 2, "css info: need to authenticate" );
|
||||
_dvdcss_debug( dvdcss, "need to authenticate" );
|
||||
}
|
||||
|
||||
/* Init sequence, request AGID */
|
||||
for( i = 1; i < 4 ; ++i )
|
||||
{
|
||||
intf_WarnMsg( 2, "css info: requesting AGID %d", i );
|
||||
sprintf( psz_warning, "requesting AGID %d", i );
|
||||
_dvdcss_debug( dvdcss, psz_warning );
|
||||
|
||||
i_ret = ioctl_ReportAgid( i_fd, &i_agid );
|
||||
i_ret = ioctl_ReportAgid( dvdcss->i_fd, &i_agid );
|
||||
|
||||
if( i_ret != -1 )
|
||||
{
|
||||
@ -139,108 +134,113 @@ int CSSInit( int i_fd, css_t * p_css )
|
||||
break;
|
||||
}
|
||||
|
||||
intf_ErrMsg( "css error: ioctl_ReportAgid failed, invalidating" );
|
||||
_dvdcss_error( dvdcss, "ioctl_ReportAgid failed, invalidating" );
|
||||
|
||||
i_agid = 0;
|
||||
ioctl_InvalidateAgid( i_fd, &i_agid );
|
||||
ioctl_InvalidateAgid( dvdcss->i_fd, &i_agid );
|
||||
}
|
||||
|
||||
/* Unable to authenticate without AGID */
|
||||
if( i_ret == -1 )
|
||||
{
|
||||
intf_ErrMsg( "css error: ioctl_ReportAgid failed, fatal" );
|
||||
_dvdcss_error( dvdcss, "ioctl_ReportAgid failed, fatal" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
for( i = 0 ; i < 10; ++i )
|
||||
{
|
||||
p_css->disc.pi_challenge[i] = i;
|
||||
dvdcss->css.disc.pi_challenge[i] = i;
|
||||
}
|
||||
|
||||
/* Get challenge from host */
|
||||
for( i = 0 ; i < 10 ; ++i )
|
||||
{
|
||||
p_buffer[9-i] = p_css->disc.pi_challenge[i];
|
||||
p_buffer[9-i] = dvdcss->css.disc.pi_challenge[i];
|
||||
}
|
||||
|
||||
/* Send challenge to LU */
|
||||
if( ioctl_SendChallenge( i_fd, &i_agid, p_buffer ) < 0 )
|
||||
if( ioctl_SendChallenge( dvdcss->i_fd, &i_agid, p_buffer ) < 0 )
|
||||
{
|
||||
intf_ErrMsg( "css error: ioctl_SendChallenge failed" );
|
||||
_dvdcss_error( dvdcss, "ioctl_SendChallenge failed" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get key1 from LU */
|
||||
if( ioctl_ReportKey1( i_fd, &i_agid, p_buffer ) < 0)
|
||||
if( ioctl_ReportKey1( dvdcss->i_fd, &i_agid, p_buffer ) < 0)
|
||||
{
|
||||
intf_ErrMsg( "css error: ioctl_ReportKey1 failed" );
|
||||
_dvdcss_error( dvdcss, "ioctl_ReportKey1 failed" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Send key1 to host */
|
||||
for( i = 0 ; i < KEY_SIZE ; i++ )
|
||||
{
|
||||
p_css->disc.pi_key1[i] = p_buffer[4-i];
|
||||
dvdcss->css.disc.pi_key1[i] = p_buffer[4-i];
|
||||
}
|
||||
|
||||
for( i = 0 ; i < 32 ; ++i )
|
||||
{
|
||||
CSSCryptKey( 0, i, p_css->disc.pi_challenge,
|
||||
p_css->disc.pi_key_check );
|
||||
CSSCryptKey( 0, i, dvdcss->css.disc.pi_challenge,
|
||||
dvdcss->css.disc.pi_key_check );
|
||||
|
||||
if( memcmp( p_css->disc.pi_key_check,
|
||||
p_css->disc.pi_key1, KEY_SIZE ) == 0 )
|
||||
if( memcmp( dvdcss->css.disc.pi_key_check,
|
||||
dvdcss->css.disc.pi_key1, KEY_SIZE ) == 0 )
|
||||
{
|
||||
intf_WarnMsg( 2, "css info: drive authentic, using variant %d", i);
|
||||
p_css->disc.i_varient = i;
|
||||
sprintf( psz_warning, "drive authentic, using variant %d", i );
|
||||
_dvdcss_debug( dvdcss, psz_warning );
|
||||
dvdcss->css.disc.i_varient = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( i == 32 )
|
||||
{
|
||||
intf_ErrMsg( "css error: drive would not authenticate" );
|
||||
_dvdcss_error( dvdcss, "drive would not authenticate" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get challenge from LU */
|
||||
if( ioctl_ReportChallenge( i_fd, &i_agid, p_buffer ) < 0 )
|
||||
if( ioctl_ReportChallenge( dvdcss->i_fd, &i_agid, p_buffer ) < 0 )
|
||||
{
|
||||
intf_ErrMsg( "css error: ioctl_ReportKeyChallenge failed" );
|
||||
_dvdcss_error( dvdcss, "ioctl_ReportKeyChallenge failed" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Send challenge to host */
|
||||
for( i = 0 ; i < 10 ; ++i )
|
||||
{
|
||||
p_css->disc.pi_challenge[i] = p_buffer[9-i];
|
||||
dvdcss->css.disc.pi_challenge[i] = p_buffer[9-i];
|
||||
}
|
||||
|
||||
CSSCryptKey( 1, p_css->disc.i_varient, p_css->disc.pi_challenge,
|
||||
p_css->disc.pi_key2 );
|
||||
CSSCryptKey( 1, dvdcss->css.disc.i_varient,
|
||||
dvdcss->css.disc.pi_challenge,
|
||||
dvdcss->css.disc.pi_key2 );
|
||||
|
||||
/* Get key2 from host */
|
||||
for( i = 0 ; i < KEY_SIZE ; ++i )
|
||||
{
|
||||
p_buffer[4-i] = p_css->disc.pi_key2[i];
|
||||
p_buffer[4-i] = dvdcss->css.disc.pi_key2[i];
|
||||
}
|
||||
|
||||
/* Send key2 to LU */
|
||||
if( ioctl_SendKey2( i_fd, &i_agid, p_buffer ) < 0 )
|
||||
if( ioctl_SendKey2( dvdcss->i_fd, &i_agid, p_buffer ) < 0 )
|
||||
{
|
||||
intf_ErrMsg( "css error: ioctl_SendKey2 failed" );
|
||||
_dvdcss_error( dvdcss, "ioctl_SendKey2 failed" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
intf_WarnMsg( 2, "css info: authentication established" );
|
||||
_dvdcss_debug( dvdcss, "authentication established" );
|
||||
|
||||
memcpy( p_css->disc.pi_challenge, p_css->disc.pi_key1, KEY_SIZE );
|
||||
memcpy( p_css->disc.pi_challenge+KEY_SIZE, p_css->disc.pi_key2, KEY_SIZE );
|
||||
memcpy( dvdcss->css.disc.pi_challenge,
|
||||
dvdcss->css.disc.pi_key1, KEY_SIZE );
|
||||
memcpy( dvdcss->css.disc.pi_challenge+KEY_SIZE,
|
||||
dvdcss->css.disc.pi_key2, KEY_SIZE );
|
||||
|
||||
CSSCryptKey( 2, p_css->disc.i_varient, p_css->disc.pi_challenge,
|
||||
p_css->disc.pi_key_check );
|
||||
CSSCryptKey( 2, dvdcss->css.disc.i_varient,
|
||||
dvdcss->css.disc.pi_challenge,
|
||||
dvdcss->css.disc.pi_key_check );
|
||||
|
||||
intf_WarnMsg( 2, "css info: received session key" );
|
||||
_dvdcss_debug( dvdcss, "received session key" );
|
||||
|
||||
if( i_agid < 0 )
|
||||
{
|
||||
@ -248,56 +248,56 @@ int CSSInit( int i_fd, css_t * p_css )
|
||||
}
|
||||
|
||||
/* Test authentication success */
|
||||
switch( CSSGetASF( i_fd ) )
|
||||
switch( CSSGetASF( dvdcss ) )
|
||||
{
|
||||
case -1:
|
||||
return -1;
|
||||
|
||||
case 1:
|
||||
intf_WarnMsg( 2, "css info: already authenticated" );
|
||||
_dvdcss_debug( dvdcss, "already authenticated" );
|
||||
return 0;
|
||||
|
||||
case 0:
|
||||
intf_WarnMsg( 2, "css info: need to get disc key" );
|
||||
_dvdcss_debug( dvdcss, "need to get disc key" );
|
||||
}
|
||||
|
||||
/* Get encrypted disc key */
|
||||
if( ioctl_ReadKey( i_fd, &i_agid, p_buffer ) < 0 )
|
||||
if( ioctl_ReadKey( dvdcss->i_fd, &i_agid, p_buffer ) < 0 )
|
||||
{
|
||||
intf_ErrMsg( "css error: ioctl_ReadKey failed" );
|
||||
_dvdcss_error( dvdcss, "ioctl_ReadKey failed" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Unencrypt disc key using bus key */
|
||||
for( i = 0 ; i < 2048 ; i++ )
|
||||
{
|
||||
p_buffer[ i ] ^= p_css->disc.pi_key_check[ 4 - (i % KEY_SIZE) ];
|
||||
p_buffer[ i ] ^= dvdcss->css.disc.pi_key_check[ 4 - (i % KEY_SIZE) ];
|
||||
}
|
||||
memcpy( p_css->disc.pi_key_check, p_buffer, 2048 );
|
||||
memcpy( dvdcss->css.disc.pi_key_check, p_buffer, 2048 );
|
||||
|
||||
/* initialize title key to know it empty */
|
||||
for( i = 0 ; i < KEY_SIZE ; i++ )
|
||||
{
|
||||
p_css->pi_title_key[i] = 0;
|
||||
dvdcss->css.pi_title_key[i] = 0;
|
||||
}
|
||||
|
||||
/* Test authentication success */
|
||||
switch( CSSGetASF( i_fd ) )
|
||||
switch( CSSGetASF( dvdcss ) )
|
||||
{
|
||||
case -1:
|
||||
return -1;
|
||||
|
||||
case 1:
|
||||
intf_WarnMsg( 2, "css info: successfully authenticated" );
|
||||
_dvdcss_debug( dvdcss, "successfully authenticated" );
|
||||
return 0;
|
||||
|
||||
case 0:
|
||||
intf_ErrMsg( "css error: no way to authenticate" );
|
||||
_dvdcss_error( dvdcss, "no way to authenticate" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else /* HAVE_CSS */
|
||||
intf_ErrMsg( "css error: CSS decryption is disabled in this module" );
|
||||
_dvdcss_error( dvdcss, "CSS decryption is disabled in this module" );
|
||||
|
||||
#endif /* HAVE_CSS */
|
||||
return -1;
|
||||
@ -309,7 +309,7 @@ int CSSInit( int i_fd, css_t * p_css )
|
||||
*****************************************************************************
|
||||
* The DVD should have been opened and authenticated before.
|
||||
*****************************************************************************/
|
||||
int CSSGetKey( int i_fd, css_t * p_css )
|
||||
int CSSGetKey( dvdcss_handle dvdcss )
|
||||
{
|
||||
#ifdef HAVE_CSS
|
||||
/*
|
||||
@ -336,15 +336,15 @@ int CSSGetKey( int i_fd, css_t * p_css )
|
||||
b_stop_scanning = 0;
|
||||
|
||||
/* Position of the title on the disc */
|
||||
i_pos = p_css->i_title_pos;
|
||||
i_pos = (off_t)DVDCSS_BLOCK_SIZE * (off_t)dvdcss->css.i_title_pos;
|
||||
|
||||
do {
|
||||
#if !defined( WIN32 )
|
||||
i_pos = lseek( i_fd, i_pos, SEEK_SET );
|
||||
i_bytes_read = read( i_fd, pi_buf, 0x800 );
|
||||
i_pos = lseek( dvdcss->i_fd, i_pos, SEEK_SET );
|
||||
i_bytes_read = read( dvdcss->i_fd, pi_buf, 0x800 );
|
||||
#else
|
||||
i_pos = SetFilePointer( (HANDLE) i_fd, i_pos, 0, FILE_BEGIN );
|
||||
ReadFile( (HANDLE) i_fd, pi_buf, 0x800, &i_bytes_read, NULL );
|
||||
i_pos = SetFilePointer( (HANDLE) dvdcss->i_fd, i_pos, 0, FILE_BEGIN );
|
||||
ReadFile( (HANDLE) dvdcss->i_fd, pi_buf, 0x800, &i_bytes_read, NULL );
|
||||
#endif
|
||||
|
||||
/* PES_scrambling_control */
|
||||
@ -382,22 +382,22 @@ int CSSGetKey( int i_fd, css_t * p_css )
|
||||
|
||||
if( b_stop_scanning)
|
||||
{
|
||||
memcpy( p_css->pi_title_key,
|
||||
memcpy( dvdcss->css.pi_title_key,
|
||||
&pi_key, sizeof(dvd_key_t) );
|
||||
intf_WarnMsg( 2, "css info: vts key initialized" );
|
||||
_dvdcss_debug( dvdcss, "vts key initialized" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !b_encrypted )
|
||||
{
|
||||
intf_WarnMsg( 2, "css warning: this file was _NOT_ encrypted!" );
|
||||
_dvdcss_debug( dvdcss, "this file was _NOT_ encrypted!" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
#else /* HAVE_CSS */
|
||||
intf_ErrMsg( "css error: css decryption unavailable" );
|
||||
_dvdcss_error( dvdcss, "css decryption unavailable" );
|
||||
return -1;
|
||||
|
||||
#endif /* HAVE_CSS */
|
||||
@ -465,24 +465,30 @@ int CSSDescrambleSector( dvd_key_t pi_key, u8* pi_sec )
|
||||
* 0 if the device needs to be authenticated,
|
||||
* 1 either.
|
||||
*****************************************************************************/
|
||||
static int CSSGetASF( int i_fd )
|
||||
static int CSSGetASF( dvdcss_handle dvdcss )
|
||||
{
|
||||
int i_agid;
|
||||
int i_asf = 0;
|
||||
|
||||
for( i_agid = 0 ; i_agid < 4 ; i_agid++ )
|
||||
{
|
||||
if( ioctl_ReportASF( i_fd, &i_agid, &i_asf ) == 0 )
|
||||
if( ioctl_ReportASF( dvdcss->i_fd, &i_agid, &i_asf ) == 0 )
|
||||
{
|
||||
intf_WarnMsg( 3, "css info: GetASF %sauthenticated",
|
||||
i_asf ? "":"not " );
|
||||
if( i_asf )
|
||||
{
|
||||
_dvdcss_debug( dvdcss, "GetASF authenticated" );
|
||||
}
|
||||
else
|
||||
{
|
||||
_dvdcss_debug( dvdcss, "GetASF not authenticated" );
|
||||
}
|
||||
|
||||
return i_asf;
|
||||
}
|
||||
}
|
||||
|
||||
/* The ioctl process has failed */
|
||||
intf_ErrMsg( "css error: GetASF fatal error" );
|
||||
_dvdcss_error( dvdcss, "GetASF fatal error" );
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*****************************************************************************
|
||||
* dvd_css.h: Structures for DVD authentification and unscrambling
|
||||
* css.h: Structures for DVD authentification and unscrambling
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_css.h,v 1.8 2001/05/19 00:39:29 stef Exp $
|
||||
* $Id: css.h,v 1.1 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -60,7 +60,8 @@ typedef struct css_s
|
||||
*****************************************************************************/
|
||||
struct css_s;
|
||||
|
||||
int CSSTest ( int );
|
||||
int CSSInit ( int, struct css_s * );
|
||||
int CSSGetKey ( int, struct css_s * );
|
||||
int CSSTest ( dvdcss_handle );
|
||||
int CSSInit ( dvdcss_handle );
|
||||
int CSSGetKey ( dvdcss_handle );
|
||||
int CSSDescrambleSector ( u8 * , u8 * );
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*****************************************************************************
|
||||
* dvd_csstables.h: CSS Tables for DVD unscrambling
|
||||
* csstables.h: CSS Tables for DVD unscrambling
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_csstables.h,v 1.1 2001/03/02 13:47:01 sam Exp $
|
||||
* $Id: csstables.h,v 1.1 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
@ -1,8 +1,8 @@
|
||||
/*****************************************************************************
|
||||
* dvd_ioctl.c: DVD ioctl replacement function
|
||||
* ioctl.c: DVD ioctl replacement function
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_ioctl.c,v 1.17 2001/06/03 12:47:21 sam Exp $
|
||||
* $Id: ioctl.c,v 1.1 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
|
||||
* Samuel Hocevar <sam@zoy.org>
|
||||
@ -55,20 +55,12 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "threads.h"
|
||||
#include "mtime.h"
|
||||
|
||||
#include "intf_msg.h"
|
||||
|
||||
#ifdef SYS_DARWIN1_3
|
||||
# include "DVDioctl/DVDioctl.h"
|
||||
#endif
|
||||
|
||||
#include "dvd_css.h"
|
||||
#include "dvd_ioctl.h"
|
||||
|
||||
#include "modules.h"
|
||||
#include "modules_export.h"
|
||||
#include "ioctl.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes, BeOS specific
|
||||
@ -115,8 +107,8 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
|
||||
*pi_copyright = p_buffer[ 4 ];
|
||||
|
||||
#elif defined( SYS_DARWIN1_3 )
|
||||
intf_ErrMsg( "css error: DVD ioctls not fully functional yet" );
|
||||
intf_ErrMsg( "css error: assuming disc is encrypted" );
|
||||
_dvd_error( dvdcss, "DVD ioctls not fully functional yet, "
|
||||
"assuming disc is encrypted" );
|
||||
|
||||
*pi_copyright = 1;
|
||||
|
||||
@ -159,8 +151,8 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
|
||||
else
|
||||
{
|
||||
/* TODO: add WNASPI support for Win9x */
|
||||
intf_ErrMsg( "css error: DVD ioctls not functional yet" );
|
||||
intf_ErrMsg( "css error: assuming disc is unencrypted" );
|
||||
_dvd_error( dvdcss, "DVD ioctls not functional yet, "
|
||||
"assuming disc is unencrypted" );
|
||||
*pi_copyright = 0;
|
||||
i_ret = 0;
|
||||
}
|
||||
@ -228,8 +220,8 @@ int ioctl_ReadKey( int i_fd, int *pi_agid, u8 *p_key )
|
||||
memcpy( p_key, p_buffer + 4, 2048 );
|
||||
|
||||
#elif defined( SYS_DARWIN1_3 )
|
||||
intf_ErrMsg( "css error: DVD ioctls not fully functional yet" );
|
||||
intf_ErrMsg( "css error: sending an empty key" );
|
||||
_dvd_error( dvdcss, "DVD ioctls not fully functional yet, "
|
||||
"sending an empty key" );
|
||||
|
||||
i_ret = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* dvd_ioctl.h: DVD ioctl replacement function
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_ioctl.h,v 1.10 2001/05/31 03:57:54 sam Exp $
|
||||
* $Id: ioctl.h,v 1.1 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Authors: Samuel Hocevar <sam@zoy.org>
|
||||
*
|
425
extras/libdvdcss/libdvdcss.c
Normal file
425
extras/libdvdcss/libdvdcss.c
Normal file
@ -0,0 +1,425 @@
|
||||
/*****************************************************************************
|
||||
* libdvdcss.c: DVD reading library.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2001 VideoLAN
|
||||
* $Id: libdvdcss.c,v 1.1 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Authors: Stéphane Borel <stef@via.ecp.fr>
|
||||
* Samuel Hocevar <sam@zoy.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#include "defs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined( WIN32 )
|
||||
# include <io.h>
|
||||
# include "input_iovec.h"
|
||||
#else
|
||||
# include <sys/uio.h> /* struct iovec */
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "videolan/dvdcss.h"
|
||||
#include "libdvdcss.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*****************************************************************************/
|
||||
static int _dvdcss_open ( dvdcss_handle, char *psz_target );
|
||||
static int _dvdcss_close ( dvdcss_handle );
|
||||
static int _dvdcss_seek ( dvdcss_handle, int i_blocks );
|
||||
static int _dvdcss_read ( dvdcss_handle, void *p_buffer, int i_blocks );
|
||||
static int _dvdcss_readv ( dvdcss_handle, struct iovec *p_iovec, int i_blocks );
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_init: initialize libdvdcss
|
||||
*****************************************************************************/
|
||||
extern dvdcss_handle dvdcss_init ( int i_flags )
|
||||
{
|
||||
dvdcss_handle dvdcss;
|
||||
|
||||
/* Allocate the library structure */
|
||||
dvdcss = malloc( sizeof( struct dvdcss_s ) );
|
||||
if( dvdcss == NULL )
|
||||
{
|
||||
if( ! (i_flags & DVDCSS_INIT_QUIET) )
|
||||
{
|
||||
DVDCSS_ERROR( "could not initialize library" );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize structure */
|
||||
dvdcss->i_status = DVDCSS_STATUS_NONE;
|
||||
|
||||
dvdcss->b_debug = i_flags & DVDCSS_INIT_DEBUG;
|
||||
dvdcss->b_errors = !(i_flags & DVDCSS_INIT_QUIET);
|
||||
dvdcss->psz_error = "no error";
|
||||
|
||||
/* XXX: additional initialization stuff might come here */
|
||||
|
||||
dvdcss->i_status |= DVDCSS_STATUS_INIT;
|
||||
|
||||
return dvdcss;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_error: return the last libdvdcss error message
|
||||
*****************************************************************************/
|
||||
extern char * dvdcss_error ( dvdcss_handle dvdcss )
|
||||
{
|
||||
return dvdcss->psz_error;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_open: open a DVD device, crack CSS key if disc is encrypted
|
||||
*****************************************************************************/
|
||||
extern int dvdcss_open ( dvdcss_handle dvdcss, char *psz_target )
|
||||
{
|
||||
int i_ret;
|
||||
|
||||
if( ! (dvdcss->i_status & DVDCSS_STATUS_INIT) )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "library not initialized" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( dvdcss->i_status & DVDCSS_STATUS_OPEN )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "a device is already opened" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
i_ret = _dvdcss_open( dvdcss, psz_target );
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
i_ret = CSSTest( dvdcss );
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "css test failed" );
|
||||
_dvdcss_close( dvdcss );
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
dvdcss->b_encrypted = i_ret;
|
||||
|
||||
/* If drive is encrypted, crack its key */
|
||||
if( dvdcss->b_encrypted )
|
||||
{
|
||||
i_ret = CSSInit( dvdcss );
|
||||
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
_dvdcss_close( dvdcss );
|
||||
return i_ret;
|
||||
}
|
||||
}
|
||||
|
||||
dvdcss->i_status |= DVDCSS_STATUS_OPEN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_seek: seek into the device
|
||||
*****************************************************************************/
|
||||
extern int dvdcss_seek ( dvdcss_handle dvdcss, int i_blocks )
|
||||
{
|
||||
if( ! (dvdcss->i_status & DVDCSS_STATUS_OPEN) )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "no device opened" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _dvdcss_seek( dvdcss, i_blocks );
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_crack: crack the current title key
|
||||
*****************************************************************************/
|
||||
extern int dvdcss_crack ( dvdcss_handle dvdcss, int i_title, int i_block )
|
||||
{
|
||||
int i_ret;
|
||||
|
||||
if( ! (dvdcss->i_status & DVDCSS_STATUS_OPEN) )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "no device opened" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( ! dvdcss->b_encrypted )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Crack CSS title key for current VTS */
|
||||
dvdcss->css.i_title = i_title;
|
||||
dvdcss->css.i_title_pos = i_block;
|
||||
|
||||
i_ret = CSSGetKey( dvdcss );
|
||||
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "fatal error in vts css key" );
|
||||
return i_ret;
|
||||
}
|
||||
else if( i_ret > 0 )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "decryption unavailable" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_read: read data from the device, decrypt if requested
|
||||
*****************************************************************************/
|
||||
extern int dvdcss_read ( dvdcss_handle dvdcss, void *p_buffer,
|
||||
int i_blocks,
|
||||
int i_flags )
|
||||
{
|
||||
int i_ret;
|
||||
|
||||
if( ! (dvdcss->i_status & DVDCSS_STATUS_OPEN) )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "no device opened" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
i_ret = _dvdcss_read( dvdcss, p_buffer, i_blocks );
|
||||
|
||||
if( i_ret != i_blocks
|
||||
|| !dvdcss->b_encrypted
|
||||
|| !(i_flags & DVDCSS_READ_DECRYPT) )
|
||||
{
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
while( i_ret )
|
||||
{
|
||||
CSSDescrambleSector( dvdcss->css.pi_title_key, p_buffer );
|
||||
((u8*)p_buffer)[0x14] &= 0x8f;
|
||||
(u8*)p_buffer += DVDCSS_BLOCK_SIZE;
|
||||
i_ret--;
|
||||
}
|
||||
|
||||
return i_blocks;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_readv: read data to an iovec structure, decrypt if reaquested
|
||||
*****************************************************************************/
|
||||
extern int dvdcss_readv ( dvdcss_handle dvdcss, void *p_iovec,
|
||||
int i_blocks,
|
||||
int i_flags )
|
||||
{
|
||||
#define P_IOVEC ((struct iovec*)p_iovec)
|
||||
int i_ret;
|
||||
void *iov_base;
|
||||
size_t iov_len;
|
||||
|
||||
if( ! (dvdcss->i_status & DVDCSS_STATUS_OPEN) )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "no device opened" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
i_ret = _dvdcss_readv( dvdcss, P_IOVEC, i_blocks );
|
||||
|
||||
if( i_ret != i_blocks
|
||||
|| !dvdcss->b_encrypted
|
||||
|| !(i_flags & DVDCSS_READ_DECRYPT) )
|
||||
{
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
/* Initialize loop for decryption */
|
||||
iov_base = P_IOVEC->iov_base;
|
||||
iov_len = P_IOVEC->iov_len;
|
||||
|
||||
while( i_ret )
|
||||
{
|
||||
/* Check that iov_len is a multiple of 2048 */
|
||||
if( iov_len & 0x7ff )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
while( iov_len == 0 )
|
||||
{
|
||||
P_IOVEC++;
|
||||
iov_base = P_IOVEC->iov_base;
|
||||
iov_len = P_IOVEC->iov_len;
|
||||
}
|
||||
|
||||
CSSDescrambleSector( dvdcss->css.pi_title_key, iov_base );
|
||||
((u8*)iov_base)[0x14] &= 0x8f;
|
||||
|
||||
(u8*)iov_base += DVDCSS_BLOCK_SIZE;
|
||||
(u8*)iov_len -= DVDCSS_BLOCK_SIZE;
|
||||
|
||||
i_ret--;
|
||||
}
|
||||
|
||||
return i_blocks;
|
||||
#undef P_IOVEC
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_close: close the DVD device
|
||||
*****************************************************************************/
|
||||
extern int dvdcss_close ( dvdcss_handle dvdcss )
|
||||
{
|
||||
int i_ret;
|
||||
|
||||
if( ! (dvdcss->i_status & DVDCSS_STATUS_OPEN) )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "no device opened" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
i_ret = _dvdcss_close( dvdcss );
|
||||
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
dvdcss->i_status &= ~DVDCSS_STATUS_OPEN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* dvdcss_end: clean up the library
|
||||
*****************************************************************************/
|
||||
extern int dvdcss_end ( dvdcss_handle dvdcss )
|
||||
{
|
||||
if( dvdcss->i_status & DVDCSS_STATUS_OPEN )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "a device is still open" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
free( dvdcss );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Following functions are local */
|
||||
|
||||
static int _dvdcss_open ( dvdcss_handle dvdcss, char *psz_target )
|
||||
{
|
||||
#if defined( WIN32 )
|
||||
snprintf( buf, 7, "\\\\.\\%c:", psz_target[0] );
|
||||
(HANDLE) dvdcss->i_fd =
|
||||
CreateFile( psz_target, GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL );
|
||||
if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "failed opening device" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else
|
||||
dvdcss->i_fd = open( psz_target, 0 );
|
||||
|
||||
if( dvdcss->i_fd == -1 )
|
||||
{
|
||||
_dvdcss_error( dvdcss, "failed opening device" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _dvdcss_close ( dvdcss_handle dvdcss )
|
||||
{
|
||||
#if defined( WIN32 )
|
||||
CloseHandle( (HANDLE) dvdcss->i_fd );
|
||||
#else
|
||||
close( dvdcss->i_fd );
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _dvdcss_seek ( dvdcss_handle dvdcss, int i_blocks )
|
||||
{
|
||||
off_t i_read;
|
||||
|
||||
#if defined( WIN32 )
|
||||
i_read = SetFilePointer( (HANDLE) dvdcss->i_fd,
|
||||
(off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE,
|
||||
NULL, FILE_BEGIN );
|
||||
#else
|
||||
i_read = lseek( dvdcss->i_fd,
|
||||
(off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE, SEEK_SET );
|
||||
|
||||
#endif
|
||||
|
||||
return i_read / DVDCSS_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
static int _dvdcss_read ( dvdcss_handle dvdcss, void *p_buffer, int i_blocks )
|
||||
{
|
||||
#if defined( WIN32 )
|
||||
DWORD i_read;
|
||||
if( ReadFile( (HANDLE) dvdcss->i_fd, p_buffer,
|
||||
(off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE,
|
||||
&i_read, NULL ) == -1 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
off_t i_read;
|
||||
i_read = read( dvdcss->i_fd, p_buffer,
|
||||
(off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE );
|
||||
|
||||
#endif
|
||||
|
||||
return i_read / DVDCSS_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
static int _dvdcss_readv ( dvdcss_handle dvdcss, struct iovec *p_iovec, int i_blocks )
|
||||
{
|
||||
off_t i_read;
|
||||
i_read = readv( dvdcss->i_fd, p_iovec, i_blocks );
|
||||
|
||||
return i_read / DVDCSS_BLOCK_SIZE;
|
||||
}
|
||||
|
83
extras/libdvdcss/libdvdcss.h
Normal file
83
extras/libdvdcss/libdvdcss.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*****************************************************************************
|
||||
* private.h: private DVD reading library data
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2001 VideoLAN
|
||||
* $Id: libdvdcss.h,v 1.1 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Authors: Stéphane Borel <stef@via.ecp.fr>
|
||||
* Samuel Hocevar <sam@zoy.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Needed headers
|
||||
*****************************************************************************/
|
||||
#include "css.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* The libdvdcss structure
|
||||
*****************************************************************************/
|
||||
struct dvdcss_s
|
||||
{
|
||||
/* Status */
|
||||
int i_status;
|
||||
|
||||
/* File descriptor */
|
||||
int i_fd;
|
||||
|
||||
/* Decryption stuff */
|
||||
css_t css;
|
||||
boolean_t b_encrypted;
|
||||
|
||||
/* Error management */
|
||||
char *psz_error;
|
||||
boolean_t b_errors;
|
||||
boolean_t b_debug;
|
||||
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* Flags
|
||||
*****************************************************************************/
|
||||
#define DVDCSS_STATUS_NONE 0
|
||||
#define DVDCSS_STATUS_INIT 1 << 0
|
||||
#define DVDCSS_STATUS_OPEN 1 << 1
|
||||
|
||||
/*****************************************************************************
|
||||
* Error management
|
||||
*****************************************************************************/
|
||||
#define DVDCSS_ERROR( x... ) fprintf( stderr, "libdvdcss error: %s\n", ##x );
|
||||
#define DVDCSS_DEBUG( x... ) fprintf( stderr, "libdvdcss debug: %s\n", ##x );
|
||||
|
||||
static __inline__ void _dvdcss_error( dvdcss_handle dvdcss, char *psz_string )
|
||||
{
|
||||
if( dvdcss->b_errors )
|
||||
{
|
||||
DVDCSS_ERROR( psz_string );
|
||||
}
|
||||
|
||||
dvdcss->psz_error = psz_string;
|
||||
}
|
||||
|
||||
static __inline__ void _dvdcss_debug( dvdcss_handle dvdcss, char *psz_string )
|
||||
{
|
||||
if( dvdcss->b_debug )
|
||||
{
|
||||
DVDCSS_DEBUG( psz_string );
|
||||
}
|
||||
}
|
||||
|
||||
|
64
extras/libdvdcss/videolan/dvdcss.h
Normal file
64
extras/libdvdcss/videolan/dvdcss.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*****************************************************************************
|
||||
* libdvdcss.h: DVD reading library, exported functions.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2001 VideoLAN
|
||||
* $Id: dvdcss.h,v 1.1 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Authors: Stéphane Borel <stef@via.ecp.fr>
|
||||
* Samuel Hocevar <sam@zoy.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* The libdvdcss structure
|
||||
*****************************************************************************/
|
||||
typedef struct dvdcss_s* dvdcss_handle;
|
||||
|
||||
/*****************************************************************************
|
||||
* Flags
|
||||
*****************************************************************************/
|
||||
#define DVDCSS_NOFLAGS 0
|
||||
|
||||
#define DVDCSS_INIT_QUIET 1 << 0
|
||||
#define DVDCSS_INIT_DEBUG 1 << 1
|
||||
|
||||
#define DVDCSS_READ_DECRYPT 1 << 0
|
||||
|
||||
#define DVDCSS_BLOCK_SIZE 2048
|
||||
|
||||
/*****************************************************************************
|
||||
* Exported prototypes
|
||||
*****************************************************************************/
|
||||
extern dvdcss_handle dvdcss_init ( int i_flags );
|
||||
extern int dvdcss_end ( dvdcss_handle );
|
||||
extern int dvdcss_open ( dvdcss_handle,
|
||||
char *psz_target );
|
||||
extern int dvdcss_close ( dvdcss_handle );
|
||||
extern int dvdcss_crack ( dvdcss_handle,
|
||||
int i_title,
|
||||
int i_block );
|
||||
extern int dvdcss_seek ( dvdcss_handle,
|
||||
int i_blocks );
|
||||
extern int dvdcss_read ( dvdcss_handle,
|
||||
void *p_buffer,
|
||||
int i_blocks,
|
||||
int i_flags );
|
||||
extern int dvdcss_readv ( dvdcss_handle,
|
||||
void *p_iovec,
|
||||
int i_blocks,
|
||||
int i_flags );
|
||||
extern char * dvdcss_error ( dvdcss_handle );
|
||||
|
@ -30,7 +30,6 @@ struct iovec
|
||||
size_t iov_len; /* Length of data. */
|
||||
};
|
||||
|
||||
#if defined( WIN32 )
|
||||
/*****************************************************************************
|
||||
* readv: readv() replacement for iovec-impaired C libraries
|
||||
*****************************************************************************/
|
||||
@ -86,4 +85,3 @@ static __inline int readv( int i_fd, struct iovec *p_iovec, int i_count )
|
||||
return i_total;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -7,10 +7,10 @@
|
||||
# Objects
|
||||
#
|
||||
|
||||
PLUGIN_C = dvd.o input_dvd.o dvd_netlist.o dvd_ioctl.o dvd_ifo.o dvd_udf.o dvd_css.o dvd_summary.o
|
||||
BUILTIN_C = $(PLUGIN_C:%.o=BUILTIN_%.o)
|
||||
PLUGIN_DVD = dvd.o input_dvd.o dvd_netlist.o dvd_ifo.o dvd_udf.o dvd_summary.o
|
||||
BUILTIN_DVD = $(PLUGIN_DVD:%.o=BUILTIN_%.o)
|
||||
|
||||
ALL_OBJ = $(PLUGIN_C) $(BUILTIN_C)
|
||||
ALL_OBJ = $(PLUGIN_DVD) $(BUILTIN_DVD)
|
||||
|
||||
#
|
||||
# Virtual targets
|
||||
@ -18,14 +18,25 @@ ALL_OBJ = $(PLUGIN_C) $(BUILTIN_C)
|
||||
|
||||
include ../../Makefile.modules
|
||||
|
||||
$(PLUGIN_DVD): %.o: .dep/%.d
|
||||
$(PLUGIN_DVD): %.o: %.c
|
||||
$(CC) $(CFLAGS) $(PCFLAGS) $(CFLAGS_DVD) -DPLUGIN -c -o $@ $<
|
||||
|
||||
$(BUILTIN_DVD): BUILTIN_%.o: .dep/%.d
|
||||
$(BUILTIN_DVD): BUILTIN_%.o: %.c
|
||||
$(CC) $(CFLAGS) $(CFLAGS_DVD) -DBUILTIN -c -o $@ $<
|
||||
|
||||
#
|
||||
# Real targets
|
||||
#
|
||||
|
||||
../../lib/dvd.so: $(PLUGIN_C)
|
||||
$(CC) $(PCFLAGS) -o $@ $^ $(PLCFLAGS)
|
||||
../../lib/dvd.so: libdvdcss $(PLUGIN_DVD)
|
||||
$(CC) $(PCFLAGS) -o $@ $(PLUGIN_DVD) $(PLCFLAGS) $(LIB_DVD)
|
||||
|
||||
../../lib/dvd.a: $(BUILTIN_C)
|
||||
ar r $@ $^
|
||||
../../lib/dvd.a: libdvdcss $(BUILTIN_DVD)
|
||||
ar r $@ $(BUILTIN_DVD)
|
||||
$(RANLIB) $@
|
||||
|
||||
libdvdcss:
|
||||
cd ../../ && $(MAKE) libdvdcss
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
* dvd_ifo.h: Structures for ifo parsing
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: dvd_ifo.h,v 1.16 2001/06/07 15:27:44 sam Exp $
|
||||
* $Id: dvd_ifo.h,v 1.17 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -521,7 +521,7 @@ typedef struct time_inf_s
|
||||
typedef struct vts_s
|
||||
{
|
||||
boolean_t b_initialized;
|
||||
off_t i_pos;
|
||||
int i_pos;
|
||||
vts_manager_t manager_inf;
|
||||
vts_title_t title_inf;
|
||||
title_unit_t menu_unit;
|
||||
@ -538,18 +538,17 @@ typedef struct vts_s
|
||||
*/
|
||||
typedef struct ifo_s
|
||||
{
|
||||
int i_fd; /* File descriptor for the device */
|
||||
off_t i_off; /* Offset to video_ts.ifo on the device */
|
||||
off_t i_pos; /* Position of stream pointer */
|
||||
dvdcss_handle dvdhandle; /* File descriptor for the device */
|
||||
int i_start; /* Offset to video_ts.ifo on the device */
|
||||
int i_pos; /* Position of stream pointer */
|
||||
boolean_t b_error; /* Error Management */
|
||||
vmg_t vmg; /* Structure described in video_ts */
|
||||
int i_title; /* Current title number */
|
||||
vts_t vts; /* Vts ifo for current title set */
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
uint8_t p_remap[ 2 * DVD_LB_SIZE ];
|
||||
/* Remap buffer for unaligned reads */
|
||||
#endif
|
||||
/* Remap buffer for unaligned reads */
|
||||
u8 p_remap[ 2 * DVD_LB_SIZE ];
|
||||
|
||||
} ifo_t;
|
||||
|
||||
|
||||
@ -562,3 +561,4 @@ int IfoCreate ( struct thread_dvd_data_s * );
|
||||
int IfoInit ( struct ifo_s * );
|
||||
int IfoTitleSet ( struct ifo_s * );
|
||||
void IfoDestroy ( struct ifo_s * );
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* found in .ifo.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2001 VideoLAN
|
||||
* $Id: dvd_summary.c,v 1.5 2001/06/12 18:16:49 stef Exp $
|
||||
* $Id: dvd_summary.c,v 1.6 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -54,6 +54,8 @@
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#include <videolan/dvdcss.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "threads.h"
|
||||
@ -260,8 +262,8 @@ char * IfoLanguage( u16 i_code )
|
||||
void IfoPrintTitle( thread_dvd_data_t * p_dvd )
|
||||
{
|
||||
intf_WarnMsg( 5, "dvd info: title: %d", p_dvd->i_title );
|
||||
intf_WarnMsg( 5, " vobstart at: %lld", p_dvd->i_start );
|
||||
intf_WarnMsg( 5, " stream size: %lld", p_dvd->i_size );
|
||||
intf_WarnMsg( 5, " vobstart at: %d blocks", p_dvd->i_start );
|
||||
intf_WarnMsg( 5, " stream size: %d blocks", p_dvd->i_size );
|
||||
intf_WarnMsg( 5, " number of chapters: %d", p_dvd->i_chapter_nb );
|
||||
intf_WarnMsg( 5, " number of angles: %d", p_dvd->i_angle_nb );
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
* contains the basic udf handling functions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2001 VideoLAN
|
||||
* $Id: dvd_udf.c,v 1.10 2001/06/07 22:25:42 sam Exp $
|
||||
* $Id: dvd_udf.c,v 1.11 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -55,6 +55,8 @@
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <videolan/dvdcss.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "threads.h"
|
||||
@ -63,7 +65,6 @@
|
||||
#include "intf_msg.h"
|
||||
|
||||
#include "input_dvd.h"
|
||||
#include "dvd_css.h"
|
||||
#include "dvd_ifo.h"
|
||||
|
||||
#include "modules.h"
|
||||
@ -75,15 +76,15 @@
|
||||
|
||||
typedef struct partition_s
|
||||
{
|
||||
boolean_t b_valid;
|
||||
u8 pi_volume_desc[128];
|
||||
u16 i_flags;
|
||||
u16 i_number;
|
||||
u8 pi_contents[32];
|
||||
u32 i_access_type;
|
||||
u32 i_start;
|
||||
u32 i_length;
|
||||
int i_fd;
|
||||
boolean_t b_valid;
|
||||
u8 pi_volume_desc[128];
|
||||
u16 i_flags;
|
||||
u16 i_number;
|
||||
u8 pi_contents[32];
|
||||
u32 i_access_type;
|
||||
u32 i_start;
|
||||
u32 i_length;
|
||||
dvdcss_handle dvdhandle;
|
||||
} partition_t;
|
||||
|
||||
typedef struct ad_s
|
||||
@ -106,41 +107,16 @@ typedef struct ad_s
|
||||
*****************************************************************************
|
||||
* Returns number of read bytes on success, 0 on error
|
||||
*****************************************************************************/
|
||||
static int UDFReadLB( int i_fd, off_t i_lba, size_t i_block_count, u8 *pi_data )
|
||||
static int UDFReadLB( dvdcss_handle dvdhandle, off_t i_lba,
|
||||
size_t i_block_count, u8 *pi_data )
|
||||
{
|
||||
#if !defined( WIN32 )
|
||||
if( i_fd < 0 )
|
||||
#else
|
||||
DWORD read;
|
||||
|
||||
if( (HANDLE) i_fd == INVALID_HANDLE_VALUE )
|
||||
#endif
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined( WIN32 )
|
||||
if( lseek( i_fd, i_lba * (off_t) DVD_LB_SIZE, SEEK_SET ) < 0 )
|
||||
#else
|
||||
if( SetFilePointer( (HANDLE) i_fd, i_lba * (off_t) DVD_LB_SIZE,
|
||||
NULL, FILE_BEGIN ) == -1 )
|
||||
#endif
|
||||
if( dvdcss_seek( dvdhandle, i_lba ) < 0 )
|
||||
{
|
||||
intf_ErrMsg( "UDF: Postion not found" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined( WIN32 )
|
||||
return read( i_fd, pi_data, i_block_count *DVD_LB_SIZE);
|
||||
#else
|
||||
if(!ReadFile( (HANDLE) i_fd, pi_data, i_block_count * DVD_LB_SIZE,
|
||||
&read, NULL) || read != i_block_count * DVD_LB_SIZE )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return read;
|
||||
#endif
|
||||
return dvdcss_read( dvdhandle, pi_data, i_block_count, DVDCSS_NOFLAGS );
|
||||
}
|
||||
|
||||
|
||||
@ -413,7 +389,7 @@ static int UDFMapICB( struct ad_s icb, u8 * pi_file_type, struct ad_s * p_file,
|
||||
|
||||
do
|
||||
{
|
||||
if( !UDFReadLB( partition.i_fd, i_lba++, 1, pi_lb ) )
|
||||
if( !UDFReadLB( partition.dvdhandle, i_lba++, 1, pi_lb ) )
|
||||
{
|
||||
i_tag_id = 0;
|
||||
}
|
||||
@ -457,7 +433,7 @@ static int UDFScanDir( struct ad_s dir, char * psz_filename,
|
||||
#if 0
|
||||
do
|
||||
{
|
||||
if( !UDFReadLB( partition.i_fd, i_lba++, 1, pi_lb ) )
|
||||
if( !UDFReadLB( partition.dvdhandle, i_lba++, 1, pi_lb ) )
|
||||
{
|
||||
i_tag_id = 0;
|
||||
}
|
||||
@ -489,7 +465,7 @@ static int UDFScanDir( struct ad_s dir, char * psz_filename,
|
||||
|
||||
#else
|
||||
|
||||
if( UDFReadLB( partition.i_fd, i_lba, 2, pi_lb ) <= 0 ) {
|
||||
if( UDFReadLB( partition.dvdhandle, i_lba, 2, pi_lb ) <= 0 ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -501,7 +477,7 @@ static int UDFScanDir( struct ad_s dir, char * psz_filename,
|
||||
++i_lba;
|
||||
p -= DVD_LB_SIZE;
|
||||
dir.i_length -= DVD_LB_SIZE;
|
||||
if( UDFReadLB( partition.i_fd, i_lba, 2, pi_lb ) <= 0 )
|
||||
if( UDFReadLB( partition.dvdhandle, i_lba, 2, pi_lb ) <= 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -558,7 +534,7 @@ static int UDFFindPartition( int i_part_nb, struct partition_s *p_partition )
|
||||
/* Search anchor loop */
|
||||
while( 1 )
|
||||
{
|
||||
if( UDFReadLB( p_partition->i_fd, i_lba, 1, pi_anchor ) )
|
||||
if( UDFReadLB( p_partition->dvdhandle, i_lba, 1, pi_anchor ) )
|
||||
{
|
||||
UDFDescriptor( pi_anchor, &i_tag_id );
|
||||
}
|
||||
@ -622,7 +598,7 @@ static int UDFFindPartition( int i_part_nb, struct partition_s *p_partition )
|
||||
|
||||
do
|
||||
{
|
||||
if( !UDFReadLB( p_partition->i_fd, i_lba++, 1, pi_lb ) )
|
||||
if( !UDFReadLB( p_partition->dvdhandle, i_lba++, 1, pi_lb ) )
|
||||
{
|
||||
i_tag_id = 0;
|
||||
}
|
||||
@ -679,7 +655,7 @@ static int UDFFindPartition( int i_part_nb, struct partition_s *p_partition )
|
||||
* starting with '/'.
|
||||
* returns absolute LB number, or 0 on error
|
||||
*****************************************************************************/
|
||||
u32 UDFFindFile( int i_fd, char * psz_path )
|
||||
u32 UDFFindFile( dvdcss_handle dvdhandle, char * psz_path )
|
||||
{
|
||||
struct partition_s partition;
|
||||
struct ad_s root_icb;
|
||||
@ -696,7 +672,7 @@ u32 UDFFindFile( int i_fd, char * psz_path )
|
||||
strcat( psz_tokenline, psz_path );
|
||||
|
||||
/* Init file descriptor of UDF filesystem (== DVD) */
|
||||
partition.i_fd = i_fd;
|
||||
partition.dvdhandle = dvdhandle;
|
||||
|
||||
/* Find partition 0, standard partition for DVD-Video */
|
||||
i_partition = 0;
|
||||
@ -711,7 +687,7 @@ u32 UDFFindFile( int i_fd, char * psz_path )
|
||||
|
||||
do
|
||||
{
|
||||
if( !UDFReadLB( i_fd, i_lba++, 1, pi_lb ) )
|
||||
if( !UDFReadLB( dvdhandle, i_lba++, 1, pi_lb ) )
|
||||
{
|
||||
i_tag_id = 0;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* dvd_udf.h: structures for udf filesystem tools.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2001 VideoLAN
|
||||
* $Id: dvd_udf.h,v 1.2 2001/02/18 01:42:05 stef Exp $
|
||||
* $Id: dvd_udf.h,v 1.3 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -27,4 +27,5 @@
|
||||
/*
|
||||
* Fonctions in dvd_udf.c
|
||||
*/
|
||||
u32 UDFFindFile( int, char * );
|
||||
u32 UDFFindFile( dvdcss_handle, char * );
|
||||
|
||||
|
@ -5,12 +5,12 @@
|
||||
* especially the 2048 bytes logical block size.
|
||||
* It depends on:
|
||||
* -input_netlist used to read packets
|
||||
* -libdvdcss for access and unscrambling
|
||||
* -dvd_ifo for ifo parsing and analyse
|
||||
* -dvd_css for unscrambling
|
||||
* -dvd_udf to find files
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2001 VideoLAN
|
||||
* $Id: input_dvd.c,v 1.70 2001/06/12 18:16:49 stef Exp $
|
||||
* $Id: input_dvd.c,v 1.71 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -49,10 +49,6 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !defined( WIN32 )
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
@ -69,6 +65,8 @@
|
||||
# include <sys/uio.h> /* struct iovec */
|
||||
#endif
|
||||
|
||||
#include <videolan/dvdcss.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "threads.h"
|
||||
@ -88,7 +86,6 @@
|
||||
#include "input_dvd.h"
|
||||
#include "dvd_netlist.h"
|
||||
#include "dvd_ifo.h"
|
||||
#include "dvd_css.h"
|
||||
#include "dvd_summary.h"
|
||||
#include "mpeg_system.h"
|
||||
|
||||
@ -99,10 +96,10 @@
|
||||
|
||||
/* how many blocks DVDRead will read in each loop */
|
||||
#define DVD_BLOCK_READ_ONCE 64
|
||||
#define DVD_DATA_READ_ONCE 4*DVD_BLOCK_READ_ONCE
|
||||
#define DVD_DATA_READ_ONCE (4 * DVD_BLOCK_READ_ONCE)
|
||||
|
||||
/* Size of netlist */
|
||||
#define DVD_NETLIST_SIZE 1024
|
||||
#define DVD_NETLIST_SIZE 2048
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
@ -111,6 +108,8 @@
|
||||
static int DVDProbe ( probedata_t *p_data );
|
||||
static void DVDInit ( struct input_thread_s * );
|
||||
static void DVDEnd ( struct input_thread_s * );
|
||||
static void DVDOpen ( struct input_thread_s * );
|
||||
static void DVDClose ( struct input_thread_s * );
|
||||
static int DVDSetArea ( struct input_thread_s *, struct input_area_s * );
|
||||
static int DVDRead ( struct input_thread_s *, data_packet_t ** );
|
||||
static void DVDSeek ( struct input_thread_s *, off_t );
|
||||
@ -131,8 +130,8 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
|
||||
#define input p_function_list->functions.input
|
||||
p_function_list->pf_probe = DVDProbe;
|
||||
input.pf_init = DVDInit;
|
||||
input.pf_open = NULL; /* Set in DVDInit */
|
||||
input.pf_close = NULL;
|
||||
input.pf_open = DVDOpen;
|
||||
input.pf_close = DVDClose;
|
||||
input.pf_end = DVDEnd;
|
||||
input.pf_read = DVDRead;
|
||||
input.pf_set_area = DVDSetArea;
|
||||
@ -216,6 +215,7 @@ static void DVDInit( input_thread_t * p_input )
|
||||
input_area_t * p_area;
|
||||
int i_title;
|
||||
int i_chapter;
|
||||
int i_ret;
|
||||
int i;
|
||||
|
||||
p_dvd = malloc( sizeof(thread_dvd_data_t) );
|
||||
@ -229,7 +229,35 @@ static void DVDInit( input_thread_t * p_input )
|
||||
p_input->p_plugin_data = (void *)p_dvd;
|
||||
p_input->p_method_data = NULL;
|
||||
|
||||
p_dvd->i_fd = p_input->i_handle;
|
||||
p_dvd->dvdhandle = dvdcss_init( DVDCSS_INIT_QUIET );
|
||||
|
||||
if( p_dvd->dvdhandle == NULL )
|
||||
{
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX: put this shit in an access plugin */
|
||||
if( strlen( p_input->p_source ) > 4
|
||||
&& !strncasecmp( p_input->p_source, "dvd:", 4 ) )
|
||||
{
|
||||
i_ret = dvdcss_open( p_dvd->dvdhandle, p_input->p_source + 4 );
|
||||
}
|
||||
else
|
||||
{
|
||||
i_ret = dvdcss_open( p_dvd->dvdhandle, p_input->p_source );
|
||||
}
|
||||
|
||||
if( i_ret < 0 )
|
||||
{
|
||||
dvdcss_end( p_dvd->dvdhandle );
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
dvdcss_seek( p_dvd->dvdhandle, 0 );
|
||||
|
||||
/* We read DVD_BLOCK_READ_ONCE in each loop, so the input will receive
|
||||
* DVD_DATA_READ_ONCE at most */
|
||||
@ -237,27 +265,9 @@ static void DVDInit( input_thread_t * p_input )
|
||||
/* this value mustn't be modifed */
|
||||
p_input->i_read_once = DVD_DATA_READ_ONCE;
|
||||
|
||||
i = CSSTest( p_input->i_handle );
|
||||
|
||||
if( i < 0 )
|
||||
{
|
||||
intf_ErrMsg( "dvd error: error in css" );
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
p_dvd->b_encrypted = i;
|
||||
|
||||
#if !defined( WIN32 )
|
||||
lseek( p_input->i_handle, 0, SEEK_SET );
|
||||
#else
|
||||
SetFilePointer( (HANDLE) p_input->i_handle, 0, 0, FILE_BEGIN );
|
||||
#endif
|
||||
|
||||
/* Reading structures initialisation */
|
||||
p_input->p_method_data =
|
||||
DVDNetlistInit( DVD_NETLIST_SIZE, 2*DVD_NETLIST_SIZE,
|
||||
DVDNetlistInit( DVD_NETLIST_SIZE, 2 * DVD_NETLIST_SIZE,
|
||||
DVD_NETLIST_SIZE, DVD_LB_SIZE, p_dvd->i_block_once );
|
||||
intf_WarnMsg( 2, "dvd info: netlist initialized" );
|
||||
|
||||
@ -265,6 +275,9 @@ static void DVDInit( input_thread_t * p_input )
|
||||
if( IfoCreate( p_dvd ) < 0 )
|
||||
{
|
||||
intf_ErrMsg( "dvd error: allcation error in ifo" );
|
||||
dvdcss_close( p_dvd->dvdhandle );
|
||||
dvdcss_end( p_dvd->dvdhandle );
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
@ -272,37 +285,14 @@ static void DVDInit( input_thread_t * p_input )
|
||||
if( IfoInit( p_dvd->p_ifo ) < 0 )
|
||||
{
|
||||
intf_ErrMsg( "dvd error: fatal failure in ifo" );
|
||||
IfoDestroy( p_dvd->p_ifo );
|
||||
dvdcss_close( p_dvd->dvdhandle );
|
||||
dvdcss_end( p_dvd->dvdhandle );
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
/* CSS initialisation */
|
||||
if( p_dvd->b_encrypted )
|
||||
{
|
||||
p_dvd->p_css = malloc( sizeof(css_t) );
|
||||
if( p_dvd->p_css == NULL )
|
||||
{
|
||||
intf_ErrMsg( "dvd error: couldn't create css structure" );
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
p_dvd->p_css->i_agid = 0;
|
||||
|
||||
if( CSSInit( p_input->i_handle, p_dvd->p_css ) < 0 )
|
||||
{
|
||||
intf_ErrMsg( "dvd error: fatal failure in css" );
|
||||
free( p_dvd->p_css );
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
intf_WarnMsg( 2, "dvd info: css initialized" );
|
||||
}
|
||||
|
||||
/* Set stream and area data */
|
||||
vlc_mutex_lock( &p_input->stream.stream_lock );
|
||||
|
||||
@ -340,8 +330,8 @@ static void DVDInit( input_thread_t * p_input )
|
||||
area[i]->i_angle = 1;
|
||||
|
||||
/* Offset to vts_i_0.ifo */
|
||||
area[i]->i_plugin_data = p_dvd->p_ifo->i_off +
|
||||
( title_inf.p_attr[i-1].i_start_sector * DVD_LB_SIZE );
|
||||
area[i]->i_plugin_data = p_dvd->p_ifo->i_start +
|
||||
title_inf.p_attr[i-1].i_start_sector;
|
||||
}
|
||||
#undef area
|
||||
|
||||
@ -384,13 +374,14 @@ static void DVDEnd( input_thread_t * p_input )
|
||||
p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data;
|
||||
p_netlist = (dvd_netlist_t *)p_input->p_method_data;
|
||||
|
||||
if( p_dvd->b_encrypted )
|
||||
{
|
||||
free( p_dvd->p_css );
|
||||
}
|
||||
|
||||
IfoDestroy( p_dvd->p_ifo );
|
||||
|
||||
/* Clean up libdvdcss */
|
||||
dvdcss_close( p_dvd->dvdhandle );
|
||||
dvdcss_end( p_dvd->dvdhandle );
|
||||
|
||||
free( p_dvd );
|
||||
|
||||
DVDNetlistEnd( p_netlist );
|
||||
}
|
||||
|
||||
@ -410,7 +401,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
|
||||
int i_audio;
|
||||
int i_spu;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data;
|
||||
|
||||
@ -456,32 +446,12 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
|
||||
i_vts_title,
|
||||
p_dvd->i_title_id );
|
||||
|
||||
/* css title key for current vts */
|
||||
if( p_dvd->b_encrypted )
|
||||
{
|
||||
/* this one is vts number */
|
||||
p_dvd->p_css->i_title =
|
||||
vmg.title_inf.p_attr[p_dvd->i_title-1].i_title_set_num;
|
||||
p_dvd->p_css->i_title_pos =
|
||||
vts.i_pos +
|
||||
vts.manager_inf.i_title_vob_start_sector * DVD_LB_SIZE;
|
||||
|
||||
j = CSSGetKey( p_input->i_handle, p_dvd->p_css );
|
||||
if( j < 0 )
|
||||
{
|
||||
intf_ErrMsg( "dvd error: fatal error in vts css key" );
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return -1;
|
||||
}
|
||||
else if( j > 0 )
|
||||
{
|
||||
intf_ErrMsg( "dvd error: css decryption unavailable" );
|
||||
free( p_dvd );
|
||||
p_input->b_error = 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* CSS cracking has to be done again
|
||||
*/
|
||||
dvdcss_crack( p_dvd->dvdhandle,
|
||||
vmg.title_inf.p_attr[p_dvd->i_title-1].i_title_set_num,
|
||||
vts.i_pos + vts.manager_inf.i_title_vob_start_sector );
|
||||
|
||||
/*
|
||||
* Angle management
|
||||
@ -497,12 +467,13 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
|
||||
* Set selected title start and size
|
||||
*/
|
||||
|
||||
/* title set offset */
|
||||
p_dvd->i_title_start = vts.i_pos + DVD_LB_SIZE *
|
||||
(off_t)( vts.manager_inf.i_title_vob_start_sector );
|
||||
/* title set offset XXX: convert to block values */
|
||||
p_dvd->i_title_start =
|
||||
vts.i_pos + vts.manager_inf.i_title_vob_start_sector;
|
||||
|
||||
/* last video cell */
|
||||
p_dvd->i_cell = 0;
|
||||
intf_FlushMsg();
|
||||
p_dvd->i_prg_cell = -1 +
|
||||
vts.title_unit.p_title[p_dvd->i_title_id-1].title.i_cell_nb;
|
||||
|
||||
@ -520,10 +491,8 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
|
||||
}
|
||||
|
||||
p_dvd->i_sector = 0;
|
||||
p_dvd->i_size = DVD_LB_SIZE *
|
||||
(off_t)( vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector );
|
||||
intf_WarnMsg( 2, "dvd info: stream size 1: %lld @ %d", p_dvd->i_size,
|
||||
vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector );
|
||||
p_dvd->i_size = vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector;
|
||||
intf_WarnMsg( 2, "dvd info: stream size 1: %d", p_dvd->i_size );
|
||||
|
||||
if( DVDChapterSelect( p_dvd, 1 ) < 0 )
|
||||
{
|
||||
@ -532,13 +501,13 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
|
||||
return -1;
|
||||
}
|
||||
|
||||
p_dvd->i_size -= (off_t)( p_dvd->i_sector + 1 ) *DVD_LB_SIZE;
|
||||
p_dvd->i_size -= p_dvd->i_sector + 1;
|
||||
|
||||
IfoPrintTitle( p_dvd );
|
||||
|
||||
/* Area definition */
|
||||
p_input->stream.p_selected_area->i_start = p_dvd->i_start;
|
||||
p_input->stream.p_selected_area->i_size = p_dvd->i_size;
|
||||
p_input->stream.p_selected_area->i_start = LB2OFF( p_dvd->i_start );
|
||||
p_input->stream.p_selected_area->i_size = LB2OFF( p_dvd->i_size );
|
||||
p_input->stream.p_selected_area->i_angle_nb = p_dvd->i_angle_nb;
|
||||
p_input->stream.p_selected_area->i_angle = p_dvd->i_angle;
|
||||
|
||||
@ -755,8 +724,8 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
|
||||
return -1;
|
||||
}
|
||||
|
||||
p_input->stream.p_selected_area->i_tell = p_dvd->i_start -
|
||||
p_area->i_start;
|
||||
p_input->stream.p_selected_area->i_tell =
|
||||
LB2OFF( p_dvd->i_start ) - p_area->i_start;
|
||||
p_input->stream.p_selected_area->i_part = p_dvd->i_chapter;
|
||||
|
||||
intf_WarnMsg( 4, "dvd info: chapter %d start at: %lld",
|
||||
@ -821,7 +790,6 @@ static int DVDRead( input_thread_t * p_input,
|
||||
int i_iovec;
|
||||
int i_packet;
|
||||
int i_pos;
|
||||
int i_read_bytes;
|
||||
int i_read_blocks;
|
||||
off_t i_off;
|
||||
boolean_t b_eof;
|
||||
@ -849,9 +817,8 @@ static int DVDRead( input_thread_t * p_input,
|
||||
}
|
||||
|
||||
/* Position the fd pointer on the right address */
|
||||
i_off = lseek( p_dvd->i_fd,
|
||||
p_dvd->i_title_start +
|
||||
(off_t)( p_dvd->i_sector ) *DVD_LB_SIZE, SEEK_SET );
|
||||
i_off = LB2OFF( dvdcss_seek( p_dvd->dvdhandle,
|
||||
p_dvd->i_title_start + p_dvd->i_sector ) );
|
||||
|
||||
/* update chapter : it will be easier when we have navigation
|
||||
* ES support */
|
||||
@ -883,7 +850,7 @@ static int DVDRead( input_thread_t * p_input,
|
||||
i_block_once = p_dvd->i_end_sector - p_dvd->i_sector + 1;
|
||||
}
|
||||
|
||||
/* the number of blocks read is the maw between the requested
|
||||
/* The number of blocks read is the max between the requested
|
||||
* value and the leaving block in the cell */
|
||||
if( i_block_once > p_dvd->i_block_once )
|
||||
{
|
||||
@ -901,12 +868,8 @@ static int DVDRead( input_thread_t * p_input,
|
||||
}
|
||||
|
||||
/* Reads from DVD */
|
||||
#if !defined( WIN32 )
|
||||
i_read_bytes = readv( p_dvd->i_fd, p_vec, i_block_once );
|
||||
#else
|
||||
i_read_bytes = ReadFileV( p_dvd->i_fd, p_vec, i_block_once );
|
||||
#endif
|
||||
i_read_blocks = ( i_read_bytes + 0x7ff ) >> 11;
|
||||
i_read_blocks = dvdcss_readv( p_dvd->dvdhandle, p_vec,
|
||||
i_block_once, DVDCSS_READ_DECRYPT );
|
||||
|
||||
/* Update netlist indexes: we don't do it in DVDGetiovec since we
|
||||
* need know the real number of blocks read */
|
||||
@ -920,13 +883,6 @@ static int DVDRead( input_thread_t * p_input,
|
||||
/* Read headers to compute payload length */
|
||||
for( i_iovec = 0 ; i_iovec < i_read_blocks ; i_iovec++ )
|
||||
{
|
||||
if( p_dvd->b_encrypted )
|
||||
{
|
||||
CSSDescrambleSector( p_dvd->p_css->pi_title_key,
|
||||
p_vec[i_iovec].iov_base );
|
||||
((u8*)(p_vec[i_iovec].iov_base))[0x14] &= 0x8F;
|
||||
}
|
||||
|
||||
i_pos = 0;
|
||||
|
||||
while( i_pos < p_netlist->i_buffer_size )
|
||||
@ -987,8 +943,9 @@ static int DVDRead( input_thread_t * p_input,
|
||||
|
||||
vlc_mutex_lock( &p_input->stream.stream_lock );
|
||||
|
||||
p_input->stream.p_selected_area->i_tell += i_read_bytes;
|
||||
b_eot = !( p_input->stream.p_selected_area->i_tell < p_dvd->i_size );
|
||||
p_input->stream.p_selected_area->i_tell += LB2OFF( i_read_blocks );
|
||||
b_eot = !( p_input->stream.p_selected_area->i_tell
|
||||
< LB2OFF( p_dvd->i_size ) );
|
||||
b_eof = b_eot && ( ( p_dvd->i_title + 1 ) >= p_input->stream.i_area_nb );
|
||||
|
||||
vlc_mutex_unlock( &p_input->stream.stream_lock );
|
||||
@ -1034,7 +991,6 @@ static int DVDRewind( input_thread_t * p_input )
|
||||
static void DVDSeek( input_thread_t * p_input, off_t i_off )
|
||||
{
|
||||
thread_dvd_data_t * p_dvd;
|
||||
off_t i_pos;
|
||||
int i_prg_cell;
|
||||
int i_cell;
|
||||
int i_chapter;
|
||||
@ -1043,11 +999,8 @@ static void DVDSeek( input_thread_t * p_input, off_t i_off )
|
||||
p_dvd = ( thread_dvd_data_t * )p_input->p_plugin_data;
|
||||
|
||||
/* we have to take care of offset of beginning of title */
|
||||
i_pos = i_off + p_input->stream.p_selected_area->i_start
|
||||
- p_dvd->i_title_start;
|
||||
|
||||
/* update navigation data */
|
||||
p_dvd->i_sector = i_pos >> 11;
|
||||
p_dvd->i_sector = OFF2LB(i_off + p_input->stream.p_selected_area->i_start)
|
||||
- p_dvd->i_title_start;
|
||||
|
||||
i_prg_cell = 0;
|
||||
i_chapter = 0;
|
||||
@ -1128,26 +1081,28 @@ static void DVDSeek( input_thread_t * p_input, off_t i_off )
|
||||
p_dvd->i_chapter = i_chapter;
|
||||
p_input->stream.p_selected_area->i_part = p_dvd->i_chapter;
|
||||
|
||||
#if !defined( WIN32 )
|
||||
p_input->stream.p_selected_area->i_tell =
|
||||
lseek( p_dvd->i_fd, p_dvd->i_title_start +
|
||||
(off_t)( p_dvd->i_sector ) *DVD_LB_SIZE, SEEK_SET ) -
|
||||
p_input->stream.p_selected_area->i_start;
|
||||
#else
|
||||
p_input->stream.p_selected_area->i_tell =
|
||||
SetFilePointer( (HANDLE) p_dvd->i_fd, p_dvd->i_title_start +
|
||||
(off_t)( p_dvd->i_sector ) *DVD_LB_SIZE, NULL, FILE_BEGIN) -
|
||||
p_input->stream.p_selected_area->i_start;
|
||||
|
||||
#endif
|
||||
|
||||
/* intf_WarnMsg( 3, "Program Cell: %d Cell: %d Chapter: %d",
|
||||
LB2OFF ( dvdcss_seek( p_dvd->dvdhandle, p_dvd->i_title_start
|
||||
+ p_dvd->i_sector ) )
|
||||
- p_input->stream.p_selected_area->i_start;
|
||||
/*
|
||||
intf_WarnMsg( 3, "Program Cell: %d Cell: %d Chapter: %d",
|
||||
p_dvd->i_prg_cell, p_dvd->i_cell, p_dvd->i_chapter );
|
||||
*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void DVDOpen ( struct input_thread_s *p_input )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void DVDClose ( struct input_thread_s *p_input )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#define cell p_dvd->p_ifo->vts.cell_inf
|
||||
|
||||
/*****************************************************************************
|
||||
@ -1266,16 +1221,10 @@ static int DVDChapterSelect( thread_dvd_data_t * p_dvd, int i_chapter )
|
||||
}
|
||||
|
||||
/* start is : beginning of vts vobs + offset to vob x */
|
||||
p_dvd->i_start = p_dvd->i_title_start +
|
||||
DVD_LB_SIZE * (off_t)( p_dvd->i_sector );
|
||||
p_dvd->i_start = p_dvd->i_title_start + p_dvd->i_sector;
|
||||
|
||||
/* Position the fd pointer on the right address */
|
||||
#if !defined( WIN32 )
|
||||
p_dvd->i_start = lseek( p_dvd->i_fd, p_dvd->i_start, SEEK_SET );
|
||||
#else
|
||||
p_dvd->i_start = SetFilePointer( (HANDLE) p_dvd->i_fd,
|
||||
p_dvd->i_start, NULL, FILE_BEGIN );
|
||||
#endif
|
||||
p_dvd->i_start = dvdcss_seek( p_dvd->dvdhandle, p_dvd->i_start );
|
||||
|
||||
p_dvd->i_chapter = i_chapter;
|
||||
return 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* input_dvd.h: thread structure of the DVD plugin
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2001 VideoLAN
|
||||
* $Id: input_dvd.h,v 1.23 2001/06/07 22:25:42 sam Exp $
|
||||
* $Id: input_dvd.h,v 1.24 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Author: Stéphane Borel <stef@via.ecp.fr>
|
||||
*
|
||||
@ -26,14 +26,15 @@
|
||||
*****************************************************************************/
|
||||
/* Logical block size for DVD-VIDEO */
|
||||
#define DVD_LB_SIZE 2048
|
||||
#define LB2OFF(x) ((off_t)(x) * (off_t)(DVD_LB_SIZE))
|
||||
#define OFF2LB(x) ((x) >> 11)
|
||||
|
||||
/*****************************************************************************
|
||||
* thread_dvd_data_t: extension of input_thread_t for DVD specificity.
|
||||
*****************************************************************************/
|
||||
typedef struct thread_dvd_data_s
|
||||
{
|
||||
int i_fd; // File descriptor of device
|
||||
boolean_t b_encrypted; // CSS encryption
|
||||
dvdcss_handle dvdhandle; /* libdvdcss handle */
|
||||
|
||||
int i_block_once; // Nb of block read once by
|
||||
// readv
|
||||
@ -55,9 +56,9 @@ typedef struct thread_dvd_data_s
|
||||
int i_sector;
|
||||
int i_end_sector; /* last sector of current cell */
|
||||
|
||||
off_t i_title_start;
|
||||
off_t i_start;
|
||||
off_t i_size;
|
||||
int i_title_start;
|
||||
int i_start;
|
||||
int i_size;
|
||||
|
||||
/* Scrambling Information */
|
||||
struct css_s * p_css;
|
||||
|
2
plugins/kde/.cvsignore
Normal file
2
plugins/kde/.cvsignore
Normal file
@ -0,0 +1,2 @@
|
||||
*.moc
|
||||
.dep
|
@ -7,10 +7,10 @@
|
||||
# Objects
|
||||
#
|
||||
|
||||
PLUGIN_C = sdl.o vout_sdl.o aout_sdl.o
|
||||
BUILTIN_C = $(PLUGIN_C:%.o=BUILTIN_%.o)
|
||||
PLUGIN_SDL = sdl.o vout_sdl.o aout_sdl.o
|
||||
BUILTIN_SDL = $(PLUGIN_SDL:%.o=BUILTIN_%.o)
|
||||
|
||||
ALL_OBJ = $(PLUGIN_C) $(BUILTIN_C)
|
||||
ALL_OBJ = $(PLUGIN_SDL) $(BUILTIN_SDL)
|
||||
|
||||
#
|
||||
# Virtual targets
|
||||
@ -22,18 +22,18 @@ $(PLUGIN_SDL): %.o: .dep/%.d
|
||||
$(PLUGIN_SDL): %.o: %.c
|
||||
$(CC) $(CFLAGS) $(PCFLAGS) $(CFLAGS_SDL) -DPLUGIN -c -o $@ $<
|
||||
|
||||
$(BUILTIN_SDL): BUILTIN_SDL_%.o: .dep/%.d
|
||||
$(BUILTIN_SDL): BUILTIN_SDL_%.o: %.c
|
||||
$(BUILTIN_SDL): BUILTIN_%.o: .dep/%.d
|
||||
$(BUILTIN_SDL): BUILTIN_%.o: %.c
|
||||
$(CC) $(CFLAGS) $(CFLAGS_SDL) -DBUILTIN -c -o $@ $<
|
||||
|
||||
#
|
||||
# Real targets
|
||||
#
|
||||
|
||||
../../lib/sdl.so: $(PLUGIN_C)
|
||||
../../lib/sdl.so: $(PLUGIN_SDL)
|
||||
$(CC) $(PCFLAGS) -o $@ $^ $(PLCFLAGS) $(LIB_SDL)
|
||||
|
||||
../../lib/sdl.a: $(BUILTIN_C)
|
||||
../../lib/sdl.a: $(BUILTIN_SDL)
|
||||
ar r $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* and spawn threads.
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998, 1999, 2000 VideoLAN
|
||||
* $Id: main.c,v 1.101 2001/06/12 11:02:07 reno Exp $
|
||||
* $Id: main.c,v 1.102 2001/06/12 22:14:44 sam Exp $
|
||||
*
|
||||
* Authors: Vincent Seguin <seguin@via.ecp.fr>
|
||||
* Samuel Hocevar <sam@zoy.org>
|
||||
@ -133,6 +133,16 @@
|
||||
#define SHORT_HELP 1
|
||||
#define LONG_HELP 2
|
||||
|
||||
/* Needed for x86 CPU capabilities detection */
|
||||
#define cpuid( a ) \
|
||||
asm volatile ( "cpuid" \
|
||||
: "=a" ( i_eax ), \
|
||||
"=b" ( i_ebx ), \
|
||||
"=c" ( i_ecx ), \
|
||||
"=d" ( i_edx ) \
|
||||
: "a" ( a ) \
|
||||
: "cc" );
|
||||
|
||||
/* Long options */
|
||||
static const struct option longopts[] =
|
||||
{
|
||||
@ -912,7 +922,7 @@ static void InstructionSignalHandler( int i_signal )
|
||||
* to an interface having been destroyed */
|
||||
|
||||
/* Acknowledge the signal received */
|
||||
fprintf(stderr,"illegal instruction : optimization disable\n");
|
||||
fprintf( stderr, "illegal instruction : optimization disabled\n" );
|
||||
|
||||
i_illegal = 1;
|
||||
|
||||
@ -920,9 +930,6 @@ static void InstructionSignalHandler( int i_signal )
|
||||
longjmp( env, 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* CPUCapabilities: list the processors MMX support and other capabilities
|
||||
*****************************************************************************
|
||||
@ -937,8 +944,9 @@ static int CPUCapabilities( void )
|
||||
| CPU_CAPABILITY_586
|
||||
| CPU_CAPABILITY_MMX;
|
||||
|
||||
#elif defined( SYS_DARWIN1_3 )
|
||||
return( i_capabilities );
|
||||
|
||||
#elif defined( SYS_DARWIN1_3 )
|
||||
struct host_basic_info hi;
|
||||
kern_return_t ret;
|
||||
host_name_port_t host;
|
||||
@ -966,21 +974,14 @@ static int CPUCapabilities( void )
|
||||
i_capabilities |= CPU_CAPABILITY_ALTIVEC;
|
||||
}
|
||||
|
||||
return( i_capabilities );
|
||||
|
||||
#elif defined( __i386__ )
|
||||
volatile unsigned int i_eax, i_ebx, i_ecx, i_edx;
|
||||
volatile boolean_t b_amd;
|
||||
|
||||
signal( SIGILL, InstructionSignalHandler );
|
||||
|
||||
# define cpuid( a ) \
|
||||
asm volatile ( "cpuid" \
|
||||
: "=a" ( i_eax ), \
|
||||
"=b" ( i_ebx ), \
|
||||
"=c" ( i_ecx ), \
|
||||
"=d" ( i_edx ) \
|
||||
: "a" ( a ) \
|
||||
: "cc" ); \
|
||||
|
||||
/* test for a 486 CPU */
|
||||
asm volatile ( "pushfl\n\t"
|
||||
"popl %%eax\n\t"
|
||||
@ -1032,19 +1033,20 @@ static int CPUCapabilities( void )
|
||||
|
||||
if( i_edx & 0x02000000 )
|
||||
{
|
||||
|
||||
i_capabilities |= CPU_CAPABILITY_MMXEXT;
|
||||
|
||||
/* We test if OS support the SSE instructions */
|
||||
i_illegal = 0;
|
||||
if(setjmp(env)==0) { /* Test a SSE instruction */
|
||||
__asm__ __volatile__ (
|
||||
"xorps %%xmm0,%%xmm0\n"
|
||||
::);
|
||||
if( setjmp( env ) == 0 )
|
||||
{
|
||||
/* Test a SSE instruction */
|
||||
__asm__ __volatile__ ( "xorps %%xmm0,%%xmm0\n" : : );
|
||||
}
|
||||
|
||||
if( i_illegal != 1 )
|
||||
|
||||
if( i_illegal == 0 )
|
||||
{
|
||||
i_capabilities |= CPU_CAPABILITY_SSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* test for additional capabilities */
|
||||
@ -1062,26 +1064,30 @@ static int CPUCapabilities( void )
|
||||
if( i_edx & 0x80000000 )
|
||||
{
|
||||
i_illegal = 0;
|
||||
if(setjmp(env)==0) { /* Test a 3D Now! instruction */
|
||||
__asm__ __volatile__ (
|
||||
"pfadd %%mm0,%%mm0\n"
|
||||
"femms\n"
|
||||
::);
|
||||
if( setjmp( env ) == 0 )
|
||||
{
|
||||
/* Test a 3D Now! instruction */
|
||||
__asm__ __volatile__ ( "pfadd %%mm0,%%mm0\n" "femms\n" : : );
|
||||
}
|
||||
|
||||
if( i_illegal != 1 )
|
||||
|
||||
if( i_illegal == 0 )
|
||||
{
|
||||
i_capabilities |= CPU_CAPABILITY_3DNOW;
|
||||
}
|
||||
}
|
||||
|
||||
if( b_amd && ( i_edx & 0x00400000 ) )
|
||||
{
|
||||
i_capabilities |= CPU_CAPABILITY_MMXEXT;
|
||||
}
|
||||
#else
|
||||
/* default behaviour */
|
||||
|
||||
#endif
|
||||
signal( SIGILL, NULL );
|
||||
return( i_capabilities );
|
||||
|
||||
#else
|
||||
/* default behaviour */
|
||||
return( i_capabilities );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user