gmyth-upnp/src/gmyth_upnp.c
author renatofilho
Fri Jun 22 20:03:35 2007 +0100 (2007-06-22)
branchtrunk
changeset 758 b57cdd5fb898
parent 706 5cc97240e238
child 909 847da7267234
permissions -rw-r--r--
[svn r764] fixed bug on EOS
melunko@250
     1
/**
melunko@250
     2
 * GMyth Library
melunko@250
     3
 *
melunko@250
     4
 * @file gmyth/gmyth_upnp.c
melunko@250
     5
 * 
melunko@250
     6
 * @brief <p> GMythUPnP allows that a MythTV frontend discovers a 
melunko@250
     7
 * MythTV backend, using the UPnP architecture.
melunko@250
     8
 *
melunko@250
     9
 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
melunko@250
    10
 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
melunko@250
    11
 * 
melunko@250
    12
 * This program is free software; you can redistribute it and/or modify
melunko@250
    13
 * it under the terms of the GNU Lesser General Public License as published by
melunko@250
    14
 * the Free Software Foundation; either version 2 of the License, or
melunko@250
    15
 * (at your option) any later version.
melunko@250
    16
 *
melunko@250
    17
 * This program is distributed in the hope that it will be useful,
melunko@250
    18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
melunko@250
    19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
melunko@250
    20
 * GNU General Public License for more details.
melunko@250
    21
 *
melunko@250
    22
 * You should have received a copy of the GNU Lesser General Public License
melunko@250
    23
 * along with this program; if not, write to the Free Software
melunko@250
    24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
melunko@250
    25
 *   
melunko@250
    26
 */
melunko@250
    27
melunko@250
    28
#ifdef HAVE_CONFIG_H
melunko@250
    29
#include "config.h"
melunko@250
    30
#endif
melunko@250
    31
melunko@250
    32
#include "gmyth_upnp.h"
rosfran@696
    33
#include "gmyth_upnp_marshal.h"
melunko@250
    34
melunko@250
    35
#include <arpa/inet.h>
melunko@250
    36
#include <sys/types.h>
melunko@250
    37
#include <sys/socket.h>
melunko@250
    38
#include <netdb.h>
melunko@250
    39
#include <errno.h>
melunko@250
    40
#include <stdlib.h>
melunko@250
    41
rosfran@260
    42
#include <gmyth/gmyth_backendinfo.h>
rosfran@260
    43
#include <gmyth/gmyth_socket.h>
rosfran@260
    44
#include <gmyth/gmyth_uri.h>
rosfran@260
    45
#include <gmyth/gmyth_debug.h>
melunko@250
    46
renatofilho@754
    47
/*
renatofilho@754
    48
 * Maximum number of searches in the synchronized search 
renatofilho@754
    49
 */
melunko@250
    50
#define GMYTH_UPNP_MAX_SEARCHS		10
melunko@250
    51
rosfran@696
    52
#define GMYTH_UPNP_GET_PRIVATE(obj) \
rosfran@696
    53
    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_UPNP_TYPE, GMythUPnPPrivate))
rosfran@696
    54
rosfran@696
    55
struct _GMythUPnPPrivate {
renatofilho@754
    56
    GHashTable     *mythtv_servers;
renatofilho@754
    57
    GMythUPnPDeviceStatus last_status;
renatofilho@754
    58
    gboolean        upnp_dev_found;
renatofilho@754
    59
    gchar          *udn;
renatofilho@754
    60
    GMutex         *mutex;
rosfran@696
    61
};
rosfran@696
    62
renatofilho@754
    63
static void     gmyth_upnp_class_init(GMythUPnPClass * klass);
renatofilho@754
    64
static void     gmyth_upnp_init(GMythUPnP * object);
melunko@250
    65
renatofilho@754
    66
static void     gmyth_upnp_dispose(GObject * object);
renatofilho@754
    67
static void     gmyth_upnp_finalize(GObject * object);
melunko@250
    68
renatofilho@754
    69
static void     _mythtv_device_found(GMythUPnP * gmyth_upnp,
renatofilho@754
    70
                                     GMythUPnPDeviceStatus status,
renatofilho@754
    71
                                     gchar * dev);
renatofilho@754
    72
static void     _clinkc_mythtv_device_found(gchar * udn,
renatofilho@754
    73
                                            GMythUPnPDeviceStatus status);
melunko@250
    74
renatofilho@754
    75
