X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fplaylist%2Fdvb.c;h=9a7d6e295d3f67d96c75e6936128080c06f3424c;hb=8f3c41de941849f4ff5f2ae5975754c1907637c9;hp=31fefceb638549ea4ba54fdebad31d27f8288457;hpb=99f6722d6c42bd408e50c43e7ab397cbb0b33667;p=vlc diff --git a/modules/demux/playlist/dvb.c b/modules/demux/playlist/dvb.c index 31fefceb63..9a7d6e295d 100644 --- a/modules/demux/playlist/dvb.c +++ b/modules/demux/playlist/dvb.c @@ -1,7 +1,7 @@ /***************************************************************************** * dvb.c : DVB channel list import (szap/tzap/czap compatible channel lists) ***************************************************************************** - * Copyright (C) 2005 the VideoLAN team + * Copyright (C) 2005-20009 the VideoLAN team * $Id$ * * Authors: Gildas Bazin @@ -24,9 +24,12 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #include -#include #include #include "playlist.h" @@ -47,14 +50,14 @@ static int ParseLine( char *, char **, char ***, int *); /***************************************************************************** * Import_DVB: main import function *****************************************************************************/ -int E_(Import_DVB)( vlc_object_t *p_this ) +int Import_DVB( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; int i_peek; - vlc_bool_t b_valid = VLC_FALSE; + bool b_valid = false; - if( !demux2_IsPathExtension( p_demux, ".conf" ) && !p_demux->b_force ) + if( !demux_IsPathExtension( p_demux, ".conf" ) && !p_demux->b_force ) return VLC_EGENERIC; /* Check if this really is a channels file */ @@ -70,7 +73,7 @@ int E_(Import_DVB)( vlc_object_t *p_this ) } psz_line[i] = 0; - if( ParseLine( psz_line, 0, 0, 0 ) ) b_valid = VLC_TRUE; + if( ParseLine( psz_line, 0, 0, 0 ) ) b_valid = true; } if( !b_valid ) return VLC_EGENERIC; @@ -85,8 +88,9 @@ int E_(Import_DVB)( vlc_object_t *p_this ) /***************************************************************************** * Deactivate: frees unused data *****************************************************************************/ -void E_(Close_DVB)( vlc_object_t *p_this ) +void Close_DVB( vlc_object_t *p_this ) { + VLC_UNUSED(p_this); } /***************************************************************************** @@ -96,12 +100,12 @@ static int Demux( demux_t *p_demux ) { char *psz_line; input_item_t *p_input; - INIT_PLAYLIST_STUFF; + input_item_t *p_current_input = GetCurrentItem(p_demux); while( (psz_line = stream_ReadLine( p_demux->s )) ) { char **ppsz_options = NULL; - int i, i_options = 0; + int i_options = 0; char *psz_name = NULL; if( !ParseLine( psz_line, &psz_name, &ppsz_options, &i_options ) ) @@ -111,26 +115,26 @@ static int Demux( demux_t *p_demux ) } EnsureUTF8( psz_name ); - - p_input = input_ItemNewExt( p_playlist, "dvb:", psz_name, 0, NULL, -1 ); - for( i = 0; i< i_options; i++ ) - { + for( int i = 0; i< i_options; i++ ) EnsureUTF8( ppsz_options[i] ); - input_ItemAddOption( p_input, ppsz_options[i] ); - } - input_ItemAddSubItem( p_current_input, p_input ); + + p_input = input_item_NewExt( p_demux, "dvb://", psz_name, + i_options, (const char**)ppsz_options, VLC_INPUT_OPTION_TRUSTED, -1 ); + input_item_AddSubItem( p_current_input, p_input ); vlc_gc_decref( p_input ); - while( i_options-- ) free( ppsz_options[i_options] ); - if( ppsz_options ) free( ppsz_options ); + + while( i_options-- ) + free( ppsz_options[i_options] ); + free( ppsz_options ); free( psz_line ); } - HANDLE_PLAY_AND_RELEASE; + vlc_gc_decref(p_current_input); return 0; /* Needed for correct operation of go back */ } -static struct +static const struct { const char *psz_name; const char *psz_option; @@ -188,26 +192,26 @@ static struct static int ParseLine( char *psz_line, char **ppsz_name, char ***pppsz_options, int *pi_options ) { - char *psz_name = 0, *psz_parse = psz_line; - int i_count = 0, i_program = 0, i_frequency = 0; - vlc_bool_t b_valid = VLC_FALSE; + char *psz_name = NULL, *psz_parse = psz_line; + int i_count = 0, i_program = 0, i_frequency = 0, i_symbolrate = 0; + bool b_valid = false; - if( pppsz_options ) *pppsz_options = 0; + if( pppsz_options ) *pppsz_options = NULL; if( pi_options ) *pi_options = 0; - if( ppsz_name ) *ppsz_name = 0; + if( ppsz_name ) *ppsz_name = NULL; /* Skip leading tabs and spaces */ while( *psz_parse == ' ' || *psz_parse == '\t' || *psz_parse == '\n' || *psz_parse == '\r' ) psz_parse++; /* Ignore comments */ - if( *psz_parse == '#' ) return VLC_FALSE; + if( *psz_parse == '#' ) return false; while( psz_parse ) { - const char *psz_option = 0; - char *psz_end = strchr( psz_parse, ':' ); - if( psz_end ) { *psz_end = 0; psz_end++; } + const char *psz_option = NULL; + char *psz_option_end = strchr( psz_parse, ':' ); + if( psz_option_end ) { *psz_option_end = 0; psz_option_end++; } if( i_count == 0 ) { @@ -239,7 +243,7 @@ static int ParseLine( char *psz_line, char **ppsz_name, /* If we recognize one of the strings, then we are sure * the data is really valid (ie. a channels file). */ - b_valid = VLC_TRUE; + b_valid = true; break; } } @@ -252,6 +256,12 @@ static int ParseLine( char *psz_line, char **ppsz_name, i_value = strtol( psz_parse, &psz_end, 10 ); if( psz_end != psz_parse && + i_value != LONG_MAX && i_value != LONG_MIN && + !i_symbolrate ) + { + i_symbolrate = i_value; + } + else if( psz_end != psz_parse && i_value != LONG_MAX && i_value != LONG_MIN ) { i_program = i_value; @@ -267,7 +277,7 @@ static int ParseLine( char *psz_line, char **ppsz_name, psz_dup ); } - psz_parse = psz_end; + psz_parse = psz_option_end; i_count++; } @@ -275,25 +285,33 @@ static int ParseLine( char *psz_line, char **ppsz_name, { /* This isn't a valid channels file, cleanup everything */ while( (*pi_options)-- ) free( (*pppsz_options)[*pi_options] ); - if( *pppsz_options ) free( *pppsz_options ); - *pppsz_options = 0; *pi_options = 0; + free( *pppsz_options ); + *pppsz_options = NULL; *pi_options = 0; } if( i_program && pppsz_options && pi_options ) { char *psz_option; - asprintf( &psz_option, "program=%i", i_program ); - INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options), - psz_option ); + if( asprintf( &psz_option, "program=%i", i_program ) != -1 ) + INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options), + psz_option ); } if( i_frequency && pppsz_options && pi_options ) { char *psz_option; - asprintf( &psz_option, "dvb-frequency=%i", i_frequency ); - INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options), - psz_option ); + if( asprintf( &psz_option, "dvb-frequency=%i", i_frequency ) != -1 ) + INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options), + psz_option ); + } + if( i_symbolrate && pppsz_options && pi_options ) + { + char *psz_option; + + if( asprintf( &psz_option, "dvb-srate=%i", i_symbolrate ) != -1 ) + INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options), + psz_option ); } if( ppsz_name && psz_name ) *ppsz_name = strdup( psz_name ); @@ -302,5 +320,6 @@ static int ParseLine( char *psz_line, char **ppsz_name, static int Control( demux_t *p_demux, int i_query, va_list args ) { + VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args); return VLC_EGENERIC; }