1 #include <glib-object.h>
5 #include <gmyth/gmyth_uri.h>
6 #include <gmyth/gmyth_backendinfo.h>
7 #include <gmyth/gmyth_livetv.h>
8 #include <gmyth/gmyth_monitor_handler.h>
9 #include <gmyth/gmyth_common.h>
11 #define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9"
14 * The GObject signal handler function, from which all status messages
15 * from the Monitor Handler will be advertized, all time it receives
16 * LiveTV status messages from the MythTV backend
18 * @param monitor a GMythMonitorHandler instance
19 * @param msg_code the MythTV's server numeric status code
20 * @param message the message's string description
21 * @param user_data pointer to the GMythLiveTV instance (NULL in the tests)
24 gmyth_livetv_monitor_signal_handler(GMythMonitorHandler * monitor,
25 gint msg_code, gchar * message,
29 ("LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n",
30 message, msg_code, "NULL", user_data != NULL ? "" : "NULL");
35 * Starts the Monitor Handler to this GMythLiveTV session, in order
36 * to receive the status messages from the MythTV's backend server
38 * @param live_tv the GMythLiveTV instance
40 * @return <code>true</code> if the Monitor Handler start-up process
41 * had been concluded succcesfully
44 gmyth_test_monitor_handler_start(GMythBackendInfo * backend_info,
45 GMythMonitorHandler * *monitor)
52 g_object_unref(*monitor);
56 *monitor = gmyth_monitor_handler_new();
59 gmyth_monitor_handler_open(*monitor,
60 backend_info->hostname, backend_info->port);
65 ("Connect MythTV Monitor event socket! Trying to start the message handler...");
67 res = gmyth_monitor_handler_start(*monitor);
71 g_debug("MythTV Monitor event socket connected and listening!");
72 g_signal_connect(G_OBJECT(*monitor),
73 "backend-events-handler",
74 (GCallback) gmyth_livetv_monitor_signal_handler,
80 ("Problems when trying to start MythTV Monitor event socket!");
91 test_monitor_handler_setup(gchar * uri)
94 GMythMonitorHandler *monitor;
97 uri = g_strdup(URI_DEFAULT);
99 GMythURI *gmyth_uri = gmyth_uri_new_with_value(uri);
101 GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri(uri);
102 g_debug("uri = %s", uri);
104 ret = gmyth_test_monitor_handler_start(backend_info, &monitor);
108 g_debug("MonitorHandler couldn't start!\n");
114 g_object_unref(monitor);
116 if (gmyth_uri != NULL)
117 g_object_unref(gmyth_uri);
119 if (backend_info != NULL)
120 g_object_unref(backend_info);
127 main(gint args, const gchar ** argv)
135 fprintf(stdout, SYNC_STRING);
140 ret = test_monitor_handler_setup(argv[1]);
142 ret = test_monitor_handler_setup(NULL);
145 g_debug("Error when running Monitor Handler setup test script!");
147 g_debug("MonitorHandler setup test script setup with success.");