libgnomevfs2-mythtv/modules/mythtv-method.c
branchtrunk
changeset 351 c331f4639111
parent 344 21a15c29957b
child 354 ce009d76ffb5
     1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c	Fri Feb 09 20:28:36 2007 +0000
     1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c	Sat Feb 10 22:12:54 2007 +0000
     1.3 @@ -305,11 +305,13 @@
     1.4  {
     1.5      GMythFileTransfer *file_transfer = NULL;
     1.6      GMythRecorder			*recorder 		 = NULL;
     1.7 +    GMythTVChain			*tvchain	 		 = NULL;
     1.8      GMythBackendInfo  *backend_info  = NULL;
     1.9      GMythURI					*gmyth_uri		 = NULL;
    1.10  		GMythSocket 			*socket 			 = NULL;		 
    1.11      gboolean 					is_livetv 		 = FALSE;
    1.12      gboolean					ret						 = TRUE;
    1.13 +    gboolean 					res 					 = TRUE;
    1.14      
    1.15      /* Creates and fills out the backend info structure */    
    1.16  	  backend_info = gmyth_backend_info_new_with_uri ( 
    1.17 @@ -339,7 +341,6 @@
    1.18  
    1.19  	  /* Connect to the backend */
    1.20  	  if ( gmyth_uri != NULL && is_livetv == TRUE ) {
    1.21 -	  	gboolean res = TRUE;
    1.22  	  	
    1.23  	  	/* start to get file info from LiveTV remote encoder */	  	
    1.24  			socket = gmyth_socket_new ();
    1.25 @@ -362,8 +363,8 @@
    1.26  			/* Gets the recorder num */
    1.27  			recorder = remote_request_next_free_recorder (socket, -1);
    1.28  			
    1.29 -			if ( socket != NULL )
    1.30 -				g_object_unref (socket);
    1.31 +			//if ( socket != NULL )
    1.32 +			//	g_object_unref (socket);
    1.33  		
    1.34  			if ( recorder == NULL ) {
    1.35  				g_print ("[%s] None remote encoder available", __FUNCTION__);
    1.36 @@ -377,7 +378,25 @@
    1.37  				g_print ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
    1.38  				res = FALSE;
    1.39  				goto error;
    1.40 -			}			
    1.41 +			}
    1.42 +			
    1.43 +			/* Creates livetv chain handler */
    1.44 +			tvchain = gmyth_tvchain_new();
    1.45 +			gmyth_tvchain_initialize ( tvchain, backend_info );
    1.46 +		
    1.47 +			if ( tvchain == NULL || tvchain->tvchain_id == NULL ) {
    1.48 +				res = FALSE;
    1.49 +				goto error;
    1.50 +			}
    1.51 +			
    1.52 +			// Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly)
    1.53 +			res = gmyth_recorder_spawntv ( recorder,
    1.54 +					gmyth_tvchain_get_id(tvchain) );
    1.55 +			if (!res) {
    1.56 +				g_warning ("[%s] Fail while spawn tv\n", __FUNCTION__);
    1.57 +				res = FALSE;
    1.58 +				goto error;
    1.59 +			}		
    1.60  			
    1.61  		  //gchar* channel_name = gmyth_uri_get_channel_name( gmyth_uri );
    1.62  	
    1.63 @@ -402,6 +421,9 @@
    1.64  	    
    1.65  	    if ( prog_info != NULL )
    1.66  	    	g_object_unref( prog_info );
    1.67 +
    1.68 +	    if ( tvchain != NULL )
    1.69 +	    	g_object_unref (tvchain);
    1.70  	    
    1.71  	    file_info->size = (GnomeVFSFileSize) - 1;
    1.72  
    1.73 @@ -440,6 +462,9 @@
    1.74  error:
    1.75      if (backend_info)
    1.76     		g_object_unref (backend_info);
    1.77 +   		
    1.78 +   	if (!res)
    1.79 +   		return GNOME_VFS_ERROR_IO;
    1.80  
    1.81      return GNOME_VFS_OK;
    1.82  }