1 /*****************************************************************************
2 * freebox.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 *****************************************************************************/
34 #include <vlc_common.h>
35 #include <vlc_plugin.h>
36 #include <vlc_services_discovery.h>
38 /*****************************************************************************
40 *****************************************************************************/
42 static int Open( vlc_object_t * );
43 static void Close( vlc_object_t * );
45 VLC_SD_PROBE_HELPER("freebox", "Freebox TV", SD_CAT_INTERNET)
48 set_category( CAT_PLAYLIST )
49 set_subcategory( SUBCAT_PLAYLIST_SD )
51 set_shortname( "Freebox")
52 set_description( N_("Freebox TV") )
53 set_capability( "services_discovery", 0 )
54 set_callbacks( Open, Close )
55 add_shortcut( "freebox" )
57 VLC_SD_PROBE_SUBMODULE
61 /*****************************************************************************
63 *****************************************************************************/
65 static void *Run( void * );
66 struct services_discovery_sys_t
71 /*****************************************************************************
72 * Open: initialize and create stuff
73 *****************************************************************************/
74 static int Open(vlc_object_t *this)
76 services_discovery_t *sd = (services_discovery_t *)this;
77 sd->p_sys = malloc(sizeof(*(sd->p_sys)));
78 if (sd->p_sys == NULL)
81 if (vlc_clone(&sd->p_sys->thread, Run, sd, VLC_THREAD_PRIORITY_LOW))
89 /*****************************************************************************
91 *****************************************************************************/
92 static void ItemAdded(const vlc_event_t * event, void *user_data)
94 services_discovery_t *sd = user_data;
95 input_item_t *child = event->u.input_item_subitem_added.p_new_child;
96 input_item_AddOption(child, "deinterlace=1", VLC_INPUT_OPTION_TRUSTED);
97 services_discovery_AddItem(sd, child, NULL);
101 /*****************************************************************************
103 *****************************************************************************/
104 static void *Run(void *data)
106 services_discovery_t *sd = data;
107 int canc = vlc_savecancel();
109 const char * const name = "Freebox TV";
110 const char * const url = "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u";
111 input_item_t *input = input_item_New(sd, url, vlc_gettext(name));
112 input_item_AddOption(input, "no-playlist-autostart", VLC_INPUT_OPTION_TRUSTED);
114 /* Read every subitems, and add them in ItemAdded */
115 vlc_event_manager_t *em = &input->event_manager;
116 vlc_event_attach(em, vlc_InputItemSubItemAdded, ItemAdded, sd);
117 input_Read(sd, input);
118 vlc_event_detach(em, vlc_InputItemSubItemAdded, ItemAdded, sd);
120 vlc_gc_decref(input);
122 vlc_restorecancel(canc);
126 /*****************************************************************************
128 *****************************************************************************/
129 static void Close(vlc_object_t *this)
131 services_discovery_t *sd = (services_discovery_t *)this;
132 services_discovery_sys_t *sys = sd->p_sys;
133 vlc_join(sys->thread, NULL);