[svn r580] * Fixed bug on reset element; trunk
authorrenatofilho
Thu Apr 19 18:13:51 2007 +0100 (2007-04-19)
branchtrunk
changeset 575f7351f2fd6d8
parent 574 2dfea125c76c
child 576 6ee1dc7357e8
[svn r580] * Fixed bug on reset element;
* added property max-try for specify number of chances to connect with livtv server;
gst-plugins-mythtv/src/gstmythtvsrc.c
gst-plugins-mythtv/src/gstmythtvsrc.h
     1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c	Thu Apr 19 16:30:17 2007 +0100
     1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c	Thu Apr 19 18:13:51 2007 +0100
     1.3 @@ -131,7 +131,8 @@
     1.4    PROP_GMYTHTV_LIVEID,
     1.5    PROP_GMYTHTV_LIVE_CHAINID,
     1.6    PROP_GMYTHTV_ENABLE_TIMING_POSITION,
     1.7 -  PROP_GMYTHTV_CHANNEL_NUM
     1.8 +  PROP_GMYTHTV_CHANNEL_NUM,
     1.9 +  PROP_GMYTHTV_MAX_TRY
    1.10  };
    1.11  
    1.12  static void gst_mythtv_src_clear (GstMythtvSrc *mythtv_src);
    1.13 @@ -255,6 +256,13 @@
    1.14            "Change MythTV channel number",
    1.15            "", G_PARAM_READWRITE));
    1.16  
    1.17 +  g_object_class_install_property
    1.18 +      (gobject_class, PROP_GMYTHTV_MAX_TRY,
    1.19 +      g_param_spec_int ("max-try", "max-try",
    1.20 +          "Set the max try for get MythTV free recorder",
    1.21 +          0, G_MAXINT, 10,  G_PARAM_READWRITE));
    1.22 +
    1.23 +
    1.24  #ifndef GST_DISABLE_GST_DEBUG
    1.25    g_object_class_install_property
    1.26        (gobject_class, PROP_GMYTHTV_DBG,
    1.27 @@ -309,6 +317,8 @@
    1.28    this->bytes_queue = NULL;
    1.29  
    1.30    this->wait_to_transfer = 0;
    1.31 +  this->try_number = 0;
    1.32 +  this->max_try = 10;
    1.33  
    1.34    gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_BYTES);
    1.35  
    1.36 @@ -322,7 +332,9 @@
    1.37  static void
    1.38  gst_mythtv_src_clear (GstMythtvSrc *mythtv_src)
    1.39  {
    1.40 -    
    1.41 +  mythtv_src->unique_setup = FALSE;
    1.42 +  mythtv_src->try_number = 0;
    1.43 +
    1.44    if (mythtv_src->spawn_livetv) {
    1.45      g_object_unref (mythtv_src->spawn_livetv);
    1.46      mythtv_src->spawn_livetv = NULL;
    1.47 @@ -338,14 +350,6 @@
    1.48      mythtv_src->backend_info = NULL;
    1.49    }
    1.50  
    1.51 -  if (mythtv_src->uri_name) {
    1.52 -    g_free (mythtv_src->uri_name);
    1.53 -  }
    1.54 -
    1.55 -  if (mythtv_src->user_agent) {
    1.56 -    g_free (mythtv_src->user_agent);
    1.57 -  }
    1.58 -
    1.59    if (mythtv_src->bytes_queue) {
    1.60      g_byte_array_free (mythtv_src->bytes_queue, TRUE);
    1.61      mythtv_src->bytes_queue = NULL;
    1.62 @@ -360,6 +364,16 @@
    1.63  
    1.64    gst_mythtv_src_clear (this);
    1.65  
    1.66 +  if (this->uri_name) {
    1.67 +    g_free (this->uri_name);
    1.68 +    this->uri_name = NULL;
    1.69 +  }
    1.70 +
    1.71 +  if (this->user_agent) {
    1.72 +    g_free (this->user_agent);
    1.73 +    this->user_agent = NULL;
    1.74 +  }
    1.75 +
    1.76    G_OBJECT_CLASS (parent_class)->finalize (gobject);
    1.77  }
    1.78  
    1.79 @@ -695,10 +709,9 @@
    1.80      goto done;
    1.81    }
    1.82    
    1.83 -  gmyth_uri = gmyth_uri_new_with_value( src->uri_name );
    1.84 -
    1.85 +  gmyth_uri = gmyth_uri_new_with_value (src->uri_name);
    1.86    src->backend_info = gmyth_backend_info_new_with_uri (src->uri_name);
    1.87 -  src->live_tv |= gmyth_uri_is_livetv( gmyth_uri );
    1.88 +  src->live_tv = gmyth_uri_is_livetv( gmyth_uri );
    1.89    /* testing UPnP... */
    1.90    /* gmyth_backend_info_set_hostname( src->backend_info, NULL ); */
    1.91    if ( src->live_tv ) {
    1.92 @@ -799,37 +812,57 @@
    1.93            src->content_size, 0));
    1.94  
    1.95  done:
    1.96 -	/*if ( gmyth_uri != NULL )
    1.97 +	if (gmyth_uri != NULL)
    1.98  	{
    1.99 -  	g_object_unref( gmyth_uri );
   1.100 -  	gmyth_uri = NULL;
   1.101 -	}*/
   1.102 +  	    g_object_unref (gmyth_uri);
   1.103 +      	gmyth_uri = NULL;
   1.104 +	}
   1.105  
   1.106 -  if (chain_id_local != NULL) {
   1.107 -    g_string_free (chain_id_local, TRUE);
   1.108 -    chain_id_local = NULL;
   1.109 -  }
   1.110 +    if (chain_id_local != NULL) {
   1.111 +        g_string_free (chain_id_local, TRUE);
   1.112 +        chain_id_local = NULL;
   1.113 +    }
   1.114  
   1.115 -  return TRUE;
   1.116 +    return TRUE;
   1.117  
   1.118 -  /* ERRORS */
   1.119 +    /* ERRORS */
   1.120  init_failed:
   1.121 -  {
   1.122 -    if (src->spawn_livetv != NULL)
   1.123 -      g_object_unref (src->spawn_livetv);
   1.124 +	if (gmyth_uri != NULL)
   1.125 +	{
   1.126 +  	    g_object_unref (gmyth_uri);
   1.127 +      	gmyth_uri = NULL;
   1.128 +	}
   1.129  
   1.130 +    if (src->spawn_livetv != NULL) {
   1.131 +        g_object_unref (src->spawn_livetv);
   1.132 +        src->spawn_livetv = NULL;
   1.133 +    }
   1.134 +    
   1.135 +    /*
   1.136      GST_ELEMENT_ERROR (src, LIBRARY, INIT,
   1.137 -        (NULL), ("Could not initialize MythTV library (%i, %s)", ret,
   1.138 +            (NULL), ("Could not initialize MythTV library (%i, %s)", ret,
   1.139              src->uri_name));
   1.140 +    */            
   1.141 +
   1.142 +    if  (++src->try_number <= src->max_try) {
   1.143 +       gst_mythtv_src_clear (src);
   1.144 +       GST_DEBUG_OBJECT (src, "Starting new try for get free recorder on MythTV");
   1.145 +       g_usleep (0.5 * G_USEC_PER_SEC);
   1.146 +       return gst_mythtv_src_start (bsrc);
   1.147 +    }
   1.148 +
   1.149      return FALSE;
   1.150 -  }
   1.151  begin_req_failed:
   1.152 -  {
   1.153 +	if (gmyth_uri != NULL)
   1.154 +	{
   1.155 +  	    g_object_unref (gmyth_uri);
   1.156 +      	gmyth_uri = NULL;
   1.157 +	}
   1.158 +
   1.159      GST_ELEMENT_ERROR (src, LIBRARY, INIT,
   1.160          (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret,
   1.161              src->uri_name));
   1.162      return FALSE;
   1.163 -  }
   1.164  
   1.165  }
   1.166  
   1.167 @@ -1081,6 +1114,11 @@
   1.168        mythtvsrc->channel_name = g_value_dup_string (value);
   1.169        break;
   1.170      }
   1.171 +    case PROP_GMYTHTV_MAX_TRY:
   1.172 +    {
   1.173 +      mythtvsrc->max_try = g_value_get_int (value);
   1.174 +      break;
   1.175 +    }
   1.176      default:
   1.177        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   1.178        break;
   1.179 @@ -1133,6 +1171,12 @@
   1.180        g_value_set_string (value, mythtvsrc->channel_name);
   1.181        break;
   1.182      }
   1.183 +    case PROP_GMYTHTV_MAX_TRY:
   1.184 +    {
   1.185 +      g_value_set_int (value, mythtvsrc->max_try);
   1.186 +      break;
   1.187 +    }
   1.188 +
   1.189      default:
   1.190        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   1.191        break;
     2.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.h	Thu Apr 19 16:30:17 2007 +0100
     2.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.h	Thu Apr 19 18:13:51 2007 +0100
     2.3 @@ -113,8 +113,12 @@
     2.4  
     2.5    gboolean update_prog_chain;
     2.6  
     2.7 -	/* stablish a maximum iteration value to the IS_RECORDING message */
     2.8 -	guint wait_to_transfer;
     2.9 +  /* stablish a maximum iteration value to the IS_RECORDING message */
    2.10 +  guint wait_to_transfer;
    2.11 +
    2.12 +  /* max try number to get freerecorder */
    2.13 +  gint max_try;
    2.14 +  gint try_number;
    2.15  
    2.16  };
    2.17