gst-plugins-mythtv/src/gstmythtvsrc.c
branchtrunk
changeset 168 b8960c4f7b4d
parent 152 22db2f4b6f86
child 174 49f0333ad361
     1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c	Thu Nov 30 19:41:27 2006 +0000
     1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c	Fri Dec 01 17:12:22 2006 +0000
     1.3 @@ -654,9 +654,10 @@
     1.4  gst_mythtv_src_start ( GstBaseSrc * bsrc )
     1.5  {
     1.6    GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
     1.7 +  GMythURI *gmyth_uri = NULL;
     1.8 +  gchar* filename = NULL;
     1.9  
    1.10    GString *chain_id_local = NULL;
    1.11 -
    1.12    gboolean ret = TRUE;
    1.13  
    1.14    if ( G_UNLIKELY (src->update_prog_chain) )
    1.15 @@ -668,14 +669,18 @@
    1.16      goto done;
    1.17    }
    1.18  
    1.19 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.20 +  src->backend_info = gmyth_backend_info_new_with_uri( src->uri_name );
    1.21 +
    1.22 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.23    if ( src->live_tv ) {
    1.24 -  	src->backend_info = gmyth_backend_info_new_with_uri( src->uri_name );
    1.25      src->spawn_livetv = gmyth_livetv_new( );
    1.26      if ( gmyth_livetv_setup( src->spawn_livetv, src->backend_info ) == FALSE ) {
    1.27        ret = FALSE;
    1.28        goto init_failed;
    1.29      }    
    1.30  
    1.31 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.32      /* set up the uri variable */
    1.33      src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str );
    1.34      chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
    1.35 @@ -683,26 +688,30 @@
    1.36        src->live_chain_id = g_strdup( chain_id_local->str );
    1.37        GST_INFO_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );      
    1.38      }
    1.39 -    //if ( src->uri_name == NULL || strlen( src->uri_name ) <= 0 )
    1.40 -    //	gmyth_context_initialize();
    1.41      	
    1.42 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.43      src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
    1.44      GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name ); 
    1.45    }
    1.46  
    1.47 -  //src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, 
    1.48 -  //    g_string_new( src->uri_name ), -1, src->mythtv_version );
    1.49 -	src->file_transfer = gmyth_file_transfer_new( );
    1.50 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.51 +  src->file_transfer = gmyth_file_transfer_new( src->backend_info );
    1.52  
    1.53 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.54    if ( src->file_transfer == NULL ) {
    1.55      goto init_failed;
    1.56    }
    1.57    GST_INFO_OBJECT( src, "[%s] uri = %s.\n", __FUNCTION__, src->uri_name );
    1.58 -
    1.59 -	ret = gmyth_file_transfer_open( src->file_transfer, g_string_new( src->uri_name ) );
    1.60 -
    1.61 -  /* sets the Playback monitor connection */
    1.62 -  //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
    1.63 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.64 +  gmyth_uri = gmyth_uri_new_with_value (src->uri_name);
    1.65 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.66 +  
    1.67 +  filename = gmyth_uri_get_path (gmyth_uri);
    1.68 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.69 +  ret = gmyth_file_transfer_open( src->file_transfer, filename);
    1.70 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.71 +  g_object_unref (gmyth_uri);
    1.72 +printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
    1.73  
    1.74    if ( src->live_tv == TRUE && ret == TRUE ) {
    1.75      /* loop finished, set the max tries variable to zero again... */
    1.76 @@ -823,16 +832,17 @@
    1.77      GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
    1.78    }
    1.79  
    1.80 -  src->file_transfer = gmyth_file_transfer_new();
    1.81 +  // we do not need to create a new file transfer, just close the previous one and open with the new file name
    1.82 +  // src->file_transfer = gmyth_file_transfer_new( src->backend_info);
    1.83 +  gmyth_file_transfer_close (src->backend_info);
    1.84  
    1.85    if ( src->file_transfer == NULL ) {
    1.86      goto init_failed;
    1.87    }
    1.88    
    1.89 -	ret = gmyth_file_transfer_open( src->file_transfer, g_string_new( src->uri_name ) );
    1.90 -
    1.91 -  /* sets the Playback monitor connection */
    1.92 -  //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
    1.93 +  GMythURI *myth_uri = gmyth_uri_new_with_value (src->uri_name);
    1.94 +  ret = gmyth_file_transfer_open( src->file_transfer, gmyth_uri_get_path (myth_uri) );
    1.95 +  g_object_unref (myth_uri);
    1.96  
    1.97    if ( src->live_tv == TRUE && ret == TRUE ) {
    1.98      /* loop finished, set the max tries variable to zero again... */
    1.99 @@ -845,8 +855,6 @@
   1.100        g_usleep( 1000 );
   1.101    }
   1.102  
   1.103 -  /* sets the FileTransfer instance connection (video/audio download) */
   1.104 -  //ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
   1.105  
   1.106    if ( ret == FALSE ) {
   1.107  #ifndef GST_DISABLE_GST_DEBUG  
   1.108 @@ -949,6 +957,17 @@
   1.109      src->mythtv_caps = NULL;
   1.110    }
   1.111  
   1.112 +  if (src->backend_info != NULL) {
   1.113 +    g_object_unref (src->backend_info);
   1.114 +    src->backend_info = NULL;
   1.115 +  }
   1.116 +
   1.117 +  if (src->file_transfer != NULL) {
   1.118 +    gmyth_file_transfer_close (src->file_transfer);
   1.119 +    g_object_unref (src->file_transfer);
   1.120 +    src->file_transfer = NULL;
   1.121 +  }
   1.122 +
   1.123    src->eos = FALSE;
   1.124  
   1.125    return TRUE;