rosfran@637: #include rosfran@637: rosfran@637: #include "common.h" rosfran@637: rosfran@637: #include rosfran@637: #include rosfran@637: #include rosfran@637: #include rosfran@637: #include rosfran@637: rosfran@637: #define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9" rosfran@637: rosfran@637: static gboolean rosfran@637: test_program_info_setup ( gchar *uri ) rosfran@637: { rosfran@637: GMythLiveTV *livetv = NULL; rosfran@637: GMythStringList *str_list = NULL; rosfran@637: GMythProgramInfo *program_info = NULL; rosfran@637: rosfran@637: gchar *channel_name = NULL; rosfran@637: gboolean ret = TRUE; rosfran@637: gboolean live_tv = FALSE; rosfran@637: rosfran@637: if ( NULL == uri ) rosfran@637: uri = g_strdup( URI_DEFAULT ); rosfran@637: rosfran@637: GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri ); rosfran@637: rosfran@637: GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri); rosfran@637: live_tv = gmyth_uri_is_livetv( gmyth_uri ); rosfran@637: if ( live_tv ) { rosfran@637: livetv = gmyth_livetv_new (backend_info); rosfran@637: rosfran@637: gchar* ch = gmyth_uri_get_channel_name( gmyth_uri ); rosfran@637: if ( ch != NULL ) rosfran@637: channel_name = ch; rosfran@637: rosfran@637: if (channel_name != NULL) { rosfran@637: if (gmyth_livetv_channel_name_setup (livetv, channel_name) == FALSE) { rosfran@637: g_debug("LiveTV setup felt down on error."); rosfran@637: ret = FALSE; rosfran@637: goto init_failed; rosfran@637: } rosfran@637: } else { rosfran@637: if (gmyth_livetv_setup (livetv) == FALSE) { rosfran@637: g_debug("LiveTV setup felt down on error"); rosfran@637: ret = FALSE; rosfran@637: goto init_failed; rosfran@637: } rosfran@637: } rosfran@637: } rosfran@637: rosfran@637: g_debug( "uri = %s", uri); rosfran@637: rosfran@637: if ( ret == FALSE ) { rosfran@637: g_debug("MythTV ProgramInfo request failed when setting up socket connection!"); rosfran@637: goto init_failed; rosfran@637: } rosfran@637: rosfran@637: g_return_val_if_fail( livetv->proginfo != NULL, FALSE ); rosfran@637: rosfran@637: g_debug( "Printing ProgramInfo... [%s]", gmyth_program_info_to_string( livetv->proginfo ) ); rosfran@637: rosfran@637: str_list = gmyth_program_info_to_string_list( livetv->proginfo, str_list ); rosfran@637: rosfran@637: g_return_val_if_fail( str_list != NULL && gmyth_string_list_length( str_list ) > 0, FALSE ); rosfran@637: rosfran@637: program_info = gmyth_program_info_from_string_list( str_list ); rosfran@637: rosfran@637: /* assert it IS the same program info */ rosfran@637: g_return_val_if_fail( gmyth_program_info_is_equals( program_info, livetv->proginfo ), FALSE ); rosfran@637: rosfran@637: program_info->title = g_string_assign( program_info->title, "Another RaNdOm Title..." ); rosfran@637: rosfran@637: /* assert it is not the same program info anymore */ rosfran@637: g_return_val_if_fail( !gmyth_program_info_is_equals( program_info, livetv->proginfo ), FALSE ); rosfran@637: rosfran@637: init_failed: rosfran@637: if ( str_list != NULL ) rosfran@637: g_object_unref( str_list ); rosfran@637: rosfran@637: if ( program_info != NULL ) rosfran@637: g_object_unref( program_info ); rosfran@637: rosfran@637: if ( livetv != NULL ) rosfran@637: g_object_unref(livetv); rosfran@637: rosfran@637: if ( gmyth_uri != NULL ) rosfran@637: g_object_unref( gmyth_uri ); rosfran@637: rosfran@637: return ret; rosfran@637: rosfran@637: } rosfran@637: rosfran@637: gint rosfran@637: main (gint args, const gchar **argv) rosfran@637: { rosfran@637: gboolean ret; rosfran@637: rosfran@637: g_type_init (); rosfran@637: rosfran@637: g_thread_init (NULL); rosfran@637: rosfran@637: fprintf(stdout, SYNC_STRING); rosfran@637: fflush(NULL); rosfran@637: getchar(); rosfran@637: rosfran@637: if ( args > 1 ) rosfran@637: ret = test_program_info_setup ( argv[1] ); rosfran@637: else rosfran@637: ret = test_program_info_setup( NULL ); rosfran@637: rosfran@637: if ( !ret ) rosfran@637: g_debug ("Error when getting program info from the LiveTV instance!"); rosfran@637: else rosfran@637: g_debug ("LiveTV setup test script finished with success."); rosfran@637: rosfran@637: return(0); rosfran@637: } rosfran@637: rosfran@637: rosfran@637: rosfran@637: