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 * );
46 const char *ppsz_options[2];
48 { "http/shout-winamp://www.shoutcast.com/sbin/newxml.phtml",
49 N_("Shoutcast Radio"), { NULL } },
50 { "http/shout-winamp://www.shoutcast.com/sbin/newtvlister.phtml?alltv=1",
51 N_("Shoutcast TV"), { NULL } },
52 { "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u",
53 N_("Freebox TV"), { "m3u-extvlcopt=1", NULL } },
57 #define OPEN( type ) \
58 static int Open ## type ( vlc_object_t *p_this ) \
60 return Open( p_this, type ); \
68 set_category( CAT_PLAYLIST );
69 set_subcategory( SUBCAT_PLAYLIST_SD );
71 add_obsolete_integer( "shoutcast-limit" );
73 set_shortname( "Shoutcast");
74 set_description( _("Shoutcast radio listings") );
75 set_capability( "services_discovery", 0 );
76 set_callbacks( OpenShoutRadio, Close );
77 add_shortcut( "shoutcast" );
80 set_shortname( "ShoutcastTV" );
81 set_description( _("Shoutcast TV listings") );
82 set_capability( "services_discovery", 0 );
83 set_callbacks( OpenShoutTV, Close );
84 add_shortcut( "shoutcasttv" );
87 set_shortname( "Freebox");
88 set_description( _("Freebox TV listing (French ISP free.fr services)") );
89 set_capability( "services_discovery", 0 );
90 set_callbacks( OpenFreebox, Close );
91 add_shortcut( "freebox" );
96 /*****************************************************************************
98 *****************************************************************************/
100 static void Run( services_discovery_t *p_sd );
103 /*****************************************************************************
104 * Open: initialize and create stuff
105 *****************************************************************************/
106 static int Open( vlc_object_t *p_this, enum type_e i_type )
108 services_discovery_t *p_sd = ( services_discovery_t* )p_this;
109 services_discovery_SetLocalizedName( p_sd, _(p_items[i_type].psz_name) );
111 p_sd->p_sys = (void *)i_type;
115 /*****************************************************************************
117 *****************************************************************************/
118 static void ItemAdded( const vlc_event_t * p_event, void * user_data )
120 services_discovery_t *p_sd = user_data;
121 services_discovery_AddItem( p_sd,
122 p_event->u.input_item_subitem_added.p_new_child,
123 NULL /* no category */ );
126 /*****************************************************************************
128 *****************************************************************************/
129 static void Run( services_discovery_t *p_sd )
131 enum type_e i_type = (enum type_e)p_sd->p_sys;
133 input_item_t *p_input = input_ItemNewExt( p_sd,
134 p_items[i_type].psz_url, _(p_items[i_type].psz_name),
136 for( i = 0; p_items[i_type].ppsz_options[i] != NULL; i++ )
137 input_ItemAddOption( p_input, p_items[i_type].ppsz_options[i] );
138 input_ItemAddOption( p_input, "no-playlist-autostart" );
140 vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded,
142 input_Read( p_sd, p_input, VLC_TRUE );
143 vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded,
145 vlc_gc_decref( p_input );
148 /*****************************************************************************
150 *****************************************************************************/
151 static void Close( vlc_object_t *p_this )