]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/b4s.c
Removes trailing spaces. Removes tabs.
[vlc] / modules / demux / playlist / b4s.c
index 082ed74f2fbe9d6155c210910daa4e233cf5d191..f9d6c9ffc0522556bc5d6a8b9a3562ce796967cf 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <ctype.h>                                              /* isspace() */
 
 #include <vlc/vlc.h>
-#include <vlc/input.h>
-#include <vlc/intf.h>
+#include <vlc_demux.h>
+#include <vlc_interface.h>
 
-#include <errno.h>                                                 /* ENOMEM */
 #include "playlist.h"
 #include "vlc_xml.h"
 
@@ -47,7 +44,7 @@ struct demux_sys_t
  *****************************************************************************/
 static int Demux( demux_t *p_demux);
 static int Control( demux_t *p_demux, int i_query, va_list args );
-static char *GetNextToken(char *psz_cur_string);
+//static char *GetNextToken(char *psz_cur_string);
 static int IsWhitespace( char *psz_string );
 
 /*****************************************************************************
@@ -55,36 +52,11 @@ static int IsWhitespace( char *psz_string );
  *****************************************************************************/
 int E_(Import_B4S)( vlc_object_t *p_this )
 {
-    demux_t *p_demux = (demux_t *)p_this;
-    demux_sys_t *p_sys;
-
-    char    *psz_ext;
-
-    psz_ext = strrchr ( p_demux->psz_path, '.' );
-
-    if( ( psz_ext && !strcasecmp( psz_ext, ".b4s") ) ||
-        ( p_demux->psz_demux && !strcmp(p_demux->psz_demux, "b4s-open") ) )
-    {
-        ;
-    }
-    else
-    {
-        return VLC_EGENERIC;
-    }
-    msg_Dbg( p_demux, "using b4s playlist import");
-
-    p_demux->pf_control = Control;
-    p_demux->pf_demux = Demux;
-    p_demux->p_sys = p_sys = malloc( sizeof(demux_sys_t) );
-    if( p_sys == NULL )
-    {
-        msg_Err( p_demux, "out of memory" );
-        return VLC_ENOMEM;
-    }
-    p_sys->psz_prefix = E_(FindPrefix)( p_demux );
-    p_sys->p_xml = NULL;
-    p_sys->p_xml_reader = NULL;
-
+    DEMUX_BY_EXTENSION_OR_FORCED_MSG( ".b4s", "b4s-open",
+                                      "using B4S playlist reader" );
+    p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
+    p_demux->p_sys->p_xml = NULL;
+    p_demux->p_sys->p_xml_reader = NULL;
     return VLC_SUCCESS;
 }
 
@@ -105,12 +77,13 @@ void E_(Close_B4S)( vlc_object_t *p_this )
 static int Demux( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
-    int i_ret, i_parent_id;
+    int i_ret;
 
     xml_t *p_xml;
     xml_reader_t *p_xml_reader;
     char *psz_elname = NULL;
     int i_type;
+    input_item_t *p_input;
     char *psz_mrl = NULL, *psz_name = NULL, *psz_genre = NULL;
     char *psz_now = NULL, *psz_listeners = NULL, *psz_bitrate = NULL;
 
@@ -181,7 +154,7 @@ static int Demux( demux_t *p_demux )
         }
         else if( !strcmp( psz_name, "label" ) )
         {
-            playlist_ItemSetName( p_current, psz_value );
+            input_item_SetName( p_current_input, psz_value );
         }
         else
         {
@@ -284,26 +257,21 @@ static int Demux( demux_t *p_demux )
                     p_input = input_ItemNewExt( p_playlist, psz_mrl, psz_name,
                                                 0, NULL, -1 );
                     if( psz_now )
-                        vlc_meta_SetNowPlaying( p_input->p_meta, psz_now );
+                        input_item_SetNowPlaying( p_input, psz_now );
                     if( psz_genre )
-                        vlc_meta_SetGenre( p_input->p_meta, psz_genre );
+                        input_item_SetGenre( p_input, psz_genre );
                     if( psz_listeners )
                         msg_Err( p_playlist, "Unsupported meta listeners" );
                     if( psz_bitrate )
                         msg_Err( p_playlist, "Unsupported meta bitrate" );
 
-                    playlist_AddWhereverNeeded( p_playlist, p_input, p_current,
-                         p_item_in_category, (i_parent_id > 0 ) ? VLC_TRUE:
-                                                 VLC_FALSE, PLAYLIST_APPEND );
-
-#define FREE(a) if( a ) free( a ); a = NULL;
-                    FREE( psz_name );
-                    FREE( psz_mrl );
-                    FREE( psz_genre );
-                    FREE( psz_bitrate );
-                    FREE( psz_listeners );
-                    FREE( psz_now );
-#undef FREE
+                    input_ItemAddSubItem( p_current_input, p_input );
+                    FREENULL( psz_name );
+                    FREENULL( psz_mrl );
+                    FREENULL( psz_genre );
+                    FREENULL( psz_bitrate );
+                    FREENULL( psz_listeners );
+                    FREENULL( psz_now );
                 }
                 free( psz_elname );
                 psz_elname = strdup("");
@@ -319,7 +287,7 @@ static int Demux( demux_t *p_demux )
     }
 
     HANDLE_PLAY_AND_RELEASE;
-    return VLC_SUCCESS;
+    return -1; /* Needed for correct operation of go back */
 }
 
 static int Control( demux_t *p_demux, int i_query, va_list args )
@@ -327,6 +295,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     return VLC_EGENERIC;
 }
 
+#if 0
 /**
  * Get a in-string pointer to the start of the next token from a
  * string terminating the pointer returned by a previous call.
@@ -347,6 +316,7 @@ static char *GetNextToken(char *psz_cur_string) {
         psz_cur_string++;
     return psz_cur_string;
 }
+#endif
 
 static int IsWhitespace( char *psz_string )
 {