* dvd_css.c: Functions for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_css.c,v 1.7 2001/02/13 10:08:51 stef Exp $
+ * $Id: dvd_css.c,v 1.8 2001/02/14 04:11:01 stef Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
int i_highest;
int i,j,k;
- for( i_title = 0 ; i_title < p_css->i_title_nb ; i_title++ )
+ for( i_title = 0 ; i_title < 1/*p_css->i_title_nb*/ ; i_title++ )
{
/* Initialization for each title */
memset( p_title_key, 0, 10 );
(DVD_key_t*)&pi_buf[0x54], &key);
}
- /* Stop search if we find two occurances of the key */
- if( i_registered_keys == 1 && p_title_key[0].i >= 2 )
+ /* Stop search if we find one occurance of the key
+ * I have never found a DVD for which it is not enough
+ * but we should take care of that */
+ if( i_registered_keys == 1 && p_title_key[0].i >= 1 )
{
b_stop_scanning = 1;
}
* dvd_ifo.c: Functions for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_ifo.c,v 1.6 2001/02/13 10:08:51 stef Exp $
+ * $Id: dvd_ifo.c,v 1.7 2001/02/14 04:11:01 stef Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
static c_adt_t ReadCellInf( ifo_t* p_ifo )
{
c_adt_t c_adt;
- int i, i_max;
off_t i_start = p_ifo->i_pos;
+ int i;
//fprintf( stderr, "CELL ADD\n" );
GETS( &c_adt.i_vob_nb );
FLUSH( 2 );
GETL( &c_adt.i_ebyte );
- i_max = ( i_start + c_adt.i_ebyte + 1 - p_ifo->i_pos ) / sizeof(cell_inf_t);
- c_adt.p_cell_inf = malloc( i_max *sizeof(cell_inf_t) );
+ c_adt.i_cell_nb =
+ ( i_start + c_adt.i_ebyte + 1 - p_ifo->i_pos ) / sizeof(cell_inf_t);
+ c_adt.p_cell_inf = malloc( c_adt.i_cell_nb *sizeof(cell_inf_t) );
if( c_adt.p_cell_inf == NULL )
{
intf_ErrMsg( "Out of memory" );
p_ifo->b_error = 1;
return c_adt;
}
- for( i=0 ; i<i_max ; i++ )
+ for( i = 0 ; i < c_adt.i_cell_nb ; i++ )
{
GETS( &c_adt.p_cell_inf[i].i_vob_id );
GETC( &c_adt.p_cell_inf[i].i_cell_id );
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: input_dvd.c,v 1.9 2001/02/13 10:08:51 stef Exp $
+ * $Id: input_dvd.c,v 1.10 2001/02/14 04:11:01 stef Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
{
thread_dvd_data_t * p_method;
off_t i_start;
+ off_t i_size;
+ int i_cell, i_cell_1, i_start_cell, i_end_cell;
if( (p_method = malloc( sizeof(thread_dvd_data_t) )) == NULL )
{
#endif
}
- /* FIXME: Kludge beginning of vts_01_1.vob */
- i_start = p_method->ifo.p_vts[0].i_pos +
- p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector *DVD_LB_SIZE;
+ /* FIXME: Kludge beginning and end of the stream in vts_01_1.vob */
+ /* Determines which vob contains the movie */
+ i_cell = 0;
+ i_cell_1 = 0;
+ i_start_cell = 0;
+ i_end_cell = 0;
+
+ /* Loop on the number of vobs */
+ while( p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_cell].i_vob_id <=
+ p_method->ifo.p_vts[0].c_adt.i_vob_nb )
+ {
+ i_cell_1 = i_cell;
+
+ /* Loop to find the number of cells in the vob */
+ do
+ {
+ i_cell++;
+ if( i_cell >= p_method->ifo.p_vts[0].c_adt.i_cell_nb )
+ {
+ break;
+ }
+ }
+ while( p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_cell-1].i_cell_id <
+ p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_cell].i_cell_id );
+
+
+ if( p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_cell-1].i_cell_id >
+ p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_end_cell].i_cell_id )
+ {
+ i_start_cell = i_cell_1;
+ i_end_cell = i_cell - 1;
+ }
+ }
+
+ /* The preceding does not work with all DVD, so we give the
+ * last cell of the title as end */
+ i_end_cell = p_method->ifo.p_vts[0].c_adt.i_cell_nb - 1;
+
+ intf_WarnMsg( 2, "DVD: Start cell: %d End Cell: %d",
+ i_start_cell, i_end_cell );
+
+ p_method->i_start_cell = i_start_cell;
+ p_method->i_end_cell = i_end_cell;
+
+ /* start is : beginning of vts + offset to vobs + offset to vob x */
+ i_start = p_method->ifo.p_vts[0].i_pos + DVD_LB_SIZE *
+ ( p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector +
+ p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_start_cell].i_ssector );
+ p_method->i_start_byte = i_start;
+
i_start = lseek( p_input->i_handle, i_start, SEEK_SET );
- intf_WarnMsg( 3, "DVD: VOB start at : %lld", i_start );
+ intf_WarnMsg( 3, "DVD: VOBstart at: %lld", i_start );
+
+ i_size = (off_t)
+ ( p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_end_cell].i_esector -
+ p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_start_cell].i_ssector + 1 )
+ *DVD_LB_SIZE;
+ intf_WarnMsg( 3, "DVD: stream size: %lld", i_size );
+
/* Initialize ES structures */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
}
lseek( p_input->i_handle, i_start, SEEK_SET );
vlc_mutex_lock( &p_input->stream.stream_lock );
- p_input->stream.i_tell = i_start;
+
+ /* i_tell is an indicator from the beginning of the stream,
+ * not of the DVD */
+ p_input->stream.i_tell = 0;
+
if( p_demux_data->b_has_PSM )
{
/* (The PSM decoder will care about spawning the decoders) */
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 );
-
+ /* FIXME : ugly kludge */
+ p_input->stream.i_size = i_size;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.pp_programs[0]->b_is_ok = 0;
- /* 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 );
+ /* FIXME : ugly kludge */
+ p_input->stream.i_size = i_size;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
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 );
+ i_pos = i_off + p_method->i_start_byte;
/* 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;
+ p_input->stream.i_tell = i_pos - p_method->i_start_byte;
return;
}