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