]> git.sesse.net Git - vlc/blob - modules/demux/playlist/asx.c
129ea616365dc61b819cbdbfdb133957275de13b
[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 #define _GNU_SOURCE
31 #include <stdlib.h>                                      /* malloc(), free() */
32 #include <ctype.h>                                              /* isspace() */
33
34 #include <vlc/vlc.h>
35 #include <vlc_demux.h>
36
37 #include <errno.h>                                                 /* ENOMEM */
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     vlc_bool_t b_utf8;
48     vlc_bool_t 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     if( *ppsz_string ) 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 E_(Import_ASX)( vlc_object_t *p_this )
189 {
190     demux_t *p_demux = (demux_t *)p_this;
191     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 ) || isExtension( p_demux, ".asx" ) ||
198         isExtension( p_demux, ".wax" ) || isExtension( p_demux, ".wvx" ) ||
199         isDemux( 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 = E_(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 = VLC_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 E_(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     if( p_sys->psz_prefix ) free( p_sys->psz_prefix );
225     if( p_sys->psz_data ) 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     vlc_bool_t  b_entry = VLC_FALSE;
235     input_item_t *p_input;
236     INIT_PLAYLIST_STUFF;
237
238     /* init txt */
239     if( p_sys->i_data_len < 0 )
240     {
241         int64_t i_pos = 0;
242         p_sys->i_data_len = stream_Size( p_demux->s ) +1; /* This is a cheat to prevent unnecessary realloc */
243         if( p_sys->i_data_len <= 0 && p_sys->i_data_len < 16384 ) p_sys->i_data_len = 1024;
244         p_sys->psz_data = malloc( p_sys->i_data_len * sizeof(char) +1);
245
246         /* load the complete file */
247         for( ;; )
248         {
249             int i_read = stream_Read( p_demux->s, &p_sys->psz_data[i_pos], p_sys->i_data_len - i_pos );
250             p_sys->psz_data[i_read] = '\0';
251
252             if( i_read < p_sys->i_data_len - i_pos ) break; /* Done */
253
254             i_pos += i_read;
255             p_sys->i_data_len += 1024;
256             p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) +1 );
257         }
258         if( p_sys->i_data_len <= 0 ) return VLC_EGENERIC;
259     }
260
261     psz_parse = p_sys->psz_data;
262     /* Find first element */
263     if( ( psz_parse = strcasestr( psz_parse, "<ASX" ) ) )
264     {
265         /* ASX element */
266         char *psz_string = NULL;
267         int i_strlen = 0;
268
269         char *psz_base_asx = NULL;
270         char *psz_title_asx = NULL;
271         char *psz_artist_asx = NULL;
272         char *psz_copyright_asx = NULL;
273         char *psz_moreinfo_asx = NULL;
274         char *psz_abstract_asx = NULL;
275
276         char *psz_base_entry = NULL;
277         char *psz_title_entry = NULL;
278         char *psz_artist_entry = NULL;
279         char *psz_copyright_entry = NULL;
280         char *psz_moreinfo_entry = NULL;
281         char *psz_abstract_entry = NULL;
282         int i_entry_count = 0;
283         vlc_bool_t b_skip_entry = VLC_FALSE;
284
285         char *psz_href = NULL;
286         int i_starttime = 0;
287         int i_duration = 0;
288
289         psz_parse = strcasestr( psz_parse, ">" );
290
291         while( psz_parse && ( psz_parse = strcasestr( psz_parse, "<" ) ) )
292         {
293             if( !strncasecmp( psz_parse, "<!--", 4 ) )
294             {
295                 /* this is a comment */
296                 if( ( psz_parse = strcasestr( psz_parse, "-->" ) ) )
297                     psz_parse+=3;
298                 else continue;
299             }
300             else if( !strncasecmp( psz_parse, "<PARAM ", 7 ) )
301             {
302                 vlc_bool_t b_encoding_flag = VLC_FALSE;
303                 psz_parse = SkipBlanks(psz_parse+7, (unsigned)-1);
304                 if( !strncasecmp( psz_parse, "name", 4 ) )
305                 {
306                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
307                     {
308                         psz_backup = ++psz_parse;
309                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
310                         {
311                             i_strlen = psz_parse-psz_backup;
312                             if( i_strlen < 1 ) continue;
313                             msg_Dbg( p_demux, "param name strlen: %d", i_strlen);
314                             psz_string = malloc( i_strlen *sizeof( char ) +1);
315                             memcpy( psz_string, psz_backup, i_strlen );
316                             psz_string[i_strlen] = '\0';
317                             msg_Dbg( p_demux, "param name: %s", psz_string);
318                             b_encoding_flag = !strcasecmp( psz_string, "encoding" );
319                             free( psz_string );
320                         }
321                         else continue;
322                     }
323                     else continue;
324                 }
325                 psz_parse++;
326                 if( !strncasecmp( psz_parse, "value", 5 ) )
327                 {
328                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
329                     {
330                         psz_backup = ++psz_parse;
331                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
332                         {
333                             i_strlen = psz_parse-psz_backup;
334                             if( i_strlen < 1 ) continue;
335                             msg_Dbg( p_demux, "param value strlen: %d", i_strlen);
336                             psz_string = malloc( i_strlen *sizeof( char ) +1);
337                             memcpy( psz_string, psz_backup, i_strlen );
338                             psz_string[i_strlen] = '\0';
339                             msg_Dbg( p_demux, "param value: %s", psz_string);
340                             if( b_encoding_flag && !strcasecmp( psz_string, "utf-8" ) ) p_sys->b_utf8 = VLC_TRUE;
341                             free( psz_string );
342                         }
343                         else continue;
344                     }
345                     else continue;
346                 }
347                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
348                     psz_parse += 2;
349                 else continue;
350             }
351             else if( !strncasecmp( psz_parse, "<BANNER", 7 ) )
352             {
353                 /* We skip this element */
354                 if( ( psz_parse = strcasestr( psz_parse, "</BANNER>" ) ) )
355                     psz_parse += 9;
356                 else continue;
357             }
358             else if( !strncasecmp( psz_parse, "<PREVIEWDURATION", 16 ) ||
359                      !strncasecmp( psz_parse, "<LOGURL", 7 ) ||
360                      !strncasecmp( psz_parse, "<Skin", 5 ) )
361             {
362                 /* We skip this element */
363                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
364                     psz_parse += 2;
365                 else continue;
366             }
367             else if( !strncasecmp( psz_parse, "<BASE ", 6 ) )
368             {
369                 psz_parse = SkipBlanks(psz_parse+6, (unsigned)-1);
370                 if( !strncasecmp( psz_parse, "HREF", 4 ) )
371                 {
372                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
373                     {
374                         psz_backup = ++psz_parse;
375                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
376                         {
377                             StoreString( p_demux, (b_entry ? &psz_base_entry : &psz_base_asx), psz_backup, psz_parse );
378                         }
379                         else continue;
380                     }
381                     else continue;
382                 }
383                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
384                     psz_parse += 2;
385                 else continue;
386             }
387             else if( !strncasecmp( psz_parse, "<TITLE>", 7 ) )
388             {
389                 psz_backup = psz_parse+=7;
390                 if( ( psz_parse = strcasestr( psz_parse, "</TITLE>" ) ) )
391                 {
392                     StoreString( p_demux, (b_entry ? &psz_title_entry : &psz_title_asx), psz_backup, psz_parse );
393                     psz_parse += 8;
394                 }
395                 else continue;
396             }
397             else if( !strncasecmp( psz_parse, "<Author>", 8 ) )
398             {
399                 psz_backup = psz_parse+=8;
400                 if( ( psz_parse = strcasestr( psz_parse, "</Author>" ) ) )
401                 {
402                     StoreString( p_demux, (b_entry ? &psz_artist_entry : &psz_artist_asx), psz_backup, psz_parse );
403                     psz_parse += 9;
404                 }
405                 else continue;
406             }
407             else if( !strncasecmp( psz_parse, "<Copyright", 10 ) )
408             {
409                 psz_backup = psz_parse+=11;
410                 if( ( psz_parse = strcasestr( psz_parse, "</Copyright>" ) ) )
411                 {
412                     StoreString( p_demux, (b_entry ? &psz_copyright_entry : &psz_copyright_asx), psz_backup, psz_parse );
413                     psz_parse += 12;
414                 }
415                 else continue;
416             }
417             else if( !strncasecmp( psz_parse, "<MoreInfo ", 10 ) )
418             {
419                 psz_parse = SkipBlanks(psz_parse+10, (unsigned)-1);
420                 if( !strncasecmp( psz_parse, "HREF", 4 ) )
421                 {
422                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
423                     {
424                         psz_backup = ++psz_parse;
425                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
426                         {
427                             StoreString( p_demux, (b_entry ? &psz_moreinfo_entry : &psz_moreinfo_asx), psz_backup, psz_parse );
428                         }
429                         else continue;
430                     }
431                     else continue;
432                 }
433                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
434                     psz_parse += 2;
435                 else continue;
436             }
437             else if( !strncasecmp( psz_parse, "<ABSTRACT>", 10 ) )
438             {
439                 psz_backup = psz_parse+=10;
440                 if( ( psz_parse = strcasestr( psz_parse, "</ABSTRACT>" ) ) )
441                 {
442                     StoreString( p_demux, (b_entry ? &psz_abstract_entry : &psz_abstract_asx), psz_backup, psz_parse );
443                     psz_parse += 11;
444                 }
445                 else continue;
446             }
447             else if( !strncasecmp( psz_parse, "<EntryRef ", 10 ) )
448             {
449                 psz_parse = SkipBlanks(psz_parse+10, (unsigned)-1);
450                 if( !strncasecmp( psz_parse, "HREF", 4 ) )
451                 {
452                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
453                     {
454                         psz_backup = ++psz_parse;
455                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
456                         {
457                             i_strlen = psz_parse-psz_backup;
458                             if( i_strlen < 1 ) continue;
459                             psz_string = malloc( i_strlen*sizeof( char ) +1);
460                             memcpy( psz_string, psz_backup, i_strlen );
461                             psz_string[i_strlen] = '\0';
462                             p_input = input_ItemNew( p_playlist, psz_string, psz_title_asx );
463                             input_ItemCopyOptions( p_current->p_input, p_input );
464                             playlist_BothAddInput( p_playlist, p_input,
465                                                    p_item_in_category,
466                                             PLAYLIST_APPEND|PLAYLIST_SPREPARSE,
467                                             PLAYLIST_END, NULL, NULL,
468                                             VLC_FALSE);
469                             free( psz_string );
470                         }
471                         else continue;
472                     }
473                     else continue;
474                 }
475                 if( ( psz_parse = strcasestr( psz_parse, "/>" ) ) )
476                     psz_parse += 2;
477                 else continue;
478             }
479             else if( !strncasecmp( psz_parse, "</Entry>", 8 ) )
480             {
481                 input_item_t *p_entry = NULL;
482                 char *psz_name = NULL;
483
484                 char * ppsz_options[2];
485                 int i_options = 0;
486
487                 /* add a new entry */
488                 psz_parse+=8;
489                 if( !b_entry )
490                 {
491                     msg_Err( p_demux, "end of entry without start?" );
492                     continue;
493                 }
494
495                 if( !psz_href )
496                 {
497                     msg_Err( p_demux, "entry without href?" );
498                     continue;
499                 }
500
501                 if( p_sys->b_skip_ads && b_skip_entry )
502                 {
503                     msg_Dbg( p_demux, "skipped entry %d %s (%s)",
504                     i_entry_count, ( psz_title_entry ? psz_title_entry : p_current->p_input->psz_name ), psz_href );
505                 }
506                 else
507                 {
508                     if( i_starttime || i_duration )
509                     {
510                         if( i_starttime ) {
511                             asprintf(ppsz_options+i_options, ":start-time=%d", i_starttime);
512                             ++i_options;
513                         }
514                         if( i_duration ) {
515                             asprintf(ppsz_options+i_options, ":stop-time=%d", i_starttime + i_duration);
516                             ++i_options;
517                         }
518                     }
519
520                     /* create the new entry */
521                     asprintf( &psz_name, "%d %s", i_entry_count, ( psz_title_entry ? psz_title_entry : p_current->p_input->psz_name ) );
522
523                     p_entry = input_ItemNewExt( p_playlist, psz_href, psz_name, i_options, (const char * const *)ppsz_options, -1 );
524                     FREENULL( psz_name );
525                     input_ItemCopyOptions( p_current->p_input, p_entry );
526                     while( i_options )
527                     {
528                         psz_name = ppsz_options[--i_options];
529                         FREENULL(psz_name);
530                     }
531
532                     p_entry->p_meta = vlc_meta_New();
533                     if( psz_title_entry ) vlc_meta_SetTitle( p_entry->p_meta, psz_title_entry );
534                     if( psz_artist_entry ) vlc_meta_SetArtist( p_entry->p_meta, psz_artist_entry );
535                     if( psz_copyright_entry ) vlc_meta_SetCopyright( p_entry->p_meta, psz_copyright_entry );
536                     if( psz_moreinfo_entry ) vlc_meta_SetURL( p_entry->p_meta, psz_moreinfo_entry );
537                     if( psz_abstract_entry ) vlc_meta_SetDescription( p_entry->p_meta, psz_abstract_entry );
538                     playlist_BothAddInput( p_playlist, p_entry,
539                                          p_item_in_category,
540                                          PLAYLIST_APPEND | PLAYLIST_SPREPARSE
541                                          , PLAYLIST_END, NULL, NULL,
542                                          VLC_FALSE );
543                 }
544
545                 /* cleanup entry */
546                 FREENULL( psz_href )
547                 FREENULL( psz_title_entry )
548                 FREENULL( psz_base_entry )
549                 FREENULL( psz_artist_entry )
550                 FREENULL( psz_copyright_entry )
551                 FREENULL( psz_moreinfo_entry )
552                 FREENULL( psz_abstract_entry )
553                 b_entry = VLC_FALSE;
554             }
555             else if( !strncasecmp( psz_parse, "<Entry", 6 ) )
556             {
557                 char *psz_clientskip;
558                 psz_parse+=6;
559                 if( b_entry )
560                 {
561                     msg_Err( p_demux, "We already are in an entry section" );
562                     continue;
563                 }
564                 i_entry_count += 1;
565                 b_entry = VLC_TRUE;
566                 psz_clientskip = strcasestr( psz_parse, "clientskip=\"no\"" );
567                 psz_parse = strcasestr( psz_parse, ">" );
568
569                 /* If clientskip was enabled ... this is an ad */
570                 if( psz_clientskip < psz_parse ) b_skip_entry = VLC_TRUE;
571                 else b_skip_entry = VLC_FALSE;
572
573                 // init entry details
574                 FREENULL(psz_href);
575                 psz_href = NULL;
576                 i_starttime = 0;
577                 i_duration = 0;
578             }
579             else if( !strncasecmp( psz_parse, "<Ref ", 5 ) )
580             {
581                 psz_parse = SkipBlanks(psz_parse+5, (unsigned)-1);
582                 if( !b_entry )
583                 {
584                     msg_Err( p_demux, "A ref outside an entry section" );
585                     continue;
586                 }
587
588                 if( !strncasecmp( psz_parse, "HREF", 4 ) )
589                 {
590                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
591                     {
592                         psz_backup = ++psz_parse;
593                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
594                         {
595                             i_strlen = psz_parse-psz_backup;
596                             if( i_strlen < 1 ) continue;
597
598                             FREENULL(psz_href);
599                             psz_href = malloc( i_strlen*sizeof( char ) +1);
600                             memcpy( psz_href, psz_backup, i_strlen );
601                             psz_href[i_strlen] = '\0';
602                         }
603                         else continue;
604                     }
605                     else continue;
606                 }
607                 if( ( psz_parse = strcasestr( psz_parse, ">" ) ) )
608                     psz_parse++;
609                 else continue;
610             }
611             else if( !strncasecmp( psz_parse, "<starttime ", 11 ) )
612             {
613                 psz_parse = SkipBlanks(psz_parse+11, (unsigned)-1);
614                 if( !b_entry )
615                 {
616                     msg_Err( p_demux, "starttime outside an entry section" );
617                     continue;
618                 }
619
620                 if( !strncasecmp( psz_parse, "value", 5 ) )
621                 {
622                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
623                     {
624                         psz_backup = ++psz_parse;
625                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
626                         {
627                             i_strlen = psz_parse-psz_backup;
628                             if( i_strlen < 1 ) continue;
629
630                             i_starttime = ParseTime(psz_backup, i_strlen);
631                         }
632                         else continue;
633                     }
634                     else continue;
635                 }
636                 if( ( psz_parse = strcasestr( psz_parse, ">" ) ) )
637                     psz_parse++;
638                 else continue;
639             }
640             else if( !strncasecmp( psz_parse, "<duration ", 11 ) )
641             {
642                 psz_parse = SkipBlanks(psz_parse+5, (unsigned)-1);
643                 if( !b_entry )
644                 {
645                     msg_Err( p_demux, "duration outside an entry section" );
646                     continue;
647                 }
648
649                 if( !strncasecmp( psz_parse, "value", 5 ) )
650                 {
651                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
652                     {
653                         psz_backup = ++psz_parse;
654                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
655                         {
656                             i_strlen = psz_parse-psz_backup;
657                             if( i_strlen < 1 ) continue;
658
659                             i_duration = ParseTime(psz_backup, i_strlen);
660                         }
661                         else continue;
662                     }
663                     else continue;
664                 }
665                 if( ( psz_parse = strcasestr( psz_parse, ">" ) ) )
666                     psz_parse++;
667                 else continue;
668             }
669             else if( !strncasecmp( psz_parse, "</ASX", 5 ) )
670             {
671                 vlc_mutex_lock( &p_current->p_input->lock );
672                 if( !p_current->p_input->p_meta ) p_current->p_input->p_meta = vlc_meta_New();
673                 if( psz_title_asx ) vlc_meta_SetTitle( p_current->p_input->p_meta, psz_title_asx );
674                 if( psz_artist_asx ) vlc_meta_SetArtist( p_current->p_input->p_meta, psz_artist_asx );
675                 if( psz_copyright_asx ) vlc_meta_SetCopyright( p_current->p_input->p_meta, psz_copyright_asx );
676                 if( psz_moreinfo_asx ) vlc_meta_SetURL( p_current->p_input->p_meta, psz_moreinfo_asx );
677                 if( psz_abstract_asx ) vlc_meta_SetDescription( p_current->p_input->p_meta, psz_abstract_asx );
678                 vlc_mutex_unlock( &p_current->p_input->lock );
679                 FREENULL( psz_base_asx );
680                 FREENULL( psz_title_asx );
681                 FREENULL( psz_artist_asx );
682                 FREENULL( psz_copyright_asx );
683                 FREENULL( psz_moreinfo_asx );
684                 FREENULL( psz_abstract_asx );
685                 psz_parse++;
686             }
687             else psz_parse++;
688         }
689 #if 0
690 /* FIXME Unsupported elements */
691             PARAM
692             EVENT
693             REPEAT
694             ENDMARK
695             STARTMARK
696 #endif
697     }
698     HANDLE_PLAY_AND_RELEASE;
699     return -1; /* Needed for correct operation of go back */
700 }
701
702 static int Control( demux_t *p_demux, int i_query, va_list args )
703 {
704     return VLC_EGENERIC;
705 }