X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fplaylist%2Fpls.c;h=20a6f52a945b7b1662f9d4861a33fe9fed09af66;hb=e1ff44d2afe03c87242cd3e5e9b48146bdb1e1da;hp=3c056b1b907eba970619e0febe7f8ef725dc76ae;hpb=b4feb9f9a326f3fc58a52b315ba34ad9d083263b;p=vlc diff --git a/modules/demux/playlist/pls.c b/modules/demux/playlist/pls.c index 3c056b1b90..20a6f52a94 100644 --- a/modules/demux/playlist/pls.c +++ b/modules/demux/playlist/pls.c @@ -87,11 +87,11 @@ static int Demux( demux_t *p_demux ) char *psz_key; char *psz_value; int i_item = -1; - int i_new_item = 0; - int i_key_length; input_item_t *p_input; - INIT_PLAYLIST_STUFF; + input_item_t *p_current_input = GetCurrentItem(p_demux); + + input_item_node_t *p_subitems = input_item_node_Create( p_current_input ); while( ( psz_line = stream_ReadLine( p_demux->s ) ) ) { @@ -110,7 +110,6 @@ static int Demux( demux_t *p_demux ) } else { - msg_Warn( p_demux, "invalid line in pls file" ); free( psz_line ); continue; } @@ -126,43 +125,29 @@ static int Demux( demux_t *p_demux ) free( psz_line); continue; } + /* find the number part of of file1, title1 or length1 etc */ - i_key_length = strlen( psz_key ); - if( i_key_length >= 4 ) /* Ref1 type case */ - { - i_new_item = atoi( psz_key + 3 ); - if( i_new_item == 0 && i_key_length >= 5 ) /* file1 type case */ - { - i_new_item = atoi( psz_key + 4 ); - if( i_new_item == 0 && i_key_length >= 6 ) /* title1 type case */ - { - i_new_item = atoi( psz_key + 5 ); - if( i_new_item == 0 && i_key_length >= 7 ) /* length1 type case */ - { - i_new_item = atoi( psz_key + 6 ); - } - } - } - } - if( i_new_item == 0 ) + int i_new_item; + if( sscanf( psz_key, "%*[^0-9]%d", &i_new_item ) != 1 ) { msg_Warn( p_demux, "couldn't find number of items" ); free( psz_line ); continue; } + if( i_item == -1 ) - { i_item = i_new_item; - } - /* we found a new item, insert the previous */ - if( i_item != i_new_item ) + else if( i_item != i_new_item ) { + /* we found a new item, insert the previous */ if( psz_mrl ) { p_input = input_item_New( p_demux, psz_mrl, psz_name ); input_item_CopyOptions( p_current_input, p_input ); - input_item_AddSubItem( p_current_input, p_input ); + input_item_node_AppendItem( p_subitems, p_input ); vlc_gc_decref( p_input ); + free( psz_mrl_orig ); + psz_mrl_orig = psz_mrl = NULL; } else { @@ -172,8 +157,8 @@ static int Demux( demux_t *p_demux ) psz_name = NULL; i_duration = -1; i_item = i_new_item; - i_new_item = 0; } + if( !strncasecmp( psz_key, "file", sizeof("file") -1 ) || !strncasecmp( psz_key, "Ref", sizeof("Ref") -1 ) ) { @@ -199,7 +184,7 @@ static int Demux( demux_t *p_demux ) } else if( !strncasecmp( psz_key, "length", sizeof("length") -1 ) ) { - i_duration = atoi( psz_value ); + i_duration = atoll( psz_value ); if( i_duration != -1 ) { i_duration *= 1000000; @@ -216,10 +201,9 @@ static int Demux( demux_t *p_demux ) { p_input = input_item_New( p_demux, psz_mrl, psz_name ); input_item_CopyOptions( p_current_input, p_input ); - input_item_AddSubItem( p_current_input, p_input ); + input_item_node_AppendItem( p_subitems, p_input ); vlc_gc_decref( p_input ); free( psz_mrl_orig ); - psz_mrl = NULL; } else { @@ -228,7 +212,9 @@ static int Demux( demux_t *p_demux ) free( psz_name ); psz_name = NULL; - HANDLE_PLAY_AND_RELEASE; + input_item_node_PostAndDelete( p_subitems ); + + vlc_gc_decref(p_current_input); return 0; /* Needed for correct operation of go back */ }