static gboolean gmyth_upnp_initialize(GMythUPnP * gmyth_upnp,
renatofilho@754
    76
                                      GMythBackendInfo *
renatofilho@754
    77
                                      gmyth_backend_info,
renatofilho@754
    78
                                      GMythUPnPDeviceListener listener);
rosfran@696
    79
renatofilho@754
    80
static gboolean gmyth_upnp_got_mythtv_service(CgUpnpControlPoint *
renatofilho@754
    81
                                              controlPt, gchar ** udn,
renatofilho@754
    82
                                              GHashTable **
renatofilho@754
    83
                                              mythtv_servers_lst);
melunko@250
    84
melunko@250
    85
G_DEFINE_TYPE(GMythUPnP, gmyth_upnp, G_TYPE_OBJECT)
melunko@250
    86
renatofilho@754
    87
    static GMythUPnP *gmyth_upnp_static = NULL;
melunko@250
    88
renatofilho@754
    89
    static void
renatofilho@754
    90
                    gmyth_upnp_class_init(GMythUPnPClass * klass)
melunko@250
    91
{
renatofilho@754
    92
    GObjectClass   *gobject_class;
renatofilho@754
    93
    GMythUPnPClass *gupnp_class;
melunko@250
    94
renatofilho@754
    95
    gobject_class = (GObjectClass *) klass;
renatofilho@754
    96
    gupnp_class = (GMythUPnPClass *) gobject_class;
melunko@250
    97
renatofilho@754
    98
    gobject_class->dispose = gmyth_upnp_dispose;
renatofilho@754
    99
    gobject_class->finalize = gmyth_upnp_finalize;
rosfran@696
   100
renatofilho@754
   101
    g_type_class_add_private(gobject_class, sizeof(GMythUPnPPrivate));
rosfran@696
   102
renatofilho@754
   103
    gupnp_class->device_found_handler = _mythtv_device_found;
renatofilho@754
   104
renatofilho@754
   105
    gupnp_class->device_found_handler_signal_id =
renatofilho@754
   106
        g_signal_new("device-found",
renatofilho@754
   107
                     G_TYPE_FROM_CLASS(gupnp_class),
renatofilho@754
   108
                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
renatofilho@754
   109
                     G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
renatofilho@754
   110
                     gmyth_upnp_marshal_VOID__INT_STRING, G_TYPE_NONE, 2,
renatofilho@754
   111
                     G_TYPE_INT, G_TYPE_STRING);
rosfran@696
   112
melunko@250
   113
}
melunko@250
   114
melunko@250
   115
static void
renatofilho@754
   116
gmyth_upnp_init(GMythUPnP * gmyth_upnp)
melunko@250
   117
{
rosfran@696
   118
renatofilho@754
   119
    gmyth_upnp->backend_info = NULL;
rosfran@696
   120
renatofilho@754
   121
    gmyth_upnp->control_point = NULL;
rosfran@696
   122
renatofilho@754
   123
    gmyth_upnp->priv = GMYTH_UPNP_GET_PRIVATE(gmyth_upnp);
renatofilho@754
   124
    gmyth_upnp->priv->mutex = g_mutex_new();
renatofilho@754
   125
    gmyth_upnp->priv->upnp_dev_found = FALSE;
rosfran@696
   126
renatofilho@754
   127
    g_signal_connect(G_OBJECT(gmyth_upnp), "device-found",
renatofilho@754
   128
                     (GCallback) (GMYTH_UPNP_GET_CLASS(gmyth_upnp)->
renatofilho@754
   129
                                  device_found_handler), NULL);
rosfran@696
   130
renatofilho@754
   131
    gmyth_upnp_static = gmyth_upnp;
rosfran@696
   132
melunko@250
   133
}
melunko@250
   134
melunko@250
   135
/** Creates a new instance of GMythUPnP.
melunko@250
   136
 * 
melunko@250
   137
 * @return a new instance of GMythUPnP. 
melunko@250
   138
 */
renatofilho@754
   139
GMythUPnP      *
renatofilho@754
   140
gmyth_upnp_new(GMythBackendInfo * gmyth_backend_info,
renatofilho@754
   141
               GMythUPnPDeviceListener handler)
