* Usual weekly ChangeLog mass-update.
HEAD
+ * Fully working Windows DVD ioctl support by Jon Lech Johansen.
+ * DirectX enhancements by Gildas Bazin, such as software rendering.
+ * Merged dvdcss_init and dvdcss_open into dvdcss_open, and dvdcss_close
+ and dvdcss_end into dvdcss_close. libdvdcss API now has 7 functions.
+ * Another failed attempt at profiling vlc under Linux: ported the
+ threads API to GNU Pth. Activate with --enable-pth. It doesn't seem to
+ spawn new threads for me, maybe someone will have better luck.
+ * Makefile optimizations.
+ * Automatic build of libdvdcss if not found.
+ * The DVD netlist no longer stops when the fifo is empty ; it just waits
+ until there are free vectors again.
+ * Exported the CSS part of the dvd plugin into a library.
+ * Slight modification in input_dvd since Getiovec wasn't at the right place.
+ * Send escape packet when changing title, not to be stuck in some decoder.
+ * The position in the title is now reset when we change title to
+ prevent a title from being unavailable because we're stuck at the end.
+ * Fixed a bug with 1-chapter-long titles that displayed chapter 0.
+ * Added a _temporary_ field in p_main to know whether the audio stream is
+ AC3 (ugly). It allows a vlc launched in spdif mode to play mpeg or lpcm
+ audio.
+ * Cleaned the title property messages to get rid of the ugly stars.
+ * Added LPCM support. It should work with stereo LPCM.
+ * Fixed a warning when compiling main.c.
+ * Checked that OS supports SSE instructions on PIIIs (to avoid illegal
+ hardware instructions on Linux 2.2.x).
+ * Fixed a bug in synchro reinitialization: we no longer have a shift each
+ time we restart the synchro (for SCR discontinuity for instance)
+ * In DVD mode, we reinit the synchro only if the SCR are not continuous
+ (instead of each cell).
+ * Tried to improve AC3 spdif to prevent desynchronization.
+ * Lots of DirectX plugin fixes by Gildas Bazin.
+ * Compilation fix in message queue mode.
+ * Another FreeBSD compilation fix.
+ * SDL compilation fix for FreeBSD.
+ * Fixed compilation of motion modules as plugins.
+ * Applied old FreeBSD patch for dvd input by German Tischler.
+ * Found what was causing the slowdowns: a namespace collision. Put all
+ plugins into builtins again.
* Put most builtins in plugins again due to performances issues.
* Fixed the painfully slow build process (at last!).
* Added new dummy input plugin.
CFLAGS += -traditional-cpp
endif
-ifneq (,$(findstring mingw32,$(SYS)))
+ifneq (,$(findstring mingw32,$(SYS)))
CFLAGS += -fnative-struct
endif
# C compiler flags: plugin compilation
#
ifneq (,$(findstring mingw32,$(SYS)))
-PCFLAGS += -fPIC -fnative-struct
+PCFLAGS += -fnative-struct
else
PCFLAGS += -fPIC
endif
fi
rm -f conftest*
+
+for ac_hdr in winioctl.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:3385: 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 3390 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3395: \"$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*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+ LIBDVDCSS=1
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
for ac_hdr in sys/ioctl.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3384: checking for $ac_hdr" >&5
+echo "configure:3428: 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 3389 "configure"
+#line 3433 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3394: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3438: \"$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*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3420: checking for $ac_hdr" >&5
+echo "configure:3464: 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 3425 "configure"
+#line 3469 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3430: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3474: \"$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*
BSD_DVD_STRUCT=0
cat > conftest.$ac_ext <<EOF
-#line 3458 "configure"
+#line 3502 "configure"
#include "confdefs.h"
#include <sys/dvdio.h>
EOF
rm -f conftest*
cat > conftest.$ac_ext <<EOF
-#line 3476 "configure"
+#line 3520 "configure"
#include "confdefs.h"
#include <sys/cdio.h>
EOF
fi
cat > conftest.$ac_ext <<EOF
-#line 3500 "configure"
+#line 3544 "configure"
#include "confdefs.h"
#include <linux/cdrom.h>
EOF
enableval="$enable_pth"
if test x$enableval = xyes; then
echo $ac_n "checking for pth_init in -lpth""... $ac_c" 1>&6
-echo "configure:3528: checking for pth_init in -lpth" >&5
+echo "configure:3572: checking for pth_init in -lpth" >&5
ac_lib_var=`echo pth'_'pth_init | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lpth $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3536 "configure"
+#line 3580 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
pth_init()
; return 0; }
EOF
-if { (eval echo configure:3547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3591: \"$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
fi
cat > conftest.$ac_ext <<EOF
-#line 3575 "configure"
+#line 3619 "configure"
#include "confdefs.h"
#include <pth.h>
EOF
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3676: checking for $ac_hdr" >&5
+echo "configure:3720: 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 3681 "configure"
+#line 3725 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3686: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3730: \"$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*
# 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:3777: checking for $ac_word" >&5
+echo "configure:3821: 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
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3842: checking for $ac_hdr" >&5
+echo "configure:3886: 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 3847 "configure"
+#line 3891 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3852: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3896: \"$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*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3923: checking for $ac_hdr" >&5
+echo "configure:3967: 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 3928 "configure"
+#line 3972 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3933: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3977: \"$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*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3971: checking for $ac_hdr" >&5
+echo "configure:4015: 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 3976 "configure"
+#line 4020 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3981: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4025: \"$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*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4025: checking for $ac_hdr" >&5
+echo "configure:4069: 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 4030 "configure"
+#line 4074 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4035: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4079: \"$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*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4073: checking for $ac_hdr" >&5
+echo "configure:4117: 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 4078 "configure"
+#line 4122 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4083: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4127: \"$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*
# 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:4183: checking for $ac_word" >&5
+echo "configure:4227: 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
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4243: checking for $ac_hdr" >&5
+echo "configure:4287: 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 4248 "configure"
+#line 4292 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4253: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4297: \"$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*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4305: checking for $ac_hdr" >&5
+echo "configure:4349: 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 4310 "configure"
+#line 4354 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4315: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4359: \"$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*
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:4353: checking for sys/asoundlib.h" >&5
+echo "configure:4397: 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 4358 "configure"
+#line 4402 "configure"
#include "confdefs.h"
#include <sys/asoundlib.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4363: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4407: \"$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*
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:4380: checking for main in -lasound" >&5
+echo "configure:4424: 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
ac_save_LIBS="$LIBS"
LIBS="-lasound $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4388 "configure"
+#line 4432 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:4395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4439: \"$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
dnl
dnl libdvdcss: check for DVD ioctls
dnl
+
+dnl for windoze
+AC_CHECK_HEADERS(winioctl.h,[
+ LIBDVDCSS=1
+])
+
+dnl for Un*x
AC_CHECK_HEADERS(sys/ioctl.h,[
LIBDVDCSS=1
AC_CHECK_HEADERS(sys/cdio.h sys/dvdio.h linux/cdrom.h)
# (c)2001 VideoLAN
###############################################################################
-include ../../Makefile.opts
+-include ../../Makefile.opts
LIBDVDCSS_VERSION = 0.0.1
LIBDVDCSS_MAJOR = 0
* css.c: Functions for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: css.c,v 1.1 2001/06/12 22:14:44 sam Exp $
+ * $Id: css.c,v 1.2 2001/06/14 02:47:44 sam Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
#ifdef HAVE_UNISTD_H
# include <unistd.h>
-#elif defined( _MSC_VER ) && defined( _WIN32 )
+#elif defined( WIN32 )
# include <io.h>
#endif
off_t i_pos;
boolean_t b_encrypted;
boolean_t b_stop_scanning;
- int i_bytes_read;
+ int i_blocks_read;
int i_best_plen;
int i_best_p;
int i,j;
b_stop_scanning = 0;
/* Position of the title on the disc */
- i_pos = (off_t)DVDCSS_BLOCK_SIZE * (off_t)dvdcss->css.i_title_pos;
+ i_pos = (off_t)dvdcss->css.i_title_pos;
do {
-#if !defined( WIN32 )
- 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) dvdcss->i_fd, i_pos, 0, FILE_BEGIN );
- ReadFile( (HANDLE) dvdcss->i_fd, pi_buf, 0x800, &i_bytes_read, NULL );
-#endif
+ i_pos = dvdcss_seek( dvdcss, i_pos );
+ i_blocks_read = dvdcss_read( dvdcss, pi_buf, 1, DVDCSS_NOFLAGS );
/* PES_scrambling_control */
if( pi_buf[0x14] & 0x30 )
}
}
- i_pos += i_bytes_read;
- } while( i_bytes_read == 0x800 && !b_stop_scanning);
+ i_pos += i_blocks_read;
+ } while( i_blocks_read == 0x1 && !b_stop_scanning);
if( b_stop_scanning)
{
* ioctl.c: DVD ioctl replacement function
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: ioctl.c,v 1.1 2001/06/12 22:14:44 sam Exp $
+ * $Id: ioctl.c,v 1.2 2001/06/14 02:47:44 sam Exp $
*
* Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
* Samuel Hocevar <sam@zoy.org>
static void BeInitRDC ( raw_device_command *, int );
#endif
+/*****************************************************************************
+ * Local prototypes, win32 (aspi) specific
+ *****************************************************************************/
+#if defined( WIN32 )
+static void WinInitSSC ( struct SRB_ExecSCSICmd *, int );
+static int WinSendSSC ( int, struct SRB_ExecSCSICmd * );
+#endif
+
/*****************************************************************************
* ioctl_ReadCopyright: check whether the disc is encrypted or not
*****************************************************************************/
i_ret = 0;
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 p_buffer[ 8 ];
}
else
{
- /* TODO: add WNASPI support for Win9x */
- _dvd_error( dvdcss, "DVD ioctls not functional yet, "
- "assuming disc is unencrypted" );
- *pi_copyright = 0;
- i_ret = 0;
+ INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 );
+
+ ssc.CDBByte[ 6 ] = i_layer;
+ ssc.CDBByte[ 7 ] = DVD_STRUCT_COPYRIGHT;
+
+ i_ret = WinSendSSC( i_fd, &ssc );
+
+ *pi_copyright = p_buffer[ 4 ];
}
#else
memset( p_key, 0x00, 2048 );
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[DVD_DISK_KEY_LENGTH];
}
else
{
- i_ret = -1;
+ INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 );
+
+ ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY;
+ ssc.CDBByte[ 10 ] = *pi_agid << 6;
+
+ i_ret = WinSendSSC( i_fd, &ssc );
+
+ if( i_ret < 0 )
+ {
+ return i_ret;
+ }
+
+ memcpy( p_key, p_buffer + 4, 2048 );
}
#else
*pi_agid = p_buffer[ 7 ] >> 6;
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
ULONG id;
DWORD tmp;
}
else
{
- i_ret = -1;
+ INIT_SSC( GPCMD_REPORT_KEY, 8 );
+
+ ssc.CDBByte[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
+
+ i_ret = WinSendSSC( i_fd, &ssc );
+
+ *pi_agid = p_buffer[ 7 ] >> 6;
}
#else
memcpy( p_challenge, p_buffer + 4, 12 );
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
}
else
{
- i_ret = -1;
+ INIT_SSC( GPCMD_REPORT_KEY, 16 );
+
+ ssc.CDBByte[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
+
+ i_ret = WinSendSSC( i_fd, &ssc );
+
+ memcpy( p_challenge, p_buffer + 4, 12 );
}
#else
*pi_asf = p_buffer[ 7 ] & 1;
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[DVD_ASF_LENGTH];
}
else
{
- i_ret = -1;
+ INIT_SSC( GPCMD_REPORT_KEY, 8 );
+
+ ssc.CDBByte[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6);
+
+ i_ret = WinSendSSC( i_fd, &ssc );
+
+ *pi_asf = p_buffer[ 7 ] & 1;
}
#else
memcpy( p_key, p_buffer + 4, 8 );
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[DVD_BUS_KEY_LENGTH];
}
else
{
- i_ret = -1;
+ INIT_SSC( GPCMD_REPORT_KEY, 12 );
+
+ ssc.CDBByte[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
+
+ i_ret = WinSendSSC( i_fd, &ssc );
+
+ memcpy( p_key, p_buffer + 4, 8 );
}
#else
i_ret = ioctl( i_fd, IODVD_SEND_KEY, &dvdioctl );
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
}
else
{
- i_ret = -1;
+#if defined( __MINGW32__ )
+ INIT_SSC( GPCMD_REPORT_KEY, 0 );
+#else
+ INIT_SSC( GPCMD_REPORT_KEY, 1 );
+
+ ssc.SRB_BufLen = 0;
+ ssc.CDBByte[ 8 ] = 0;
+ ssc.CDBByte[ 9 ] = 0;
+#endif
+
+ ssc.CDBByte[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
+
+ i_ret = WinSendSSC( i_fd, &ssc );
}
#else
return ioctl( i_fd, IODVD_SEND_KEY, &dvdioctl );
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
}
else
{
- return -1;
+ INIT_SSC( GPCMD_SEND_KEY, 16 );
+
+ ssc.CDBByte[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
+
+ p_buffer[ 1 ] = 0xe;
+ memcpy( p_buffer + 4, p_challenge, 12 );
+
+ return WinSendSSC( i_fd, &ssc );
}
#else
return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
#elif defined( WIN32 )
- if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
+ if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[DVD_BUS_KEY_LENGTH];
}
else
{
- return -1;
+ INIT_SSC( GPCMD_SEND_KEY, 12 );
+
+ ssc.CDBByte[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
+
+ p_buffer[ 1 ] = 0xa;
+ memcpy( p_buffer + 4, p_key, 8 );
+
+ return WinSendSSC( i_fd, &ssc );
}
#elif defined( SYS_DARWIN1_3 )
}
#endif
+#if defined( WIN32 )
+/*****************************************************************************
+ * WinInitSSC: initialize a ssc structure for the win32 aspi layer
+ *****************************************************************************
+ * This function initializes a ssc raw device command structure for future
+ * use, either a read command or a write command.
+ *****************************************************************************/
+static void WinInitSSC( struct SRB_ExecSCSICmd *p_ssc, int i_type )
+{
+ memset( p_ssc->SRB_BufPointer, 0, p_ssc->SRB_BufLen );
+
+ switch( i_type )
+ {
+ case GPCMD_SEND_KEY:
+ p_ssc->SRB_Flags = SRB_DIR_OUT;
+ break;
+
+ case GPCMD_READ_DVD_STRUCTURE:
+ case GPCMD_REPORT_KEY:
+ p_ssc->SRB_Flags = SRB_DIR_IN;
+ break;
+ }
+
+ p_ssc->SRB_Cmd = SC_EXEC_SCSI_CMD;
+ p_ssc->SRB_Flags |= SRB_EVENT_NOTIFY;
+
+ p_ssc->CDBByte[ 0 ] = i_type;
+
+ p_ssc->CDBByte[ 8 ] = (u8)(p_ssc->SRB_BufLen >> 8) & 0xff;
+ p_ssc->CDBByte[ 9 ] = (u8) p_ssc->SRB_BufLen & 0xff;
+ p_ssc->SRB_CDBLen = 12;
+
+ p_ssc->SRB_SenseLen = SENSE_LEN;
+}
+
+/*****************************************************************************
+ * WinSendSSC: send a ssc structure to the aspi layer
+ *****************************************************************************/
+static int WinSendSSC( int i_fd, struct SRB_ExecSCSICmd *p_ssc )
+{
+ HANDLE hEvent = NULL;
+ struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
+
+ hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
+ if( hEvent == NULL )
+ {
+ return -1;
+ }
+
+ p_ssc->SRB_PostProc = hEvent;
+ p_ssc->SRB_HaId = LOBYTE( fd->i_sid );
+ p_ssc->SRB_Target = HIBYTE( fd->i_sid );
+
+ ResetEvent( hEvent );
+ if( fd->lpSendCommand( (void*) p_ssc ) == SS_PENDING )
+ WaitForSingleObject( hEvent, INFINITE );
+
+ CloseHandle( hEvent );
+
+ return p_ssc->SRB_Status == SS_COMP ? 0 : -1;
+}
+#endif
* dvd_ioctl.h: DVD ioctl replacement function
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: ioctl.h,v 1.1 2001/06/12 22:14:44 sam Exp $
+ * $Id: ioctl.h,v 1.2 2001/06/14 02:47:44 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
memset( p_buffer, 0, (SIZE) );
#endif
+/*****************************************************************************
+ * Common macro, win32 (ASPI) specific
+ *****************************************************************************/
+#if defined( WIN32 )
+#define INIT_SSC( TYPE, SIZE ) \
+ struct SRB_ExecSCSICmd ssc; \
+ u8 p_buffer[ (SIZE) ]; \
+ memset( &ssc, 0, sizeof( struct SRB_ExecSCSICmd ) ); \
+ ssc.SRB_BufPointer = (char *)p_buffer; \
+ ssc.SRB_BufLen = (SIZE); \
+ WinInitSSC( &ssc, (TYPE) );
+#endif
+
/*****************************************************************************
* Various DVD I/O tables
*****************************************************************************/
#if defined( WIN32 )
+/*****************************************************************************
+ * win32 ioctl specific
+ *****************************************************************************/
+
#define IOCTL_DVD_START_SESSION CTL_CODE(FILE_DEVICE_DVD, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_DVD_READ_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_DVD_SEND_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(FILE_DEVICE_CONTROLLER, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define DVD_CHALLENGE_KEY_LENGTH (12 + sizeof(DVD_COPY_PROTECT_KEY))
-#define DVD_BUS_KEY_LENGTH (8 + sizeof(DVD_COPY_PROTECT_KEY))
-#define DVD_DISK_KEY_LENGTH (2048 + sizeof(DVD_COPY_PROTECT_KEY))
-#define DVD_ASF_LENGTH (sizeof(DVD_ASF) + sizeof(DVD_COPY_PROTECT_KEY))
+#define DVD_CHALLENGE_KEY_LENGTH (12 + sizeof(DVD_COPY_PROTECT_KEY))
+#define DVD_BUS_KEY_LENGTH (8 + sizeof(DVD_COPY_PROTECT_KEY))
+#define DVD_DISK_KEY_LENGTH (2048 + sizeof(DVD_COPY_PROTECT_KEY))
+#define DVD_ASF_LENGTH (sizeof(DVD_ASF) + sizeof(DVD_COPY_PROTECT_KEY))
+
+#define SCSI_IOCTL_DATA_OUT 0
+#define SCSI_IOCTL_DATA_IN 1
typedef ULONG DVD_SESSION_ID, *PDVD_SESSION_ID;
UCHAR Cdb[16];
} SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
-#define SCSI_IOCTL_DATA_OUT 0
-#define SCSI_IOCTL_DATA_IN 1
+/*****************************************************************************
+ * win32 aspi specific
+ *****************************************************************************/
+
+#define WIN2K ( GetVersion() < 0x80000000 )
+#define ASPI_HAID 0
+#define ASPI_TARGET 0
+
+#define SENSE_LEN 0x0E
+#define SC_EXEC_SCSI_CMD 0x02
+#define SC_GET_DISK_INFO 0x06
+#define SS_COMP 0x01
+#define SS_PENDING 0x00
+#define SS_NO_ADAPTERS 0xE8
+#define SRB_DIR_IN 0x08
+#define SRB_DIR_OUT 0x10
+#define SRB_EVENT_NOTIFY 0x40
+
+struct w32_aspidev
+{
+ long hASPI;
+ short i_sid;
+ off_t i_pos;
+ long (*lpSendCommand)( void* );
+};
+
+#pragma pack(1)
+
+struct SRB_GetDiskInfo
+{
+ unsigned char SRB_Cmd;
+ unsigned char SRB_Status;
+ unsigned char SRB_HaId;
+ unsigned char SRB_Flags;
+ unsigned long SRB_Hdr_Rsvd;
+ unsigned char SRB_Target;
+ unsigned char SRB_Lun;
+ unsigned char SRB_DriveFlags;
+ unsigned char SRB_Int13HDriveInfo;
+ unsigned char SRB_Heads;
+ unsigned char SRB_Sectors;
+ unsigned char SRB_Rsvd1[22];
+};
+
+struct SRB_ExecSCSICmd
+{
+ unsigned char SRB_Cmd;
+ unsigned char SRB_Status;
+ unsigned char SRB_HaId;
+ unsigned char SRB_Flags;
+ unsigned long SRB_Hdr_Rsvd;
+ unsigned char SRB_Target;
+ unsigned char SRB_Lun;
+ unsigned short SRB_Rsvd1;
+ unsigned long SRB_BufLen;
+ unsigned char *SRB_BufPointer;
+ unsigned char SRB_SenseLen;
+ unsigned char SRB_CDBLen;
+ unsigned char SRB_HaStat;
+ unsigned char SRB_TargStat;
+ unsigned long *SRB_PostProc;
+ unsigned char SRB_Rsvd2[20];
+ unsigned char CDBByte[16];
+ unsigned char SenseArea[SENSE_LEN+2];
+};
+
+#pragma pack()
#endif
* libdvdcss.c: DVD reading library.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: libdvdcss.c,v 1.2 2001/06/14 01:49:44 sam Exp $
+ * $Id: libdvdcss.c,v 1.3 2001/06/14 02:47:44 sam Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#if defined( WIN32 )
# include <io.h>
#include "videolan/dvdcss.h"
#include "libdvdcss.h"
+#include "ioctl.h"
/*****************************************************************************
* Local prototypes
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 );
+/*****************************************************************************
+ * Local prototypes, win32 specific
+ *****************************************************************************/
+#if defined( WIN32 )
+static int _win32_readv ( int i_fd, struct iovec *p_iovec, int i_blocks );
+static int _win32_aopen ( char c_drive, dvdcss_handle dvdcss );
+static int _win32_aclose ( int i_fd );
+static int _win32_aseek ( int i_fd, off_t i_pos, int i_method );
+static int _win32_aread ( int i_fd, void *p_data, int i_len );
+static int _win32_areadv ( int i_fd, struct iovec *p_iovec, int i_blocks );
+#endif
+
/*****************************************************************************
* dvdcss_open: initialize library, open a DVD device, crack CSS key
*****************************************************************************/
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 )
+ if( WIN2K )
{
- _dvdcss_error( dvdcss, "failed opening device" );
- return -1;
+ char psz_dvd[7];
+ _snprintf( psz_dvd, 7, "\\\\.\\%c:", psz_target[0] );
+ (HANDLE) dvdcss->i_fd =
+ CreateFile( psz_dvd, 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 = _win32_aopen( psz_target[0], dvdcss );
+ if( dvdcss->i_fd == -1 )
+ {
+ _dvdcss_error( dvdcss, "failed opening device" );
+ return -1;
+ }
}
#else
static int _dvdcss_close ( dvdcss_handle dvdcss )
{
#if defined( WIN32 )
- CloseHandle( (HANDLE) dvdcss->i_fd );
+ if( WIN2K )
+ {
+ CloseHandle( (HANDLE) dvdcss->i_fd );
+ }
+ else
+ {
+ _win32_aclose( dvdcss->i_fd );
+ }
#else
close( dvdcss->i_fd );
#endif
off_t i_read;
#if defined( WIN32 )
- i_read = SetFilePointer( (HANDLE) dvdcss->i_fd,
+ if( WIN2K )
+ {
+ i_read = SetFilePointer( (HANDLE) dvdcss->i_fd,
(off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE,
NULL, FILE_BEGIN );
+ }
+ else
+ {
+ i_read = _win32_aseek( dvdcss->i_fd,
+ (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE, SEEK_SET );
+ }
#else
i_read = lseek( dvdcss->i_fd,
(off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE, SEEK_SET );
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_read;
+
+#if defined( WIN32 )
+ if( WIN2K )
+ {
+ if( ReadFile( (HANDLE) dvdcss->i_fd, p_buffer,
(off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE,
&i_read, NULL ) == -1 )
+ {
+ return 0;
+ }
+ }
+ else
{
- return 0;
+ i_read = _win32_aread( dvdcss->i_fd, p_buffer,
+ (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE );
}
-#else
- off_t i_read;
+#else
i_read = read( dvdcss->i_fd, p_buffer,
(off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE );
static int _dvdcss_readv ( dvdcss_handle dvdcss, struct iovec *p_iovec, int i_blocks )
{
off_t i_read;
+
+#if defined( WIN32 )
+ if( WIN2K )
+ {
+ i_read = _win32_readv( dvdcss->i_fd, p_iovec, i_blocks );
+ }
+ else
+ {
+ i_read = _win32_areadv( dvdcss->i_fd, p_iovec, i_blocks );
+ }
+#else
i_read = readv( dvdcss->i_fd, p_iovec, i_blocks );
+#endif
return i_read / DVDCSS_BLOCK_SIZE;
}
+#if defined( WIN32 )
+
+/*****************************************************************************
+ * _win32_readv: vectored read using ReadFile instead of read
+ *****************************************************************************/
+static int _win32_readv( int i_fd, struct iovec *p_iovec, int i_blocks )
+{
+ int i_index, i_len, i_total = 0;
+ char *p_base;
+
+ for( i_index = i_blocks; i_index; i_index-- )
+ {
+ unsigned long i_bytes;
+
+ i_len = p_iovec->iov_len;
+ p_base = p_iovec->iov_base;
+
+ /* Loop is unrolled one time to spare the (i_bytes < 0) test */
+ if( i_len > 0 )
+ {
+ if( !ReadFile( (HANDLE) i_fd, p_base, i_len, &i_bytes, NULL ) )
+ {
+ i_bytes = -1;
+ }
+
+ if( ( i_total == 0 ) && ( i_bytes < 0 ) )
+ {
+ return -1;
+ }
+
+ if( i_bytes <= 0 )
+ {
+ return i_total;
+ }
+
+ i_len -= i_bytes;
+ i_total += i_bytes;
+ p_base += i_bytes;
+
+ while( i_len > 0 )
+ {
+ if( !ReadFile( (HANDLE) i_fd, p_base, i_len, &i_bytes, NULL ) )
+ {
+ return i_total;
+ }
+
+ i_len -= i_bytes;
+ i_total += i_bytes;
+ p_base += i_bytes;
+ }
+ }
+
+ p_iovec++;
+ }
+
+ return i_total;
+}
+
+/*****************************************************************************
+ * _win32_aopen: open dvd drive (load aspi and init w32_aspidev structure)
+ *****************************************************************************/
+static int _win32_aopen( char c_drive, dvdcss_handle dvdcss )
+{
+ HMODULE hASPI;
+ DWORD dwSupportInfo;
+ struct w32_aspidev *fd;
+ int i, j, i_hostadapters;
+ long (*lpGetSupport)( void );
+ long (*lpSendCommand)( void* );
+
+ hASPI = LoadLibrary( "wnaspi32.dll" );
+ if( hASPI == NULL )
+ {
+ _dvdcss_error( dvdcss, "unable to load wnaspi32.dll" );
+ return -1;
+ }
+
+ (FARPROC) lpGetSupport = GetProcAddress( hASPI, "GetASPI32SupportInfo" );
+ (FARPROC) lpSendCommand = GetProcAddress( hASPI, "SendASPI32Command" );
+
+ if(lpGetSupport == NULL || lpSendCommand == NULL )
+ {
+ _dvdcss_debug( dvdcss, "unable to get aspi function pointers" );
+ FreeLibrary( hASPI );
+ return -1;
+ }
+
+ dwSupportInfo = lpGetSupport();
+
+ if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS )
+ {
+ _dvdcss_debug( dvdcss, "no host adapters found (aspi)" );
+ FreeLibrary( hASPI );
+ return -1;
+ }
+
+ if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP )
+ {
+ _dvdcss_error( dvdcss, "unable to initalize aspi layer" );
+ FreeLibrary( hASPI );
+ return -1;
+ }
+
+ i_hostadapters = LOBYTE( LOWORD( dwSupportInfo ) );
+ if( i_hostadapters == 0 )
+ {
+ FreeLibrary( hASPI );
+ return -1;
+ }
+
+ fd = malloc( sizeof( struct w32_aspidev ) );
+ if( fd == NULL )
+ {
+ FreeLibrary( hASPI );
+ return -1;
+ }
+
+ fd->i_pos = 0;
+ fd->hASPI = (long) hASPI;
+ fd->lpSendCommand = lpSendCommand;
+
+ if( !WIN2K )
+ {
+ fd->i_sid = MAKEWORD( ASPI_HAID, ASPI_TARGET );
+ return (int) fd;
+ }
+
+ c_drive = c_drive > 'Z' ? c_drive - 'a' : c_drive - 'A';
+
+ for( i = 0; i < i_hostadapters; i++ )
+ {
+ for( j = 0; j < 15; j++ )
+ {
+ struct SRB_GetDiskInfo srbDiskInfo;
+
+ srbDiskInfo.SRB_Cmd = SC_GET_DISK_INFO;
+ srbDiskInfo.SRB_HaId = i;
+ srbDiskInfo.SRB_Flags = 0;
+ srbDiskInfo.SRB_Hdr_Rsvd = 0;
+ srbDiskInfo.SRB_Target = j;
+ srbDiskInfo.SRB_Lun = 0;
+
+ lpSendCommand( (void*) &srbDiskInfo );
+
+ if( srbDiskInfo.SRB_Status == SS_COMP &&
+ srbDiskInfo.SRB_Int13HDriveInfo == c_drive )
+ {
+ fd->i_sid = MAKEWORD( i, j );
+ return (int) fd;
+ }
+ }
+ }
+
+ free( (void*) fd );
+ FreeLibrary( hASPI );
+ _dvdcss_debug( dvdcss, "unable to get haid and target (aspi)" );
+
+ return( -1 );
+}
+
+/*****************************************************************************
+ * _win32_aclose: close dvd drive (unload aspi and free w32_aspidev structure)
+ *****************************************************************************/
+static int _win32_aclose( int i_fd )
+{
+ struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
+
+ FreeLibrary( (HMODULE) fd->hASPI );
+ free( (void*) i_fd );
+
+ return 0;
+}
+
+/*****************************************************************************
+ * _win32_aseek: aspi version of lseek
+ *****************************************************************************/
+static int _win32_aseek( int i_fd, off_t i_pos, int i_method )
+{
+ int i_oldpos;
+ char sz_buf[ 2048 ];
+ struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
+
+ i_oldpos = fd->i_pos;
+ fd->i_pos = i_pos;
+
+ if( _win32_aread( i_fd, sz_buf, sizeof(sz_buf) ) == -1 )
+ {
+ fd->i_pos = i_oldpos;
+ return -1;
+ }
+
+ fd->i_pos -= sizeof(sz_buf);
+
+ return fd->i_pos;
+}
+
+/*****************************************************************************
+ * _win32_aread: aspi version of read
+ *****************************************************************************/
+static int _win32_aread( int i_fd, void *p_data, int i_len )
+{
+ HANDLE hEvent;
+ char *p_buf = NULL;
+ DWORD dwStart, dwLen;
+ struct SRB_ExecSCSICmd ssc;
+ struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
+
+ memset( &ssc, 0, sizeof( ssc ) );
+
+ dwStart = fd->i_pos / 2048;
+ dwLen = ( i_len % 2048 ? ( i_len / 2048 ) + 1 : ( i_len / 2048 ) ) +
+ (int)( fd->i_pos % 2048 ? 1 : 0 );
+
+ if( fd->i_pos % 2048 || i_len % 2048 )
+ {
+ p_buf = malloc( dwLen * 2048 );
+ if( p_buf == NULL )
+ {
+ return -1;
+ }
+ }
+
+ hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
+ if( hEvent == NULL )
+ {
+ if( p_buf != NULL )
+ {
+ free( p_buf );
+ }
+ return -1;
+ }
+
+ ssc.SRB_Cmd = SC_EXEC_SCSI_CMD;
+ ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY;
+ ssc.SRB_HaId = LOBYTE( fd->i_sid );
+ ssc.SRB_Target = HIBYTE( fd->i_sid );
+ ssc.SRB_SenseLen = SENSE_LEN;
+ ssc.SRB_PostProc = (LPVOID) hEvent;
+
+ ssc.SRB_BufLen = dwLen * 2048;
+ ssc.SRB_BufPointer = p_buf ? p_buf : p_data;
+ ssc.SRB_CDBLen = 12;
+
+ ssc.CDBByte[0] = 0xA8; /* RAW */
+ ssc.CDBByte[2] = (UCHAR) dwStart >> 24;
+ ssc.CDBByte[3] = (UCHAR) (dwStart >> 16) & 0xff;
+ ssc.CDBByte[4] = (UCHAR) (dwStart >> 8) & 0xff;
+ ssc.CDBByte[5] = (UCHAR) (dwStart) & 0xff;
+ ssc.CDBByte[6] = (UCHAR) dwLen >> 24;
+ ssc.CDBByte[7] = (UCHAR) (dwLen >> 16) & 0xff;
+ ssc.CDBByte[8] = (UCHAR) (dwLen >> 8) & 0xff;
+ ssc.CDBByte[9] = (UCHAR) (dwLen) & 0xff;
+
+ ResetEvent( hEvent );
+ if( fd->lpSendCommand( (void*) &ssc ) == SS_PENDING )
+ WaitForSingleObject( hEvent, INFINITE );
+
+ CloseHandle( hEvent );
+
+ if( p_buf != NULL )
+ {
+ memcpy( p_data, p_buf + ( fd->i_pos - ( dwStart * 2048 ) ), i_len );
+ free( p_buf );
+ }
+
+ if(ssc.SRB_Status != SS_COMP)
+ {
+ return -1;
+ }
+
+ fd->i_pos += i_len;
+
+ return i_len;
+}
+
+/*****************************************************************************
+ * _win32_areadv: aspi version of readv
+ *****************************************************************************/
+static int _win32_areadv( int i_fd, struct iovec *p_iovec, int i_blocks )
+{
+ int i_index, i_len, i_total = 0;
+ char *p_base;
+
+ for( i_index = i_blocks; i_index; i_index-- )
+ {
+ register signed int i_bytes;
+
+ i_len = p_iovec->iov_len;
+ p_base = p_iovec->iov_base;
+
+ /* Loop is unrolled one time to spare the (i_bytes < 0) test */
+ if( i_len > 0 )
+ {
+ i_bytes = _win32_aread( i_fd, p_base, i_len );
+
+ if( ( i_total == 0 ) && ( i_bytes < 0 ) )
+ {
+ return -1;
+ }
+
+ if( i_bytes <= 0 )
+ {
+ return i_total;
+ }
+
+ i_len -= i_bytes;
+ i_total += i_bytes;
+ p_base += i_bytes;
+
+ while( i_len > 0 )
+ {
+ i_bytes = _win32_aread( i_fd, p_base, i_len );
+
+ if( i_bytes <= 0 )
+ {
+ return i_total;
+ }
+
+ i_len -= i_bytes;
+ i_total += i_bytes;
+ p_base += i_bytes;
+ }
+ }
+
+ p_iovec++;
+ }
+
+ return i_total;
+}
+
+#endif
* private.h: private DVD reading library data
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: libdvdcss.h,v 1.2 2001/06/14 01:49:44 sam Exp $
+ * $Id: libdvdcss.h,v 1.3 2001/06/14 02:47:44 sam Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
/*****************************************************************************
* Error management
*****************************************************************************/
-#define DVDCSS_ERROR( x... ) fprintf( stderr, "libdvdcss error: %s\n", ##x );
-#define DVDCSS_DEBUG( x... ) fprintf( stderr, "libdvdcss debug: %s\n", ##x );
+#if defined( _WIN32 ) && defined( _MSC_VER )
+# define DVDCSS_ERROR( x ) fprintf( stderr, "libdvdcss error: %s\n", x );
+# define DVDCSS_DEBUG( x ) fprintf( stderr, "libdvdcss debug: %s\n", x );
+#else
+# define DVDCSS_ERROR( x... ) fprintf( stderr, "libdvdcss error: %s\n", ##x );
+# define DVDCSS_DEBUG( x... ) fprintf( stderr, "libdvdcss debug: %s\n", ##x );
+#endif
static __inline__ void _dvdcss_error( dvdcss_handle dvdcss, char *psz_string )
{
/* Define if you have the <videolan/dvdcss.h> header file. */
#undef HAVE_VIDEOLAN_DVDCSS_H
+/* Define if you have the <winioctl.h> header file. */
+#undef HAVE_WINIOCTL_H
+
/* Define if you have the pth library (-lpth). */
#undef HAVE_LIBPTH
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: input_dvd.c,v 1.73 2001/06/14 01:49:44 sam Exp $
+ * $Id: input_dvd.c,v 1.74 2001/06/14 02:47:45 sam Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
input_thread_t * p_input = (input_thread_t *)p_data;
char * psz_name = p_input->p_source;
- int i_handle;
+ dvdcss_handle dvdhandle;
int i_score = 5;
-#if defined( WIN32 )
- char buf[7];
-#endif
if( TestMethod( INPUT_METHOD_VAR, "dvd" ) )
{
psz_name += 4;
}
-#if !defined( WIN32 )
- i_handle = open( psz_name, 0 );
- if( i_handle == -1 )
+ dvdhandle = dvdcss_open( psz_name, DVDCSS_INIT_QUIET );
+ if( dvdhandle == NULL )
{
return( 0 );
}
- close( i_handle );
-#else
- snprintf( buf, 7, "\\\\.\\%c:", psz_name[0] );
- (HANDLE) i_handle = CreateFile( i_score < 90 ? psz_name : buf,
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING, 0, NULL );
- if( (HANDLE) i_handle == INVALID_HANDLE_VALUE )
- {
- return( 0 );
- }
- CloseHandle( (HANDLE) i_handle );
-#endif
return( i_score );
}
* decoders.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.121 2001/06/14 01:49:44 sam Exp $
+ * $Id: input.c,v 1.122 2001/06/14 02:47:45 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
struct stat stat_info;
int i_stat;
-#if defined( WIN32 )
- char buf[7] = { 0 };
-#endif
-
char *psz_name = p_input->p_source;
/* FIXME: this code ought to be in the plugin so that code can
/* get rid of the 'dvd:' stuff and try again */
psz_name += 4;
i_stat = stat( psz_name, &stat_info );
-#if defined( WIN32 )
- _snprintf( buf, 7, "\\\\.\\%c:", psz_name[0] );
-#endif
}
else if( ( i_size > 5 )
&& !strncasecmp( psz_name, "file:", 5 ) )
i_stat = stat( psz_name, &stat_info );
}
- if( i_stat == (-1)
-#if defined( WIN32 )
- && !buf[0]
-#endif
- )
+ if( i_stat == (-1) )
{
intf_ErrMsg( "input error: cannot stat() file `%s' (%s)",
psz_name, strerror(errno));
p_input->stream.b_pace_control = 1;
if( S_ISREG(stat_info.st_mode) || S_ISCHR(stat_info.st_mode)
- || S_ISBLK(stat_info.st_mode)
-#if defined( WIN32 )
- || ( buf[0] && ( ( stat_info.st_size = 0 ) == 0 ) )
-#endif
- )
+ || S_ISBLK(stat_info.st_mode) )
{
p_input->stream.b_seekable = 1;
p_input->stream.p_selected_area->i_size = stat_info.st_size;
vlc_mutex_unlock( &p_input->stream.stream_lock );
intf_WarnMsg( 1, "input: opening file `%s'", p_input->p_source );
-#ifndef WIN32
+#if defined( WIN32 )
+ if( (p_input->i_handle = open( psz_name, O_BINARY ) ) == (-1) )
+#else
if( (p_input->i_handle = open( psz_name,
/*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) )
-#else
- if( ( buf[0] && ( (HANDLE) p_input->i_handle = CreateFile( buf,
- GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING, 0, NULL ) ) == INVALID_HANDLE_VALUE ) ||
- ( !buf[0] && (p_input->i_handle = open( psz_name, O_BINARY ) ) == (-1) ) )
#endif
{
intf_ErrMsg( "input error: cannot open file (%s)", strerror(errno) );
static void FileClose( input_thread_t * p_input )
{
intf_WarnMsg( 1, "input: closing file `%s'", p_input->p_source );
-#if defined( WIN32 )
- if( ( strlen( p_input->p_source ) > 4 ) &&
- !strncasecmp( p_input->p_source, "dvd:", 4 ) )
- {
- CloseHandle( (HANDLE) p_input->i_handle );
- }
- else
-#endif
+
close( p_input->i_handle );
return;
* modules.c : Built-in and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: modules.c,v 1.35 2001/06/14 01:49:44 sam Exp $
+ * $Id: modules.c,v 1.36 2001/06/14 02:47:45 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
#elif defined(HAVE_IMAGE_H) /* BeOS */
# include <image.h>
# define HAVE_DYNAMIC_PLUGINS
-#elif defined(WIN32)
+#elif defined(WIN32) && defined( __MINGW32__ )
# define HAVE_DYNAMIC_PLUGINS
#else
# undef HAVE_DYNAMIC_PLUGINS