[vlc-devel] commit: freebox: Bring back freebox SD in C. (Pierre d'Herbemont )
git version control
git at videolan.org
Mon Feb 15 17:50:06 CET 2010
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Mon Feb 15 17:47:40 2010 +0100| [c8a67b80e5af4c5bad8d1d3409570c024e7bc8c9] | committer: Pierre d'Herbemont
freebox: Bring back freebox SD in C.
lua version doesn't support adding subitems and passing the option over to subitems.
One day the lua libs will be ready to offer feature parity for luafreebox and
this one will be able to go away. But not yet.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c8a67b80e5af4c5bad8d1d3409570c024e7bc8c9
---
modules/misc/lua/vlc.c | 2 +-
modules/services_discovery/Modules.am | 2 +
modules/services_discovery/freebox.c | 141 +++++++++++++++++++++++++++++++++
3 files changed, 144 insertions(+), 1 deletions(-)
diff --git a/modules/misc/lua/vlc.c b/modules/misc/lua/vlc.c
index 9084739..7d9dae3 100644
--- a/modules/misc/lua/vlc.c
+++ b/modules/misc/lua/vlc.c
@@ -126,7 +126,7 @@ vlc_module_begin ()
add_submodule ()
set_description( N_("Freebox TV") )
- add_shortcut( "freebox" )
+ add_shortcut( "luafreebox" )
set_capability( "services_discovery", 0 )
set_callbacks( Open_LuaSD, Close_LuaSD )
diff --git a/modules/services_discovery/Modules.am b/modules/services_discovery/Modules.am
index bb60329..33f1866 100644
--- a/modules/services_discovery/Modules.am
+++ b/modules/services_discovery/Modules.am
@@ -1,3 +1,4 @@
+SOURCES_freebox = freebox.c
SOURCES_sap = sap.c
SOURCES_upnp_cc = upnp_cc.cpp
SOURCES_upnp_intel = upnp_intel.cpp upnp_intel.hpp
@@ -19,5 +20,6 @@ EXTRA_LTLIBRARIES += \
libvlc_LTLIBRARIES += \
libmediadirs_plugin.la \
libpodcast_plugin.la \
+ libfreebox_plugin.la \
libsap_plugin.la \
$(LTLIBxcb_apps)
diff --git a/modules/services_discovery/freebox.c b/modules/services_discovery/freebox.c
new file mode 100644
index 0000000..7619aeb
--- /dev/null
+++ b/modules/services_discovery/freebox.c
@@ -0,0 +1,141 @@
+/*****************************************************************************
+ * freebox.c: Shoutcast services discovery module
+ *****************************************************************************
+ * Copyright (C) 2005-2007 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Sigmund Augdal Helberg <dnumgis at videolan.org>
+ * Antoine Cellerier <dionoea - at T- videolan -d.t- org>
+ * Pierre d'Herbemont <pdherbemont # videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Includes
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_services_discovery.h>
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+
+static int Open( vlc_object_t * );
+static void Close( vlc_object_t * );
+
+static int vlc_sd_probe_Open( vlc_object_t * );
+
+vlc_module_begin ()
+ set_category( CAT_PLAYLIST )
+ set_subcategory( SUBCAT_PLAYLIST_SD )
+
+ set_shortname( "Freebox")
+ set_description( N_("Freebox TV") )
+ set_capability( "services_discovery", 0 )
+ set_callbacks( Open, Close )
+ add_shortcut( "freebox" )
+
+ VLC_SD_PROBE_SUBMODULE
+vlc_module_end ()
+
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+
+static void *Run( void * );
+struct services_discovery_sys_t
+{
+ vlc_thread_t thread;
+};
+
+/*****************************************************************************
+ * Open: initialize and create stuff
+ *****************************************************************************/
+static int Open(vlc_object_t *this)
+{
+ services_discovery_t *sd = (services_discovery_t *)this;
+ sd->p_sys = malloc(sizeof(*(sd->p_sys)));
+ if (sd->p_sys == NULL)
+ return VLC_ENOMEM;
+
+ if (vlc_clone(&sd->p_sys->thread, Run, sd, VLC_THREAD_PRIORITY_LOW))
+ {
+ free(sd->p_sys);
+ return VLC_EGENERIC;
+ }
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * ItemAdded:
+ *****************************************************************************/
+static void ItemAdded(const vlc_event_t * event, void *user_data)
+{
+ services_discovery_t *sd = user_data;
+ input_item_t *child = event->u.input_item_subitem_added.p_new_child;
+ input_item_AddOption(child, "deinterlace=1", VLC_INPUT_OPTION_TRUSTED);
+ services_discovery_AddItem(sd, child, NULL);
+}
+
+
+/*****************************************************************************
+ * Run:
+ *****************************************************************************/
+static void *Run(void *data)
+{
+ services_discovery_t *sd = data;
+ int canc = vlc_savecancel();
+
+ const char * const name = "Freebox TV";
+ const char * const url = "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u";
+ input_item_t *input = input_item_New(sd, url, vlc_gettext(name));
+ input_item_AddOption(input, "no-playlist-autostart", VLC_INPUT_OPTION_TRUSTED);
+
+ /* Read every subitems, and add them in ItemAdded */
+ vlc_event_manager_t *em = &input->event_manager;
+ vlc_event_attach(em, vlc_InputItemSubItemAdded, ItemAdded, sd);
+ input_Read(sd, input);
+ vlc_event_detach(em, vlc_InputItemSubItemAdded, ItemAdded, sd);
+
+ vlc_gc_decref(input);
+
+ vlc_restorecancel(canc);
+ return NULL;
+}
+
+/*****************************************************************************
+ * Close:
+ *****************************************************************************/
+static void Close(vlc_object_t *this)
+{
+ services_discovery_t *sd = (services_discovery_t *)this;
+ services_discovery_sys_t *sys = sd->p_sys;
+ vlc_join(sys->thread, NULL);
+ free(sys);
+}
+
+static int vlc_sd_probe_Open(vlc_object_t *obj)
+{
+ VLC_UNUSED(obj);
+ return VLC_PROBE_CONTINUE;
+}
More information about the vlc-devel
mailing list