melunko@250
   142
{
renatofilho@754
   143
    GMythUPnP      *gmyth_upnp =
renatofilho@754
   144
        GMYTH_UPNP(g_object_new(GMYTH_UPNP_TYPE, NULL));
renatofilho@754
   145
renatofilho@754
   146
    g_object_ref(gmyth_backend_info);
rosfran@696
   147
rosfran@696
   148
    gmyth_upnp->backend_info = gmyth_backend_info;
rosfran@696
   149
renatofilho@754
   150
    if (!gmyth_upnp_initialize(gmyth_upnp, gmyth_backend_info, handler)) {
renatofilho@754
   151
        gmyth_debug("Error initializing the GMythUPnP!!!");
rosfran@696
   152
    }
renatofilho@754
   153
melunko@250
   154
    return gmyth_upnp;
melunko@250
   155
}
melunko@250
   156
melunko@250
   157
static void
renatofilho@754
   158
gmyth_upnp_dispose(GObject * object)
melunko@250
   159
{
renatofilho@754
   160
    GMythUPnP      *gmyth_upnp = GMYTH_UPNP(object);
melunko@250
   161
renatofilho@754
   162
    if (gmyth_upnp->control_point != NULL) {
renatofilho@754
   163
        cg_upnp_controlpoint_stop(gmyth_upnp->control_point);
renatofilho@754
   164
        cg_upnp_controlpoint_delete(gmyth_upnp->control_point);
renatofilho@754
   165
        gmyth_upnp->control_point = NULL;
renatofilho@754
   166
    }
melunko@250
   167
renatofilho@754
   168
    if (gmyth_upnp->priv->mythtv_servers != NULL) {
renatofilho@754
   169
        g_hash_table_destroy(gmyth_upnp->priv->mythtv_servers);
renatofilho@754
   170
        gmyth_upnp->priv->mythtv_servers = NULL;
renatofilho@754
   171
    }
rosfran@696
   172
renatofilho@754
   173
    if (gmyth_upnp->backend_info != NULL) {
renatofilho@754
   174
        g_object_unref(gmyth_upnp->backend_info);
renatofilho@754
   175
        gmyth_upnp->backend_info = NULL;
renatofilho@754
   176
    }
renatofilho@754
   177
renatofilho@754
   178
    G_OBJECT_CLASS(gmyth_upnp_parent_class)->dispose(object);
melunko@250
   179
}
melunko@250
   180
melunko@250
   181
static void
renatofilho@754
   182
gmyth_upnp_finalize(GObject * object)
melunko@250
   183
{
renatofilho@754
   184
    g_signal_handlers_destroy(object);
melunko@250
   185
renatofilho@754
   186
    G_OBJECT_CLASS(gmyth_upnp_parent_class)->finalize(object);
melunko@250
   187
}
melunko@250
   188
renatofilho@754
   189
gchar          *
renatofilho@754
   190
gmyth_upnp_device_status_to_string(GMythUPnPDeviceStatus status)
rosfran@706
   191
{
renatofilho@754
   192
    if (status == CgUpnpDeviceStatusAdded)
renatofilho@754
   193
        return "Added";
renatofilho@754
   194
    else if (status == CgUpnpDeviceStatusUpdated)
renatofilho@754
   195
        return "Updated";
renatofilho@754
   196
    else if (status == CgUpnpDeviceStatusInvalid)
renatofilho@754
   197
        return "Invalid";
renatofilho@754
   198
    else if (status == CgUpnpDeviceStatusRemoved)
renatofilho@754
   199
        return "Removed";
rosfran@706
   200
renatofilho@754
   201
    return "";
rosfran@696
   202
}
rosfran@696
   203
rosfran@696
   204
/**
rosfran@696
   205
 * GObject's signal handler
rosfran@696
   206
 */
renatofilho@754
   207
static void
renatofilho@754
   208
_mythtv_device_found(GMythUPnP * gmyth_upnp, GMythUPnPDeviceStatus status,
renatofilho@754
   209
                     gchar * udn)
rosfran@696
   210
{
renatofilho@754
   211
    g_debug("Device: [status = %s, UDN = %s]\n",
renatofilho@754
   212
            gmyth_upnp_device_status_to_string(status), udn);
renatofilho@754
   213
}
renatofilho@754
   214
renatofilho@754
   215
/**
renatofilho@754
   216
 * GObject's signal handler
renatofilho@754
   217
 */
renatofilho@754
   218
static void
renatofilho@754
   219
_clinkc_mythtv_device_found(gchar * udn, GMythUPnPDeviceStatus status)
renatofilho@754
   220
{
renatofilho@754
   221
    if (gmyth_upnp_static != NULL && udn != NULL)
renatofilho@754
   222
        g_signal_emit(gmyth_upnp_static, GMYTH_UPNP_GET_CLASS(gmyth_upnp_static)->device_found_handler_signal_id, 0,    /* details 
renatofilho@754
   223
                                                                                                                         */
renatofilho@754
   224
                      status, udn);
rosfran@696
   225
}
rosfran@696
   226
