# HG changeset patch # User melunko # Date 1168448377 0 # Node ID 0f6b44cf56bb4586e2f7a8afb507dab46c179e39 # Parent 336a58ad1a901a3c482104ade8a048b01ace39b2 [svn r249] All upnp code removed. Now we have a library called gmyth-upnp diff -r 336a58ad1a90 -r 0f6b44cf56bb gmyth/configure.ac --- a/gmyth/configure.ac Tue Jan 09 22:43:23 2007 +0000 +++ b/gmyth/configure.ac Wed Jan 10 16:59:37 2007 +0000 @@ -234,31 +234,6 @@ AC_SUBST(MYSQL_CFLAGS) AC_SUBST(MYSQL_LIBS) -dnl ========== Check for Cyberlink UPnP Libraries -AC_ARG_ENABLE(upnp, - [AC_HELP_STRING([--enable-upnp], [enable building UPnP related stuff])], - enable_upnp="$enableval", - enable_upnp=no) - -if test "x$enable_upnp" = "xyes" ; then - AC_MSG_NOTICE([Checking for the UPnP CyberLink for C library...]) - PKG_CHECK_MODULES(CYBERLINK, - clinkc, - HAVE_CYBERLINK=yes, HAVE_CYBERLINK=no) -fi - -if test "x$HAVE_CYBERLINK" = "xyes"; then - AC_DEFINE(WITH_UPNP, 1, [build with upnp related stuff]) -else - AC_MSG_RESULT([UPnP features (using clinkc library) will not be added.]) -fi - -AM_CONDITIONAL(WITH_UPNP, test "x$HAVE_CYBERLINK" = "xyes") - -dnl make CYBERLINK_CFLAGS and CYBERLINK_LIBS available -AC_SUBST(CYBERLINK_CFLAGS) -AC_SUBST(CYBERLINK_LIBS) - #dnl Enable gtk-doc #GTK_DOC_CHECK(1.4) diff -r 336a58ad1a90 -r 0f6b44cf56bb gmyth/src/Makefile.am --- a/gmyth/src/Makefile.am Tue Jan 09 22:43:23 2007 +0000 +++ b/gmyth/src/Makefile.am Wed Jan 10 16:59:37 2007 +0000 @@ -26,10 +26,6 @@ gmyth_uri.c \ $(BUILT_SOURCES) -if WITH_UPNP -libgmyth_la_SOURCES += \ - gmyth_upnp.c -endif EXTRA_libgmyth_la_SOURCES = gmyth_marshal.list @@ -52,11 +48,6 @@ $(GSTPLUGINSBASE_CFLAGS) \ $(MYSQL_CFLAGS) -if WITH_UPNP -libgmyth_la_CFLAGS += \ - $(CYBERLINK_CFLAGS) -endif - libgmyth_la_LDFLAGS = \ -export-dynamic \ $(MYSQL_LIBS) \ @@ -64,13 +55,6 @@ $(GSTBASE_LIBS) \ $(GSTPLUGINS_LIBS) -if WITH_UPNP -libgmyth_la_LDFLAGS += \ - $(CYBERLINK_LIBS) -libgmyth_la_LIBS = \ - $(CYBERLINK_LIBS) -endif - libgmyth_includedir = \ $(pkgincludedir) @@ -94,9 +78,4 @@ gmyth_programinfo.h \ gmyth_uri.h -if WITH_UPNP -libgmyth_include_HEADERS += \ - gmyth_upnp.h -endif - CLEANFILES = $(BUILT_SOURCES) diff -r 336a58ad1a90 -r 0f6b44cf56bb gmyth/src/gmyth_backendinfo.c --- a/gmyth/src/gmyth_backendinfo.c Tue Jan 09 22:43:23 2007 +0000 +++ b/gmyth/src/gmyth_backendinfo.c Wed Jan 10 16:59:37 2007 +0000 @@ -32,10 +32,6 @@ #include "gmyth_uri.h" #include "gmyth_debug.h" -#ifdef WITH_UPNP -#include "gmyth_upnp.h" -#endif - static void gmyth_backend_info_class_init (GMythBackendInfoClass *klass); static void gmyth_backend_info_init (GMythBackendInfo *object); @@ -152,15 +148,7 @@ if ( NULL == hostname || strlen(hostname) <= 0 ) { - #ifdef WITH_UPNP - GMythUPnP *gmyth_upnp = gmyth_upnp_new( backend_info ); - /* backend_info = gmyth_upnp_get_backend_info( gmyth_upnp ); */ - backend_info->hostname = g_strdup ( gmyth_upnp_get_host( gmyth_upnp ) ); - g_object_unref( gmyth_upnp ); - #else - gmyth_debug ( "Error trying to set a hostname equals to NULL (it doesn't using UPnP)." ); - return NULL; - #endif + gmyth_debug ( "Error trying to set a hostname equals to NULL (it doesn't using UPnP)." ); } else { backend_info->hostname = g_strdup (hostname); } @@ -197,15 +185,7 @@ if ( port <= 0 ) { - #ifdef WITH_UPNP - GMythUPnP *gmyth_upnp = gmyth_upnp_new( backend_info ); - backend_info = gmyth_upnp_get_backend_info( gmyth_upnp ); - backend_info->port = gmyth_upnp_get_port( gmyth_upnp ); - g_object_unref( gmyth_upnp ); - #else - gmyth_debug ( "Error trying to set a hostname equals to NULL (it doesn't using UPnP)." ); - return NULL; - #endif + gmyth_debug ( "Error trying to set a hostname equals to NULL (it doesn't using UPnP)." ); } else { backend_info->port = port; } diff -r 336a58ad1a90 -r 0f6b44cf56bb gmyth/src/gmyth_upnp.c --- a/gmyth/src/gmyth_upnp.c Tue Jan 09 22:43:23 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,350 +0,0 @@ -/** - * GMyth Library - * - * @file gmyth/gmyth_upnp.c - * - * @brief

