| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
#ifdef HAVE_CONFIG_H |
|---|
| 31 |
# include "config.h" |
|---|
| 32 |
#endif |
|---|
| 33 |
|
|---|
| 34 |
#include <vlc_common.h> |
|---|
| 35 |
#include <vlc_plugin.h> |
|---|
| 36 |
#include <vlc_services_discovery.h> |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
enum type_e { ShoutRadio = 0, ShoutTV = 1, Freebox = 2, FrenchTV = 3 }; |
|---|
| 43 |
|
|---|
| 44 |
static int Open( vlc_object_t *, enum type_e ); |
|---|
| 45 |
static void Close( vlc_object_t * ); |
|---|
| 46 |
|
|---|
| 47 |
struct shout_item_t |
|---|
| 48 |
{ |
|---|
| 49 |
const char *psz_url; |
|---|
| 50 |
const char *psz_name; |
|---|
| 51 |
const char *ppsz_options[2]; |
|---|
| 52 |
const struct shout_item_t * p_children; |
|---|
| 53 |
}; |
|---|
| 54 |
|
|---|
| 55 |
#define endItem( ) { NULL, NULL, { NULL }, NULL } |
|---|
| 56 |
#define item( title, url ) { url, title, { NULL }, NULL } |
|---|
| 57 |
#define itemWithOption( title, url, option ) { url, title, { option, NULL }, NULL } |
|---|
| 58 |
#define itemWithChildren( title, children ) { "vlc://nop", title, { NULL }, children } |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
static const struct shout_item_t p_frenchtv_canalplus[] = { |
|---|
| 63 |
itemWithOption( N_("Les Guignols"), "http://www.canalplus.fr/index.php?pid=1784", "http-forward-cookies" ), |
|---|
| 64 |
endItem() |
|---|
| 65 |
}; |
|---|
| 66 |
|
|---|
| 67 |
static const struct shout_item_t p_frenchtv[] = { |
|---|
| 68 |
itemWithChildren( N_("Canal +"), p_frenchtv_canalplus ), |
|---|
| 69 |
endItem() |
|---|
| 70 |
}; |
|---|
| 71 |
|
|---|
| 72 |
static const struct shout_item_t p_items[] = { |
|---|
| 73 |
item( N_("Shoutcast Radio"), "http/shout-winamp://www.shoutcast.com/sbin/newxml.phtml" ), |
|---|
| 74 |
item( N_("Shoutcast TV"), "http/shout-winamp://www.shoutcast.com/sbin/newtvlister.phtml?alltv=1" ), |
|---|
| 75 |
item( N_("Freebox TV"), "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u" ), |
|---|
| 76 |
itemWithChildren(N_("French TV"), p_frenchtv ), |
|---|
| 77 |
endItem() |
|---|
| 78 |
}; |
|---|
| 79 |
|
|---|
| 80 |
#undef endItem |
|---|
| 81 |
#undef item |
|---|
| 82 |
#undef itemWithOptions |
|---|
| 83 |
#undef itemWithChildren |
|---|
| 84 |
|
|---|
| 85 |
struct shout_category_t { |
|---|
| 86 |
services_discovery_t * p_sd; |
|---|
| 87 |
const char * psz_category; |
|---|
| 88 |
}; |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
#define OPEN( type ) \ |
|---|
| 92 |
static int Open ## type ( vlc_object_t *p_this ) \ |
|---|
| 93 |
{ \ |
|---|
| 94 |
msg_Dbg( p_this, "Starting " #type ); \ |
|---|
| 95 |
return Open( p_this, type ); \ |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
OPEN( ShoutRadio ) |
|---|
| 99 |
OPEN( ShoutTV ) |
|---|
| 100 |
OPEN( Freebox ) |
|---|
| 101 |
OPEN( FrenchTV ) |
|---|
| 102 |
|
|---|
| 103 |
vlc_module_begin(); |
|---|
| 104 |
set_category( CAT_PLAYLIST ); |
|---|
| 105 |
set_subcategory( SUBCAT_PLAYLIST_SD ); |
|---|
| 106 |
|
|---|
| 107 |
add_obsolete_integer( "shoutcast-limit" ); |
|---|
| 108 |
|
|---|
| 109 |
set_shortname( "Shoutcast"); |
|---|
| 110 |
set_description( N_("Shoutcast radio listings") ); |
|---|
| 111 |
set_capability( "services_discovery", 0 ); |
|---|
| 112 |
set_callbacks( OpenShoutRadio, Close ); |
|---|
| 113 |
add_shortcut( "shoutcast" ); |
|---|
| 114 |
|
|---|
| 115 |
add_submodule(); |
|---|
| 116 |
set_shortname( "ShoutcastTV" ); |
|---|
| 117 |
set_description( N_("Shoutcast TV listings") ); |
|---|
| 118 |
set_capability( "services_discovery", 0 ); |
|---|
| 119 |
set_callbacks( OpenShoutTV, Close ); |
|---|
| 120 |
add_shortcut( "shoutcasttv" ); |
|---|
| 121 |
|
|---|
| 122 |
add_submodule(); |
|---|
| 123 |
set_shortname( "frenchtv"); |
|---|
| 124 |
set_description( N_("French TV") ); |
|---|
| 125 |
set_capability( "services_discovery", 0 ); |
|---|
| 126 |
set_callbacks( OpenFrenchTV, Close ); |
|---|
| 127 |
add_shortcut( "frenchtv" ); |
|---|
| 128 |
|
|---|
| 129 |
add_submodule(); |
|---|
| 130 |
set_shortname( "Freebox"); |
|---|
| 131 |
set_description( N_("Freebox TV listing (French ISP free.fr services)") ); |
|---|
| 132 |
set_capability( "services_discovery", 0 ); |
|---|
| 133 |
set_callbacks( OpenFreebox, Close ); |
|---|
| 134 |
add_shortcut( "freebox" ); |
|---|
| 135 |
|
|---|
| 136 |
vlc_module_end(); |
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
static void Run( services_discovery_t *p_sd ); |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
static int Open( vlc_object_t *p_this, enum type_e i_type ) |
|---|
| 150 |
{ |
|---|
| 151 |
services_discovery_t *p_sd = ( services_discovery_t* )p_this; |
|---|
| 152 |
services_discovery_SetLocalizedName( p_sd, _(p_items[i_type].psz_name) ); |
|---|
| 153 |
p_sd->pf_run = Run; |
|---|
| 154 |
p_sd->p_sys = (void *)i_type; |
|---|
| 155 |
return VLC_SUCCESS; |
|---|
| 156 |
} |
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
static void ItemAdded( const vlc_event_t * p_event, void * user_data ) |
|---|
| 162 |
{ |
|---|
| 163 |
struct shout_category_t * params = user_data; |
|---|
| 164 |
services_discovery_AddItem( params->p_sd, |
|---|
| 165 |
p_event->u.input_item_subitem_added.p_new_child, |
|---|
| 166 |
params->psz_category ); |
|---|
| 167 |
} |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
static input_item_t * CreateInputItemFromShoutItem( services_discovery_t *p_sd, |
|---|
| 173 |
const struct shout_item_t * p_item ) |
|---|
| 174 |
{ |
|---|
| 175 |
int i; |
|---|
| 176 |
|
|---|
| 177 |
input_item_t *p_input = input_item_NewExt( p_sd, |
|---|
| 178 |
p_item->psz_url, _(p_item->psz_name), |
|---|
| 179 |
0, NULL, -1 ); |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
for( i = 0; p_item->ppsz_options[i] != NULL; i++ ) |
|---|
| 183 |
input_item_AddOption( p_input, p_item->ppsz_options[i] ); |
|---|
| 184 |
input_item_AddOption( p_input, "no-playlist-autostart" ); |
|---|
| 185 |
|
|---|
| 186 |
return p_input; |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
static void AddSubitemsOfShoutItemURL( services_discovery_t *p_sd, |
|---|
| 193 |
const struct shout_item_t * p_item, |
|---|
| 194 |
const char * psz_category ) |
|---|
| 195 |
{ |
|---|
| 196 |
struct shout_category_t category = { p_sd, psz_category }; |
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
input_item_t *p_input = CreateInputItemFromShoutItem( p_sd, p_item ); |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded, |
|---|
| 203 |
ItemAdded, &category ); |
|---|
| 204 |
input_Read( p_sd, p_input, true ); |
|---|
| 205 |
vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded, |
|---|
| 206 |
ItemAdded, &category ); |
|---|
| 207 |
|
|---|
| 208 |
vlc_gc_decref( p_input ); |
|---|
| 209 |
} |
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
static void Run( services_discovery_t *p_sd ) |
|---|
| 215 |
{ |
|---|
| 216 |
enum type_e i_type = (enum type_e)p_sd->p_sys; |
|---|
| 217 |
int i, j; |
|---|
| 218 |
int canc = vlc_savecancel(); |
|---|
| 219 |
|
|---|
| 220 |
if( !p_items[i_type].p_children ) |
|---|
| 221 |
{ |
|---|
| 222 |
AddSubitemsOfShoutItemURL( p_sd, &p_items[i_type], NULL ); |
|---|
| 223 |
return; |
|---|
| 224 |
} |
|---|
| 225 |
for( i = 0; p_items[i_type].p_children[i].psz_name; i++ ) |
|---|
| 226 |
{ |
|---|
| 227 |
const struct shout_item_t * p_subitem = &p_items[i_type].p_children[i]; |
|---|
| 228 |
if( !p_subitem->p_children ) |
|---|
| 229 |
{ |
|---|
| 230 |
AddSubitemsOfShoutItemURL( p_sd, p_subitem, p_subitem->psz_name ); |
|---|
| 231 |
continue; |
|---|
| 232 |
} |
|---|
| 233 |
for( j = 0; p_subitem->p_children[j].psz_name; j++ ) |
|---|
| 234 |
{ |
|---|
| 235 |
input_item_t *p_input = CreateInputItemFromShoutItem( p_sd, &p_subitem->p_children[j] ); |
|---|
| 236 |
services_discovery_AddItem( p_sd, |
|---|
| 237 |
p_input, |
|---|
| 238 |
p_subitem->psz_name ); |
|---|
| 239 |
vlc_gc_decref( p_input ); |
|---|
| 240 |
} |
|---|
| 241 |
} |
|---|
| 242 |
vlc_restorecancel(canc); |
|---|
| 243 |
} |
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
static void Close( vlc_object_t *p_this ) |
|---|
| 249 |
{ |
|---|
| 250 |
VLC_UNUSED(p_this); |
|---|
| 251 |
} |
|---|