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_programinfo.h>
9 #include <gmyth/gmyth_common.h>
11 #define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9"
14 test_program_info_setup ( gchar *uri )
16 GMythLiveTV *livetv = NULL;
17 GMythStringList *str_list = NULL;
18 GMythProgramInfo *program_info = NULL;
20 gchar *channel_name = NULL;
22 gboolean live_tv = FALSE;
25 uri = g_strdup( URI_DEFAULT );
27 GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri );
29 GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri);
30 live_tv = gmyth_uri_is_livetv( gmyth_uri );
32 livetv = gmyth_livetv_new (backend_info);
34 gchar* ch = gmyth_uri_get_channel_name( gmyth_uri );
38 if (channel_name != NULL) {
39 if (gmyth_livetv_channel_name_setup (livetv, channel_name) == FALSE) {
40 g_debug("LiveTV setup felt down on error.");
45 if (gmyth_livetv_setup (livetv) == FALSE) {
46 g_debug("LiveTV setup felt down on error");
53 g_debug( "uri = %s", uri);
56 g_debug("MythTV ProgramInfo request failed when setting up socket connection!");
60 g_return_val_if_fail( livetv->proginfo != NULL, FALSE );
62 g_debug( "Printing ProgramInfo... [%s]", gmyth_program_info_to_string( livetv->proginfo ) );
64 str_list = gmyth_program_info_to_string_list( livetv->proginfo, str_list );
66 g_return_val_if_fail( str_list != NULL && gmyth_string_list_length( str_list ) > 0, FALSE );
68 program_info = gmyth_program_info_from_string_list( str_list );
70 /* assert it IS the same program info */
71 g_return_val_if_fail( gmyth_program_info_is_equals( program_info, livetv->proginfo ), FALSE );
73 program_info->title = g_string_assign( program_info->title, "Another RaNdOm Title..." );
75 /* assert it is not the same program info anymore */
76 g_return_val_if_fail( !gmyth_program_info_is_equals( program_info, livetv->proginfo ), FALSE );
79 if ( str_list != NULL )
80 g_object_unref( str_list );
82 if ( program_info != NULL )
83 g_object_unref( program_info );
86 g_object_unref(livetv);
88 if ( gmyth_uri != NULL )
89 g_object_unref( gmyth_uri );
96 main (gint args, const gchar **argv)
102 g_thread_init (NULL);
104 fprintf(stdout, SYNC_STRING);
109 ret = test_program_info_setup ( argv[1] );
111 ret = test_program_info_setup( NULL );
114 g_debug ("Error when getting program info from the LiveTV instance!");
116 g_debug ("LiveTV setup test script finished with success.");