Commit ff77ef78 authored by Stéphane Borel's avatar Stéphane Borel

-New method using netlist to read packets on DVD device by sectors of

2048 bytes.
-Some modifications in netlist to make it work with DVD.
-Fixed � bug in mpeg_system.c

We use INPUT_READ_ONCE many times in the input code. I think that
we should replace it with a field in input_thread_t to give more
flexibility to modules. I have done it in DVD plugin but it can't work
if input.c is limited by INPUT_READ_ONCE.

The DVD method is slower than input_ps ; but there are things to
improve.
CSS descrambling is broken.
parent 7cb79b9f
......@@ -2,6 +2,7 @@
* css_table.h : Various tables needed by css unencryption
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: css_table.h,v 1.2 2001/02/08 01:34:41 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......
......@@ -2,6 +2,7 @@
* dvd_css.c: Functions for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_css.c,v 1.5 2001/02/08 01:34:41 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -46,6 +47,8 @@
#include "intf_msg.h"
#include "dvd_css.h"
#include "dvd_ifo.h"
#include "input_dvd.h"
#include "css_table.h"
/*****************************************************************************
......@@ -658,6 +661,25 @@ static int CSScracker( int StartVal,
* Authentication and keys
*/
/*****************************************************************************
* CSSTest : check if the disc is encrypted or not
*****************************************************************************/
int CSSTest( int i_fd )
{
dvd_struct dvd;
dvd.type = DVD_STRUCT_COPYRIGHT;
dvd.copyright.layer_num = 0;
if( ioctl( i_fd, DVD_READ_STRUCT, &dvd ) < 0 )
{
intf_ErrMsg( "DVD ioctl error" );
return -1;
}
return dvd.copyright.cpst;
}
/*****************************************************************************
* CSSInit : CSS Structure initialisation and DVD authentication.
*****************************************************************************/
......
......@@ -2,6 +2,7 @@
* dvd_css.h: Structures for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_css.h,v 1.5 2001/02/08 01:34:41 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -19,7 +20,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
#define KEY_SIZE 5
typedef u8 DVD_key_t[KEY_SIZE];
......@@ -52,11 +52,3 @@ typedef struct css_s
int i_title_nb;
title_key_t* p_title_key;
} css_t;
/*****************************************************************************
* Prototypes in dvd_css.c
*****************************************************************************/
struct css_s CSSInit ( int );
int CSSGetKeys ( struct css_s* );
int CSSDescrambleSector( DVD_key_t , u8* );
#endif
......@@ -2,6 +2,7 @@
* dvd_ifo.c: Functions for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.c,v 1.7 2001/02/08 01:34:41 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -33,6 +34,7 @@
#include "intf_msg.h"
#include "dvd_ifo.h"
#include "input_dvd.h"
/*
* IFO Management.
......@@ -176,8 +178,7 @@ void IfoEnd( ifo_t* p_ifo )
/*fprintf(stderr, "Pos : %lld Val : %llx\n", \
(long long)(p_ifo->i_pos - i_start), \
(long long)*(p_field) ); */ \
p_ifo->i_pos = \
lseek64( p_ifo->i_fd, p_ifo->i_pos + (i_len), SEEK_SET );\
p_ifo->i_pos += i_len; \
}
#define GETC( p_field ) \
......@@ -186,7 +187,7 @@ void IfoEnd( ifo_t* p_ifo )
/*fprintf(stderr, "Pos : %lld Value : %d\n", \
(long long)(p_ifo->i_pos - i_start), \
*(p_field) );*/ \
p_ifo->i_pos = lseek64( p_ifo->i_fd , p_ifo->i_pos + 1 , SEEK_SET );\
p_ifo->i_pos += 1; \
}
#define GETS( p_field ) \
......@@ -196,7 +197,7 @@ void IfoEnd( ifo_t* p_ifo )
/*fprintf(stderr, "Pos : %lld Value : %d\n", \
(long long)(p_ifo->i_pos - i_start), \
*(p_field) );*/ \
p_ifo->i_pos = lseek64( p_ifo->i_fd , p_ifo->i_pos + 2 , SEEK_SET );\
p_ifo->i_pos += 2; \
}
#define GETL( p_field ) \
......@@ -206,7 +207,7 @@ void IfoEnd( ifo_t* p_ifo )
/*fprintf(stderr, "Pos : %lld Value : %d\n", \
(long long)(p_ifo->i_pos - i_start), \
*(p_field) );*/ \
p_ifo->i_pos = lseek64( p_ifo->i_fd , p_ifo->i_pos + 4 , SEEK_SET );\
p_ifo->i_pos += 4; \
}
#define GETLL( p_field ) \
......@@ -216,7 +217,7 @@ void IfoEnd( ifo_t* p_ifo )
/*fprintf(stderr, "Pos : %lld Value : %lld\n", \
(long long)(p_ifo->i_pos - i_start), \
*(p_field) );*/ \
p_ifo->i_pos = lseek64( p_ifo->i_fd , p_ifo->i_pos + 8 , SEEK_SET );\
p_ifo->i_pos += 8; \
}
#define FLUSH( i_len ) \
......@@ -246,9 +247,8 @@ void IfoEnd( ifo_t* p_ifo )
(int)((p_com)->i_sub_cmd), \
(int)((p_com)->i_v0), \
(int)((p_com)->i_v2), \
(int)((p_com)->i_v4) );*/ \
p_ifo->i_pos = \
lseek64( p_ifo->i_fd, p_ifo->i_pos + 8, SEEK_SET ); \
(int)((p_com)->i_v4) ); */ \
p_ifo->i_pos += 8; \
}
static pgc_t ReadPGC( ifo_t* p_ifo )
......@@ -1110,19 +1110,70 @@ void IfoRead( ifo_t* p_ifo )
/*
* IFO virtual machine : a set of commands that give the behaviour of the dvd
*/
#if 0
/*****************************************************************************
* CommandRead : translates the command strings in ifo into command
* structures.
*****************************************************************************/
ifo_command_t CommandRead( ifo_t* p_ifo )
void CommandRead( ifo_command_t com )
{
ifo_command_t com;
u8* pi_code = (u8*)(&com);
return com;
switch( com.i_type )
{
case 0: /* Goto */
if( !pi_code[1] )
{
fprintf( stderr, "NOP\n" );
}
else if( cmd.i_cmp )
{
}
break;
case 1: /* Lnk */
break;
case 2: /* SetSystem */
break;
case 3: /* Set */
break;
case 4: /* */
break;
case 5: /* */
break;
case 6: /* */
break;
default:
fprintf( stderr, "Unknown Command\n" );
break;
}
return;
}
/*****************************************************************************
*
* IfoGoto
*****************************************************************************/
static void IfoGoto( ifo_command_t cmd )
{
return;
}
/*****************************************************************************
* IfoLnk
*****************************************************************************/
static void IfoLnk( ifo_t* p_ifo )
{
return;
}
/*****************************************************************************
* IfoJmp
*****************************************************************************/
static void IfoJmp( ifo_t* p_ifo )
{
return;
}
#endif
......@@ -2,6 +2,7 @@
* dvd_ifo.h: Structures for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.h,v 1.7 2001/02/08 01:34:42 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -20,11 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#define DVD_LB_SIZE 2048
/*****************************************************************************
* Common structures for Video Management and Video Title sets
*****************************************************************************/
......@@ -481,9 +477,9 @@ typedef struct ifo_s
/* File descriptor for the device */
int i_fd;
/* Offset to video_ts.ifo on the device */
off64_t i_off;
off64_t i_off;
/* Position of stream pointer */
off64_t i_pos;
off64_t i_pos;
/* Error Management */
boolean_t b_error;
/* Structure described in video_ts */
......@@ -492,8 +488,3 @@ typedef struct ifo_s
vts_t * p_vts;
} ifo_t;
/*****************************************************************************
* Prototypes in dvd_ifo.c
*****************************************************************************/
ifo_t IfoInit( int );
void IfoRead( ifo_t* );
This diff is collapsed.
......@@ -20,19 +20,42 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#define DVD_LB_SIZE 2048
/*****************************************************************************
* thread_dvd_data_t: extension of input_thread_t for DVD specificity
*****************************************************************************/
typedef struct thread_dvd_data_s
{
int i_fd;
boolean_t b_encrypted;
#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
int i_fd; // File descriptor of device
boolean_t b_encrypted; // CSS encryption
int i_read_once; // NB of bytes read by DVDRead
int i_title; // Current Title
/* Scrambling Information */
#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
struct css_s css;
#endif
/* Structure that contains all information of the DVD */
struct ifo_s ifo;
} thread_dvd_data_t;
/*****************************************************************************
* Prototypes in dvd_ifo.c
*****************************************************************************/
struct ifo_s IfoInit( int );
void IfoRead( struct ifo_s * );
void IfoEnd( ifo_t * );
/*****************************************************************************
* Prototypes in dvd_css.c
*****************************************************************************/
#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
int CSSTest ( int );
struct css_s CSSInit ( int );
int CSSGetKeys ( struct css_s * );
int CSSDescrambleSector( u8 * , u8 * );
#endif
......@@ -2,7 +2,7 @@
* input_netlist.c: netlist management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_netlist.c,v 1.28 2001/01/07 03:56:40 henri Exp $
* $Id: input_netlist.c,v 1.29 2001/02/08 01:34:42 stef Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
......@@ -52,7 +52,7 @@
* input_NetlistInit: allocates netlist buffers and init indexes
*****************************************************************************/
int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
size_t i_buffer_size )
size_t i_buffer_size, int i_read_once )
{
unsigned int i_loop;
netlist_t * p_netlist;
......@@ -155,13 +155,16 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
p_netlist->i_nb_pes = i_nb_pes;
p_netlist->i_buffer_size = i_buffer_size;
p_netlist->i_read_once = i_read_once;
return (0); /* Everything went all right */
}
/*****************************************************************************
* input_NetlistGetiovec: returns an iovec pointer for a readv() operation
*****************************************************************************/
struct iovec * input_NetlistGetiovec( void * p_method_data )
struct iovec * input_NetlistGetiovec( void * p_method_data,
struct data_packet_s ** pp_data )
{
netlist_t * p_netlist;
......@@ -169,9 +172,9 @@ struct iovec * input_NetlistGetiovec( void * p_method_data )
p_netlist = ( netlist_t * ) p_method_data;
/* check */
if (
if(
(p_netlist->i_data_end - p_netlist->i_data_start + p_netlist->i_nb_data)
%p_netlist->i_nb_data < INPUT_READ_ONCE )
%p_netlist->i_nb_data < p_netlist->i_read_once )
{
intf_ErrMsg("Empty iovec FIFO. Unable to allocate memory");
return (NULL);
......@@ -181,13 +184,21 @@ struct iovec * input_NetlistGetiovec( void * p_method_data )
* so, as a solution, we chose to have a FIFO a bit longer
* than i_nb_data, and copy the begining of the FIFO to its end
* if the readv needs to go after the end */
if( p_netlist->i_nb_data - p_netlist->i_data_start < INPUT_READ_ONCE )
if( p_netlist->i_nb_data - p_netlist->i_data_start <
p_netlist->i_read_once )
{
memcpy( &p_netlist->p_free_iovec[p_netlist->i_nb_data],
p_netlist->p_free_iovec,
INPUT_READ_ONCE-(p_netlist->i_nb_data-p_netlist->i_data_start)
* sizeof(struct iovec *)
(p_netlist->i_read_once-
(p_netlist->i_nb_data-p_netlist->i_data_start))
* sizeof(struct iovec*)
);
}
/* Gives a pointer to the data_packet struct associated with io_vec */
*pp_data = p_netlist->pp_free_data[p_netlist->i_data_start];
/* Initialize payload start and end */
p_netlist->pp_free_data[p_netlist->i_data_start]->p_payload_start
= p_netlist->pp_free_data[p_netlist->i_data_start]->p_buffer;
......@@ -259,10 +270,6 @@ struct data_packet_s * input_NetlistNewPacket( void * p_method_data,
/* unlock */
vlc_mutex_unlock (&p_netlist->lock);
if (i_buffer_size < p_netlist->i_buffer_size)
{
p_return->p_payload_end = p_return->p_payload_start + i_buffer_size;
}
/* initialize data */
p_return->p_next = NULL;
......@@ -363,7 +370,7 @@ void input_NetlistDeletePES( void * p_method_data, pes_packet_t * p_pes )
p_netlist->pp_free_data[p_netlist->i_data_end] = p_current_packet;
p_netlist->p_free_iovec[p_netlist->i_data_end].iov_base
= p_netlist->p_data->p_buffer;
= p_current_packet->p_buffer;
p_current_packet = p_current_packet->p_next;
}
......@@ -375,6 +382,7 @@ void input_NetlistDeletePES( void * p_method_data, pes_packet_t * p_pes )
/* unlock */
vlc_mutex_unlock (&p_netlist->lock);
}
/*****************************************************************************
......
......@@ -24,6 +24,9 @@ typedef struct netlist_s
/* Index */
unsigned int i_data_start, i_data_end;
unsigned int i_pes_start, i_pes_end;
/* Number of blocs read once by readv */
unsigned int i_read_once;
} netlist_t;
/*****************************************************************************
......@@ -31,8 +34,9 @@ typedef struct netlist_s
*****************************************************************************/
int input_NetlistInit( struct input_thread_s *,
int i_nb_data, int i_nb_pes,
size_t i_buffer_size );
struct iovec * input_NetlistGetiovec( void * );
size_t i_buffer_size,
int i_read_once );
struct iovec * input_NetlistGetiovec( void *, struct data_packet_s** );
void input_NetlistMviovec( void *, size_t );
struct data_packet_s * input_NetlistNewPacket( void *, size_t );
struct pes_packet_s * input_NetlistNewPES( void * );
......
......@@ -2,7 +2,7 @@
* mpeg_system.c: TS, PS and PES management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: mpeg_system.c,v 1.30 2001/02/07 17:44:52 massiot Exp $
* $Id: mpeg_system.c,v 1.31 2001/02/08 01:34:42 stef Exp $
*
* Authors:
*
......@@ -396,6 +396,7 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
p_pes = NULL;
}
#undef p_pes
}
/*****************************************************************************
......@@ -858,7 +859,7 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
/* Trash the packet if it has no payload or if it isn't selected */
if( b_trash )
{
p_input->p_plugin->pf_delete_packet( p_input, p_data );
p_input->p_plugin->pf_delete_packet( p_input->p_method_data, p_data );
#ifdef STATS
p_input->c_packets_trashed++;
#endif
......
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