]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/shoutcast.c
codecleanup: Replace input_Item by input_item.
[vlc] / modules / demux / playlist / shoutcast.c
index d47e41312eaaeb9b71fce73f3ada84624d025183..e967fd347b79562ca6f926113ff7523550571189 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <ctype.h>                                              /* isspace() */
 
-#include <vlc/vlc.h>
-#include <vlc/input.h>
-#include <vlc/intf.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_demux.h>
 
-#include <errno.h>                                                 /* ENOMEM */
 #include "playlist.h"
 #include "vlc_xml.h"
 
 struct demux_sys_t
 {
-    playlist_t *p_playlist;
-    playlist_item_t *p_current;
-    playlist_item_t *p_item_in_category;
-    int i_parent_id;
+    input_item_t *p_current_input;
 
     xml_t *p_xml;
     xml_reader_t *p_xml_reader;
 
-    vlc_bool_t b_adult;
+    bool b_adult;
 };
 
 /* duplicate from modules/services_discovery/shout.c */
@@ -65,15 +63,14 @@ static int DemuxStation( demux_t *p_demux );
 /*****************************************************************************
  * Import_Shoutcast: main import function
  *****************************************************************************/
-int E_(Import_Shoutcast)( vlc_object_t *p_this )
+int Import_Shoutcast( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
-    if( !isDemux( p_demux, "shout-winamp" ) )
+    if( !demux_IsForced( p_demux, "shout-winamp" ) )
         return VLC_EGENERIC;
-    
+
     STANDARD_DEMUX_INIT_MSG( "using shoutcast playlist reader" );
-    p_demux->p_sys->p_playlist = NULL;
     p_demux->p_sys->p_xml = NULL;
     p_demux->p_sys->p_xml_reader = NULL;
 
@@ -88,13 +85,11 @@ int E_(Import_Shoutcast)( vlc_object_t *p_this )
 /*****************************************************************************
  * Deactivate: frees unused data
  *****************************************************************************/
-void E_(Close_Shoutcast)( vlc_object_t *p_this )
+void Close_Shoutcast( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    if( p_sys->p_playlist )
-        vlc_object_release( p_sys->p_playlist );
     if( p_sys->p_xml_reader )
         xml_ReaderDelete( p_sys->p_xml, p_sys->p_xml_reader );
     if( p_sys->p_xml )
@@ -109,10 +104,7 @@ static int Demux( demux_t *p_demux )
     xml_reader_t *p_xml_reader;
     char *psz_eltname = NULL;
     INIT_PLAYLIST_STUFF;
-    p_sys->p_playlist = p_playlist;
-    p_sys->p_current = p_current;
-    p_sys->i_parent_id = i_parent_id;
-    p_sys->p_item_in_category = p_item_in_category;
+    p_sys->p_current_input = p_current_input;
 
     p_xml = p_sys->p_xml = xml_Create( p_demux );
     if( !p_xml ) return -1;
@@ -135,7 +127,7 @@ static int Demux( demux_t *p_demux )
     {
         msg_Err( p_demux, "invalid root node %i, %s",
                  xml_ReaderNodeType( p_xml_reader ), psz_eltname );
-        if( psz_eltname ) free( psz_eltname );
+        free( psz_eltname );
         return -1;
     }
 
@@ -153,8 +145,7 @@ static int Demux( demux_t *p_demux )
     }
 
     HANDLE_PLAY_AND_RELEASE;
-    p_sys->p_playlist = NULL;
-    return VLC_SUCCESS;
+    return 0; /* Needed for correct operation of go back */
 }
 
 #define GET_VALUE( a ) \
@@ -237,15 +228,13 @@ static int DemuxGenre( demux_t *p_demux )
                             + strlen( "?genre=" ) + strlen( psz_name ) + 1 );
                     sprintf( psz_mrl, SHOUTCAST_BASE_URL "?genre=%s",
                              psz_name );
-                    p_input = input_ItemNewExt( p_sys->p_playlist, psz_mrl,
+                    p_input = input_item_NewExt( p_demux, psz_mrl,
                                                 psz_name, 0, NULL, -1 );
-                    vlc_input_item_CopyOptions( p_sys->p_current->p_input,
+                    input_item_CopyOptions( p_sys->p_current_input,
                                                 p_input );
                     free( psz_mrl );
-                    playlist_AddWhereverNeeded( p_sys->p_playlist, p_input,
-                             p_sys->p_current, p_sys->p_item_in_category,
-                             (p_sys->i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE,
-                             PLAYLIST_APPEND );
+                    input_item_AddSubItem( p_sys->p_current_input, p_input );
+                    vlc_gc_decref( p_input );
                     FREENULL( psz_name );
                 }
                 FREENULL( psz_eltname );
@@ -413,40 +402,35 @@ static int DemuxStation( demux_t *p_demux )
                         sprintf( psz_mrl, SHOUTCAST_TUNEIN_BASE_URL "%s?id=%s",
                              psz_base, psz_id );
                     }
-                    p_input = input_ItemNewExt( p_sys->p_playlist, psz_mrl,
+                    p_input = input_item_NewExt( p_demux, psz_mrl,
                                                 psz_name , 0, NULL, -1 );
                     free( psz_mrl );
 
-                    vlc_input_item_CopyOptions( p_sys->p_current->p_input,
+                    input_item_CopyOptions( p_sys->p_current_input,
                                                 p_input );
 
-#define SADD_INFO( type, field ) if( field ) { vlc_input_item_AddInfo( \
+#define SADD_INFO( type, field ) if( field ) { input_item_AddInfo( \
                     p_input, _("Shoutcast"), _(type), "%s", field ) ; }
                     SADD_INFO( "Mime type", psz_mt );
                     SADD_INFO( "Bitrate", psz_br );
                     SADD_INFO( "Listeners", psz_lc );
                     SADD_INFO( "Load", psz_load );
-                    p_input->p_meta = vlc_meta_New();
                     if( psz_genre )
-                        vlc_meta_SetGenre( p_input->p_meta, psz_genre );
+                        input_item_SetGenre( p_input, psz_genre );
                     if( psz_ct )
-                        vlc_meta_SetNowPlaying( p_input->p_meta, psz_ct );
+                        input_item_SetNowPlaying( p_input, psz_ct );
                     if( psz_rt )
-                        vlc_meta_SetRating( p_input->p_meta, psz_rt );
-
-                    playlist_AddWhereverNeeded( p_sys->p_playlist, p_input,
-                             p_sys->p_current, p_sys->p_item_in_category,
-                             (p_sys->i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE,
-                             PLAYLIST_APPEND );
-
+                        input_item_SetRating( p_input, psz_rt );
+                    input_item_AddSubItem( p_sys->p_current_input, p_input );
+                    vlc_gc_decref( p_input );
                     FREENULL( psz_name );
-                    FREENULL( psz_mt )
-                    FREENULL( psz_id )
-                    FREENULL( psz_br )
-                    FREENULL( psz_genre )
-                    FREENULL( psz_ct )
-                    FREENULL( psz_lc )
-                    FREENULL( psz_rt )
+                    FREENULL( psz_mt );
+                    FREENULL( psz_id );
+                    FREENULL( psz_br );
+                    FREENULL( psz_genre );
+                    FREENULL( psz_ct );
+                    FREENULL( psz_lc );
+                    FREENULL( psz_rt );
                 }
                 free( psz_eltname );
                 break;
@@ -457,5 +441,6 @@ static int DemuxStation( demux_t *p_demux )
 
 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;
 }