]> git.sesse.net Git - vlc/blob - modules/demux/playlist/asx.c
Revert [23949].
[vlc] / modules / demux / playlist / asx.c
1 /*****************************************************************************
2  * asx.c : ASX playlist format import
3  *****************************************************************************
4  * Copyright (C) 2005-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Derk-Jan Hartman <hartman at videolan dot org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /* See also: http://msdn.microsoft.com/library/en-us/wmplay10/mmp_sdk/windowsmediametafilereference.asp
25  */
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include <vlc/vlc.h>
31 #include <vlc_demux.h>
32
33 #include <ctype.h>
34 #include <vlc_charset.h>
35 #include "playlist.h"
36 #include "vlc_meta.h"
37
38 struct demux_sys_t
39 {
40     char    *psz_prefix;
41     char    *psz_data;
42     int64_t i_data_len;
43     vlc_bool_t b_utf8;
44     vlc_bool_t b_skip_ads;
45 };
46
47 /*****************************************************************************
48  * Local prototypes
49  *****************************************************************************/
50 static int Demux( demux_t *p_demux);
51 static int Control( demux_t *p_demux, int i_query, va_list args );
52
53 static int StoreString( demux_t *p_demux, char **ppsz_string,
54                         const char *psz_source_start,
55                         const char *psz_source_end )
56 {
57     demux_sys_t *p_sys = p_demux->p_sys;
58     unsigned len = psz_source_end - psz_source_start;
59
60     if( *ppsz_string ) free( *ppsz_string );
61
62     char *buf = *ppsz_string = malloc ((len * (1 + !p_sys->b_utf8)) + 1);
63     if (buf == NULL)
64         return VLC_ENOMEM;
65
66     if( p_sys->b_utf8 )
67     {
68         memcpy (buf, psz_source_start, len);
69         (*ppsz_string)[len] = '\0';
70         EnsureUTF8 (*ppsz_string);
71     }
72     else
73     {
74         /* Latin-1 -> UTF-8 */
75         for (unsigned i = 0; i < len; i++)
76         {
77             unsigned char c = psz_source_start[i];
78             if (c & 0x80)
79             {
80                 *buf++ = 0xc0 | (c >> 6);
81                 *buf++ = 0x80 | (c & 0x3f);
82             }
83             else
84                 *buf++ = c;
85         }
86         *buf++ = '\0';
87
88         buf = *ppsz_string = realloc (*ppsz_string, buf - *ppsz_string);
89     }
90     return VLC_SUCCESS;
91 }
92
93 static char *SkipBlanks(char *s, size_t i_strlen )
94 {
95     while( i_strlen > 0 ) {
96         switch( *s )
97         {
98             case ' ':
99             case '\t':
100             case '\r':
101             case '\n':
102                 --i_strlen;
103                 ++s;
104                 break;
105             default:
106                 i_strlen = 0;
107         }
108     }
109     return s;
110 }
111
112 static int ParseTime(char *s, size_t i_strlen)
113 {
114     // need to parse hour:minutes:sec.fraction string
115     int result = 0;
116     int val;
117     const char *end = s + i_strlen;
118     // skip leading spaces if any
119     s = SkipBlanks(s, i_strlen);
120
121     val = 0;
122     while( (s < end) && isdigit(*s) )
123     {
124         int newval = val*10 + (*s - '0');
125         if( newval < val )
126         {
127             // overflow
128             val = 0;
129             break;
130         }
131         val = newval;
132         ++s;
133     }
134     result = val;
135     s = SkipBlanks(s, end-s);
136     if( *s == ':' )
137     {
138         ++s;
139         s = SkipBlanks(s, end-s);
140         result = result * 60;
141         val = 0;
142         while( (s < end) && isdigit(*s) )
143         {
144             int newval = val*10 + (*s - '0');
145             if( newval < val )
146             {
147                 // overflow
148                 val = 0;
149                 break;
150             }
151             val = newval;
152             ++s;
153         }
154         result += val;
155         s = SkipBlanks(s, end-s);
156         if( *s == ':' )
157         {
158             ++s;
159             s = SkipBlanks(s, end-s);
160             result = result * 60;
161             val = 0;
162             while( (s < end) && isdigit(*s) )
163             {
164                 int newval = val*10 + (*s - '0');
165                 if( newval < val )
166                 {
167                     // overflow
168                     val = 0;
169                     break;
170                 }
171                 val = newval;
172                 ++s;
173             }
174             result += val;
175             // TODO: one day, we may need to parse fraction for sub-second resolution
176         }
177     }
178     return result;
179 }
180
181 /*****************************************************************************
182  * Import_ASX: main import function
183  *****************************************************************************/
184 int E_(Import_ASX)( vlc_object_t *p_this )
185 {
186     demux_t *p_demux = (demux_t *)p_this;
187     const uint8_t *p_peek;
188     CHECK_PEEK( p_peek, 10 );
189
190     // skip over possible leading empty lines and empty spaces
191     p_peek = (uint8_t *)SkipBlanks((char *)p_peek, 6);
192
193     if( POKE( p_peek, "<asx", 4 ) || demux2_IsPathExtension( p_demux, ".asx" ) ||
194         demux2_IsPathExtension( p_demux, ".wax" ) || demux2_IsPathExtension( p_demux, ".wvx" ) ||
195         demux2_IsForced( p_demux, "asx-open" ) )
196     {
197         ;
198     }
199     else
200         return VLC_EGENERIC;
201
202     STANDARD_DEMUX_INIT_MSG( "found valid ASX playlist" );
203     p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
204     p_demux->p_sys->psz_data = NULL;
205     p_demux->p_sys->i_data_len = -1;
206     p_demux->p_sys->b_utf8 = VLC_FALSE;
207     p_demux->p_sys->b_skip_ads = config_GetInt( p_demux, "playlist-skip-ads" );
208
209     return VLC_SUCCESS;
210 }
211
212 /*****************************************************************************
213  * Deactivate: frees unused data
214  *****************************************************************************/
215 void E_(Close_ASX)( vlc_object_t *p_this )
216 {
217     demux_t *p_demux = (demux_t *)p_this;
218     demux_sys_t *p_sys = p_demux->p_sys;
219
220     if( p_sys->psz_prefix ) free( p_sys->psz_prefix );
221     if( p_sys->psz_data ) free( p_sys->psz_data );
222     free( p_sys );
223 }
224
225 static int Demux( demux_t *p_demux )
226 {
227     demux_sys_t *p_sys = p_demux->p_sys;
228     char        *psz_parse = NULL;
229     char        *psz_backup = NULL;
230     vlc_bool_t  b_entry = VLC_FALSE;
231     input_item_t *p_input;
232     INIT_PLAYLIST_STUFF;
233
234     /* init txt */
235     if( p_sys->i_data_len < 0 )
236     {
237         int64_t i_pos = 0;
238         p_sys->i_data_len = stream_Size( p_demux->s ) +1; /* This is a cheat to prevent unnecessary realloc */
239         if( p_sys->i_data_len <= 0 && p_sys->i_data_len < 16384 ) p_sys->i_data_len = 1024;
240         p_sys->psz_data = malloc( p_sys->i_data_len * sizeof(char) +1);
241
242         /* load the complete file */
243         for( ;; )
244         {
245             int i_read = stream_Read( p_demux->s, &p_sys->psz_data[i_pos], p_sys->i_data_len - i_pos );
246             p_sys->psz_data[i_read] = '\0';
247
248             if( i_read < p_sys->i_data_len - i_pos ) break; /* Done */
249
250             i_pos += i_read;
251             p_sys->i_data_len += 1024;
252             p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) +1 );
253         }
254         if( p_sys->i_data_len <= 0 ) return -1;
255     }
256
257     psz_parse = p_sys->psz_data;
258     /* Find first element */
259     if( ( psz_parse = strcasestr( psz_parse, "<ASX" ) ) )
260     {
261         /* ASX element */
262         char *psz_string = NULL;
263         int i_strlen = 0;
264
265         char *psz_base_asx = NULL;
266         char *psz_title_asx = NULL;
267         char *psz_artist_asx = NULL;
268         char *psz_copyright_asx = NULL;
269         char *psz_moreinfo_asx = NULL;
270         char *psz_abstract_asx = NULL;
271
272         char *psz_base_entry = NULL;
273         char *psz_title_entry = NULL;
274         char *psz_artist_entry = NULL;
275         char *psz_copyright_entry = NULL;
276         char *psz_moreinfo_entry = NULL;
277         char *psz_abstract_entry = NULL;
278         int i_entry_count = 0;
279         vlc_bool_t b_skip_entry = VLC_FALSE;
280
281         char *psz_href = NULL;
282         int i_starttime = 0;
283         int i_duration = 0;
284
285         psz_parse = strcasestr( psz_parse, ">" );
286
287         while( psz_parse && ( psz_parse = strcasestr( psz_parse, "<" ) ) )
288         {
289             if( !strncasecmp( psz_parse, "<!--", 4 ) )
290             {
291                 /* this is a comment */
292                 if( ( psz_parse = strcasestr( psz_parse, "-->" ) ) )
293                     psz_parse+=3;
294                 else continue;
295             }
296             else if( !strncasecmp( psz_parse, "<PARAM ", 7 ) )
297             {
298                 vlc_bool_t b_encoding_flag = VLC_FALSE;
299                 psz_parse = SkipBlanks(psz_parse+7, (unsigned)-1);
300                 if( !strncasecmp( psz_parse, "name", 4 ) )
301                 {
302                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
303                     {
304                         psz_backup = ++psz_parse;
305                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
306                         {
307                             i_strlen = psz_parse-psz_backup;
308                             if( i_strlen < 1 ) continue;
309                             msg_Dbg( p_demux, "param name strlen: %d", i_strlen);
310                             psz_string = malloc( i_strlen *sizeof( char ) +1);
311                             memcpy( psz_string, psz_backup, i_strlen );
312                             psz_string[i_strlen] = '\0';
313                             msg_Dbg( p_demux, "param name: %s", psz_string);
314                             b_encoding_flag = !strcasecmp( psz_string, "encoding" );
315                             free( psz_string );
316                         }
317                         else continue;
318                     }
319                     else continue;
320                 }
321                 psz_parse++;
322                 if( !strncasecmp( psz_parse, "value", 5 ) )
323                 {
324                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
325                     {
326                         psz_backup = ++psz_parse;
327                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
328                         {
329                             i_strlen = psz_parse-psz_backup;
330                             if( i_strlen < 1 ) continue;
331                             msg_Dbg( p_demux, "param value strlen: %d", i_strlen);
332                             psz_string = malloc( i_strlen *sizeof( char ) +1);
333                             memcpy( psz_string, psz_backup, i_strlen );
334                             psz_string[i_strlen] = '\0';
335                             msg_Dbg( p_demux, "param value: %s", psz_string);
336                             if( b_encoding_flag && !strcasecmp( psz_string, "utf-8" ) ) p_sys->b_utf8 = VLC_TRUE;
337                             free( psz_string );
338                         }
339                         else continue;
340                     }
341                     else continue;
342                 }
343                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
344                     psz_parse += 2;
345                 else continue;
346             }
347             else if( !strncasecmp( psz_parse, "<BANNER", 7 ) )
348             {
349                 /* We skip this element */
350                 if( ( psz_parse = strcasestr( psz_parse, "</BANNER>" ) ) )
351                     psz_parse += 9;
352                 else continue;
353             }
354             else if( !strncasecmp( psz_parse, "<PREVIEWDURATION", 16 ) ||
355                      !strncasecmp( psz_parse, "<LOGURL", 7 ) ||
356                      !strncasecmp( psz_parse, "<Skin", 5 ) )
357             {
358                 /* We skip this element */
359                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
360                     psz_parse += 2;
361                 else continue;
362             }
363             else if( !strncasecmp( psz_parse, "<BASE ", 6 ) )
364             {
365                 psz_parse = SkipBlanks(psz_parse+6, (unsigned)-1);
366                 if( !strncasecmp( psz_parse, "HREF", 4 ) )
367                 {
368                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
369                     {
370                         psz_backup = ++psz_parse;
371                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
372                         {
373                             StoreString( p_demux, (b_entry ? &psz_base_entry : &psz_base_asx), psz_backup, psz_parse );
374                         }
375                         else continue;
376                     }
377                     else continue;
378                 }
379                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
380                     psz_parse += 2;
381                 else continue;
382             }
383             else if( !strncasecmp( psz_parse, "<TITLE>", 7 ) )
384             {
385                 psz_backup = psz_parse+=7;
386                 if( ( psz_parse = strcasestr( psz_parse, "</TITLE>" ) ) )
387                 {
388                     StoreString( p_demux, (b_entry ? &psz_title_entry : &psz_title_asx), psz_backup, psz_parse );
389                     psz_parse += 8;
390                 }
391                 else continue;
392             }
393             else if( !strncasecmp( psz_parse, "<Author>", 8 ) )
394             {
395                 psz_backup = psz_parse+=8;
396                 if( ( psz_parse = strcasestr( psz_parse, "</Author>" ) ) )
397                 {
398                     StoreString( p_demux, (b_entry ? &psz_artist_entry : &psz_artist_asx), psz_backup, psz_parse );
399                     psz_parse += 9;
400                 }
401                 else continue;
402             }
403             else if( !strncasecmp( psz_parse, "<Copyright", 10 ) )
404             {
405                 psz_backup = psz_parse+=11;
406                 if( ( psz_parse = strcasestr( psz_parse, "</Copyright>" ) ) )
407                 {
408                     StoreString( p_demux, (b_entry ? &psz_copyright_entry : &psz_copyright_asx), psz_backup, psz_parse );
409                     psz_parse += 12;
410                 }
411                 else continue;
412             }
413             else if( !strncasecmp( psz_parse, "<MoreInfo ", 10 ) )
414             {
415                 psz_parse = SkipBlanks(psz_parse+10, (unsigned)-1);
416                 if( !strncasecmp( psz_parse, "HREF", 4 ) )
417                 {
418                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
419                     {
420                         psz_backup = ++psz_parse;
421                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
422                         {
423                             StoreString( p_demux, (b_entry ? &psz_moreinfo_entry : &psz_moreinfo_asx), psz_backup, psz_parse );
424                         }
425                         else continue;
426                     }
427                     else continue;
428                 }
429                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
430                     psz_parse += 2;
431                 else continue;
432             }
433             else if( !strncasecmp( psz_parse, "<ABSTRACT>", 10 ) )
434             {
435                 psz_backup = psz_parse+=10;
436                 if( ( psz_parse = strcasestr( psz_parse, "</ABSTRACT>" ) ) )
437                 {
438                     StoreString( p_demux, (b_entry ? &psz_abstract_entry : &psz_abstract_asx), psz_backup, psz_parse );
439                     psz_parse += 11;
440                 }
441                 else continue;
442             }
443             else if( !strncasecmp( psz_parse, "<EntryRef ", 10 ) )
444             {
445                 psz_parse = SkipBlanks(psz_parse+10, (unsigned)-1);
446                 if( !strncasecmp( psz_parse, "HREF", 4 ) )
447                 {
448                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
449                     {
450                         psz_backup = ++psz_parse;
451                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
452                         {
453                             i_strlen = psz_parse-psz_backup;
454                             if( i_strlen < 1 ) continue;
455                             psz_string = malloc( i_strlen*sizeof( char ) +1);
456                             memcpy( psz_string, psz_backup, i_strlen );
457                             psz_string[i_strlen] = '\0';
458                             p_input = input_ItemNew( p_playlist, psz_string, psz_title_asx );
459                             input_ItemCopyOptions( p_current_input, p_input );
460                             input_ItemAddSubItem( p_current_input, p_input );
461                             free( psz_string );
462                         }
463                         else continue;
464                     }
465                     else continue;
466                 }
467                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
468                     psz_parse += 2;
469                 else continue;
470             }
471             else if( !strncasecmp( psz_parse, "</Entry>", 8 ) )
472             {
473                 input_item_t *p_entry = NULL;
474                 char *psz_name = NULL;
475
476                 char * ppsz_options[2];
477                 int i_options = 0;
478
479                 /* add a new entry */
480                 psz_parse+=8;
481                 if( !b_entry )
482                 {
483                     msg_Err( p_demux, "end of entry without start?" );
484                     continue;
485                 }
486
487                 if( !psz_href )
488                 {
489                     msg_Err( p_demux, "entry without href?" );
490                     continue;
491                 }
492
493                 if( p_sys->b_skip_ads && b_skip_entry )
494                 {
495                     msg_Dbg( p_demux, "skipped entry %d %s (%s)",
496                     i_entry_count, ( psz_title_entry ? psz_title_entry : p_current_input->psz_name ), psz_href );
497                 }
498                 else
499                 {
500                     if( i_starttime || i_duration )
501                     {
502                         if( i_starttime ) {
503                             asprintf(ppsz_options+i_options, ":start-time=%d", i_starttime);
504                             ++i_options;
505                         }
506                         if( i_duration ) {
507                             asprintf(ppsz_options+i_options, ":stop-time=%d", i_starttime + i_duration);
508                             ++i_options;
509                         }
510                     }
511
512                     /* create the new entry */
513                     asprintf( &psz_name, "%d %s", i_entry_count, ( psz_title_entry ? psz_title_entry : p_current_input->psz_name ) );
514
515                     p_entry = input_ItemNewExt( p_playlist, psz_href, psz_name, i_options, (const char * const *)ppsz_options, -1 );
516                     FREENULL( psz_name );
517                     input_ItemCopyOptions( p_current_input, p_entry );
518                     while( i_options )
519                     {
520                         psz_name = ppsz_options[--i_options];
521                         FREENULL(psz_name);
522                     }
523
524                     if( psz_title_entry ) input_item_SetTitle( p_entry, psz_title_entry );
525                     if( psz_artist_entry ) input_item_SetArtist( p_entry, psz_artist_entry );
526                     if( psz_copyright_entry ) input_item_SetCopyright( p_entry, psz_copyright_entry );
527                     if( psz_moreinfo_entry ) input_item_SetURL( p_entry, psz_moreinfo_entry );
528                     if( psz_abstract_entry ) input_item_SetDescription( p_entry, psz_abstract_entry );
529                     input_ItemAddSubItem( p_current_input, p_entry );
530                     vlc_gc_decref( p_entry );
531                 }
532
533                 /* cleanup entry */;
534                 FREENULL( psz_href );
535                 FREENULL( psz_title_entry );
536                 FREENULL( psz_base_entry );
537                 FREENULL( psz_artist_entry );
538                 FREENULL( psz_copyright_entry );
539                 FREENULL( psz_moreinfo_entry );
540                 FREENULL( psz_abstract_entry );
541                 b_entry = VLC_FALSE;
542             }
543             else if( !strncasecmp( psz_parse, "<Entry", 6 ) )
544             {
545                 char *psz_clientskip;
546                 psz_parse+=6;
547                 if( b_entry )
548                 {
549                     msg_Err( p_demux, "We already are in an entry section" );
550                     continue;
551                 }
552                 i_entry_count += 1;
553                 b_entry = VLC_TRUE;
554                 psz_clientskip = strcasestr( psz_parse, "clientskip=\"no\"" );
555                 psz_parse = strcasestr( psz_parse, ">" );
556
557                 /* If clientskip was enabled ... this is an ad */
558                 b_skip_entry = (NULL != psz_clientskip) && (psz_clientskip < psz_parse);
559
560                 // init entry details
561                 FREENULL(psz_href);
562                 psz_href = NULL;
563                 i_starttime = 0;
564                 i_duration = 0;
565             }
566             else if( !strncasecmp( psz_parse, "<Ref ", 5 ) )
567             {
568                 psz_parse = SkipBlanks(psz_parse+5, (unsigned)-1);
569                 if( !b_entry )
570                 {
571                     msg_Err( p_demux, "A ref outside an entry section" );
572                     continue;
573                 }
574
575                 if( !strncasecmp( psz_parse, "HREF", 4 ) )
576                 {
577                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
578                     {
579                         psz_backup = ++psz_parse;
580                         psz_backup = SkipBlanks(psz_backup, (unsigned)-1);
581                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
582                         {
583                             char *psz_tmp;
584                             i_strlen = psz_parse-psz_backup;
585                             if( i_strlen < 1 ) continue;
586
587                             FREENULL(psz_href);
588                             psz_href = malloc( i_strlen*sizeof( char ) +1);
589                             memcpy( psz_href, psz_backup, i_strlen );
590                             psz_href[i_strlen] = '\0';
591                             psz_tmp = psz_href + (i_strlen-1);
592                             while( psz_tmp >= psz_href &&
593                                  ( *psz_tmp == '\r' || *psz_tmp == '\n' ) )
594                             {
595                                 *psz_tmp = '\0';
596                                 psz_tmp++;
597                             }
598                         }
599                         else continue;
600                     }
601                     else continue;
602                 }
603                 if( ( psz_parse = strcasestr( psz_parse, ">" ) ) )
604                     psz_parse++;
605                 else continue;
606             }
607             else if( !strncasecmp( psz_parse, "<starttime ", 11 ) )
608             {
609                 psz_parse = SkipBlanks(psz_parse+11, (unsigned)-1);
610                 if( !b_entry )
611                 {
612                     msg_Err( p_demux, "starttime outside an entry section" );
613                     continue;
614                 }
615
616                 if( !strncasecmp( psz_parse, "value", 5 ) )
617                 {
618                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
619                     {
620                         psz_backup = ++psz_parse;
621                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
622                         {
623                             i_strlen = psz_parse-psz_backup;
624                             if( i_strlen < 1 ) continue;
625
626                             i_starttime = ParseTime(psz_backup, i_strlen);
627                         }
628                         else continue;
629                     }
630                     else continue;
631                 }
632                 if( ( psz_parse = strcasestr( psz_parse, ">" ) ) )
633                     psz_parse++;
634                 else continue;
635             }
636             else if( !strncasecmp( psz_parse, "<duration ", 11 ) )
637             {
638                 psz_parse = SkipBlanks(psz_parse+5, (unsigned)-1);
639                 if( !b_entry )
640                 {
641                     msg_Err( p_demux, "duration outside an entry section" );
642                     continue;
643                 }
644
645                 if( !strncasecmp( psz_parse, "value", 5 ) )
646                 {
647                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
648                     {
649                         psz_backup = ++psz_parse;
650                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
651                         {
652                             i_strlen = psz_parse-psz_backup;
653                             if( i_strlen < 1 ) continue;
654
655                             i_duration = ParseTime(psz_backup, i_strlen);
656                         }
657                         else continue;
658                     }
659                     else continue;
660                 }
661                 if( ( psz_parse = strcasestr( psz_parse, ">" ) ) )
662                     psz_parse++;
663                 else continue;
664             }
665             else if( !strncasecmp( psz_parse, "</ASX", 5 ) )
666             {
667                 if( psz_title_asx ) input_item_SetTitle( p_current_input, psz_title_asx );
668                 if( psz_artist_asx ) input_item_SetArtist( p_current_input, psz_artist_asx );
669                 if( psz_copyright_asx ) input_item_SetCopyright( p_current_input, psz_copyright_asx );
670                 if( psz_moreinfo_asx ) input_item_SetURL( p_current_input, psz_moreinfo_asx );
671                 if( psz_abstract_asx ) input_item_SetDescription( p_current_input, psz_abstract_asx );
672                 FREENULL( psz_base_asx );
673                 FREENULL( psz_title_asx );
674                 FREENULL( psz_artist_asx );
675                 FREENULL( psz_copyright_asx );
676                 FREENULL( psz_moreinfo_asx );
677                 FREENULL( psz_abstract_asx );
678                 psz_parse++;
679             }
680             else psz_parse++;
681         }
682 #if 0
683 /* FIXME Unsupported elements */
684             PARAM
685             EVENT
686             REPEAT
687             ENDMARK
688             STARTMARK
689 #endif
690     }
691     HANDLE_PLAY_AND_RELEASE;
692     return 0; /* Needed for correct operation of go back */
693 }
694
695 static int Control( demux_t *p_demux, int i_query, va_list args )
696 {
697     return VLC_EGENERIC;
698 }