* libdvdcss.c: DVD reading library.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: libdvdcss.c,v 1.9 2001/07/25 08:41:21 gbazin Exp $
+ * $Id: libdvdcss.c,v 1.13 2001/07/30 18:56:35 gbazin Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#endif
#if defined( WIN32 )
-# include <io.h>
-# include "input_iovec.h"
+# include <io.h> /* read() */
#else
# include <sys/uio.h> /* struct iovec */
#endif
#include "config.h"
#include "common.h"
+#if defined( WIN32 )
+# include "input_iovec.h"
+#endif
+
#include "videolan/dvdcss.h"
#include "libdvdcss.h"
#include "ioctl.h"
}
/*****************************************************************************
- * dvdcss_crack: crack the current title key
+ * dvdcss_title: crack the current title key if needed
*****************************************************************************/
-extern int dvdcss_crack ( dvdcss_handle dvdcss, int i_block )
+extern int dvdcss_title ( dvdcss_handle dvdcss, int i_block )
{
dvd_title_t *p_title;
dvd_key_t p_key;
return 0;
}
+ //fprintf( stderr, "looking for a key for offset %i\n", i_block );
+
/* Check if we've already cracked this key */
p_title = dvdcss->p_titles;
while( p_title != NULL
return -1;
}
+ //fprintf( stderr, "cracked key is %.2x %.2x %.2x %.2x %.2x\n",
+ // p_key[0], p_key[1], p_key[2], p_key[3], p_key[4] );
+
/* Add key to keytable if it isn't empty */
if( p_key[0] | p_key[1] | p_key[2] | p_key[3] | p_key[4] )
{
p_title = dvdcss->p_titles;
while( p_title != NULL
&& p_title->p_next
- && p_title->p_next->i_startlb < dvdcss->i_seekpos )
+ && p_title->p_next->i_startlb <= dvdcss->i_seekpos )
{
p_title = p_title->p_next;
}
p_title = dvdcss->p_titles;
while( p_title != NULL
&& p_title->p_next != NULL
- && p_title->p_next->i_startlb < dvdcss->i_seekpos )
+ && p_title->p_next->i_startlb <= dvdcss->i_seekpos )
{
p_title = p_title->p_next;
}
static int _dvdcss_seek ( dvdcss_handle dvdcss, int i_blocks )
{
#if defined( WIN32 )
+ dvdcss->i_seekpos = i_blocks;
+
if( WIN2K )
{
LARGE_INTEGER li_read;
/* transfer the next 64kb (_win32_dvdcss_aread is called recursively)
* We need to check the status of the read on return */
- if( _win32_dvdcss_aread( i_fd, p_data + 32 * DVDCSS_BLOCK_SIZE,
+ if( _win32_dvdcss_aread( i_fd, (u8*) p_data + 32 * DVDCSS_BLOCK_SIZE,
i_blocks - 32) < 0 )
{
return -1;