rosfran@637
|
1 |
#include <glib-object.h>
|
rosfran@637
|
2 |
|
rosfran@637
|
3 |
#include "common.h"
|
rosfran@637
|
4 |
|
rosfran@637
|
5 |
#include <gmyth/gmyth_uri.h>
|
rosfran@637
|
6 |
#include <gmyth/gmyth_backendinfo.h>
|
rosfran@637
|
7 |
#include <gmyth/gmyth_livetv.h>
|
rosfran@637
|
8 |
#include <gmyth/gmyth_programinfo.h>
|
rosfran@637
|
9 |
#include <gmyth/gmyth_common.h>
|
rosfran@637
|
10 |
|
rosfran@637
|
11 |
#define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9"
|
rosfran@637
|
12 |
|
rosfran@637
|
13 |
static gboolean
|
rosfran@637
|
14 |
test_program_info_setup ( gchar *uri )
|
rosfran@637
|
15 |
{
|
rosfran@637
|
16 |
GMythLiveTV *livetv = NULL;
|
rosfran@637
|
17 |
GMythStringList *str_list = NULL;
|
rosfran@637
|
18 |
GMythProgramInfo *program_info = NULL;
|
rosfran@637
|
19 |
|
rosfran@637
|
20 |
gchar *channel_name = NULL;
|
rosfran@637
|
21 |
gboolean ret = TRUE;
|
rosfran@637
|
22 |
gboolean live_tv = FALSE;
|
rosfran@637
|
23 |
|
rosfran@637
|
24 |
if ( NULL == uri )
|
rosfran@637
|
25 |
uri = g_strdup( URI_DEFAULT );
|
rosfran@637
|
26 |
|
rosfran@637
|
27 |
GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri );
|
rosfran@637
|
28 |
|
rosfran@637
|
29 |
GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri);
|
rosfran@637
|
30 |
live_tv = gmyth_uri_is_livetv( gmyth_uri );
|
rosfran@637
|
31 |
if ( live_tv ) {
|
rosfran@637
|
32 |
livetv = gmyth_livetv_new (backend_info);
|
rosfran@637
|
33 |
|
rosfran@637
|
34 |
gchar* ch = gmyth_uri_get_channel_name( gmyth_uri );
|
rosfran@637
|
35 |
if ( ch != NULL )
|
rosfran@637
|
36 |
channel_name = ch;
|
rosfran@637
|
37 |
|
rosfran@637
|
38 |
if (channel_name != NULL) {
|
rosfran@637
|
39 |
if (gmyth_livetv_channel_name_setup (livetv, channel_name) == FALSE) {
|
rosfran@637
|
40 |
g_debug("LiveTV setup felt down on error.");
|
rosfran@637
|
41 |
ret = FALSE;
|
rosfran@637
|
42 |
goto init_failed;
|
rosfran@637
|
43 |
}
|
rosfran@637
|
44 |
} else {
|
rosfran@637
|
45 |
if (gmyth_livetv_setup (livetv) == FALSE) {
|
rosfran@637
|
46 |
g_debug("LiveTV setup felt down on error");
|
rosfran@637
|
47 |
ret = FALSE;
|
rosfran@637
|
48 |
goto init_failed;
|
rosfran@637
|
49 |
}
|
rosfran@637
|
50 |
}
|
rosfran@637
|
51 |
}
|
rosfran@637
|
52 |
|
rosfran@637
|
53 |
g_debug( "uri = %s", uri);
|
rosfran@637
|
54 |
|
rosfran@637
|
55 |
if ( ret == FALSE ) {
|
rosfran@637
|
56 |
g_debug("MythTV ProgramInfo request failed when setting up socket connection!");
|
rosfran@637
|
57 |
goto init_failed;
|
rosfran@637
|
58 |
}
|
rosfran@637
|
59 |
|
rosfran@637
|
60 |
g_return_val_if_fail( livetv->proginfo != NULL, FALSE );
|
rosfran@637
|
61 |
|
rosfran@637
|
62 |
g_debug( "Printing ProgramInfo... [%s]", gmyth_program_info_to_string( livetv->proginfo ) );
|
rosfran@637
|
63 |
|
rosfran@637
|
64 |
str_list = gmyth_program_info_to_string_list( livetv->proginfo, str_list );
|
rosfran@637
|
65 |
|
rosfran@637
|
66 |
g_return_val_if_fail( str_list != NULL && gmyth_string_list_length( str_list ) > 0, FALSE );
|
rosfran@637
|
67 |
|
rosfran@637
|
68 |
program_info = gmyth_program_info_from_string_list( str_list );
|
rosfran@637
|
69 |
|
rosfran@637
|
70 |
/* assert it IS the same program info */
|
rosfran@637
|
71 |
g_return_val_if_fail( gmyth_program_info_is_equals( program_info, livetv->proginfo ), FALSE );
|
rosfran@637
|
72 |
|
rosfran@637
|
73 |
program_info->title = g_string_assign( program_info->title, "Another RaNdOm Title..." );
|
rosfran@637
|
74 |
|
rosfran@637
|
75 |
/* assert it is not the same program info anymore */
|
rosfran@637
|
76 |
g_return_val_if_fail( !gmyth_program_info_is_equals( program_info, livetv->proginfo ), FALSE );
|
rosfran@637
|
77 |
|
rosfran@637
|
78 |
init_failed:
|
rosfran@637
|
79 |
if ( str_list != NULL )
|
rosfran@637
|
80 |
g_object_unref( str_list );
|
rosfran@637
|
81 |
|
rosfran@637
|
82 |
if ( program_info != NULL )
|
rosfran@637
|
83 |
g_object_unref( program_info );
|
rosfran@637
|
84 |
|
rosfran@637
|
85 |
if ( livetv != NULL )
|
rosfran@637
|
86 |
g_object_unref(livetv);
|
rosfran@637
|
87 |
|
rosfran@637
|
88 |
if ( gmyth_uri != NULL )
|
rosfran@637
|
89 |
g_object_unref( gmyth_uri );
|
rosfran@637
|
90 |
|
rosfran@637
|
91 |
return ret;
|
rosfran@637
|
92 |
|
rosfran@637
|
93 |
}
|
rosfran@637
|
94 |
|
rosfran@637
|
95 |
gint
|
rosfran@637
|
96 |
main (gint args, const gchar **argv)
|
rosfran@637
|
97 |
{
|
rosfran@637
|
98 |
gboolean ret;
|
rosfran@637
|
99 |
|
rosfran@637
|
100 |
g_type_init ();
|
rosfran@637
|
101 |
|
rosfran@637
|
102 |
g_thread_init (NULL);
|
rosfran@637
|
103 |
|
rosfran@637
|
104 |
fprintf(stdout, SYNC_STRING);
|
rosfran@637
|
105 |
fflush(NULL);
|
rosfran@637
|
106 |
getchar();
|
rosfran@637
|
107 |
|
rosfran@637
|
108 |
if ( args > 1 )
|
rosfran@637
|
109 |
ret = test_program_info_setup ( argv[1] );
|
rosfran@637
|
110 |
else
|
rosfran@637
|
111 |
ret = test_program_info_setup( NULL );
|
rosfran@637
|
112 |
|
rosfran@637
|
113 |
if ( !ret )
|
rosfran@637
|
114 |
g_debug ("Error when getting program info from the LiveTV instance!");
|
rosfran@637
|
115 |
else
|
rosfran@637
|
116 |
g_debug ("LiveTV setup test script finished with success.");
|
rosfran@637
|
117 |
|
rosfran@637
|
118 |
return(0);
|
rosfran@637
|
119 |
}
|
rosfran@637
|
120 |
|
rosfran@637
|
121 |
|
rosfran@637
|
122 |
|
rosfran@637
|
123 |
|