Commit 6ff20862 authored by Stéphane Borel's avatar Stéphane Borel

-adaptation of DVD module to navigation slider. The seek has to be

done on a multiple of 2048, and shopuld take care of the offset to the
beginning of the stream. It works with most of my DVDs by fails to
detect size of some streams.

-change of the order of call to ifo and css functions in input_dvd.c,
because we can't read ifo files before authentification on some DVDs.

-changed location of some css tables.

-we read ifo date and decrypt css keys for all titles now. It takes quite a
long time to initialize with some DVDs (if you have 42 titles for
instance). The key decryption might give a false value if the title is
less than 10 Mb ; I'm working on that :)
parent 1e19c01b
/*****************************************************************************
* css_table.h : Various tables needed by css unencryption
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: css_table.h,v 1.1 2001/02/08 04:43:27 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
* 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.
*****************************************************************************/
u8 pi_css_mangle0[256] = {
0x00,0x81,0x03,0x82,0x06,0x87,0x05,0x84,0x0C,0x8D,0x0F,0x8E,0x0A,0x8B,0x09,0x88,
0x18,0x99,0x1B,0x9A,0x1E,0x9F,0x1D,0x9C,0x14,0x95,0x17,0x96,0x12,0x93,0x11,0x90,
0x30,0xB1,0x33,0xB2,0x36,0xB7,0x35,0xB4,0x3C,0xBD,0x3F,0xBE,0x3A,0xBB,0x39,0xB8,
0x28,0xA9,0x2B,0xAA,0x2E,0xAF,0x2D,0xAC,0x24,0xA5,0x27,0xA6,0x22,0xA3,0x21,0xA0,
0x60,0xE1,0x63,0xE2,0x66,0xE7,0x65,0xE4,0x6C,0xED,0x6F,0xEE,0x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0,0x42,0xA2,0x92,0xB2,0x41,0xA1,0x91,0xB1,0x47,0xA7,0x97,0xB7,
0x00,0xE0,0xD0,0xF0,0x02,0xE2,0xD2,0xF2,0x01,0xE1,0xD1,0xF1,0x07,0xE7,0xD7,0xF7,
0x80,0x60,0x50,0x70,0x82,0x62,0x52,0x72,0x81,0x61,0x51,0x71,0x87,0x67,0x57,0x77
};
u8 pi_reverse[256] = {
0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF
};
......@@ -2,7 +2,7 @@
* dvd_css.c: Functions for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_css.c,v 1.6 2001/02/12 09:58:06 stef Exp $
* $Id: dvd_css.c,v 1.7 2001/02/13 10:08:51 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -849,7 +849,7 @@ css_t CSSInit( int i_fd )
/* Send key1 to host */
for( i = 0 ; i < KEY_SIZE ; i++ )
{
css.disc.pi_key1[i] = auth_info.lsk.key[4-i];
css.disc.pi_key1[i] = auth_info.lsk.key[4-i];
}
for( i = 0 ; i < 32 ; ++i )
......@@ -857,7 +857,7 @@ css_t CSSInit( int i_fd )
CSSCryptKey( 0, i, css.disc.pi_challenge,
css.disc.pi_key_check );
if( memcmp( css.disc.pi_key_check,
if( memcmp( css.disc.pi_key_check,
css.disc.pi_key1, KEY_SIZE ) == 0 )
{
intf_WarnMsg( 3, "CSS: Drive Authentic - using varient %d", i);
......@@ -884,14 +884,14 @@ css_t CSSInit( int i_fd )
}
/* Send challenge to host */
for( i = 0 ; i < 10 ; ++i )
for( i = 0 ; i < 10 ; ++i )
{
css.disc.pi_challenge[i] = auth_info.hsc.chal[9-i];
css.disc.pi_challenge[i] = auth_info.hsc.chal[9-i];
}
CSSCryptKey( 1, css.disc.i_varient, css.disc.pi_challenge,
css.disc.pi_key2 );
auth_info.type = DVD_HOST_SEND_KEY2;
auth_info.type = DVD_HOST_SEND_KEY2;
/* Get key2 from host */
for( i = 0 ; i < KEY_SIZE ; ++i )
......@@ -953,7 +953,7 @@ css_t CSSInit( int i_fd )
css.b_error = 1;
return css;
}
#if 0
#if 1
/* Unencrypt disc key using bus key */
for( i = 0 ; i < sizeof(dvd.disckey.value) ; i++ )
{
......@@ -985,30 +985,40 @@ int CSSGetKeys( css_t * p_css )
* with Frank A. Stevenson algorithm.
* Does not use any player key table and ioctls.
*/
u8 pi_buf[0x800] ;
DVD_key_t my_key;
title_key_t title_key[10] ;
off_t i_pos = 0;
boolean_t b_encrypted = 0;
boolean_t b_stop_scanning = 0 ;
u8 pi_buf[0x800] ;
DVD_key_t key;
title_key_t p_title_key[10] ;
off_t i_pos;
boolean_t b_encrypted;
boolean_t b_stop_scanning;
int i_title;
int i_bytes_read;
int i_best_plen;
int i_best_p;
int i_registered_keys = 0 ;
int i_total_keys_found = 0 ;
int i_highest= 0;
int i_registered_keys;
int i_total_keys_found;
int i_highest;
int i,j,k;
int i_fd = p_css->i_fd;
for( i_title=0 ; i_title<1/*p_css->i_title_nb*/ ; i_title++ )
for( i_title = 0 ; i_title < p_css->i_title_nb ; i_title++ )
{
/* Initialization for each title */
memset( p_title_key, 0, 10 );
memset( &key, 0, 10 );
b_encrypted = 0;
b_stop_scanning = 0;
i_registered_keys = 0 ;
i_total_keys_found = 0 ;
i_highest = 0;
/* Position of the title on the disc */
i_pos = p_css->p_title_key[i_title].i;
//fprintf( stderr, "CSS %d start pos: %lld\n", i_title, i_pos );
do {
i_pos = lseek( i_fd, i_pos, SEEK_SET );
i_bytes_read = read( i_fd, pi_buf, 0x800 );
i_pos = lseek( p_css->i_fd, i_pos, SEEK_SET );
i_bytes_read = read( p_css->i_fd, pi_buf, 0x800 );
/* PES_scrambling_control */
if( pi_buf[0x14] & 0x30 )
......@@ -1035,16 +1045,16 @@ int CSSGetKeys( css_t * p_css )
i = CSSCracker( 0, &pi_buf[0x80],
&pi_buf[0x80 - ( i_best_plen / i_best_p) *i_best_p],
(DVD_key_t*)&pi_buf[0x54],
&my_key );
&key );
while( i>=0 )
{
k = 0;
for( j=0 ; j<i_registered_keys ; j++ )
{
if( memcmp( &(title_key[j].key),
&my_key, sizeof(DVD_key_t) ) == 0 )
if( memcmp( &(p_title_key[j].key),
&key, sizeof(DVD_key_t) ) == 0 )
{
title_key[j].i++;
p_title_key[j].i++;
i_total_keys_found++;
k = 1;
}
......@@ -1052,19 +1062,18 @@ int CSSGetKeys( css_t * p_css )
if( k == 0 )
{
memcpy( &(title_key[i_registered_keys].key),
&my_key,
sizeof(DVD_key_t) );
title_key[i_registered_keys++].i = 1;
memcpy( &(p_title_key[i_registered_keys].key),
&key, sizeof(DVD_key_t) );
p_title_key[i_registered_keys++].i = 1;
i_total_keys_found++;
}
i = CSSCracker( i, &pi_buf[0x80],
&pi_buf[0x80 -( i_best_plen / i_best_p) *i_best_p],
(DVD_key_t*)&pi_buf[0x54], &my_key);
(DVD_key_t*)&pi_buf[0x54], &key);
}
/* Stop search if we find two occurances of the key */
if( i_registered_keys == 1 && title_key[0].i >= 2 )
if( i_registered_keys == 1 && p_title_key[0].i >= 2 )
{
b_stop_scanning = 1;
}
......@@ -1076,7 +1085,7 @@ int CSSGetKeys( css_t * p_css )
if( b_stop_scanning)
{
intf_WarnMsg( 3,
intf_WarnMsg( 1,
"CSS: Found enough occurancies of the same key." );
}
......@@ -1088,26 +1097,29 @@ int CSSGetKeys( css_t * p_css )
if( b_encrypted && i_registered_keys == 0 )
{
intf_WarnMsg( 3 , "CSS: Unable to determine keys from file.");
intf_ErrMsg( "CSS: Unable to determine keys from file.");
return(1);
}
for( i=0 ; i<i_registered_keys-1 ; i++ )
for( i = 0 ; i < i_registered_keys - 1 ; i++ )
{
for( j=i+1 ; j<i_registered_keys ; j++ )
for( j = i + 1 ; j < i_registered_keys ; j++ )
{
if( title_key[j].i > title_key[i].i )
if( p_title_key[j].i > p_title_key[i].i )
{
memcpy( &my_key, &(title_key[j].key), sizeof(DVD_key_t) );
k = title_key[j].i;
memcpy( &(title_key[j].key),
&(title_key[i].key), sizeof(DVD_key_t) );
title_key[j].i = title_key[i].i;
memcpy( &(title_key[i].key),&my_key, sizeof(DVD_key_t) );
title_key[i].i = k;
memcpy( &key, &(p_title_key[j].key), sizeof(DVD_key_t) );
k = p_title_key[j].i;
memcpy( &(p_title_key[j].key),
&(p_title_key[i].key), sizeof(DVD_key_t) );
p_title_key[j].i = p_title_key[i].i;
memcpy( &(p_title_key[i].key),&key, sizeof(DVD_key_t) );
p_title_key[i].i = k;
}
}
}
i_highest = 0;
#ifdef STATS
intf_WarnMsg( 1, " Key(s) & key probability\n---------------------");
#endif
......@@ -1115,13 +1127,13 @@ int CSSGetKeys( css_t * p_css )
{
#ifdef STATS
intf_WarnMsg( 1, "%d) %02X %02X %02X %02X %02X - %3.2f%%", i,
title_key[i].key[0], title_key[i].key[1],
title_key[i].key[2], title_key[i].key[3],
title_key[i].key[4],
title_key[i].i * 100.0 / i_total_keys_found );
p_title_key[i].key[0], p_title_key[i].key[1],
p_title_key[i].key[2], p_title_key[i].key[3],
p_title_key[i].key[4],
p_title_key[i].i * 100.0 / i_total_keys_found );
#endif
if( title_key[i_highest].i * 100.0 / i_total_keys_found
<= title_key[i].i*100.0 / i_total_keys_found )
if( p_title_key[i_highest].i * 100.0 / i_total_keys_found
<= p_title_key[i].i*100.0 / i_total_keys_found )
{
i_highest = i;
}
......@@ -1133,15 +1145,15 @@ int CSSGetKeys( css_t * p_css )
* produces multiple keys (RT)
*/
intf_WarnMsg( 3, "CSS: Title %d key: %02X %02X %02X %02X %02X",
i_title+1,
title_key[i_highest].key[0],
title_key[i_highest].key[1],
title_key[i_highest].key[2],
title_key[i_highest].key[3],
title_key[i_highest].key[4] );
i_title + 1,
p_title_key[i_highest].key[0],
p_title_key[i_highest].key[1],
p_title_key[i_highest].key[2],
p_title_key[i_highest].key[3],
p_title_key[i_highest].key[4] );
memcpy( p_css->p_title_key[i_title].key,
title_key[i_highest].key, KEY_SIZE );
p_title_key[i_highest].key, KEY_SIZE );
}
return 0;
......
......@@ -2,7 +2,7 @@
* dvd_css.h: Structures for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_css.h,v 1.1 2001/02/08 04:43:27 sam Exp $
* $Id: dvd_css.h,v 1.2 2001/02/13 10:08:51 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -35,10 +35,10 @@ typedef struct disc_s
typedef struct title_key_s
{
u32 i; /* This signification of this parameter
off_t i; /* This signification of this parameter
depends on the function it is called from :
*from DVDInit -> i == i_lba
*from CSSGetKeys -> i == i_occ */
*from DVDInit -> i == position
*from CSSGetKeys -> i == nb occurence */
DVD_key_t key;
} title_key_t;
......
......@@ -2,7 +2,7 @@
* dvd_ifo.c: Functions for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.c,v 1.5 2001/02/12 09:58:06 stef Exp $
* $Id: dvd_ifo.c,v 1.6 2001/02/13 10:08:51 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -1096,7 +1096,7 @@ void IfoRead( ifo_t* p_ifo )
off_t i_off;
/* Video Manager Initialization */
intf_WarnMsg( 2, "Ifo: Initializing VMG" );
intf_WarnMsg( 2, "ifo: initializing VMG" );
p_ifo->vmg = ReadVMG( p_ifo );
/* Video Title Sets initialization */
......@@ -1107,13 +1107,14 @@ void IfoRead( ifo_t* p_ifo )
p_ifo->b_error = 1;
return;
}
for( i=0 ; i<1/*p_ifo->vmg.mat.i_tts_nb*/ ; i++ )
for( i=0 ; i<p_ifo->vmg.mat.i_tts_nb ; i++ )
{
intf_WarnMsg( 2, "Ifo: Initializing VTS %d", i+1 );
intf_WarnMsg( 2, "ifo: initializing VTS %d", i+1 );
i_off = p_ifo->vmg.ptt_srpt.p_tts[i].i_ssector *DVD_LB_SIZE;
i_off = (off_t)(p_ifo->vmg.ptt_srpt.p_tts[i].i_ssector) *DVD_LB_SIZE;
p_ifo->i_pos = lseek( p_ifo->i_fd, i_off, SEEK_SET );
//fprintf( stderr, "%lld\n" , p_ifo->i_pos );
/* FIXME : use udf filesystem to avoid this */
IfoFindVTS( p_ifo );
......
......@@ -2,7 +2,7 @@
* dvd_ifo.h: Structures for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.h,v 1.3 2001/02/09 03:51:42 stef Exp $
* $Id: dvd_ifo.h,v 1.4 2001/02/13 10:08:51 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -451,7 +451,7 @@ typedef struct vts_tmap_ti_s
*/
typedef struct vts_s
{
u32 i_pos;
off_t i_pos;
vtsi_mat_t mat;
/* Part Of Title Search Pointer Table Info */
vts_ptt_srpt_t ptt_srpt;
......
......@@ -10,7 +10,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.8 2001/02/12 09:58:06 stef Exp $
* $Id: input_dvd.c,v 1.9 2001/02/13 10:08:51 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -80,8 +80,6 @@ static int DVDProbe ( probedata_t *p_data );
static int DVDCheckCSS ( struct input_thread_s * );
static int DVDRead ( struct input_thread_s *, data_packet_t ** );
static void DVDInit ( struct input_thread_s * );
static void DVDOpen ( struct input_thread_s * );
static void DVDClose ( struct input_thread_s * );
static void DVDEnd ( struct input_thread_s * );
static void DVDSeek ( struct input_thread_s *, off_t );
static int DVDRewind ( struct input_thread_s * );
......@@ -95,8 +93,8 @@ void 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 = DVDOpen;
input.pf_close = DVDClose;
input.pf_open = input_FileOpen;
input.pf_close = input_FileClose;
input.pf_end = DVDEnd;
input.pf_read = DVDRead;
input.pf_demux = input_DemuxPS;
......@@ -163,7 +161,7 @@ static void DVDInit( input_thread_t * p_input )
/* FIXME: read several packets once */
p_method->i_read_once = 1;
p_method->i_title = 0;
p_method->b_encrypted = DVDCheckCSS( p_input );
lseek( p_input->i_handle, 0, SEEK_SET );
......@@ -173,23 +171,39 @@ static void DVDInit( input_thread_t * p_input )
/* Ifo initialisation */
p_method->ifo = IfoInit( p_input->i_handle );
IfoRead( &(p_method->ifo) );
intf_Msg( "Ifo: Initialized" );
/* CSS authentication and keys */
if( ( p_method->b_encrypted = DVDCheckCSS( p_input ) ) )
/* CSS initialisation */
if( p_method->b_encrypted )
{
#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
int i;
#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
p_method->css = CSSInit( p_input->i_handle );
if( ( p_input->b_error = p_method->css.b_error ) )
{
fprintf( stderr, " boaruf \n" );
intf_ErrMsg( "CSS fatal error" );
return;
}
#else
intf_ErrMsg( "Unscrambling not supported" );
p_input->b_error = 1;
return;
#endif
}
/* Ifo structures reading */
IfoRead( &(p_method->ifo) );
intf_WarnMsg( 3, "Ifo: Initialized" );
/* CSS title keys */
if( p_method->b_encrypted )
{
#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
int i;
p_method->css.i_title_nb = p_method->ifo.vmg.mat.i_tts_nb;
if( (p_method->css.p_title_key =
malloc( p_method->css.i_title_nb *sizeof(title_key_t) ) ) == NULL )
{
......@@ -197,16 +211,21 @@ static void DVDInit( input_thread_t * p_input )
p_input->b_error = 1;
return;
}
for( i=0 ; i<p_method->css.i_title_nb ; i++ )
{
p_method->css.p_title_key[i].i =
p_method->ifo.p_vts[i].i_pos +
p_method->ifo.p_vts[i].mat.i_tt_vobs_ssector *DVD_LB_SIZE;
p_method->ifo.p_vts[i].i_pos +
p_method->ifo.p_vts[i].mat.i_tt_vobs_ssector * DVD_LB_SIZE;
}
CSSGetKeys( &(p_method->css) );
intf_Msg( "CSS: Initialized" );
intf_WarnMsg( 3, "CSS: initialized" );
#else
intf_ErrMsg( "Unscrambling not supported" );
p_input->b_error = 1;
return;
#endif
}
......@@ -215,7 +234,7 @@ static void DVDInit( input_thread_t * p_input )
p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector *DVD_LB_SIZE;
i_start = lseek( p_input->i_handle, i_start, SEEK_SET );
intf_Msg( "VOB start at : %lld", (long long)i_start );
intf_WarnMsg( 3, "DVD: VOB start at : %lld", i_start );
/* Initialize ES structures */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
......@@ -267,7 +286,7 @@ static void DVDInit( input_thread_t * p_input )
}
lseek( p_input->i_handle, i_start, SEEK_SET );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.i_tell = 0;
p_input->stream.i_tell = i_start;
if( p_demux_data->b_has_PSM )
{
/* (The PSM decoder will care about spawning the decoders) */
......@@ -339,6 +358,14 @@ static void DVDInit( input_thread_t * p_input )
#ifdef STATS
input_DumpStream( p_input );
#endif
/* FIXME: kludge to implement file size */
p_input->stream.i_size =
(off_t)( p_method->ifo.vmg.ptt_srpt.p_tts[1].i_ssector -
p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector ) *DVD_LB_SIZE;
intf_WarnMsg( 3, "DVD: stream size: %lld", p_input->stream.i_size );
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else
......@@ -346,45 +373,16 @@ static void DVDInit( input_thread_t * p_input )
/* The programs will be added when we read them. */
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.pp_programs[0]->b_is_ok = 0;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
}
/*****************************************************************************
* DVDOpen : open the dvd device
*****************************************************************************/
static void DVDOpen( input_thread_t * p_input )
{
intf_Msg( "input: opening DVD %s", p_input->p_source );
p_input->i_handle = open( p_input->p_source, O_RDONLY | O_NONBLOCK );
/* FIXME: kludge to implement file size */
p_input->stream.i_size =
( p_method->ifo.vmg.ptt_srpt.p_tts[1].i_ssector -
p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector ) *DVD_LB_SIZE;
intf_WarnMsg( 3, "DVD: stream size: %lld", p_input->stream.i_size );
if( p_input->i_handle == -1 )
{
intf_ErrMsg( "input error: cannot open device (%s)", strerror(errno) );
p_input->b_error = 1;
return;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_pace_control = 1;
p_input->stream.b_seekable = 1;
p_input->stream.i_size = 0;
p_input->stream.i_tell = 0;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
/*****************************************************************************
* DVDClose : close a file descriptor
*****************************************************************************/
static void DVDClose( input_thread_t * p_input )
{
close( p_input->i_handle );
return;
}
/*****************************************************************************
......@@ -527,5 +525,21 @@ 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_method;
off_t i_pos;
p_method = ( 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_method->ifo.p_vts[0].i_pos +
p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector *DVD_LB_SIZE );
/* With DVD, we have to be on a sector boundary */
i_pos = i_pos & (~0x7ff);
i_pos = lseek( p_input->i_handle, i_pos, SEEK_SET );
p_input->stream.i_tell = i_pos;
return;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment