1 /*****************************************************************************
2 * shout.c: Shoutcast services discovery module
3 *****************************************************************************
4 * Copyright (C) 2005-2007 the VideoLAN team
7 * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
8 * Antoine Cellerier <dionoea -@T- videolan -d.t- org>
9 * Pierre d'Herbemont <pdherbemont # videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
31 #include <vlc_services_discovery.h>
33 /*****************************************************************************
35 *****************************************************************************/
37 enum type_e { ShoutRadio = 0, ShoutTV = 1, Freebox = 2 };
39 static int Open( vlc_object_t *, enum type_e );
40 static void Close( vlc_object_t * );
47 { "http/shout-winamp://www.shoutcast.com/sbin/newxml.phtml",
48 N_("Shoutcast Radio") },
49 { "http/shout-winamp://www.shoutcast.com/sbin/newtvlister.phtml?alltv=1",
51 { "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u",
56 #define OPEN( type ) \
57 static int Open ## type ( vlc_object_t *p_this ) \
59 return Open( p_this, type ); \
67 set_category( CAT_PLAYLIST );
68 set_subcategory( SUBCAT_PLAYLIST_SD );
70 add_obsolete_integer( "shoutcast-limit" );
72 set_shortname( "Shoutcast");
73 set_description( _("Shoutcast radio listings") );
74 set_capability( "services_discovery", 0 );
75 set_callbacks( OpenShoutRadio, Close );
76 add_shortcut( "shoutcast" );
79 set_shortname( "ShoutcastTV" );
80 set_description( _("Shoutcast TV listings") );
81 set_capability( "services_discovery", 0 );
82 set_callbacks( OpenShoutTV, Close );
83 add_shortcut( "shoutcasttv" );
86 set_shortname( "Freebox");
87 set_description( _("Freebox TV listing (French ISP free.fr services)") );
88 set_capability( "services_discovery", 0 );
89 set_callbacks( OpenFreebox, Close );
90 add_shortcut( "freebox" );
95 /*****************************************************************************
97 *****************************************************************************/
99 static void Run( services_discovery_t *p_sd );
102 /*****************************************************************************
103 * Open: initialize and create stuff
104 *****************************************************************************/
105 static int Open( vlc_object_t *p_this, enum type_e i_type )
107 services_discovery_t *p_sd = ( services_discovery_t* )p_this;
108 services_discovery_SetLocalizedName( p_sd, _(p_items[i_type].psz_name) );
110 p_sd->p_sys = (void *)i_type;
114 /*****************************************************************************
116 *****************************************************************************/
117 static void ItemAdded( const vlc_event_t * p_event, void * user_data )
119 services_discovery_t *p_sd = user_data;
120 services_discovery_AddItem( p_sd,
121 p_event->u.input_item_subitem_added.p_new_child,
122 NULL /* no category */ );
125 /*****************************************************************************
127 *****************************************************************************/
128 static void Run( services_discovery_t *p_sd )
130 enum type_e i_type = (enum type_e)p_sd->p_sys;
131 input_item_t *p_input = input_ItemNewExt( p_sd,
132 p_items[i_type].psz_url, _(p_items[i_type].psz_name),
134 input_ItemAddOption( p_input, "no-playlist-autostart" );
136 vlc_gc_incref( p_input );
137 vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded,
139 input_Read( p_sd, p_input, VLC_TRUE );
140 vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded,
142 vlc_gc_decref( p_input );
145 /*****************************************************************************
147 *****************************************************************************/
148 static void Close( vlc_object_t *p_this )