GMythUPnP allows that a MythTV frontend discovers a - * MythTV backend, using the UPnP architecture. - * - * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. - * @author Rosfran Lins Borges - * - *//* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gmyth_upnp.h" - -#include -#include -#include -#include -#include -#include - -#include "gmyth_backendinfo.h" -#include "gmyth_socket.h" -#include "gmyth_uri.h" -#include "gmyth_debug.h" - -#define GMYTH_UPNP_MAX_SEARCHS 10 - -static void gmyth_upnp_class_init (GMythUPnPClass *klass); -static void gmyth_upnp_init (GMythUPnP *object); - -static void gmyth_upnp_dispose (GObject *object); -static void gmyth_upnp_finalize (GObject *object); - -static gboolean gmyth_upnp_initialize ( GMythUPnP *gmyth_upnp, GMythBackendInfo *gmyth_backend_info ); - -static gboolean gmyth_upnp_print_cp_device_list( CgUpnpControlPoint* controlPt, gchar **udn, - GList **mythtv_servers_lst ); - -G_DEFINE_TYPE(GMythUPnP, gmyth_upnp, G_TYPE_OBJECT) - -static GStaticMutex mutex = G_STATIC_MUTEX_INIT; - -static void -gmyth_upnp_class_init (GMythUPnPClass *klass) -{ - GObjectClass *gobject_class; - - gobject_class = (GObjectClass *) klass; - - gobject_class->dispose = gmyth_upnp_dispose; - gobject_class->finalize = gmyth_upnp_finalize; -} - -static void -gmyth_upnp_init ( GMythUPnP *gmyth_upnp ) -{ - gmyth_upnp->upnp_dev_found = FALSE; - - gmyth_upnp->uri = NULL; - gmyth_upnp->host = NULL; - gmyth_upnp->port = 0; - gmyth_upnp->protocol = NULL; - - gmyth_upnp->gmyth_backend_info = NULL; - - gmyth_upnp->control_point = NULL; - -} - -/** Creates a new instance of GMythUPnP. - * - * @return a new instance of GMythUPnP. - */ -GMythUPnP * -gmyth_upnp_new ( GMythBackendInfo *gmyth_backend_info ) -{ - GMythUPnP *gmyth_upnp = GMYTH_UPNP (g_object_new (GMYTH_UPNP_TYPE, NULL)); - - gmyth_upnp->gmyth_backend_info = gmyth_backend_info; - - if ( !gmyth_upnp_initialize ( gmyth_upnp, gmyth_backend_info ) ) - return NULL; - - return gmyth_upnp; -} - -static void -gmyth_upnp_dispose (GObject *object) -{ - GMythUPnP *gmyth_upnp = GMYTH_UPNP(object); - - if ( gmyth_upnp->control_point != NULL ) { - cg_upnp_controlpoint_stop( gmyth_upnp->control_point ); - cg_upnp_controlpoint_delete( gmyth_upnp->control_point ); - gmyth_upnp->control_point = NULL; - } - - if ( gmyth_upnp->uri != NULL ) { - g_free ( gmyth_upnp->uri ); - gmyth_upnp->uri = NULL; - } - - if ( gmyth_upnp->host != NULL ) { - g_free ( gmyth_upnp->host ); - gmyth_upnp->host = NULL; - } - - if ( gmyth_upnp->protocol != NULL ) { - g_free ( gmyth_upnp->protocol ); - gmyth_upnp->protocol = NULL; - } - - if ( gmyth_upnp->mythtv_servers != NULL ) { - g_list_free( gmyth_upnp->mythtv_servers ); - gmyth_upnp->mythtv_servers = NULL; - } - - G_OBJECT_CLASS (gmyth_upnp_parent_class)->dispose (object); -} - -static void -gmyth_upnp_finalize (GObject *object) -{ - g_signal_handlers_destroy (object); - - G_OBJECT_CLASS (gmyth_upnp_parent_class)->finalize (object); -} - -/** - * Create a control point and start it. - */ -static gboolean -gmyth_upnp_initialize ( GMythUPnP *gmyth_upnp, GMythBackendInfo *gmyth_backend_info ) -{ - - gboolean ret = FALSE; - - GMythURI* uri = NULL; - - guint iter_count = GMYTH_UPNP_MAX_SEARCHS; - - g_return_val_if_fail( gmyth_backend_info != NULL, FALSE ); - - /* Create the cybergarage control point */ - gmyth_upnp->control_point = cg_upnp_controlpoint_new(); - /* cg_upnp_controlpoint_setdevicelistener( gmyth_upnp->control_point, device_listener ); */ - - /* Start the control point */ - if ( cg_upnp_controlpoint_start( gmyth_upnp->control_point ) == FALSE) - { - gmyth_debug( "Unable to start UPnP control point!!!" ); - goto done; - } - else - { - gmyth_debug( "Control point started." ); - } - - while ( gmyth_upnp->upnp_dev_found == FALSE && ( --iter_count > 0 ) ) { - - gmyth_debug( "UPnP MythTV Client control point is searching MythTV AV Device server...\n" ); - - if ( gmyth_upnp->control_point != NULL ) - cg_upnp_controlpoint_search ( gmyth_upnp->control_point, - "urn:schemas-upnp-org:service:ContentDirectory:1" ); - - /* just to avoid clinkc pthread concurrency faults */ - cg_wait( 1000 ); - - /* discover if it was found */ - gmyth_upnp->upnp_dev_found = gmyth_upnp_print_cp_device_list( gmyth_upnp->control_point, &gmyth_upnp->udn, - &gmyth_upnp->mythtv_servers ); - - } - - if ( gmyth_upnp->upnp_dev_found ) { - - gmyth_debug( "Found UPnP MythTV AV Device...\n" ); - - if ( g_list_first( gmyth_upnp->mythtv_servers ) != NULL && (g_list_first( gmyth_upnp->mythtv_servers ))->data != NULL ) - { - gmyth_upnp->uri = (gchar*) (g_list_first( gmyth_upnp->mythtv_servers ))->data; - uri = gmyth_uri_new_with_value( gmyth_upnp->uri ); - - gmyth_upnp->host = gmyth_uri_get_host( uri ); - gmyth_upnp->port = gmyth_uri_get_port( uri ); - gmyth_upnp->protocol = gmyth_uri_get_protocol( uri ); - - /* sets all the discovered data from the UPnP remote device, like host name, IP address, port,... */ - if ( NULL != gmyth_upnp->host ) - gmyth_backend_info_set_hostname ( gmyth_upnp->gmyth_backend_info, gmyth_upnp->host ); - - if ( gmyth_upnp->port > 0 ) - gmyth_backend_info_set_port ( gmyth_upnp->gmyth_backend_info, gmyth_upnp->port ); - - ret = TRUE; - } - } - -done: - - if ( uri != NULL ) - { - g_object_unref( uri ); - uri = NULL; - } - - return ret; - -} - -/** - * Prints the Control Point's device list - */ -static gboolean -gmyth_upnp_print_cp_device_list( CgUpnpControlPoint* controlPt, gchar **udn, GList **mythtv_servers_lst ) -{ - - g_return_val_if_fail( mythtv_servers_lst != NULL, FALSE ); - g_return_val_if_fail( controlPt != NULL, FALSE ); - - gchar* mythtvFriendlyName = "Myth"; - /* begin assertion about the size of discovered devices */ - gint numDevices = cg_upnp_controlpoint_getndevices(controlPt); - gint cntDevs = 0; - //CgUpnpDeviceList *devList = NULL; - CgUpnpDevice *childDev; - gchar *devName = NULL, *dev_url = NULL; - gboolean upnp_dev_found = FALSE; - - gmyth_debug( "UPnP MythTV AV Device list size = %d\n", numDevices ); - - for ( childDev = cg_upnp_controlpoint_getdevices(controlPt); childDev != NULL; - childDev = cg_upnp_device_next(childDev) ) { - devName = cg_upnp_device_getfriendlyname(childDev); - dev_url = cg_upnp_device_getlocationfromssdppacket( childDev ); - gmyth_debug( "Device's friendly name = %s, and device's URL = %s\n", devName, dev_url ); - if ( ( upnp_dev_found = ( g_strstr_len( devName, strlen( devName ), mythtvFriendlyName ) != NULL ) ) == TRUE ) - { - *udn = cg_upnp_device_getudn( childDev ); - *mythtv_servers_lst = g_list_append( *mythtv_servers_lst, dev_url ); - } - ++cntDevs; - } - - if ( upnp_dev_found == TRUE ) { - gmyth_debug( "MythTV AV Device found, from a total of %d devices.\n", cntDevs ); - } else if ( numDevices == cntDevs ) { - gmyth_debug( "MythTV AV Device not found, from a total of %d devices.\n", cntDevs ); - } else { - gmyth_debug( "Control Point's MythTV AV Device count is wrong: iterated over %d devices, but there are %d registered devices.\n", cntDevs, numDevices ); - } - - return upnp_dev_found; - -} - -/** Gets the GMythBackendInfo host object associated to this upnp. - * - * @return The string host object currently valid or NULL if the settings - * were not opened. - */ -gchar* -gmyth_upnp_get_host ( GMythUPnP *gmyth_upnp ) -{ - - if ( NULL == gmyth_upnp || NULL == gmyth_upnp->host ) - { - gmyth_debug ("[%s] GMythUPnP host field not initialized\n", __FUNCTION__); - return NULL; - } - - return gmyth_upnp->host; -} - -/** Gets the GMythBackendInfo port object associated to this upnp. - * - * @return The string object currently valid or NULL if the port number. - */ -gint -gmyth_upnp_get_port( GMythUPnP *gmyth_upnp ) -{ - - if ( NULL == gmyth_upnp || gmyth_upnp->port <= 0 ) - { - gmyth_debug ("[%s] GMythUPnP host field not initialized\n", __FUNCTION__); - return 0; - } - - return gmyth_upnp->port; -} - -/** Gets the UPnP AV devices server's list associated to this upnp. - * - * @return The GList* containing all the URI values for each recognized UPnP device, - * or NULL if it couldn't recognize any MythTV AV device. - */ -GList* -gmyth_upnp_get_servers ( GMythUPnP *gmyth_upnp ) -{ - - if ( NULL == gmyth_upnp || NULL == gmyth_upnp->mythtv_servers ) - { - gmyth_debug ("[%s] GMythUPnP has no MythTV servers recognized.\n", __FUNCTION__); - return NULL; - } - - return gmyth_upnp->mythtv_servers; -} - -/** Gets the GMythBackendInfo object associated to this upnp. - * - * @return The GMythBackendInfo object currently valid or NULL if the settings - * were not opened. - */ -GMythBackendInfo* -gmyth_upnp_get_backend_info ( GMythUPnP *gmyth_upnp ) -{ - - if ( NULL == gmyth_upnp || NULL == gmyth_upnp->gmyth_backend_info ) - { - gmyth_debug ("[%s] GMythUPnP not initialized\n", __FUNCTION__); - return NULL; - } - - return gmyth_upnp->gmyth_backend_info; -} - diff -r 336a58ad1a90 -r 0f6b44cf56bb gmyth/src/gmyth_upnp.h --- a/gmyth/src/gmyth_upnp.h Tue Jan 09 22:43:23 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -/** - * GMyth Library - * - * @file gmyth/gmyth_upnp.h - * - * @brief

