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