rosfran@696
   227
/**
melunko@250
   228
 * Create a control point and start it.
melunko@250
   229
 */
renatofilho@754
   230
static          gboolean
renatofilho@754
   231
gmyth_upnp_initialize(GMythUPnP * gmyth_upnp,
renatofilho@754
   232
                      GMythBackendInfo * gmyth_backend_info,
renatofilho@754
   233
                      GMythUPnPDeviceListener device_found_handler)
melunko@250
   234
{
renatofilho@754
   235
    gboolean        ret = TRUE;
rosfran@696
   236
renatofilho@754
   237
    g_return_val_if_fail(gmyth_backend_info != NULL, FALSE);
rosfran@696
   238
renatofilho@754
   239
    /*
renatofilho@754
   240
     * Create the cybergarage control point 
renatofilho@754
   241
     */
renatofilho@754
   242
    gmyth_upnp->control_point = cg_upnp_controlpoint_new();
rosfran@696
   243
renatofilho@754
   244
    if (device_found_handler != NULL) {
renatofilho@754
   245
        GMYTH_UPNP_GET_CLASS(gmyth_upnp)->device_found_handler =
renatofilho@754
   246
            device_found_handler;
rosfran@696
   247
renatofilho@754
   248
        cg_upnp_controlpoint_setdevicelistener(gmyth_upnp->control_point,
renatofilho@754
   249
                                               _clinkc_mythtv_device_found);
renatofilho@754
   250
    }
rosfran@696
   251
renatofilho@754
   252
    /*
renatofilho@754
   253
     * Start the control point 
renatofilho@754
   254
     */
renatofilho@754
   255
    if (cg_upnp_controlpoint_start(gmyth_upnp->control_point) == FALSE) {
renatofilho@754
   256
        gmyth_debug("Unable to start UPnP control point!!!");
renatofilho@754
   257
        ret = FALSE;
renatofilho@754
   258
        goto done;
renatofilho@754
   259
    } else {
renatofilho@754
   260
        gmyth_debug("Control point started.");
renatofilho@754
   261
    }
rosfran@696
   262
renatofilho@754
   263
  done:
rosfran@696
   264
renatofilho@754
   265
    return ret;
rosfran@696
   266
}
rosfran@696
   267
rosfran@696
   268
static void
renatofilho@754
   269
_gmyth_foreach_key_value(gchar * udn, gchar * dev,
renatofilho@754
   270
                         GList * upnp_servers_list)
rosfran@696
   271
{
renatofilho@754
   272
    GMythUPnPDevice *gmyth_upnp = g_malloc0(sizeof(GMythUPnPDevice));
rosfran@696
   273
renatofilho@754
   274
    GMythURI       *uri = NULL;
renatofilho@754
   275
    gmyth_upnp->uri = (gchar *) (dev);
renatofilho@754
   276
    uri = gmyth_uri_new_with_value(gmyth_upnp->uri);
rosfran@696
   277
renatofilho@754
   278
    gmyth_upnp->host = gmyth_uri_get_host(uri);
renatofilho@754
   279
    gmyth_upnp->port = gmyth_uri_get_port(uri);
renatofilho@754
   280
    gmyth_upnp->protocol = gmyth_uri_get_protocol(uri);
rosfran@696
   281
renatofilho@754
   282
    gmyth_debug("MythTV UPnP service [ %s, %d ].", gmyth_upnp->host,
renatofilho@754
   283
                gmyth_upnp->port);
rosfran@706
   284
renatofilho@754
   285
    upnp_servers_list = g_list_append(upnp_servers_list, gmyth_upnp);
rosfran@696
   286
renatofilho@754
   287
    if (uri != NULL) {
renatofilho@754
   288
        g_object_unref(uri);
renatofilho@754
   289
        uri = NULL;
renatofilho@754
   290
    }
rosfran@696
   291
rosfran@696
   292
}
rosfran@696
   293
renatofilho@754
   294
GList          *
renatofilho@754
   295
