# HG changeset patch # User rosfran # Date 1176909698 -3600 # Node ID 25f194cfa60b2fde6779650ad56c879daa723624 # Parent ed34b1dab10357caadf0cf0e419bf14e70959d6e [svn r571] Added test to the LiveTV module. diff -r ed34b1dab103 -r 25f194cfa60b gmyth/tests/Makefile.am --- a/gmyth/tests/Makefile.am Wed Apr 18 15:59:10 2007 +0100 +++ b/gmyth/tests/Makefile.am Wed Apr 18 16:21:38 2007 +0100 @@ -22,6 +22,7 @@ gmyth_test_recordings \ gmyth_test_transcode \ gmyth_test_vlc \ + gmyth_test_livetv \ gmyth_test_http TESTS = \ @@ -32,6 +33,7 @@ gmyth_test_recordings \ gmyth_test_transcode \ gmyth_test_vlc \ + gmyth_test_livetv \ gmyth_test_http #TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) @GLIB_LIBS@ @GOBJECT_LIBS@ @LIBCURL_LIBS@ @@ -60,3 +62,6 @@ gmyth_test_transcode_SOURCES = \ gmyth_test_transcode.c +gmyth_test_livetv_SOURCES = \ + gmyth_test_livetv.c + diff -r ed34b1dab103 -r 25f194cfa60b gmyth/tests/gmyth_test_livetv.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/gmyth_test_livetv.c Wed Apr 18 16:21:38 2007 +0100 @@ -0,0 +1,138 @@ +#include + +#include "gmyth_uri.h" +#include "gmyth_backendinfo.h" +#include "gmyth_livetv.h" +#include "gmyth_file.h" +#include "gmyth_file_transfer.h" +#include "gmyth_file_local.h" +#include "gmyth_common.h" + +static gboolean +test_livetv_setup () +{ + GMythLiveTV *livetv = NULL; + GMythFile *file = NULL; + gchar *channel_name = NULL; + gboolean ret = TRUE; + gboolean live_tv = FALSE; + + gchar *uri = "myth://192.168.3.165:6543/livetv?channel=9"; + + GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri ); + + GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri); + live_tv = gmyth_uri_is_livetv( gmyth_uri ); + if ( live_tv ) { + livetv = gmyth_livetv_new (backend_info); + + gchar* ch = gmyth_uri_get_channel_name( gmyth_uri ); + if ( ch != NULL ) + channel_name = ch; + + if (channel_name != NULL) { + if (gmyth_livetv_channel_name_setup (livetv, channel_name) == FALSE) { + g_debug("LiveTV setup felt down on error."); + ret = FALSE; + goto init_failed; + } + } else { + if (gmyth_livetv_setup (livetv) == FALSE) { + g_debug("LiveTV setup felt down on error"); + ret = FALSE; + goto init_failed; + } + } + + file = GMYTH_FILE( gmyth_livetv_create_file_transfer (livetv) ); + + if (NULL == file) { + g_debug("[LiveTV] FileTransfer equals to NULL"); + ret = FALSE; + goto init_failed; + } + + /* Check if the file is local to this specific client renderer */ + if ( gmyth_uri_is_local_file(gmyth_uri) ) + ret = gmyth_file_local_open( GMYTH_FILE_LOCAL(file) ); + else + ret = gmyth_file_transfer_open( GMYTH_FILE_TRANSFER(file), livetv->uri != NULL ? + gmyth_uri_get_path(livetv->uri) : + livetv->proginfo->pathname->str ); + + if ( !ret ) + { + g_debug("Error: couldn't open the FileTransfer from LiveTV source!" ); + goto init_failed; + } + } else { + + /* Check if the file is local to this specific client renderer, and tries to open + * a local connection + */ + if ( gmyth_uri_is_local_file(gmyth_uri) ) + { + g_debug ( "Opening local file connection to download..." ); + file = GMYTH_FILE(gmyth_file_local_new(backend_info)); + ret = gmyth_file_local_open ( GMYTH_FILE_LOCAL( file ) ); + } else { + g_debug ( "Opening remote file connection to download..." ); + file = GMYTH_FILE(gmyth_file_transfer_new(backend_info)); + ret = gmyth_file_transfer_open ( GMYTH_FILE_TRANSFER(file), uri ); + } + + } /* if (else) - recorded FileTransfer */ + + if (NULL == file) { + g_debug("FileTransfer is NULL"); + ret = FALSE; + goto init_failed; + } + g_debug( "uri = %s", uri); + + if (ret == FALSE) { + g_debug("MythTV FileTransfer request failed when setting up socket connection!"); + goto init_failed; + } + + g_debug( "MythTV FileTransfer filesize = %lld", + gmyth_file_get_filesize( file )); + +init_failed: + if ( livetv != NULL ) + g_object_unref(livetv); + + if ( file != NULL ) + g_object_unref(file); + +// if ( uri != NULL ) +// g_free( uri ); + + if ( gmyth_uri != NULL ) + g_object_unref( gmyth_uri ); + +// if ( backend_info != NULL ) +// g_object_unref( backend_info ); + + return ret; + +} + +gint +main (gint args, const gchar **argv) +{ + g_type_init (); + + g_thread_init (NULL); + + gboolean ret = test_livetv_setup (); + + if ( !ret ) + g_debug ("Error when running LiveTV setup test script!"); + else + g_debug ("LiveTV setup test script finished with success."); +} + + + +