From 7917d2ef3f36d47ad90509812755facc07bec9d7 Mon Sep 17 00:00:00 2001 From: Johan Bilien Date: Fri, 7 Dec 2001 16:47:47 +0000 Subject: [PATCH] * added functions in inputs to change the current program (most of them do nothing) All inputs should now have a pf_setprogram function. A default one is provided in input_programs.c. --- include/input_ext-intf.h | 4 ++- include/input_ext-plugins.h | 3 ++- include/modules.h | 4 ++- plugins/dvd/input_dvd.c | 33 +++++++++++++++-------- plugins/mpeg/input_es.c | 22 ++++++++++++---- plugins/mpeg/input_ps.c | 36 +++++++++++++++---------- plugins/mpeg/input_ts.c | 3 ++- plugins/vcd/input_vcd.c | 52 +++++++++++++++++++++++-------------- src/input/input.c | 28 ++++++++++++++++++-- src/input/input_ext-intf.c | 17 +++++++++++- src/input/input_programs.c | 25 +++++++++++++++++- 11 files changed, 170 insertions(+), 57 deletions(-) diff --git a/include/input_ext-intf.h b/include/input_ext-intf.h index d91ca0c10a..24692eddbd 100644 --- a/include/input_ext-intf.h +++ b/include/input_ext-intf.h @@ -4,7 +4,7 @@ * control the pace of reading. ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: input_ext-intf.h,v 1.50 2001/12/05 03:31:04 jobi Exp $ + * $Id: input_ext-intf.h,v 1.51 2001/12/07 16:47:47 jobi Exp $ * * Authors: Christophe Massiot * @@ -275,6 +275,8 @@ typedef struct input_thread_s void (* pf_delete_pes)( void *, struct pes_packet_s * ); /* Stream control capabilities */ + int (* pf_set_program)( struct input_thread_s *, + struct pgrm_descriptor_s * ); int (* pf_set_area)( struct input_thread_s *, struct input_area_s * ); int (* pf_rewind)( struct input_thread_s * ); diff --git a/include/input_ext-plugins.h b/include/input_ext-plugins.h index 114d11afe3..d3abaf98ba 100644 --- a/include/input_ext-plugins.h +++ b/include/input_ext-plugins.h @@ -3,7 +3,7 @@ * but exported to plug-ins ***************************************************************************** * Copyright (C) 1999, 2000, 2001 VideoLAN - * $Id: input_ext-plugins.h,v 1.6 2001/11/25 22:52:21 gbazin Exp $ + * $Id: input_ext-plugins.h,v 1.7 2001/12/07 16:47:47 jobi Exp $ * * Authors: Christophe Massiot * @@ -58,6 +58,7 @@ struct pgrm_descriptor_s * input_FindProgram( struct input_thread_s *, u16 ); struct pgrm_descriptor_s * input_AddProgram ( struct input_thread_s *, u16, size_t ); void input_DelProgram( struct input_thread_s *, struct pgrm_descriptor_s * ); +int input_SetProgram( struct input_thread_s *, struct pgrm_descriptor_s * ); struct input_area_s * input_AddArea( struct input_thread_s * ); void input_DelArea ( struct input_thread_s *, struct input_area_s * ); struct es_descriptor_s * input_FindES( struct input_thread_s *, u16 ); diff --git a/include/modules.h b/include/modules.h index c45654e2b3..f7b72a618d 100644 --- a/include/modules.h +++ b/include/modules.h @@ -2,7 +2,7 @@ * modules.h : Module management functions. ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: modules.h,v 1.33 2001/12/03 16:18:37 sam Exp $ + * $Id: modules.h,v 1.34 2001/12/07 16:47:47 jobi Exp $ * * Authors: Samuel Hocevar * @@ -128,6 +128,8 @@ typedef struct function_list_s void ( * pf_delete_packet ) ( void *, struct data_packet_s * ); void ( * pf_delete_pes ) ( void *, struct pes_packet_s * ); + int ( * pf_set_program ) ( struct input_thread_s *, + struct pgrm_descriptor_s * ); int ( * pf_set_area ) ( struct input_thread_s *, struct input_area_s * ); diff --git a/plugins/dvd/input_dvd.c b/plugins/dvd/input_dvd.c index 6626b1ff57..04749d4501 100644 --- a/plugins/dvd/input_dvd.c +++ b/plugins/dvd/input_dvd.c @@ -10,7 +10,7 @@ * -dvd_udf to find files ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: input_dvd.c,v 1.103 2001/12/05 03:31:04 jobi Exp $ + * $Id: input_dvd.c,v 1.104 2001/12/07 16:47:47 jobi Exp $ * * Author: Stéphane Borel * @@ -105,15 +105,16 @@ * Local prototypes *****************************************************************************/ /* called from outside */ -static int DVDProbe ( probedata_t *p_data ); -static void DVDInit ( struct input_thread_s * ); -static void DVDEnd ( struct input_thread_s * ); -static void DVDOpen ( struct input_thread_s * ); -static void DVDClose ( struct input_thread_s * ); -static int DVDSetArea ( struct input_thread_s *, struct input_area_s * ); -static int DVDRead ( struct input_thread_s *, data_packet_t ** ); -static void DVDSeek ( struct input_thread_s *, off_t ); -static int DVDRewind ( struct input_thread_s * ); +static int DVDProbe ( probedata_t *p_data ); +static void DVDInit ( struct input_thread_s * ); +static void DVDEnd ( struct input_thread_s * ); +static void DVDOpen ( struct input_thread_s * ); +static void DVDClose ( struct input_thread_s * ); +static int DVDSetArea ( struct input_thread_s *, struct input_area_s * ); +static int DVDSetProgram ( struct input_thread_s *, pgrm_descriptor_t * ); +static int DVDRead ( struct input_thread_s *, data_packet_t ** ); +static void DVDSeek ( struct input_thread_s *, off_t ); +static int DVDRewind ( struct input_thread_s * ); /* called only inside */ static int DVDChooseAngle( thread_dvd_data_t * ); @@ -136,6 +137,7 @@ void _M( input_getfunctions )( function_list_t * p_function_list ) input.pf_init_bit_stream = InitBitstream; input.pf_read = DVDRead; input.pf_set_area = DVDSetArea; + input.pf_set_program = DVDSetProgram; input.pf_demux = input_DemuxPS; input.pf_new_packet = input_NetlistNewPacket; input.pf_new_pes = input_NetlistNewPES; @@ -389,6 +391,15 @@ static void DVDEnd( input_thread_t * p_input ) input_NetlistEnd( p_input ); } +/***************************************************************************** + * DVDSetProgram: Does nothing, a DVD is mono-program + *****************************************************************************/ +static int DVDSetProgram( input_thread_t * p_input, + pgrm_descriptor_t * p_program ) +{ + return 0; +} + /***************************************************************************** * DVDSetArea: initialize input data for title x, chapter y. * It should be called for each user navigation request. @@ -504,7 +515,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) * decrypted disc key are fast enough to check the key at each seek */ if( dvdcss_seek( p_dvd->dvdhandle, p_dvd->i_start, - DVDCSS_SEEK_KEY ) < 0 ) + DVDCSS_SEEK_KEY ) < 0 ) { intf_ErrMsg( "dvd error: %s", dvdcss_error( p_dvd->dvdhandle ) ); return -1; diff --git a/plugins/mpeg/input_es.c b/plugins/mpeg/input_es.c index 7550df42ce..a229925484 100644 --- a/plugins/mpeg/input_es.c +++ b/plugins/mpeg/input_es.c @@ -2,7 +2,7 @@ * input_es.c: Elementary Stream demux and packet management ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: input_es.c,v 1.14 2001/11/28 15:08:05 massiot Exp $ + * $Id: input_es.c,v 1.15 2001/12/07 16:47:47 jobi Exp $ * * Author: Christophe Massiot * @@ -79,10 +79,12 @@ static int ESProbe ( probedata_t * ); static int ESRead ( struct input_thread_s *, data_packet_t * p_packets[INPUT_READ_ONCE] ); -static void ESInit ( struct input_thread_s * ); -static void ESEnd ( struct input_thread_s * ); -static void ESSeek ( struct input_thread_s *, off_t ); -static void ESDemux ( struct input_thread_s *, struct data_packet_s * ); +static void ESInit ( struct input_thread_s * ); +static void ESEnd ( struct input_thread_s * ); +static void ESSeek ( struct input_thread_s *, off_t ); +static int ESSetProgram ( struct input_thread_s *, pgrm_descriptor_t * ); +static void ESDemux ( struct input_thread_s *, + struct data_packet_s * ); static void ESNextDataPacket( struct bit_stream_s * ); static void ESInitBitstream( struct bit_stream_s *, struct decoder_fifo_s *, void (* pf_bitstream_callback)( struct bit_stream_s *, @@ -104,6 +106,7 @@ void _M( input_getfunctions )( function_list_t * p_function_list ) input.pf_end = ESEnd; input.pf_init_bit_stream = ESInitBitstream; input.pf_set_area = NULL; + input.pf_set_program = ESSetProgram; input.pf_read = ESRead; input.pf_demux = ESDemux; input.pf_new_packet = input_NetlistNewPacket; @@ -219,6 +222,15 @@ static void ESSeek( input_thread_t * p_input, off_t i_position ) p_input->stream.p_selected_area->i_tell = i_position; } + +/***************************************************************************** + * ESSetProgram: Does nothing + *****************************************************************************/ +static int ESSetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm ) +{ + return( 0 ); +} + /***************************************************************************** * ESDemux: fakes a demultiplexer *****************************************************************************/ diff --git a/plugins/mpeg/input_ps.c b/plugins/mpeg/input_ps.c index e96d5d38d7..929bde73a8 100644 --- a/plugins/mpeg/input_ps.c +++ b/plugins/mpeg/input_ps.c @@ -2,7 +2,7 @@ * input_ps.c: PS demux and packet management ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: input_ps.c,v 1.42 2001/12/05 03:31:04 jobi Exp $ + * $Id: input_ps.c,v 1.43 2001/12/07 16:47:47 jobi Exp $ * * Authors: Christophe Massiot * Cyril Deguet @@ -87,16 +87,17 @@ static __inline__ off_t fseeko( FILE *p_file, off_t i_offset, int i_pos ) /***************************************************************************** * Local prototypes *****************************************************************************/ -static int PSProbe ( probedata_t * ); -static int PSRead ( struct input_thread_s *, - data_packet_t * p_packets[INPUT_READ_ONCE] ); -static void PSInit ( struct input_thread_s * ); -static void PSEnd ( struct input_thread_s * ); -static void PSSeek ( struct input_thread_s *, off_t ); +static int PSProbe ( probedata_t * ); +static int PSRead ( struct input_thread_s *, + data_packet_t * p_packets[INPUT_READ_ONCE] ); +static void PSInit ( struct input_thread_s * ); +static void PSEnd ( struct input_thread_s * ); +static int PSSetProgram ( struct input_thread_s * , pgrm_descriptor_t * ); +static void PSSeek ( struct input_thread_s *, off_t ); static struct pes_packet_s * NewPES ( void * ); static struct data_packet_s * NewPacket ( void *, size_t ); -static void DeletePacket( void *, struct data_packet_s * ); -static void DeletePES ( void *, struct pes_packet_s * ); +static void DeletePacket ( void *, struct data_packet_s * ); +static void DeletePES ( void *, struct pes_packet_s * ); /***************************************************************************** * Functions exported as capabilities. They are declared as static so that @@ -112,6 +113,7 @@ void _M( input_getfunctions )( function_list_t * p_function_list ) input.pf_end = PSEnd; input.pf_init_bit_stream = InitBitstream; input.pf_set_area = NULL; + input.pf_set_program = PSSetProgram; input.pf_read = PSRead; input.pf_demux = input_DemuxPS; input.pf_new_packet = NewPacket; @@ -236,9 +238,9 @@ static void PSInit( input_thread_t * p_input ) input_AddProgram( p_input, 0, sizeof( stream_ps_data_t ) ); p_input->stream.p_selected_program = - p_input->stream.pp_programs[0] ; + p_input->stream.pp_programs[0] ; p_input->stream.p_new_program = - p_input->stream.pp_programs[0] ; + p_input->stream.pp_programs[0] ; if( p_input->stream.b_seekable ) { @@ -576,6 +578,14 @@ static int PSRead( input_thread_t * p_input, return( 0 ); } +/***************************************************************************** + * PSSetProgram: Does nothing since a PS Stream is mono-program + *****************************************************************************/ +static int PSSetProgram( input_thread_t * p_input, + pgrm_descriptor_t * p_program) +{ + return( 0 ); +} /***************************************************************************** * PSSeek: changes the stream position indicator *****************************************************************************/ @@ -776,7 +786,7 @@ static pes_packet_t * NewPES( void * p_packet_cache ) } #endif - vlc_mutex_lock( &p_cache->lock ); + vlc_mutex_lock( &p_cache->lock ); /* Checks whether the PES cache is empty */ if( p_cache->pes.l_index == 0 ) @@ -786,7 +796,7 @@ static pes_packet_t * NewPES( void * p_packet_cache ) if( p_pes == NULL ) { intf_DbgMsg( "Out of memory" ); - vlc_mutex_unlock( &p_cache->lock ); + vlc_mutex_unlock( &p_cache->lock ); return NULL; } #ifdef TRACE_INPUT diff --git a/plugins/mpeg/input_ts.c b/plugins/mpeg/input_ts.c index bf9ee96f68..7f531a927b 100644 --- a/plugins/mpeg/input_ts.c +++ b/plugins/mpeg/input_ts.c @@ -2,7 +2,7 @@ * input_ts.c: TS demux and netlist management ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: input_ts.c,v 1.40 2001/12/03 17:34:08 stef Exp $ + * $Id: input_ts.c,v 1.41 2001/12/07 16:47:47 jobi Exp $ * * Authors: Henri Fallon * @@ -106,6 +106,7 @@ void _M( input_getfunctions )( function_list_t * p_function_list ) input.pf_end = TSEnd; input.pf_init_bit_stream = InitBitstream; input.pf_set_area = NULL; + input.pf_set_area = input_SetProgram; input.pf_read = TSRead; input.pf_demux = input_DemuxTS; input.pf_new_packet = input_NetlistNewPacket; diff --git a/plugins/vcd/input_vcd.c b/plugins/vcd/input_vcd.c index fc37b177d9..7f644ed7f3 100644 --- a/plugins/vcd/input_vcd.c +++ b/plugins/vcd/input_vcd.c @@ -89,19 +89,20 @@ * Local prototypes *****************************************************************************/ /* called from outside */ -static int VCDProbe ( probedata_t *p_data ); -static void VCDInit ( struct input_thread_s * ); -static int VCDRead ( struct input_thread_s *, data_packet_t ** ); -static int VCDSetArea ( struct input_thread_s *, struct input_area_s * ); -static void VCDOpen ( struct input_thread_s *); -static void VCDClose ( struct input_thread_s *); -static void VCDEnd ( struct input_thread_s *); -static void VCDSeek ( struct input_thread_s *, off_t ); -static int VCDRewind ( struct input_thread_s * ); +static int VCDProbe ( probedata_t *p_data ); +static void VCDInit ( struct input_thread_s * ); +static int VCDRead ( struct input_thread_s *, data_packet_t ** ); +static int VCDSetArea ( struct input_thread_s *, struct input_area_s * ); +static int VCDSetProgram ( struct input_thread_s *, pgrm_descriptor_t * ); +static void VCDOpen ( struct input_thread_s *); +static void VCDClose ( struct input_thread_s *); +static void VCDEnd ( struct input_thread_s *); +static void VCDSeek ( struct input_thread_s *, off_t ); +static int VCDRewind ( struct input_thread_s * ); static struct data_packet_s * NewPacket( void *, size_t ); static pes_packet_t * NewPES ( void * ); -static void DeletePacket ( void *, data_packet_t * ); -static void DeletePES ( void *, pes_packet_t *); +static void DeletePacket ( void *, data_packet_t * ); +static void DeletePES ( void *, pes_packet_t *); @@ -112,21 +113,22 @@ static void DeletePES ( void *, pes_packet_t *); void _M( input_getfunctions )( function_list_t * p_function_list ) { #define input p_function_list->functions.input - p_function_list->pf_probe = VCDProbe ; - input.pf_init = VCDInit ; - input.pf_open = VCDOpen ; - input.pf_close = VCDClose ; - input.pf_end = VCDEnd ; + p_function_list->pf_probe = VCDProbe; + input.pf_init = VCDInit; + input.pf_open = VCDOpen; + input.pf_close = VCDClose; + input.pf_end = VCDEnd; input.pf_init_bit_stream = InitBitstream; - input.pf_read = VCDRead ; - input.pf_set_area = VCDSetArea ; + input.pf_read = VCDRead; + input.pf_set_area = VCDSetArea; + input.pf_set_program = VCDSetProgram; input.pf_demux = input_DemuxPS; input.pf_new_packet = NewPacket; input.pf_new_pes = NewPES; input.pf_delete_packet = DeletePacket; input.pf_delete_pes = DeletePES; - input.pf_rewind = VCDRewind ; - input.pf_seek = VCDSeek ; + input.pf_rewind = VCDRewind; + input.pf_seek = VCDSeek; #undef input } @@ -409,6 +411,16 @@ static void VCDEnd( input_thread_t * p_input ) } +/***************************************************************************** + * VCDSetProgram: Does nothing since a VCD is mono_program + *****************************************************************************/ +static int VCDSetProgram( input_thread_t * p_input, + pgrm_descriptor_t * p_program) +{ + return 0; +} + + /***************************************************************************** * VCDSetArea: initialize input data for title x, chapter y. * It should be called for each user navigation request. diff --git a/src/input/input.c b/src/input/input.c index 6bdcc3ba50..1eca5e2b69 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -4,7 +4,7 @@ * decoders. ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: input.c,v 1.161 2001/11/28 15:08:06 massiot Exp $ + * $Id: input.c,v 1.162 2001/12/07 16:47:47 jobi Exp $ * * Authors: Christophe Massiot * @@ -265,6 +265,29 @@ static void RunThread( input_thread_t *p_input ) vlc_mutex_lock( &p_input->stream.stream_lock ); + if( p_input->stream.p_new_program ) + { + if( p_input->pf_set_program != NULL ) + { + + p_input->pf_set_program( p_input, + p_input->stream.p_new_program ); + + for( i = 0; i < p_input->stream.i_pgrm_number; i++ ) + { + pgrm_descriptor_t * p_pgrm + = p_input->stream.pp_programs[i]; + /* Escape all decoders for the stream discontinuity they + * will encounter. */ + input_EscapeDiscontinuity( p_input, p_pgrm ); + + /* Reinitialize synchro. */ + p_pgrm->i_synchro_state = SYNCHRO_REINIT; + } + } + p_input->stream.p_new_program = NULL; + } + if( p_input->stream.p_new_area ) { if( p_input->stream.b_seekable && p_input->pf_set_area != NULL ) @@ -410,6 +433,7 @@ static int InitThread( input_thread_t * p_input ) p_input->pf_init_bit_stream= f.pf_init_bit_stream; p_input->pf_read = f.pf_read; p_input->pf_set_area = f.pf_set_area; + p_input->pf_set_program = f.pf_set_program; p_input->pf_demux = f.pf_demux; p_input->pf_new_packet = f.pf_new_packet; p_input->pf_new_pes = f.pf_new_pes; @@ -653,7 +677,7 @@ static void FileOpen( input_thread_t * p_input ) psz_name += 8; i_stat = stat( psz_name, &stat_info ); } - else if( ( i_size > 4 ) + else if( ( i_size > 4 ) && !strncasecmp( psz_name, "dvd:", 4 ) ) { /* get rid of the 'dvd:' stuff and try again */ diff --git a/src/input/input_ext-intf.c b/src/input/input_ext-intf.c index 6f7f8387a5..60d3683caf 100644 --- a/src/input/input_ext-intf.c +++ b/src/input/input_ext-intf.c @@ -2,7 +2,7 @@ * input_ext-intf.c: services to the interface ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: input_ext-intf.c,v 1.29 2001/11/28 15:08:06 massiot Exp $ + * $Id: input_ext-intf.c,v 1.30 2001/12/07 16:47:47 jobi Exp $ * * Authors: Christophe Massiot * @@ -333,6 +333,21 @@ int input_ChangeArea( input_thread_t * p_input, input_area_t * p_area ) return 0; } +/**************************************************************************** + * input_ChangeProgram: interface request an area change + ****************************************************************************/ +int input_ChangeProgram( input_thread_t * p_input, + pgrm_descriptor_t * p_program ) +{ + vlc_mutex_lock( &p_input->stream.stream_lock ); + + p_input->stream.p_new_program = p_program; + + vlc_mutex_unlock( &p_input->stream.stream_lock ); + + return 0; +} + /**************************************************************************** * input_ToggleGrayscale: change to grayscale or color output ****************************************************************************/ diff --git a/src/input/input_programs.c b/src/input/input_programs.c index 5fdcd7b220..7f219b3546 100644 --- a/src/input/input_programs.c +++ b/src/input/input_programs.c @@ -2,7 +2,7 @@ * input_programs.c: es_descriptor_t, pgrm_descriptor_t management ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: input_programs.c,v 1.67 2001/12/05 03:31:04 jobi Exp $ + * $Id: input_programs.c,v 1.68 2001/12/07 16:47:47 jobi Exp $ * * Authors: Christophe Massiot * @@ -302,6 +302,29 @@ input_area_t * input_AddArea( input_thread_t * p_input ) return p_input->stream.pp_areas[i_area_index]; } +/***************************************************************************** + * input_SetProgram: changes the current program + *****************************************************************************/ +int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg ) +{ + int i_es_index; +#define old_prg p_input->stream.p_selected_program + for ( i_es_index = 0 ; i_es_index < old_prg->i_es_number ; i_es_index ++ ) + { + input_UnselectES( p_input , old_prg->pp_es[i_es_index] ); + } +#undef old_prg + for (i_es_index = 0 ; i_es_index < p_new_prg->i_es_number ; i_es_index ++ ) + { + input_SelectES( p_input , p_new_prg->pp_es[i_es_index] ); + } + + p_input->stream.p_selected_program = p_new_prg; + + return( 0 ); +} + + /***************************************************************************** * input_DelArea: destroy a area descriptor ***************************************************************************** -- 2.39.2