gmyth_upnp_do_search_sync(GMythUPnP * gmyth_upnp)
rosfran@696
   296
{
renatofilho@754
   297
    GList          *upnp_servers_list = NULL;
renatofilho@754
   298
    guint           iter_count = GMYTH_UPNP_MAX_SEARCHS;
renatofilho@754
   299
    /*
renatofilho@754
   300
     * gmyth_upnp->priv = GMYTH_UPNP_GET_PRIVATE( gmyth_upnp ); 
renatofilho@754
   301
     */
rosfran@696
   302
renatofilho@754
   303
    while (gmyth_upnp->priv->upnp_dev_found == FALSE && (--iter_count > 0)) {
rosfran@696
   304
renatofilho@754
   305
        gmyth_debug
renatofilho@754
   306
            ("UPnP MythTV Client control point is searching MythTV AV Device server...\n");
rosfran@696
   307
renatofilho@754
   308
        if (gmyth_upnp->control_point != NULL)
renatofilho@754
   309
            cg_upnp_controlpoint_search(gmyth_upnp->control_point,
renatofilho@754
   310
                                        "urn:schemas-upnp-org:service:ContentDirectory:1");
melunko@250
   311
renatofilho@754
   312
        /*
renatofilho@754
   313
         * just to avoid clinkc pthread concurrency faults 
renatofilho@754
   314
         */
renatofilho@754
   315
        cg_wait(1000);
rosfran@696
   316
renatofilho@754
   317
        /*
renatofilho@754
   318
         * discover if it was found 
renatofilho@754
   319
         */
renatofilho@754
   320
        gmyth_upnp->priv->upnp_dev_found =
renatofilho@754
   321
            gmyth_upnp_got_mythtv_service(gmyth_upnp->control_point,
renatofilho@754
   322
                                          &gmyth_upnp->priv->udn,
renatofilho@754
   323
                                          &gmyth_upnp->priv->
renatofilho@754
   324
                                          mythtv_servers);
rosfran@696
   325
renatofilho@754
   326
    }                           /* while */
rosfran@696
   327
renatofilho@754
   328
    if (gmyth_upnp->priv->upnp_dev_found) {
rosfran@696
   329
renatofilho@754
   330
        gmyth_debug("Found UPnP MythTV AV Device...\n");
melunko@250
   331
renatofilho@754
   332
        g_hash_table_foreach(gmyth_upnp->priv->mythtv_servers,
renatofilho@754
   333
                             (GHFunc) _gmyth_foreach_key_value,
renatofilho@754
   334
                             upnp_servers_list);
melunko@250
   335
renatofilho@754
   336
    }
renatofilho@754
   337
    /*
renatofilho@754
   338
     * if - found UPnP device 
renatofilho@754
   339
     */
renatofilho@754
   340
    return upnp_servers_list;
melunko@250
   341
}
melunko@250
   342
melunko@250
   343
/** 
rosfran@696
   344
 * Checks if got the MythTV service in the Control Point's device list.
melunko@250
   345
 */
renatofilho@754
   346
static          gboolean
renatofilho@754
   347
gmyth_upnp_got_mythtv_service(CgUpnpControlPoint * controlPt, gchar ** udn,
renatofilho@754
   348
                              GHashTable ** mythtv_servers_lst)
