X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fplaylist%2Fasx.c;h=b996b7e0e3be0cc9f38f17345fbdded2513cb5c2;hb=15643af1;hp=56e9f07166b7eee772b2a3914fe8f1aa00b4e554;hpb=8baae61a21c1ea12076df2987476c4fedb16bee8;p=vlc diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c index 56e9f07166..b996b7e0e3 100644 --- a/modules/demux/playlist/asx.c +++ b/modules/demux/playlist/asx.c @@ -31,6 +31,8 @@ # include "config.h" #endif +#include + #include #include @@ -38,6 +40,7 @@ #include #include "playlist.h" #include +#include struct demux_sys_t { @@ -234,15 +237,16 @@ static int Demux( demux_t *p_demux ) char *psz_parse = NULL; char *psz_backup = NULL; bool b_entry = false; - INIT_PLAYLIST_STUFF; + input_item_t *p_current_input = GetCurrentItem(p_demux); /* init txt */ if( p_sys->i_data_len < 0 ) { int64_t i_pos = 0; - p_sys->i_data_len = stream_Size( p_demux->s ) +1; /* This is a cheat to prevent unnecessary realloc */ - if( p_sys->i_data_len <= 0 && p_sys->i_data_len < 16384 ) p_sys->i_data_len = 1024; + p_sys->i_data_len = stream_Size( p_demux->s ) + 1; /* This is a cheat to prevent unnecessary realloc */ + if( p_sys->i_data_len <= 0 || p_sys->i_data_len > 16384 ) p_sys->i_data_len = 1024; p_sys->psz_data = malloc( p_sys->i_data_len +1); + assert( p_sys->psz_data ); /* load the complete file */ for( ;; ) @@ -252,10 +256,11 @@ static int Demux( demux_t *p_demux ) if( i_read < p_sys->i_data_len - i_pos ) break; /* Done */ - /* XXX this looks fishy and inefficient */ i_pos += i_read; - p_sys->i_data_len += 1024; - p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) +1 ); + p_sys->i_data_len <<= 1 ; + p_sys->psz_data = realloc_or_free( p_sys->psz_data, + p_sys->i_data_len * sizeof( char * ) + 1 ); + assert( p_sys->psz_data ); } if( p_sys->i_data_len <= 0 ) return -1; } @@ -314,6 +319,7 @@ static int Demux( demux_t *p_demux ) if( i_strlen < 1 ) continue; msg_Dbg( p_demux, "param name strlen: %d", i_strlen); psz_string = malloc( i_strlen + 1); + assert( psz_string ); memcpy( psz_string, psz_backup, i_strlen ); psz_string[i_strlen] = '\0'; msg_Dbg( p_demux, "param name: %s", psz_string); @@ -336,6 +342,7 @@ static int Demux( demux_t *p_demux ) if( i_strlen < 1 ) continue; msg_Dbg( p_demux, "param value strlen: %d", i_strlen); psz_string = malloc( i_strlen +1); + assert( psz_string ); memcpy( psz_string, psz_backup, i_strlen ); psz_string[i_strlen] = '\0'; msg_Dbg( p_demux, "param value: %s", psz_string); @@ -434,6 +441,8 @@ static int Demux( demux_t *p_demux ) } if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) ) psz_parse += 2; + else if( ( psz_parse = strcasestr( psz_parse, "") ) ) + psz_parse += 11; else continue; } else if( !strncasecmp( psz_parse, "", 10 ) ) @@ -459,6 +468,7 @@ static int Demux( demux_t *p_demux ) i_strlen = psz_parse-psz_backup; if( i_strlen < 1 ) continue; psz_string = malloc( i_strlen +1); + assert( psz_string ); memcpy( psz_string, psz_backup, i_strlen ); psz_string[i_strlen] = '\0'; input_item_t *p_input; @@ -531,9 +541,11 @@ static int Demux( demux_t *p_demux ) char *psz_current_input_name = input_item_GetName( p_current_input ); if( asprintf( &psz_name, "%d %s", i_entry_count, ( psz_title_entry ? psz_title_entry : psz_current_input_name ) ) != -1 ) { - p_entry = input_item_NewExt( p_demux, psz_href, psz_name, + char *psz_mrl = ProcessMRL( psz_href, p_demux->p_sys->psz_prefix ); + p_entry = input_item_NewExt( p_demux, psz_mrl, psz_name, i_options, (const char * const *)ppsz_options, VLC_INPUT_OPTION_TRUSTED, -1 ); free( psz_name ); + free( psz_mrl ); input_item_CopyOptions( p_current_input, p_entry ); while( i_options ) { @@ -606,8 +618,30 @@ static int Demux( demux_t *p_demux ) i_strlen = psz_parse-psz_backup; if( i_strlen < 1 ) continue; + if( psz_href ) + { + /* we have allready one href in this entry, lets make new input from it and + continue with new href, don't free meta/options*/ + input_item_t *p_entry = NULL; + char *psz_name = input_item_GetName( p_current_input ); + + char *psz_mrl = ProcessMRL( psz_href, p_demux->p_sys->psz_prefix ); + p_entry = input_item_NewExt( p_demux, psz_mrl, psz_name, + 0, NULL, VLC_INPUT_OPTION_TRUSTED, -1 ); + free( psz_mrl ); + input_item_CopyOptions( p_current_input, p_entry ); + if( psz_title_entry ) input_item_SetTitle( p_entry, psz_title_entry ); + if( psz_artist_entry ) input_item_SetArtist( p_entry, psz_artist_entry ); + if( psz_copyright_entry ) input_item_SetCopyright( p_entry, psz_copyright_entry ); + if( psz_moreinfo_entry ) input_item_SetURL( p_entry, psz_moreinfo_entry ); + if( psz_abstract_entry ) input_item_SetDescription( p_entry, psz_abstract_entry ); + input_item_AddSubItem( p_current_input, p_entry ); + vlc_gc_decref( p_entry ); + } + free( psz_href ); psz_href = malloc( i_strlen +1); + assert( psz_string ); memcpy( psz_href, psz_backup, i_strlen ); psz_href[i_strlen] = '\0'; psz_tmp = psz_href + (i_strlen-1); @@ -710,7 +744,7 @@ static int Demux( demux_t *p_demux ) STARTMARK #endif } - HANDLE_PLAY_AND_RELEASE; + vlc_gc_decref(p_current_input); return 0; /* Needed for correct operation of go back */ }