]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/dvb.c
Use Latin-1 rather than local charset for ASX files
[vlc] / modules / demux / playlist / dvb.c
index dc6ee78ae936da26e709697031a6df364455cc7b..1af284c58073ab948475786ff0d649d297f4e404 100644 (file)
@@ -24,8 +24,6 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 #include <vlc/intf.h>
@@ -54,13 +52,10 @@ int E_(Import_DVB)( vlc_object_t *p_this )
     demux_t *p_demux = (demux_t *)p_this;
     uint8_t *p_peek;
     int     i_peek;
-    char    *psz_ext;
     vlc_bool_t b_valid = VLC_FALSE;
 
-    psz_ext = strrchr ( p_demux->psz_path, '.' );
-
-    if( !( psz_ext && !strncasecmp( psz_ext, ".conf", 5 ) ) &&
-        !p_demux->b_force ) return VLC_EGENERIC;
+    if( !isExtension( p_demux, ".conf" ) && !p_demux->b_force )
+        return VLC_EGENERIC;
 
     /* Check if this really is a channels file */
     if( (i_peek = stream_Peek( p_demux->s, &p_peek, 1024 )) > 0 )
@@ -81,7 +76,6 @@ int E_(Import_DVB)( vlc_object_t *p_this )
     if( !b_valid ) return VLC_EGENERIC;
 
     msg_Dbg( p_demux, "found valid DVB conf playlist file");
-
     p_demux->pf_control = Control;
     p_demux->pf_demux = Demux;
 
@@ -100,28 +94,12 @@ void E_(Close_DVB)( vlc_object_t *p_this )
  *****************************************************************************/
 static int Demux( demux_t *p_demux )
 {
-#if 0
-    playlist_t *p_playlist;
     char       *psz_line;
-    playlist_item_t *p_current;
-    vlc_bool_t b_play;
-
-    p_playlist = (playlist_t *) vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
-                                                 FIND_ANYWHERE );
-    if( !p_playlist )
-    {
-        msg_Err( p_demux, "can't find playlist" );
-        return -1;
-    }
-
-    b_play = E_(FindItem)( p_demux, p_playlist, &p_current );
-
-    playlist_ItemToNode( p_playlist, p_current );
-    p_current->p_input->i_type = ITEM_TYPE_PLAYLIST;
+    input_item_t *p_input;
+    INIT_PLAYLIST_STUFF;
 
     while( (psz_line = stream_ReadLine( p_demux->s )) )
     {
-        playlist_item_t *p_item;
         char **ppsz_options = NULL;
         int  i, i_options = 0;
         char *psz_name = NULL;
@@ -134,20 +112,14 @@ static int Demux( demux_t *p_demux )
 
         EnsureUTF8( psz_name );
 
-        p_item = playlist_ItemNew( p_playlist, "dvb:", psz_name );
+        p_input = input_ItemNewExt( p_playlist, "dvb:", psz_name, 0, NULL, -1 );
         for( i = 0; i< i_options; i++ )
         {
             EnsureUTF8( ppsz_options[i] );
-            playlist_ItemAddOption( p_item, ppsz_options[i] );
+            input_ItemAddOption( p_input, ppsz_options[i] );
         }
-        playlist_NodeAddItem( p_playlist, p_item,
-                              p_current->pp_parents[0]->i_view,
-                              p_current, PLAYLIST_APPEND, PLAYLIST_END );
-
-        /* We need to declare the parents of the node as the
-         *                  * same of the parent's ones */
-        playlist_CopyParents( p_current, p_item );
-        vlc_input_item_CopyOptions( &p_current->input, &p_item->input );
+        playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
+                               PLAYLIST_APPEND, PLAYLIST_END );
 
         while( i_options-- ) free( ppsz_options[i_options] );
         if( ppsz_options ) free( ppsz_options );
@@ -155,26 +127,14 @@ static int Demux( demux_t *p_demux )
         free( psz_line );
     }
 
-    /* Go back and play the playlist */
-    if( b_play && p_playlist->status.p_item &&
-        p_playlist->status.p_item->i_children > 0 )
-    {
-        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
-                          p_playlist->status.i_view,
-                          p_playlist->status.p_item,
-                          p_playlist->status.p_item->pp_children[0] );
-    }
-
-    vlc_object_release( p_playlist );
+    HANDLE_PLAY_AND_RELEASE;
     return VLC_SUCCESS;
-#endif
-    return 0;
 }
 
 static struct
 {
-    char *psz_name;
-    char *psz_option;
+    const char *psz_name;
+    const char *psz_option;
 
 } dvb_options[] =
 {
@@ -244,7 +204,7 @@ static int ParseLine( char *psz_line, char **ppsz_name,
 
     while( psz_parse )
     {
-        char *psz_option = 0;
+        const char *psz_option = 0;
         char *psz_end = strchr( psz_parse, ':' );
         if( psz_end ) { *psz_end = 0; psz_end++; }
 
@@ -300,9 +260,10 @@ static int ParseLine( char *psz_line, char **ppsz_name,
 
         if( psz_option && pppsz_options && pi_options )
         {
-            psz_option = strdup( psz_option );
-            INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options),
-                         psz_option );
+            char *psz_dup = strdup( psz_option );
+            if (psz_dup != NULL)
+                INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options),
+                             psz_dup );
         }
 
         psz_parse = psz_end;