]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/dvb.c
fix #1410.
[vlc] / modules / demux / playlist / dvb.c
index 0be77b3016d86e97a99dea9cb693df5664da3428..5e3edb5ce18242b44c5bba029886a316d5769a34 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-
 #include <vlc/vlc.h>
-#include <vlc/input.h>
-#include <vlc/intf.h>
-#include "charset.h"
+#include <vlc_demux.h>
+#include <vlc_interface.h>
+#include <vlc_charset.h>
 
 #include "playlist.h"
 
@@ -52,15 +50,12 @@ static int ParseLine( char *, char **, char ***, int *);
 int E_(Import_DVB)( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
-    uint8_t *p_peek;
+    const 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( !demux2_IsPathExtension( 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;
 
@@ -101,11 +95,11 @@ void E_(Close_DVB)( vlc_object_t *p_this )
 static int Demux( demux_t *p_demux )
 {
     char       *psz_line;
+    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;
@@ -122,13 +116,10 @@ static int Demux( demux_t *p_demux )
         for( i = 0; i< i_options; i++ )
         {
             EnsureUTF8( ppsz_options[i] );
-            vlc_input_item_AddOption( p_input, ppsz_options[i] );
+            input_ItemAddOption( p_input, ppsz_options[i] );
         }
-        playlist_AddWhereverNeeded( p_playlist, p_input, p_current, 
-                                    p_item_in_category,
-                                    (i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE,
-                                    PLAYLIST_APPEND );
-
+        input_ItemAddSubItem( p_current_input, p_input, VLC_FALSE );
+        vlc_gc_decref( p_input );
         while( i_options-- ) free( ppsz_options[i_options] );
         if( ppsz_options ) free( ppsz_options );
 
@@ -136,13 +127,13 @@ static int Demux( demux_t *p_demux )
     }
 
     HANDLE_PLAY_AND_RELEASE;
-    return VLC_SUCCESS;
+    return 0; /* Needed for correct operation of go back */
 }
 
 static struct
 {
-    char *psz_name;
-    char *psz_option;
+    const char *psz_name;
+    const char *psz_option;
 
 } dvb_options[] =
 {
@@ -184,6 +175,8 @@ static struct
     { "QAM_64", "dvb-modulation=64" },
     { "QAM_128", "dvb-modulation=128" },
     { "QAM_256", "dvb-modulation=256" },
+    { "8VSB", "dvb-modulation=8"  },
+    { "16VSB", "dvb-modulation=16"  },
 
     { "TRANSMISSION_MODE_AUTO", "dvb-transmission=0" },
     { "TRANSMISSION_MODE_2K", "dvb-transmission=2" },
@@ -212,7 +205,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++; }
 
@@ -268,9 +261,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;