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