diff -r b57cdd5fb898 -r 7f290a3a34b1 gst-gmyth/mythsrc/gstmythtvsrc.c --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Fri Jun 22 20:03:35 2007 +0100 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Tue Aug 21 16:04:44 2007 +0100 @@ -81,26 +81,15 @@ #include GST_DEBUG_CATEGORY_STATIC(mythtvsrc_debug); -#define GST_CAT_DEFAULT mythtvsrc_debug - #define GST_GMYTHTV_ID_NUM 1 - #define GST_GMYTHTV_CHANNEL_DEFAULT_NUM (-1) - -#define GMYTHTV_VERSION_DEFAULT 30 - +#define GMYTHTV_VERSION_DEFAULT 30 #define GMYTHTV_TRANSFER_MAX_WAITS 100 - #define GMYTHTV_TRANSFER_MAX_RESENDS 2 - #define GMYTHTV_TRANSFER_MAX_BUFFER (128*1024) - #define MAX_READ_SIZE (4*1024) - #define GST_FLOW_ERROR_NO_DATA (-101) - #define REQUEST_MAX_SIZE (64*1024) - #define INTERNAL_BUFFER_SIZE (90*1024) static const GstElementDetails gst_mythtv_src_details = @@ -121,16 +110,12 @@ enum { PROP_0, PROP_LOCATION, -#ifndef GST_DISABLE_GST_DEBUG - PROP_GMYTHTV_DBG, -#endif PROP_GMYTHTV_VERSION, PROP_GMYTHTV_LIVE, PROP_GMYTHTV_LIVEID, PROP_GMYTHTV_LIVE_CHAINID, PROP_GMYTHTV_ENABLE_TIMING_POSITION, - PROP_GMYTHTV_CHANNEL_NUM, - PROP_GMYTHTV_MAX_TRY + PROP_GMYTHTV_CHANNEL_NUM }; static void gst_mythtv_src_clear(GstMythtvSrc * mythtv_src); @@ -265,21 +250,6 @@ "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, - g_param_spec_boolean("mythtv-debug", "mythtv-debug", - "Enable MythTV debug messages", FALSE, - G_PARAM_READWRITE)); -#endif - gstbasesrc_class->start = gst_mythtv_src_start; gstbasesrc_class->stop = gst_mythtv_src_stop; gstbasesrc_class->get_size = gst_mythtv_src_get_size; @@ -296,40 +266,24 @@ gst_mythtv_src_init(GstMythtvSrc * this, GstMythtvSrcClass * g_class) { this->file = NULL; - this->unique_setup = FALSE; - this->mythtv_version = GMYTHTV_VERSION_DEFAULT; - this->state = GST_MYTHTV_SRC_FILE_TRANSFER; - this->bytes_read = 0; - this->prev_content_size = 0; - this->content_size = 0; this->read_offset = 0; - this->content_size_last = 0; - this->live_tv = FALSE; - this->enable_timing_position = FALSE; this->update_prog_chain = FALSE; - this->user_agent = g_strdup("mythtvsrc"); this->update_prog_chain = FALSE; - this->channel_name = NULL; - this->eos = FALSE; - this->bytes_queue = NULL; - this->wait_to_transfer = 0; - gst_base_src_set_format(GST_BASE_SRC(this), GST_FORMAT_BYTES); - gst_pad_set_event_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)), gst_mythtv_src_handle_event); gst_pad_set_query_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)), @@ -889,12 +843,9 @@ */ if (ret == FALSE) { -#ifndef GST_DISABLE_GST_DEBUG - if (src->mythtv_msgs_dbg) - GST_INFO_OBJECT(src, - "MythTV FileTransfer request failed when setting up socket connection!"); -#endif - goto begin_req_failed; + GST_INFO_OBJECT(src, + "MythTV FileTransfer request failed when setting up socket connection!"); + goto begin_req_failed; } GST_INFO_OBJECT(src, @@ -1032,17 +983,17 @@ gboolean ret = TRUE; switch (GST_EVENT_TYPE(event)) { - case GST_EVENT_EOS: + case GST_EVENT_EOS: if (src->live_tv) { - cont_size = gst_mythtv_src_get_position(src); - if (cont_size > src->content_size) { - src->content_size = cont_size; - src->eos = FALSE; - } else { - src->eos = TRUE; - gst_element_set_state(GST_ELEMENT(src), GST_STATE_NULL); - gst_element_set_locked_state(GST_ELEMENT(src), FALSE); - } + cont_size = gst_mythtv_src_get_position(src); + if (cont_size > src->content_size) { + src->content_size = cont_size; + src->eos = FALSE; + } else { + src->eos = TRUE; + gst_element_set_state(GST_ELEMENT(src), GST_STATE_NULL); + gst_element_set_locked_state(GST_ELEMENT(src), FALSE); + } } break; default: @@ -1068,37 +1019,32 @@ switch (GST_QUERY_TYPE(query)) { - case GST_QUERY_POSITION: - { - gst_query_parse_position(query, &formt, NULL); - if (formt == GST_FORMAT_BYTES) { - gst_query_set_position(query, formt, myth->read_offset); - GST_DEBUG_OBJECT(myth, "POS %" G_GINT64_FORMAT, - myth->read_offset); - res = TRUE; - } else if (formt == GST_FORMAT_TIME) { - res = gst_pad_query_default(pad, query); - } - break; + case GST_QUERY_POSITION: + gst_query_parse_position(query, &formt, NULL); + if (formt == GST_FORMAT_BYTES) { + gst_query_set_position(query, formt, myth->read_offset); + GST_DEBUG_OBJECT(myth, "POS %" G_GINT64_FORMAT, + myth->read_offset); + res = TRUE; + } else if (formt == GST_FORMAT_TIME) { + res = gst_pad_query_default(pad, query); } - case GST_QUERY_DURATION: - { - gst_query_parse_duration(query, &formt, NULL); - if (formt == GST_FORMAT_BYTES) { - gint64 size = myth->content_size; - gst_query_set_duration(query, GST_FORMAT_BYTES, 10); - GST_DEBUG_OBJECT(myth, "SIZE %" G_GINT64_FORMAT, size); - res = TRUE; - } else if (formt == GST_FORMAT_TIME) { - res = gst_pad_query_default(pad, query); - } - break; + break; + case GST_QUERY_DURATION: + gst_query_parse_duration(query, &formt, NULL); + if (formt == GST_FORMAT_BYTES) { + gint64 size = myth->content_size; + + gst_query_set_duration(query, GST_FORMAT_BYTES, 10); + GST_DEBUG_OBJECT(myth, "SIZE %" G_GINT64_FORMAT, size); + res = TRUE; + } else if (formt == GST_FORMAT_TIME) { + res = gst_pad_query_default(pad, query); } - default: - { - res = gst_pad_query_default(pad, query); - break; - } + break; + default: + res = gst_pad_query_default(pad, query); + break; } gst_object_unref(myth); @@ -1117,17 +1063,21 @@ case GST_STATE_CHANGE_NULL_TO_READY: break; case GST_STATE_CHANGE_READY_TO_PAUSED: + if (!src->uri_name) { + GST_WARNING_OBJECT (src, "Invalid location"); + return ret; + } + break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: - if (src->live_tv) { - if (!gmyth_recorder_send_frontend_ready_command - (src->spawn_livetv->recorder)) - GST_WARNING_OBJECT(src, - "Couldn't send the FRONTEND_READY message to the backend!"); - else - GST_DEBUG_OBJECT(src, - "FRONTEND_READY was sent to the backend"); - } - break; + if (src->live_tv) { + if (!gmyth_recorder_send_frontend_ready_command + (src->spawn_livetv->recorder)) + GST_WARNING_OBJECT(src, + "Couldn't send the FRONTEND_READY message to the backend!"); + else + GST_DEBUG_OBJECT(src, "FRONTEND_READY was sent to the backend"); + } + break; default: break; } @@ -1160,73 +1110,46 @@ GST_OBJECT_LOCK(mythtvsrc); switch (prop_id) { - case PROP_LOCATION: - { - if (!g_value_get_string(value)) { - GST_WARNING("location property cannot be NULL"); - break; - } + case PROP_LOCATION: + if (!g_value_get_string(value)) { + GST_WARNING("location property cannot be NULL"); + break; + } - if (mythtvsrc->uri_name != NULL) { - g_free(mythtvsrc->uri_name); - mythtvsrc->uri_name = NULL; - } - mythtvsrc->uri_name = g_value_dup_string(value); + if (mythtvsrc->uri_name != NULL) { + g_free(mythtvsrc->uri_name); + mythtvsrc->uri_name = NULL; + } + mythtvsrc->uri_name = g_value_dup_string(value); + break; + case PROP_GMYTHTV_VERSION: + mythtvsrc->mythtv_version = g_value_get_int(value); + break; + case PROP_GMYTHTV_LIVEID: + mythtvsrc->live_tv_id = g_value_get_int(value); + break; + case PROP_GMYTHTV_LIVE: + mythtvsrc->live_tv = g_value_get_boolean(value); + break; + case PROP_GMYTHTV_ENABLE_TIMING_POSITION: + mythtvsrc->enable_timing_position = g_value_get_boolean(value); + break; + case PROP_GMYTHTV_LIVE_CHAINID: + if (!g_value_get_string(value)) { + GST_WARNING_OBJECT(object, "MythTV Live chainid property cannot be NULL"); + break; + } - break; - } -#ifndef GST_DISABLE_GST_DEBUG - case PROP_GMYTHTV_DBG: - { - mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean(value); - break; - } -#endif - case PROP_GMYTHTV_VERSION: - { - mythtvsrc->mythtv_version = g_value_get_int(value); - break; - } - case PROP_GMYTHTV_LIVEID: - { - mythtvsrc->live_tv_id = g_value_get_int(value); - break; - } - case PROP_GMYTHTV_LIVE: - { - mythtvsrc->live_tv = g_value_get_boolean(value); - break; - } - case PROP_GMYTHTV_ENABLE_TIMING_POSITION: - { - mythtvsrc->enable_timing_position = g_value_get_boolean(value); - break; - } - case PROP_GMYTHTV_LIVE_CHAINID: - { - if (!g_value_get_string(value)) { - GST_WARNING("MythTV Live chainid property cannot be NULL"); - break; - } - - if (mythtvsrc->live_chain_id != NULL) { - g_free(mythtvsrc->live_chain_id); - mythtvsrc->live_chain_id = NULL; - } - mythtvsrc->live_chain_id = g_value_dup_string(value); - break; - } - case PROP_GMYTHTV_CHANNEL_NUM: - { - mythtvsrc->channel_name = g_value_dup_string(value); - break; - } - case PROP_GMYTHTV_MAX_TRY: - { - mythtvsrc->max_try = g_value_get_int(value); - break; - } - default: + if (mythtvsrc->live_chain_id != NULL) { + g_free(mythtvsrc->live_chain_id); + mythtvsrc->live_chain_id = NULL; + } + mythtvsrc->live_chain_id = g_value_dup_string(value); + break; + case PROP_GMYTHTV_CHANNEL_NUM: + mythtvsrc->channel_name = g_value_dup_string(value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } @@ -1242,48 +1165,27 @@ GST_OBJECT_LOCK(mythtvsrc); switch (prop_id) { - case PROP_LOCATION: - { - g_value_set_string(value, mythtvsrc->uri_name); - break; - } -#ifndef GST_DISABLE_GST_DEBUG - case PROP_GMYTHTV_DBG: - g_value_set_boolean(value, mythtvsrc->mythtv_msgs_dbg); + case PROP_LOCATION: + g_value_set_string(value, mythtvsrc->uri_name); break; -#endif - case PROP_GMYTHTV_VERSION: - { - g_value_set_int(value, mythtvsrc->mythtv_version); - break; - } - case PROP_GMYTHTV_LIVEID: - { - g_value_set_int(value, mythtvsrc->live_tv_id); - break; - } - case PROP_GMYTHTV_LIVE: + case PROP_GMYTHTV_VERSION: + g_value_set_int(value, mythtvsrc->mythtv_version); + break; + case PROP_GMYTHTV_LIVEID: + g_value_set_int(value, mythtvsrc->live_tv_id); + break; + case PROP_GMYTHTV_LIVE: g_value_set_boolean(value, mythtvsrc->live_tv); break; - case PROP_GMYTHTV_ENABLE_TIMING_POSITION: + case PROP_GMYTHTV_ENABLE_TIMING_POSITION: g_value_set_boolean(value, mythtvsrc->enable_timing_position); break; - case PROP_GMYTHTV_LIVE_CHAINID: - { - g_value_set_string(value, mythtvsrc->live_chain_id); - break; - } - case PROP_GMYTHTV_CHANNEL_NUM: - { - g_value_set_string(value, mythtvsrc->channel_name); - break; - } - case PROP_GMYTHTV_MAX_TRY: - { - g_value_set_int(value, mythtvsrc->max_try); - break; - } - + case PROP_GMYTHTV_LIVE_CHAINID: + g_value_set_string(value, mythtvsrc->live_chain_id); + break; + case PROP_GMYTHTV_CHANNEL_NUM: + g_value_set_string(value, mythtvsrc->channel_name); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break;