]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/asx.c
demux/playlist/ : removes useless unused parameter warnings
[vlc] / modules / demux / playlist / asx.c
index 129ea616365dc61b819cbdbfdb133957275de13b..b24c91772bc210f239a7f60867c9828ce00c9eab 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#define _GNU_SOURCE
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <ctype.h>                                              /* isspace() */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include <vlc/vlc.h>
 #include <vlc_demux.h>
 
-#include <errno.h>                                                 /* ENOMEM */
+#include <ctype.h>
 #include <vlc_charset.h>
 #include "playlist.h"
 #include "vlc_meta.h"
@@ -188,15 +188,15 @@ static int ParseTime(char *s, size_t i_strlen)
 int E_(Import_ASX)( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
-    uint8_t *p_peek;
+    const uint8_t *p_peek;
     CHECK_PEEK( p_peek, 10 );
 
     // skip over possible leading empty lines and empty spaces
     p_peek = (uint8_t *)SkipBlanks((char *)p_peek, 6);
 
-    if( POKE( p_peek, "<asx", 4 ) || isExtension( p_demux, ".asx" ) ||
-        isExtension( p_demux, ".wax" ) || isExtension( p_demux, ".wvx" ) ||
-        isDemux( p_demux, "asx-open" ) )
+    if( POKE( p_peek, "<asx", 4 ) || demux2_IsPathExtension( p_demux, ".asx" ) ||
+        demux2_IsPathExtension( p_demux, ".wax" ) || demux2_IsPathExtension( p_demux, ".wvx" ) ||
+        demux2_IsForced( p_demux, "asx-open" ) )
     {
         ;
     }
@@ -255,7 +255,7 @@ static int Demux( demux_t *p_demux )
             p_sys->i_data_len += 1024;
             p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) +1 );
         }
-        if( p_sys->i_data_len <= 0 ) return VLC_EGENERIC;
+        if( p_sys->i_data_len <= 0 ) return -1;
     }
 
     psz_parse = p_sys->psz_data;
@@ -460,12 +460,8 @@ static int Demux( demux_t *p_demux )
                             memcpy( psz_string, psz_backup, i_strlen );
                             psz_string[i_strlen] = '\0';
                             p_input = input_ItemNew( p_playlist, psz_string, psz_title_asx );
-                            input_ItemCopyOptions( p_current->p_input, p_input );
-                            playlist_BothAddInput( p_playlist, p_input,
-                                                   p_item_in_category,
-                                            PLAYLIST_APPEND|PLAYLIST_SPREPARSE,
-                                            PLAYLIST_END, NULL, NULL,
-                                            VLC_FALSE);
+                            input_ItemCopyOptions( p_current_input, p_input );
+                            input_ItemAddSubItem( p_current_input, p_input );
                             free( psz_string );
                         }
                         else continue;
@@ -501,7 +497,7 @@ static int Demux( demux_t *p_demux )
                 if( p_sys->b_skip_ads && b_skip_entry )
                 {
                     msg_Dbg( p_demux, "skipped entry %d %s (%s)",
-                    i_entry_count, ( psz_title_entry ? psz_title_entry : p_current->p_input->psz_name ), psz_href );
+                    i_entry_count, ( psz_title_entry ? psz_title_entry : p_current_input->psz_name ), psz_href );
                 }
                 else
                 {
@@ -518,38 +514,34 @@ static int Demux( demux_t *p_demux )
                     }
 
                     /* create the new entry */
-                    asprintf( &psz_name, "%d %s", i_entry_count, ( psz_title_entry ? psz_title_entry : p_current->p_input->psz_name ) );
+                    asprintf( &psz_name, "%d %s", i_entry_count, ( psz_title_entry ? psz_title_entry : p_current_input->psz_name ) );
 
                     p_entry = input_ItemNewExt( p_playlist, psz_href, psz_name, i_options, (const char * const *)ppsz_options, -1 );
                     FREENULL( psz_name );
-                    input_ItemCopyOptions( p_current->p_input, p_entry );
+                    input_ItemCopyOptions( p_current_input, p_entry );
                     while( i_options )
                     {
                         psz_name = ppsz_options[--i_options];
                         FREENULL(psz_name);
                     }
 
-                    p_entry->p_meta = vlc_meta_New();
-                    if( psz_title_entry ) vlc_meta_SetTitle( p_entry->p_meta, psz_title_entry );
-                    if( psz_artist_entry ) vlc_meta_SetArtist( p_entry->p_meta, psz_artist_entry );
-                    if( psz_copyright_entry ) vlc_meta_SetCopyright( p_entry->p_meta, psz_copyright_entry );
-                    if( psz_moreinfo_entry ) vlc_meta_SetURL( p_entry->p_meta, psz_moreinfo_entry );
-                    if( psz_abstract_entry ) vlc_meta_SetDescription( p_entry->p_meta, psz_abstract_entry );
-                    playlist_BothAddInput( p_playlist, p_entry,
-                                         p_item_in_category,
-                                         PLAYLIST_APPEND | PLAYLIST_SPREPARSE
-                                         , PLAYLIST_END, NULL, NULL,
-                                         VLC_FALSE );
+                    if( psz_title_entry ) input_item_SetTitle( p_entry, psz_title_entry );
+                    if( psz_artist_entry ) input_item_SetArtist( p_entry, psz_artist_entry );
+                    if( psz_copyright_entry ) input_item_SetCopyright( p_entry, psz_copyright_entry );
+                    if( psz_moreinfo_entry ) input_item_SetURL( p_entry, psz_moreinfo_entry );
+                    if( psz_abstract_entry ) input_item_SetDescription( p_entry, psz_abstract_entry );
+                    input_ItemAddSubItem( p_current_input, p_entry );
+                    vlc_gc_decref( p_entry );
                 }
 
