Commit 55ce4df1 authored by Stéphane Borel's avatar Stéphane Borel

*Removed an occurance of former angle item in gtk.

*Fixed a bug in ES management introduced lately in DVD/DvdRead.

*Beginning of reorganisation in DVD plugin source files, in order to try to
make it easier to understand. There is some work left though :p.

*Decreased the score for VCD plugin, as the VCD demuxer was used even
for DVD :p. It should make autodetection work.
Some comment:
-I think that VCDInit should make a test on the access plugin and be launched
only if the access plugin is VCD,
-VCDOpen shouldn't set p_input->b_error: if it fails we just try another
module,
-PSRead doesn't need to be duplicated anymore: input_ReadPS is now available
for plugins (cf Christophe's commit).

Please comment around that: I'd like to know if the behaviour I've described
is the one everyone expects.

Enjoy my new bugs :p
parent 0a3aa895
......@@ -33,7 +33,7 @@ recognizes several URL-style items:
.B *.mpg, *.vob
Plain MPEG-1/2 files
.TP
.B dvd:<device>[@<raw device>]
.B dvd:[<device>][@<raw device>][@[<title>][,[<chapter>][,<angle>]]]
DVD device (for instance dvd:/dev/dvd). The raw device is optional and
must have been prepared beforehands.
.TP
......@@ -140,35 +140,19 @@ displaying of all images.
Note that vlc is not guaranteed to behave properly if you ask it to
display more images than your CPU can cope with.
.TP
.B \-t, \-\-dvdtitle <title>
Choose the DVD title. Most movies on DVDs start on the first title, but you may want to manually select another title.
.TP
.B \-T, \-\-dvdchapter <title>
Choose the DVD chapter. DVDs are divided into titles, which in turn are divided into chapters.
.TP
.B \-a, \-\-dvdaudio [ ac3 | lpcm | mpeg | off ]
.B \-a, \-\-input_audio [ ac3 | lpcm | mpeg | off ]
Choose the audio channel type. Most DVDs have AC3 audio channels, but
you can also have Linear PCM or MPEG layer 2 sound. Also, one might decide
not to activate the audio channel.
.TP
.B \-u, \-\-dvdangle <num>
Choose the angle, available on some DVDs.
.TP
.B \-c, \-\-dvdchannel [ 0\-15 ]
.B \-c, \-\-input_channel [ 0\-15 ]
Select the audio channel. Most DVDs only have one or two audio channels,
but some of them have a great number of available languages. Note that the
audio channel will also depend on the channel type.
.TP
.B \-s, \-\-dvdsubtitle [ 0\-31 ]
.B \-s, \-\-input_subtitle [ 0\-31 ]
Select the subtitle channel, if there is one in the stream.
.TP
.B \-\-dvdcss-method <method>
Select the CSS decryption scheme when using libdvdcss. Usually to choose
from "disc", "title" or "key", but depends on your libdvdcss version.
.TP
.B \-\-dvdcss-verbose <level>
Select the CSS decryption verbosity level, 0, 1 or 2.
.TP
.B \-\-input <method>
Choose the input method, "dvd", "ps", "ts" for instance.
.TP
......
dvd_SOURCES = dvd.c input_dvd.c dvd_ifo.c dvd_udf.c dvd_summary.c $(SRC_DVD_EXTRA)
dvd_SOURCES = dvd.c dvd_access.c dvd_demux.c dvd_seek.c dvd_es.c dvd_ifo.c dvd_udf.c dvd_summary.c $(SRC_DVD_EXTRA)
EXTRA_DEP = ../../lib/libdvdcss.a ../../lib/libdvdcss.so
......
/*****************************************************************************
* input_dvd.h: thread structure of the DVD plugin
* dvd.h: thread structure of the DVD plugin
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_dvd.h,v 1.25 2002/03/01 01:12:28 stef Exp $
* $Id: dvd.h,v 1.1 2002/03/06 01:20:56 stef Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
......@@ -36,6 +36,9 @@ typedef struct thread_dvd_data_s
{
dvdcss_handle dvdhandle; /* libdvdcss handle */
int i_audio_nb;
int i_spu_nb;
/* Navigation information */
int i_title;
int i_title_id;
......@@ -57,9 +60,6 @@ typedef struct thread_dvd_data_s
int i_start;
int i_size;
/* Scrambling Information */
struct css_s * p_css;
/* Structure that contains all information of the DVD */
struct ifo_s * p_ifo;
......
/* input_dvd.c: DVD raw reading plugin.
/* dvd_access.c: DVD access plugin.
*****************************************************************************
* This plugins should handle all the known specificities of the DVD format,
* especially the 2048 bytes logical block size.
......@@ -8,7 +8,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.132 2002/03/05 17:46:33 stef Exp $
* $Id: dvd_access.c,v 1.1 2002/03/06 01:20:56 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -50,10 +50,6 @@
# include <strings.h>
#endif
#if defined( WIN32 )
# include <io.h> /* read() */
#endif
#ifdef GOD_DAMN_DMCA
# include "dummy_dvdcss.h"
#else
......@@ -65,16 +61,15 @@
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
#include "input_dvd.h"
#include "dvd.h"
#include "dvd_es.h"
#include "dvd_seek.h"
#include "dvd_ifo.h"
#include "dvd_summary.h"
#include "iso_lang.h"
#include "debug.h"
/* how many packets DVDDemux will read in each loop */
#define DVD_READ_ONCE 64
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -87,17 +82,7 @@ static int DVDSetProgram ( struct input_thread_s *, pgrm_descriptor_t * );
static int DVDRead ( struct input_thread_s *, byte_t *, size_t );
static void DVDSeek ( struct input_thread_s *, off_t );
static int DVDRewind ( struct input_thread_s * );
static int DVDDemux ( struct input_thread_s * );
static int DVDInit ( struct input_thread_s * );
static void DVDEnd ( struct input_thread_s * );
/* called only inside */
static void DVDLaunchDecoders( input_thread_t * p_input );
static int DVDChooseAngle( thread_dvd_data_t * );
static int DVDFindCell( thread_dvd_data_t * );
static int DVDFindSector( thread_dvd_data_t * );
static int DVDChapterSelect( thread_dvd_data_t *, int );
static char * DVDParse( input_thread_t * );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
......@@ -115,124 +100,6 @@ void _M( access_getfunctions)( function_list_t * p_function_list )
#undef input
}
void _M( demux_getfunctions)( function_list_t * p_function_list )
{
#define demux p_function_list->functions.demux
demux.pf_init = DVDInit;
demux.pf_end = DVDEnd;
demux.pf_demux = DVDDemux;
demux.pf_rewind = DVDRewind;
#undef demux
}
/*
* Data demux functions
*/
/*****************************************************************************
* DVDInit: initializes DVD structures
*****************************************************************************/
static int DVDInit( input_thread_t * p_input )
{
if( strncmp( p_input->p_access_module->psz_name, "dvd", 3 ) )
{
return -1;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
DVDLaunchDecoders( p_input );
vlc_mutex_unlock( &p_input->stream.stream_lock );
return 0;
}
/*****************************************************************************
* DVDEnd: frees unused data
*****************************************************************************/
static void DVDEnd( input_thread_t * p_input )
{
}
/*****************************************************************************
* DVDDemux
*****************************************************************************/
#define PEEK( SIZE ) \
i_result = input_Peek( p_input, &p_peek, SIZE ); \
if( i_result == -1 ) \
{ \
return( -1 ); \
} \
else if( i_result < SIZE ) \
{ \
/* EOF */ \
return( 0 ); \
}
static int DVDDemux( input_thread_t * p_input )
{
int i;
byte_t * p_peek;
data_packet_t * p_data;
ssize_t i_result;
int i_packet_size;
/* Read headers to compute payload length */
for( i = 0 ; i < DVD_READ_ONCE ; i++ )
{
/* Read what we believe to be a packet header. */
PEEK( 4 );
/* Default header */
if( U32_AT( p_peek ) != 0x1BA )
{
/* That's the case for all packets, except pack header. */
i_packet_size = U16_AT( p_peek + 4 );
}
else
{
/* MPEG-2 Pack header. */
i_packet_size = 8;
}
/* Fetch a packet of the appropriate size. */
i_result = input_SplitBuffer( p_input, &p_data, i_packet_size + 6 );
if( i_result <= 0 )
{
return( i_result );
}
/* In MPEG-2 pack headers we still have to read stuffing bytes. */
if( (p_data->p_demux_start[3] == 0xBA) && (i_packet_size == 8) )
{
size_t i_stuffing = (p_data->p_demux_start[13] & 0x7);
/* Force refill of the input buffer - though we don't care
* about p_peek. Please note that this is unoptimized. */
PEEK( i_stuffing );
p_input->p_current_data += i_stuffing;
}
input_DemuxPS( p_input, p_data );
}
return i;
}
/*****************************************************************************
* DVDRewind : reads a stream backward
*****************************************************************************/
static int DVDRewind( input_thread_t * p_input )
{
return( -1 );
}
/*
* Data access functions
*/
......@@ -242,216 +109,39 @@ static int DVDRewind( input_thread_t * p_input )
*****************************************************************************/
static int DVDOpen( struct input_thread_s *p_input )
{
struct stat stat_info;
char * psz_orig;
char * psz_parser;
char * psz_device;
char * psz_raw;
char * psz_next;
dvdcss_handle dvdhandle;
thread_dvd_data_t * p_dvd;
input_area_t * p_area;
boolean_t b_options = 0;
int i_title = 1;
int i_chapter = 1;
int i_angle = 1;
int i;
psz_orig = psz_parser = psz_device = strdup( p_input->psz_name );
if( !psz_orig )
{
return( -1 );
}
/* Parse input string :
* [device][@rawdevice][@[title][,[chapter][,angle]]] */
while( *psz_parser && *psz_parser != '@' )
{
psz_parser++;
}
if( *psz_parser == '@' )
{
/* Maybe found raw device or option list */
*psz_parser = '\0';
psz_raw = ++psz_parser;
}
else
{
psz_raw = NULL;
}
if( *psz_parser && !strtol( psz_parser, NULL, 10 ) )
{
/* what we've found is either a raw device or a partial option
* list e.g. @,29 or both a device and a list ; search end of string */
while( *psz_parser && *psz_parser != '@' )
{
psz_parser++;
}
if( *psz_parser == '@' )
{
/* found end of raw device, and beginning of options */
*psz_parser = '\0';
++psz_parser;
b_options = 1;
}
else
{
psz_parser = psz_raw + 1;
for( i=0 ; i<3 ; i++ )
{
if( !*psz_parser )
{
/* we have only a raw device */
break;
}
if( strtol( psz_parser, NULL, 10 ) )
{
/* we have only a partial list of options, no device */
psz_parser = psz_raw;
psz_raw = NULL;
b_options = 1;
break;
}
psz_parser++;
}
}
}
else
{
/* found beginning of options ; no raw device specified */
psz_raw = NULL;
b_options = 1;
}
if( b_options )
{
/* Found options */
i_title = (int)strtol( psz_parser, &psz_next, 10 );
if( *psz_next )
{
psz_parser = psz_next + 1;
i_chapter = (int)strtol( psz_parser, &psz_next, 10 );
if( *psz_next )
{
i_angle = (int)strtol( psz_next + 1, NULL, 10 );
}
}
i_title = i_title ? i_title : 1;
i_chapter = i_chapter ? i_chapter : 1;
i_angle = i_angle ? i_angle : 1;
}
if( psz_raw )
{
if( *psz_raw )
{
/* check the raw device */
if( stat( psz_raw, &stat_info ) == -1 )
{
intf_WarnMsg( 3, "dvd warning: cannot stat() raw"
" device `%s' (%s)",
psz_raw, strerror(errno));
/* put back '@' */
*(psz_raw - 1) = '@';
psz_raw = NULL;
}
else
{
char * psz_env;
#ifndef WIN32
if( !S_ISCHR(stat_info.st_mode) )
{
intf_WarnMsg( 3, "dvd warning: raw device %s is"
" not a valid char device", psz_raw );
/* put back '@' */
*(psz_raw - 1) = '@';
psz_raw = NULL;
}
else
#endif
{
psz_env = malloc( strlen("DVDCSS_RAW_DEVICE=")
+ strlen( psz_raw ) + 1 );
sprintf( psz_env, "DVDCSS_RAW_DEVICE=%s", psz_raw );
putenv( psz_env );
}
}
}
else
{
psz_raw = NULL;
}
}
if( !*psz_device )
{
if( !p_input->psz_access )
{
/* no device and no access specified: we probably don't want DVD */
free( psz_orig );
return -1;
}
psz_device = config_GetPszVariable( INPUT_DVD_DEVICE_VAR );
}
/* check block device */
if( stat( psz_device, &stat_info ) == -1 )
{
intf_ErrMsg( "input error: cannot stat() device `%s' (%s)",
psz_device, strerror(errno));
return( -1 );
}
#ifndef WIN32
if( !S_ISBLK(stat_info.st_mode) && !S_ISCHR(stat_info.st_mode) )
p_dvd = malloc( sizeof(thread_dvd_data_t) );
if( p_dvd == NULL )
{
intf_WarnMsg( 3, "input: DVD plugin discarded"
" (not a valid block device)" );
intf_ErrMsg( "dvd error: out of memory" );
return -1;
}
#endif
p_input->p_access_data = (void *)p_dvd;
if( psz_raw )
/* Parse command line */
if( !( psz_device = DVDParse( p_input ) ) )
{
free( p_dvd );
return -1;
}
intf_WarnMsg( 2, "input: dvd=%s raw=%s title=%d chapter=%d angle=%d",
psz_device, psz_raw, i_title, i_chapter, i_angle );
/*
* set up input
*/
p_input->i_mtu = 0;
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.i_method = INPUT_METHOD_DVD;
/* If we are here we can control the pace... */
p_input->stream.b_pace_control = 1;
p_input->stream.b_seekable = 1;
p_input->stream.p_selected_area->i_size = 0;
p_input->stream.p_selected_area->i_tell = 0;
vlc_mutex_unlock( &p_input->stream.stream_lock );
/*
* get plugin ready
*/
dvdhandle = dvdcss_open( psz_device );
/* free allocated strings */
if( psz_device != psz_orig )
free( psz_device );
free( psz_orig );
/* free allocated string */
free( psz_device );
if( dvdhandle == NULL )
......@@ -460,15 +150,7 @@ static int DVDOpen( struct input_thread_s *p_input )
return -1;
}
p_dvd = malloc( sizeof(thread_dvd_data_t) );
if( p_dvd == NULL )
{
intf_ErrMsg( "dvd error: out of memory" );
return -1;
}
p_dvd->dvdhandle = (dvdcss_handle) dvdhandle;
p_input->p_access_data = (void *)p_dvd;
if( dvdcss_seek( p_dvd->dvdhandle, 0, DVDCSS_NOFLAGS ) < 0 )
{
......@@ -495,11 +177,17 @@ static int DVDOpen( struct input_thread_s *p_input )
/* Set stream and area data */
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.i_method = INPUT_METHOD_DVD;
p_input->stream.b_pace_control = 1;
p_input->stream.b_seekable = 1;
p_input->stream.p_selected_area->i_size = 0;
p_input->stream.p_selected_area->i_tell = 0;
/* Initialize ES structures */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
#define title_inf p_dvd->p_ifo->vmg.title_inf
intf_WarnMsg( 2, "dvd info: number of titles: %d", title_inf.i_title_nb );
intf_WarnMsg( 3, "dvd info: number of titles: %d", title_inf.i_title_nb );
#define area p_input->stream.pp_areas
/* We start from 1 here since the default area 0
......@@ -527,17 +215,19 @@ static int DVDOpen( struct input_thread_s *p_input )
}
#undef area
p_dvd->i_title = i_title <= title_inf.i_title_nb ? i_title : 1;
p_dvd->i_title = p_dvd->i_title <= title_inf.i_title_nb ?
p_dvd->i_title : 1;
#undef title_inf
p_area = p_input->stream.pp_areas[p_dvd->i_title];
p_dvd->i_chapter = i_chapter < p_area->i_part_nb ? i_chapter : 1;
p_dvd->i_chapter = p_dvd->i_chapter < p_area->i_part_nb ?
p_dvd->i_chapter : 1;
p_area->i_part = p_dvd->i_chapter;
p_dvd->i_angle = i_angle;
p_dvd->i_audio_nb = 0;
p_dvd->i_spu_nb = 0;
/* set title, chapter, audio and subpic */
if( DVDSetArea( p_input, p_area ) )
{
......@@ -548,7 +238,6 @@ static int DVDOpen( struct input_thread_s *p_input )
vlc_mutex_unlock( &p_input->stream.stream_lock );
return 0;
}
/*****************************************************************************
......@@ -570,7 +259,7 @@ static void DVDClose( struct input_thread_s *p_input )
}
/*****************************************************************************
* DVDSetProgram: Does nothing, a DVD is mono-program
* DVDSetProgram: used to change angle
*****************************************************************************/
static int DVDSetProgram( input_thread_t * p_input,
pgrm_descriptor_t * p_program )
......@@ -583,6 +272,8 @@ static int DVDSetProgram( input_thread_t * p_input,
p_dvd = (thread_dvd_data_t*)(p_input->p_access_data);
i_angle = p_program->i_number;
/* DVD is actually mono-program: we only need the current angle
* number, so copy the data between programs */
memcpy( p_program, p_input->stream.p_selected_program,
sizeof(pgrm_descriptor_t) );
p_program->i_number = i_angle;
......@@ -623,11 +314,7 @@ static int DVDSetProgram( input_thread_t * p_input,
static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
{
thread_dvd_data_t * p_dvd;
es_descriptor_t * p_es;
u16 i_id;
int i_vts_title;
int i_audio_nb = 0;
int i_spu_nb = 0;
int i;
p_dvd = (thread_dvd_data_t*)(p_input->p_access_data);
......@@ -639,13 +326,12 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
{
/* Reset the Chapter position of the old title */
p_input->stream.p_selected_area->i_part = 0;
p_input->stream.p_selected_area = p_area;
/*
* We have to load all title information
*/
/* Change the default area */
p_input->stream.p_selected_area =
p_input->stream.pp_areas[p_area->i_id];
/* title number: it is not vts nb!,
* it is what appears in the interface list */
......@@ -674,15 +360,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
intf_WarnMsg( 3, "dvd: title %d vts_title %d pgc %d",
p_dvd->i_title, i_vts_title, p_dvd->i_title_id );
/*
* Angle management
*/
p_dvd->i_angle_nb = vmg.title_inf.p_attr[p_dvd->i_title-1].i_angle_nb;
if( ( p_dvd->i_angle <= 0 ) || p_dvd->i_angle > p_dvd->i_angle_nb )
{
p_dvd->i_angle = 1;
}
/*
* Set selected title start and size
*/
......@@ -738,14 +416,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
p_input->stream.p_selected_area->i_start = LB2OFF( p_dvd->i_start );
p_input->stream.p_selected_area->i_size = LB2OFF( p_dvd->i_size );
#if 0
/* start at the beginning of the title */
/* FIXME: create a conf option to select whether to restart
* title or not */
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.p_selected_area->i_part = 1;
#endif
/*
* Destroy obsolete ES by reinitializing programs
* and find all ES in title with ifo data
......@@ -754,23 +424,14 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
{
/* We don't use input_EndStream here since
* we keep area structures */
/* Unselect all ES */
/*
for( i = 0 ; i < p_input->stream.i_selected_es_number ; i++ )
while( p_input->stream.i_es_number )
{
input_UnselectES( p_input, p_input->stream.pp_selected_es[i] );
input_DelES( p_input, p_input->stream.pp_es[0] );
}
*/
for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
while( p_input->stream.i_pgrm_number )
{
input_DelES( p_input, p_input->stream.pp_es[i] );
}