1 /*****************************************************************************
2 * shout.c: Shoutcast services discovery module
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
7 * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
8 * Antoine Cellerier <dionoea -@T- videolan -d.t- org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
30 #include <vlc_services_discovery.h>
31 #include <vlc_interface.h>
33 #include <vlc_network.h>
35 #include <errno.h> /* ENOMEM */
40 #ifdef HAVE_SYS_TIME_H
41 # include <sys/time.h>
44 /************************************************************************
45 * Macros and definitions
46 ************************************************************************/
48 #define MAX_LINE_LENGTH 256
49 #define SHOUTCAST_BASE_URL "http/shout-winamp://www.shoutcast.com/sbin/newxml.phtml"
50 #define SHOUTCAST_TV_BASE_URL "http/shout-winamp://www.shoutcast.com/sbin/newtvlister.phtml?alltv=1"
52 /*****************************************************************************
54 *****************************************************************************/
57 static int Open ( vlc_object_t *, int );
58 static int OpenRadio ( vlc_object_t * );
59 static int OpenTV ( vlc_object_t * );
60 static void Close( vlc_object_t * );
63 set_shortname( "Shoutcast");
64 set_description( _("Shoutcast radio listings") );
65 add_shortcut( "shoutcast" );
66 set_category( CAT_PLAYLIST );
67 set_subcategory( SUBCAT_PLAYLIST_SD );
69 add_obsolete_integer( "shoutcast-limit" );
71 set_capability( "services_discovery", 0 );
72 set_callbacks( OpenRadio, Close );
75 set_shortname( "ShoutcastTV" );
76 set_description( _("Shoutcast TV listings") );
77 set_capability( "services_discovery", 0 );
78 set_callbacks( OpenTV, Close );
79 add_shortcut( "shoutcasttv" );
84 /*****************************************************************************
86 *****************************************************************************/
88 struct services_discovery_sys_t
90 input_item_t *p_input;
97 /*****************************************************************************
99 *****************************************************************************/
101 static void Run( services_discovery_t *p_sd );
104 static int OpenRadio( vlc_object_t *p_this )
106 return Open( p_this, RADIO );
109 static int OpenTV( vlc_object_t *p_this )
111 return Open( p_this, TV );
114 /*****************************************************************************
115 * Open: initialize and create stuff
116 *****************************************************************************/
117 static int Open( vlc_object_t *p_this, int i_type )
119 services_discovery_t *p_sd = ( services_discovery_t* )p_this;
120 DECMALLOC_ERR( p_sys, services_discovery_sys_t );
127 p_sys->p_input = input_ItemNewExt( p_sd,
128 SHOUTCAST_TV_BASE_URL, _("Shoutcast TV"),
133 p_sys->p_input = input_ItemNewExt( p_sd,
134 SHOUTCAST_BASE_URL, _("Shoutcast Radio"),
138 input_ItemAddOption( p_sys->p_input, "no-playlist-autostart" );
142 /*****************************************************************************
144 *****************************************************************************/
145 static void Run( services_discovery_t *p_sd )
147 p_sd->p_sys->p_input->b_prefers_tree = VLC_TRUE;
148 services_discovery_AddItem( p_sd, p_sd->p_sys->p_input, NULL /* no category */ );
150 input_Read( p_sd, p_sd->p_sys->p_input, VLC_FALSE );
153 /*****************************************************************************
155 *****************************************************************************/
156 static void Close( vlc_object_t *p_this )
158 services_discovery_t *p_sd = ( services_discovery_t* )p_this;
159 services_discovery_sys_t *p_sys = p_sd->p_sys;
160 services_discovery_RemoveItem( p_sd, p_sys->p_input );