# HG changeset patch # User renatofilho # Date 1177002831 -3600 # Node ID f7351f2fd6d83c5c4ce3c20d453b7942daa3b3e9 # Parent 2dfea125c76cdaa753789ad3c50bc0ef61cdae7d [svn r580] * Fixed bug on reset element; * added property max-try for specify number of chances to connect with livtv server; diff -r 2dfea125c76c -r f7351f2fd6d8 gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Apr 19 16:30:17 2007 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Apr 19 18:13:51 2007 +0100 @@ -131,7 +131,8 @@ PROP_GMYTHTV_LIVEID, PROP_GMYTHTV_LIVE_CHAINID, PROP_GMYTHTV_ENABLE_TIMING_POSITION, - PROP_GMYTHTV_CHANNEL_NUM + PROP_GMYTHTV_CHANNEL_NUM, + PROP_GMYTHTV_MAX_TRY }; static void gst_mythtv_src_clear (GstMythtvSrc *mythtv_src); @@ -255,6 +256,13 @@ "Change MythTV channel number", "", G_PARAM_READWRITE)); + g_object_class_install_property + (gobject_class, PROP_GMYTHTV_MAX_TRY, + g_param_spec_int ("max-try", "max-try", + "Set the max try for get MythTV free recorder", + 0, G_MAXINT, 10, G_PARAM_READWRITE)); + + #ifndef GST_DISABLE_GST_DEBUG g_object_class_install_property (gobject_class, PROP_GMYTHTV_DBG, @@ -309,6 +317,8 @@ this->bytes_queue = NULL; this->wait_to_transfer = 0; + this->try_number = 0; + this->max_try = 10; gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_BYTES); @@ -322,7 +332,9 @@ static void gst_mythtv_src_clear (GstMythtvSrc *mythtv_src) { - + mythtv_src->unique_setup = FALSE; + mythtv_src->try_number = 0; + if (mythtv_src->spawn_livetv) { g_object_unref (mythtv_src->spawn_livetv); mythtv_src->spawn_livetv = NULL; @@ -338,14 +350,6 @@ mythtv_src->backend_info = NULL; } - if (mythtv_src->uri_name) { - g_free (mythtv_src->uri_name); - } - - if (mythtv_src->user_agent) { - g_free (mythtv_src->user_agent); - } - if (mythtv_src->bytes_queue) { g_byte_array_free (mythtv_src->bytes_queue, TRUE); mythtv_src->bytes_queue = NULL; @@ -360,6 +364,16 @@ gst_mythtv_src_clear (this); + if (this->uri_name) { + g_free (this->uri_name); + this->uri_name = NULL; + } + + if (this->user_agent) { + g_free (this->user_agent); + this->user_agent = NULL; + } + G_OBJECT_CLASS (parent_class)->finalize (gobject); } @@ -695,10 +709,9 @@ goto done; } - gmyth_uri = gmyth_uri_new_with_value( src->uri_name ); - + gmyth_uri = gmyth_uri_new_with_value (src->uri_name); src->backend_info = gmyth_backend_info_new_with_uri (src->uri_name); - src->live_tv |= gmyth_uri_is_livetv( gmyth_uri ); + src->live_tv = gmyth_uri_is_livetv( gmyth_uri ); /* testing UPnP... */ /* gmyth_backend_info_set_hostname( src->backend_info, NULL ); */ if ( src->live_tv ) { @@ -799,37 +812,57 @@ src->content_size, 0)); done: - /*if ( gmyth_uri != NULL ) + if (gmyth_uri != NULL) { - g_object_unref( gmyth_uri ); - gmyth_uri = NULL; - }*/ + g_object_unref (gmyth_uri); + gmyth_uri = NULL; + } - if (chain_id_local != NULL) { - g_string_free (chain_id_local, TRUE); - chain_id_local = NULL; - } + if (chain_id_local != NULL) { + g_string_free (chain_id_local, TRUE); + chain_id_local = NULL; + } - return TRUE; + return TRUE; - /* ERRORS */ + /* ERRORS */ init_failed: - { - if (src->spawn_livetv != NULL) - g_object_unref (src->spawn_livetv); + if (gmyth_uri != NULL) + { + g_object_unref (gmyth_uri); + gmyth_uri = NULL; + } + if (src->spawn_livetv != NULL) { + g_object_unref (src->spawn_livetv); + src->spawn_livetv = NULL; + } + + /* GST_ELEMENT_ERROR (src, LIBRARY, INIT, - (NULL), ("Could not initialize MythTV library (%i, %s)", ret, + (NULL), ("Could not initialize MythTV library (%i, %s)", ret, src->uri_name)); + */ + + if (++src->try_number <= src->max_try) { + gst_mythtv_src_clear (src); + GST_DEBUG_OBJECT (src, "Starting new try for get free recorder on MythTV"); + g_usleep (0.5 * G_USEC_PER_SEC); + return gst_mythtv_src_start (bsrc); + } + return FALSE; - } begin_req_failed: - { + if (gmyth_uri != NULL) + { + g_object_unref (gmyth_uri); + gmyth_uri = NULL; + } + GST_ELEMENT_ERROR (src, LIBRARY, INIT, (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret, src->uri_name)); return FALSE; - } } @@ -1081,6 +1114,11 @@ mythtvsrc->channel_name = g_value_dup_string (value); break; } + case PROP_GMYTHTV_MAX_TRY: + { + mythtvsrc->max_try = g_value_get_int (value); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1133,6 +1171,12 @@ g_value_set_string (value, mythtvsrc->channel_name); break; } + case PROP_GMYTHTV_MAX_TRY: + { + g_value_set_int (value, mythtvsrc->max_try); + break; + } + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff -r 2dfea125c76c -r f7351f2fd6d8 gst-plugins-mythtv/src/gstmythtvsrc.h --- a/gst-plugins-mythtv/src/gstmythtvsrc.h Thu Apr 19 16:30:17 2007 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.h Thu Apr 19 18:13:51 2007 +0100 @@ -113,8 +113,12 @@ gboolean update_prog_chain; - /* stablish a maximum iteration value to the IS_RECORDING message */ - guint wait_to_transfer; + /* stablish a maximum iteration value to the IS_RECORDING message */ + guint wait_to_transfer; + + /* max try number to get freerecorder */ + gint max_try; + gint try_number; };