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_file.h>
9 #include <gmyth/gmyth_file_transfer.h>
10 #include <gmyth/gmyth_file_local.h>
11 #include <gmyth/gmyth_common.h>
13 #define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9"
16 test_livetv_setup ( gchar *uri )
18 GMythLiveTV *livetv = NULL;
19 GMythFile *file = 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");
52 file = GMYTH_FILE( gmyth_livetv_create_file_transfer (livetv) );
55 g_debug("[LiveTV] FileTransfer equals to NULL");
60 /* Check if the file is local to this specific client renderer */
61 if ( gmyth_uri_is_local_file(gmyth_uri) )
62 ret = gmyth_file_local_open( GMYTH_FILE_LOCAL(file) );
64 ret = gmyth_file_transfer_open( GMYTH_FILE_TRANSFER(file), livetv->uri != NULL ?
65 gmyth_uri_get_path(livetv->uri) :
66 livetv->proginfo->pathname->str );
70 g_debug("Error: couldn't open the FileTransfer from LiveTV source!" );
75 /* Check if the file is local to this specific client renderer, and tries to open
78 if ( gmyth_uri_is_local_file(gmyth_uri) )
80 g_debug ( "Opening local file connection to download..." );
81 file = GMYTH_FILE(gmyth_file_local_new(backend_info));
82 ret = gmyth_file_local_open ( GMYTH_FILE_LOCAL( file ) );
84 g_debug ( "Opening remote file connection to download..." );
85 file = GMYTH_FILE(gmyth_file_transfer_new(backend_info));
86 ret = gmyth_file_transfer_open ( GMYTH_FILE_TRANSFER(file), uri );
89 } /* if (else) - recorded FileTransfer */
92 g_debug("FileTransfer is NULL");
96 g_debug( "uri = %s", uri);
99 g_debug("MythTV FileTransfer request failed when setting up socket connection!");
103 g_debug( "MythTV FileTransfer filesize = %lld",
104 gmyth_file_get_filesize( file ));
107 if ( livetv != NULL )
108 g_object_unref(livetv);
111 g_object_unref(file);
113 // if ( uri != NULL )
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)
133 g_thread_init (NULL);
135 fprintf(stdout, SYNC_STRING);
140 ret = test_livetv_setup ( argv[1] );
142 ret = test_livetv_setup ( NULL );
145 g_debug ("Error when running LiveTV setup test script!");
147 g_debug ("LiveTV setup test script finished with success.");