diff -r 21a15c29957b -r c9134ac45054 libgnomevfs2-mythtv/modules/mythtv-method.c --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Fri Feb 09 20:28:36 2007 +0000 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Fri Feb 09 21:30:05 2007 +0000 @@ -305,11 +305,13 @@ { GMythFileTransfer *file_transfer = NULL; GMythRecorder *recorder = NULL; + GMythTVChain *tvchain = NULL; GMythBackendInfo *backend_info = NULL; GMythURI *gmyth_uri = NULL; GMythSocket *socket = NULL; gboolean is_livetv = FALSE; gboolean ret = TRUE; + gboolean res = TRUE; /* Creates and fills out the backend info structure */ backend_info = gmyth_backend_info_new_with_uri ( @@ -339,7 +341,6 @@ /* Connect to the backend */ if ( gmyth_uri != NULL && is_livetv == TRUE ) { - gboolean res = TRUE; /* start to get file info from LiveTV remote encoder */ socket = gmyth_socket_new (); @@ -362,8 +363,8 @@ /* Gets the recorder num */ recorder = remote_request_next_free_recorder (socket, -1); - if ( socket != NULL ) - g_object_unref (socket); + //if ( socket != NULL ) + // g_object_unref (socket); if ( recorder == NULL ) { g_print ("[%s] None remote encoder available", __FUNCTION__); @@ -377,7 +378,25 @@ g_print ("[%s] Fail while setting remote encoder\n", __FUNCTION__); res = FALSE; goto error; - } + } + + /* Creates livetv chain handler */ + tvchain = gmyth_tvchain_new(); + gmyth_tvchain_initialize ( tvchain, backend_info ); + + if ( tvchain == NULL || tvchain->tvchain_id == NULL ) { + res = FALSE; + goto error; + } + + // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly) + res = gmyth_recorder_spawntv ( recorder, + gmyth_tvchain_get_id(tvchain) ); + if (!res) { + g_warning ("[%s] Fail while spawn tv\n", __FUNCTION__); + res = FALSE; + goto error; + } //gchar* channel_name = gmyth_uri_get_channel_name( gmyth_uri ); @@ -402,6 +421,9 @@ if ( prog_info != NULL ) g_object_unref( prog_info ); + + if ( tvchain != NULL ) + g_object_unref (tvchain); file_info->size = (GnomeVFSFileSize) - 1; @@ -440,6 +462,9 @@ error: if (backend_info) g_object_unref (backend_info); + + if (!res) + return GNOME_VFS_ERROR_IO; return GNOME_VFS_OK; }