melunko@250
   349
{
rosfran@696
   350
renatofilho@754
   351
    g_return_val_if_fail(mythtv_servers_lst != NULL, FALSE);
renatofilho@754
   352
    g_return_val_if_fail(controlPt != NULL, FALSE);
renatofilho@754
   353
renatofilho@754
   354
    *mythtv_servers_lst = g_hash_table_new(g_str_hash, g_str_equal);
renatofilho@754
   355
renatofilho@754
   356
    const gchar    *mythtvFriendlyName = "Myth";
renatofilho@754
   357
    /*
renatofilho@754
   358
     * begin assertion about the size of discovered devices 
renatofilho@754
   359
     */
renatofilho@754
   360
    gint            numDevices =
renatofilho@754
   361
        cg_upnp_controlpoint_getndevices(controlPt);
renatofilho@754
   362
    gint            cntDevs = 0;
renatofilho@754
   363
    CgUpnpDevice   *childDev;
renatofilho@754
   364
    gchar          *devName = NULL,
renatofilho@754
   365
        *dev_url = NULL;
renatofilho@754
   366
    gboolean        upnp_dev_found = FALSE;
renatofilho@754
   367
renatofilho@754
   368
    gmyth_debug("UPnP MythTV AV Device list size = %d\n", numDevices);
renatofilho@754
   369
renatofilho@754
   370
    for (childDev = cg_upnp_controlpoint_getdevices(controlPt);
renatofilho@754
   371
         childDev != NULL; childDev = cg_upnp_device_next(childDev)) {
renatofilho@754
   372
        devName = cg_upnp_device_getfriendlyname(childDev);
renatofilho@754
   373
        dev_url = cg_upnp_device_getlocationfromssdppacket(childDev);
renatofilho@754
   374
        gmyth_debug
renatofilho@754
   375
            ("Device's friendly name = %s, and  device's URL = %s\n",
renatofilho@754
   376
             devName, dev_url);
renatofilho@754
   377
        if ((g_strstr_len(devName, strlen(devName), mythtvFriendlyName) !=
renatofilho@754
   378
             NULL) == TRUE) {
renatofilho@754
   379
            upnp_dev_found = TRUE;
renatofilho@754
   380
            /*
renatofilho@754
   381
             * stores the last UDN number ID 
renatofilho@754
   382
             */
renatofilho@754
   383
            *udn = cg_upnp_device_getudn(childDev);
renatofilho@754
   384
            /*
renatofilho@754
   385
             *mythtv_servers_lst = g_list_append( *mythtv_servers_lst, dev_url );  */
renatofilho@754
   386
            g_hash_table_insert(*mythtv_servers_lst, (gpointer) * udn,
renatofilho@754
   387
                                (gpointer) dev_url);
renatofilho@754
   388
        }
renatofilho@754
   389
        ++cntDevs;
renatofilho@754
   390
    }
renatofilho@754
   391
renatofilho@754
   392
    if (upnp_dev_found == TRUE) {
renatofilho@754
   393
        gmyth_debug
renatofilho@754
   394
            ("MythTV AV Device found, from a total of %d devices.\n",
renatofilho@754
   395
             cntDevs);
renatofilho@754
   396
    } else if (numDevices == cntDevs) {
renatofilho@754
   397
        gmyth_debug
renatofilho@754
   398
            ("MythTV AV Device not found, from a total of %d devices.\n",
renatofilho@754
   399
             cntDevs);
renatofilho@754
   400
    } else {
renatofilho@754
   401
        gmyth_debug
renatofilho@754
   402
            ("Control Point's MythTV AV Device count is wrong: iterated over %d devices, but there are %d registered devices.\n",
renatofilho@754
   403
             cntDevs, numDevices);
renatofilho@754
   404
    }
renatofilho@754
   405
renatofilho@754
   406
    return upnp_dev_found;
melunko@250
   407
melunko@250
   408
}
melunko@250
   409
melunko@250
   410
/** Gets the UPnP AV devices server's list associated to this upnp.
melunko@250
   411
 * 
rosfran@696
   412
 * @return The GHashTable* containing all the URI values for each recognized UPnP device,
melunko@250
   413
 * 			or NULL if it couldn't recognize any MythTV AV device.
melunko@250
   414
 */
renatofilho@754
   415
GHashTable     *
renatofilho@754
   416
gmyth_upnp_get_servers(GMythUPnP * gmyth_upnp)
melunko@250
   417
{
melunko@250
   418
renatofilho@754
   419
    if (NULL == gmyth_upnp || NULL == gmyth_upnp->priv->mythtv_servers) {
renatofilho@754
   420
        gmyth_debug("[%s] GMythUPnP has no MythTV servers recognized.\n",
renatofilho@754
   421
                    __FUNCTION__);
renatofilho@754
   422
        return NULL;
renatofilho@754
   423
    }
renatofilho@754
   424
renatofilho@754
   425
    return gmyth_upnp->priv->mythtv_servers;
melunko@250
   426
}
melunko@250
   427
melunko@250
   428
/** Gets the GMythBackendInfo object associated to this upnp.
melunko@250
   429
 * 
melunko@250
   430
 * @return The GMythBackendInfo object currently valid or NULL if the settings
melunko@250
   431
 * were not opened.
melunko@250
   432
 */
renatofilho@754
   433
GMythBackendInfo *
renatofilho@754
   434
gmyth_upnp_get_backend_info(GMythUPnP * gmyth_upnp)
melunko@250
   435
{
melunko@250
   436
renatofilho@754
   437
    if (NULL == gmyth_upnp || NULL == gmyth_upnp->backend_info) {
renatofilho@754
   438
        gmyth_debug("[%s] GMythUPnP not initialized\n", __FUNCTION__);
renatofilho@754
   439
        return NULL;
renatofilho@754
   440
    }
renatofilho@754
   441
renatofilho@754
   442
    return gmyth_upnp->backend_info;
melunko@250
   443
}