-                /* cleanup entry */
-                FREENULL( psz_href )
-                FREENULL( psz_title_entry )
-                FREENULL( psz_base_entry )
-                FREENULL( psz_artist_entry )
-                FREENULL( psz_copyright_entry )
-                FREENULL( psz_moreinfo_entry )
-                FREENULL( psz_abstract_entry )
+                /* cleanup entry */;
+                FREENULL( psz_href );
+                FREENULL( psz_title_entry );
+                FREENULL( psz_base_entry );
+                FREENULL( psz_artist_entry );
+                FREENULL( psz_copyright_entry );
+                FREENULL( psz_moreinfo_entry );
+                FREENULL( psz_abstract_entry );
                 b_entry = VLC_FALSE;
             }
             else if( !strncasecmp( psz_parse, "<Entry", 6 ) )
@@ -567,8 +559,7 @@ static int Demux( demux_t *p_demux )
                 psz_parse = strcasestr( psz_parse, ">" );
 
                 /* If clientskip was enabled ... this is an ad */
-                if( psz_clientskip < psz_parse ) b_skip_entry = VLC_TRUE;
-                else b_skip_entry = VLC_FALSE;
+                b_skip_entry = (NULL != psz_clientskip) && (psz_clientskip < psz_parse);
 
                 // init entry details
                 FREENULL(psz_href);
@@ -590,8 +581,10 @@ static int Demux( demux_t *p_demux )
                     if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
                     {
                         psz_backup = ++psz_parse;
+                        psz_backup = SkipBlanks(psz_backup, (unsigned)-1);
                         if( ( psz_parse = strcasestr( psz_parse, "\"" ) ) )
                         {
+                            char *psz_tmp;
                             i_strlen = psz_parse-psz_backup;
                             if( i_strlen < 1 ) continue;
 
@@ -599,6 +592,13 @@ static int Demux( demux_t *p_demux )
                             psz_href = malloc( i_strlen*sizeof( char ) +1);
                             memcpy( psz_href, psz_backup, i_strlen );
                             psz_href[i_strlen] = '\0';
+                            psz_tmp = psz_href + (i_strlen-1);
+                            while( psz_tmp >= psz_href &&
+                                 ( *psz_tmp == '\r' || *psz_tmp == '\n' ) )
+                            {
+                                *psz_tmp = '\0';
+                                psz_tmp++;
+                            }
                         }
                         else continue;
                     }
@@ -668,14 +668,11 @@ static int Demux( demux_t *p_demux )
             }
             else if( !strncasecmp( psz_parse, "</ASX", 5 ) )
             {
-                vlc_mutex_lock( &p_current->p_input->lock );
-                if( !p_current->p_input->p_meta ) p_current->p_input->p_meta = vlc_meta_New();
-                if( psz_title_asx ) vlc_meta_SetTitle( p_current->p_input->p_meta, psz_title_asx );
-                if( psz_artist_asx ) vlc_meta_SetArtist( p_current->p_input->p_meta, psz_artist_asx );
-                if( psz_copyright_asx ) vlc_meta_SetCopyright( p_current->p_input->p_meta, psz_copyright_asx );
-                if( psz_moreinfo_asx ) vlc_meta_SetURL( p_current->p_input->p_meta, psz_moreinfo_asx );
-                if( psz_abstract_asx ) vlc_meta_SetDescription( p_current->p_input->p_meta, psz_abstract_asx );
-                vlc_mutex_unlock( &p_current->p_input->lock );
+                if( psz_title_asx ) input_item_SetTitle( p_current_input, psz_title_asx );
+                if( psz_artist_asx ) input_item_SetArtist( p_current_input, psz_artist_asx );
+                if( psz_copyright_asx ) input_item_SetCopyright( p_current_input, psz_copyright_asx );
+                if( psz_moreinfo_asx ) input_item_SetURL( p_current_input, psz_moreinfo_asx );
+                if( psz_abstract_asx ) input_item_SetDescription( p_current_input, psz_abstract_asx );
                 FREENULL( psz_base_asx );
                 FREENULL( psz_title_asx );
                 FREENULL( psz_artist_asx );
@@ -696,10 +693,11 @@ static int Demux( demux_t *p_demux )
 #endif
     }
     HANDLE_PLAY_AND_RELEASE;
-    return -1; /* Needed for correct operation of go back */
+    return 0; /* Needed for correct operation of go back */
 }
 
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
+    VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args);
     return VLC_EGENERIC;
 }