GMythUPnP allows that a MythTV frontend discovers a - * MythTV backend, using the UPnP architecture. - * - * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. - * @author Rosfran Lins Borges - * - *//* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _GMYTH_UPNP_H_ -#define _GMYTH_UPNP_H_ - -#include -#include - -#include -#include -#include - -#include -#include "gmyth_backendinfo.h" - -G_BEGIN_DECLS - -#define GMYTH_UPNP_TYPE (gmyth_upnp_get_type ()) -#define GMYTH_UPNP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_UPNP_TYPE, GMythUPnP)) -#define GMYTH_UPNP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_UPNP_TYPE, GMythUPnPClass)) -#define IS_GMYTH_UPNP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_UPNP_TYPE)) -#define IS_GMYTH_UPNP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_UPNP_TYPE)) -#define GMYTH_UPNP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_UPNP_TYPE, GMythUPnPClass)) - -typedef struct _GMythUPnP GMythUPnP; -typedef struct _GMythUPnPClass GMythUPnPClass; - -/**************************************** -* Data Type -****************************************/ - -struct _GMythUPnPClass -{ - GObjectClass parent_class; - - /* callbacks */ - /* no one for now */ -}; - -struct _GMythUPnP { - - GObject parent; - - gchar *uri; - gchar *host; - gint port; - gchar *protocol; - - CgUpnpControlPoint* control_point; - - gchar *udn; - - GMythBackendInfo *gmyth_backend_info; - - GList* mythtv_servers; - - gboolean upnp_dev_found; - -}; - -GType gmyth_upnp_get_type (void); -GMythUPnP * gmyth_upnp_new ( GMythBackendInfo *gmyth_backend_info ); -gchar* gmyth_upnp_get_host ( GMythUPnP *gmyth_upnp ); -gint gmyth_upnp_get_port ( GMythUPnP *gmyth_upnp ); -GMythBackendInfo* gmyth_upnp_get_backend_info ( GMythUPnP *gmyth_upnp ); - -G_END_DECLS - -#endif /* _GMYTH_UPNP_H_ */