]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/m3u.c
xspf: factorize and set to NULL only when needed.
[vlc] / modules / demux / playlist / m3u.c
index 49e4869583e01700d3908e28f51b59e316663285..9770b29a147e67ef207e9f6ee1d8bed577246727 100644 (file)
@@ -60,8 +60,6 @@ int Import_M3U( vlc_object_t *p_this )
 
     if(! ( POKE( p_peek, "#EXTM3U", 7 ) || POKE( p_peek, "RTSPtext", 8 ) ||
            demux_IsPathExtension( p_demux, ".m3u" ) || demux_IsPathExtension( p_demux, ".vlc" ) ||
-           /* A .ram file can contain a single rtsp link */
-           demux_IsPathExtension( p_demux, ".ram" ) || demux_IsPathExtension( p_demux, ".rm" ) ||
            demux_IsForced( p_demux,  "m3u" ) || ContainsURL( p_demux ) ) )
         return VLC_EGENERIC;
 
@@ -73,9 +71,8 @@ int Import_M3U( vlc_object_t *p_this )
 
 static bool ContainsURL( demux_t *p_demux )
 {
-    uint8_t *p_peek;
+    const uint8_t *p_peek, *p_peek_end;
     int i_peek;
-    uint8_t *p_peek_end;
 
     i_peek = stream_Peek( p_demux->s, &p_peek, 1024 );
     if( i_peek <= 0 ) return false;
@@ -84,11 +81,11 @@ static bool ContainsURL( demux_t *p_demux )
     while( p_peek + sizeof( "https://" ) < p_peek_end )
     {
         /* One line starting with an URL is enough */
-        if( !strncasecmp( p_peek, "http://", sizeof( "http://" ) - 1 ) ||
-            !strncasecmp( p_peek, "mms://", sizeof( "mms://" ) - 1 ) ||
-            !strncasecmp( p_peek, "rtsp://", sizeof( "rtsp://" ) - 1 ) ||
-            !strncasecmp( p_peek, "https://", sizeof( "https://" ) - 1 ) ||
-            !strncasecmp( p_peek, "ftp://", sizeof( "ftp://" ) - 1 ) )
+        if( !strncasecmp( (const char *)p_peek, "http://", 7 ) ||
+            !strncasecmp( (const char *)p_peek, "mms://", 6 ) ||
+            !strncasecmp( (const char *)p_peek, "rtsp://", 7 ) ||
+            !strncasecmp( (const char *)p_peek, "https://", 8 ) ||
+            !strncasecmp( (const char *)p_peek, "ftp://", 6 ) )
         {
             return true;
         }
@@ -218,15 +215,13 @@ static int Demux( demux_t *p_demux )
             b_cleanup = true;
             if( !psz_mrl ) goto error;
 
-            p_input = input_ItemNewExt( p_demux, psz_mrl, psz_name,
-                                        0, NULL, i_duration );
+            p_input = input_item_NewExt( p_demux, psz_mrl, psz_name,
+                                        i_options, ppsz_options, 0, i_duration );
 
             if ( psz_artist && *psz_artist )
                 input_item_SetArtist( p_input, psz_artist );
 
-            input_ItemAddSubItem( p_current_input, p_input );
-            for( int i = 0; i < i_options; i++ )
-                input_ItemAddOpt( p_input, ppsz_options[i], 0 );
+            input_item_AddSubItem( p_current_input, p_input );
             vlc_gc_decref( p_input );
             free( psz_mrl );
         }