1.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Fri Jun 22 20:03:35 2007 +0100
1.2 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Tue Aug 21 16:02:24 2007 +0100
1.3 @@ -81,26 +81,15 @@
1.4 #include <unistd.h>
1.5
1.6 GST_DEBUG_CATEGORY_STATIC(mythtvsrc_debug);
1.7 -#define GST_CAT_DEFAULT mythtvsrc_debug
1.8 -
1.9 #define GST_GMYTHTV_ID_NUM 1
1.10 -
1.11 #define GST_GMYTHTV_CHANNEL_DEFAULT_NUM (-1)
1.12 -
1.13 -#define GMYTHTV_VERSION_DEFAULT 30
1.14 -
1.15 +#define GMYTHTV_VERSION_DEFAULT 30
1.16 #define GMYTHTV_TRANSFER_MAX_WAITS 100
1.17 -
1.18 #define GMYTHTV_TRANSFER_MAX_RESENDS 2
1.19 -
1.20 #define GMYTHTV_TRANSFER_MAX_BUFFER (128*1024)
1.21 -
1.22 #define MAX_READ_SIZE (4*1024)
1.23 -
1.24 #define GST_FLOW_ERROR_NO_DATA (-101)
1.25 -
1.26 #define REQUEST_MAX_SIZE (64*1024)
1.27 -
1.28 #define INTERNAL_BUFFER_SIZE (90*1024)
1.29
1.30 static const GstElementDetails gst_mythtv_src_details =
1.31 @@ -121,16 +110,12 @@
1.32 enum {
1.33 PROP_0,
1.34 PROP_LOCATION,
1.35 -#ifndef GST_DISABLE_GST_DEBUG
1.36 - PROP_GMYTHTV_DBG,
1.37 -#endif
1.38 PROP_GMYTHTV_VERSION,
1.39 PROP_GMYTHTV_LIVE,
1.40 PROP_GMYTHTV_LIVEID,
1.41 PROP_GMYTHTV_LIVE_CHAINID,
1.42 PROP_GMYTHTV_ENABLE_TIMING_POSITION,
1.43 - PROP_GMYTHTV_CHANNEL_NUM,
1.44 - PROP_GMYTHTV_MAX_TRY
1.45 + PROP_GMYTHTV_CHANNEL_NUM
1.46 };
1.47
1.48 static void gst_mythtv_src_clear(GstMythtvSrc * mythtv_src);
1.49 @@ -265,21 +250,6 @@
1.50 "Change MythTV channel number",
1.51 "", G_PARAM_READWRITE));
1.52
1.53 - g_object_class_install_property
1.54 - (gobject_class, PROP_GMYTHTV_MAX_TRY,
1.55 - g_param_spec_int("max-try", "max-try",
1.56 - "Set the max try for get MythTV free recorder",
1.57 - 0, G_MAXINT, 10, G_PARAM_READWRITE));
1.58 -
1.59 -
1.60 -#ifndef GST_DISABLE_GST_DEBUG
1.61 - g_object_class_install_property
1.62 - (gobject_class, PROP_GMYTHTV_DBG,
1.63 - g_param_spec_boolean("mythtv-debug", "mythtv-debug",
1.64 - "Enable MythTV debug messages", FALSE,
1.65 - G_PARAM_READWRITE));
1.66 -#endif
1.67 -
1.68 gstbasesrc_class->start = gst_mythtv_src_start;
1.69 gstbasesrc_class->stop = gst_mythtv_src_stop;
1.70 gstbasesrc_class->get_size = gst_mythtv_src_get_size;
1.71 @@ -296,40 +266,24 @@
1.72 gst_mythtv_src_init(GstMythtvSrc * this, GstMythtvSrcClass * g_class)
1.73 {
1.74 this->file = NULL;
1.75 -
1.76 this->unique_setup = FALSE;
1.77 -
1.78 this->mythtv_version = GMYTHTV_VERSION_DEFAULT;
1.79 -
1.80 this->state = GST_MYTHTV_SRC_FILE_TRANSFER;
1.81 -
1.82 this->bytes_read = 0;
1.83 -
1.84 this->prev_content_size = 0;
1.85 -
1.86 this->content_size = 0;
1.87 this->read_offset = 0;
1.88 -
1.89 this->content_size_last = 0;
1.90 -
1.91 this->live_tv = FALSE;
1.92 -
1.93 this->enable_timing_position = FALSE;
1.94 this->update_prog_chain = FALSE;
1.95 -
1.96 this->user_agent = g_strdup("mythtvsrc");
1.97 this->update_prog_chain = FALSE;
1.98 -
1.99 this->channel_name = NULL;
1.100 -
1.101 this->eos = FALSE;
1.102 -
1.103 this->bytes_queue = NULL;
1.104 -
1.105 this->wait_to_transfer = 0;
1.106 -
1.107 gst_base_src_set_format(GST_BASE_SRC(this), GST_FORMAT_BYTES);
1.108 -
1.109 gst_pad_set_event_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
1.110 gst_mythtv_src_handle_event);
1.111 gst_pad_set_query_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
1.112 @@ -889,12 +843,9 @@
1.113 */
1.114
1.115 if (ret == FALSE) {
1.116 -#ifndef GST_DISABLE_GST_DEBUG
1.117 - if (src->mythtv_msgs_dbg)
1.118 - GST_INFO_OBJECT(src,
1.119 - "MythTV FileTransfer request failed when setting up socket connection!");
1.120 -#endif
1.121 - goto begin_req_failed;
1.122 + GST_INFO_OBJECT(src,
1.123 + "MythTV FileTransfer request failed when setting up socket connection!");
1.124 + goto begin_req_failed;
1.125 }
1.126
1.127 GST_INFO_OBJECT(src,
1.128 @@ -1032,17 +983,17 @@
1.129 gboolean ret = TRUE;
1.130
1.131 switch (GST_EVENT_TYPE(event)) {
1.132 - case GST_EVENT_EOS:
1.133 + case GST_EVENT_EOS:
1.134 if (src->live_tv) {
1.135 - cont_size = gst_mythtv_src_get_position(src);
1.136 - if (cont_size > src->content_size) {
1.137 - src->content_size = cont_size;
1.138 - src->eos = FALSE;
1.139 - } else {
1.140 - src->eos = TRUE;
1.141 - gst_element_set_state(GST_ELEMENT(src), GST_STATE_NULL);
1.142 - gst_element_set_locked_state(GST_ELEMENT(src), FALSE);
1.143 - }
1.144 + cont_size = gst_mythtv_src_get_position(src);
1.145 + if (cont_size > src->content_size) {
1.146 + src->content_size = cont_size;
1.147 + src->eos = FALSE;
1.148 + } else {
1.149 + src->eos = TRUE;
1.150 + gst_element_set_state(GST_ELEMENT(src), GST_STATE_NULL);
1.151 + gst_element_set_locked_state(GST_ELEMENT(src), FALSE);
1.152 + }
1.153 }
1.154 break;
1.155 default:
1.156 @@ -1068,37 +1019,32 @@
1.157
1.158
1.159 switch (GST_QUERY_TYPE(query)) {
1.160 - case GST_QUERY_POSITION:
1.161 - {
1.162 - gst_query_parse_position(query, &formt, NULL);
1.163 - if (formt == GST_FORMAT_BYTES) {
1.164 - gst_query_set_position(query, formt, myth->read_offset);
1.165 - GST_DEBUG_OBJECT(myth, "POS %" G_GINT64_FORMAT,
1.166 - myth->read_offset);
1.167 - res = TRUE;
1.168 - } else if (formt == GST_FORMAT_TIME) {
1.169 - res = gst_pad_query_default(pad, query);
1.170 - }
1.171 - break;
1.172 + case GST_QUERY_POSITION:
1.173 + gst_query_parse_position(query, &formt, NULL);
1.174 + if (formt == GST_FORMAT_BYTES) {
1.175 + gst_query_set_position(query, formt, myth->read_offset);
1.176 + GST_DEBUG_OBJECT(myth, "POS %" G_GINT64_FORMAT,
1.177 + myth->read_offset);
1.178 + res = TRUE;
1.179 + } else if (formt == GST_FORMAT_TIME) {
1.180 + res = gst_pad_query_default(pad, query);
1.181 }
1.182 - case GST_QUERY_DURATION:
1.183 - {
1.184 - gst_query_parse_duration(query, &formt, NULL);
1.185 - if (formt == GST_FORMAT_BYTES) {
1.186 - gint64 size = myth->content_size;
1.187 - gst_query_set_duration(query, GST_FORMAT_BYTES, 10);
1.188 - GST_DEBUG_OBJECT(myth, "SIZE %" G_GINT64_FORMAT, size);
1.189 - res = TRUE;
1.190 - } else if (formt == GST_FORMAT_TIME) {
1.191 - res = gst_pad_query_default(pad, query);
1.192 - }
1.193 - break;
1.194 + break;
1.195 + case GST_QUERY_DURATION:
1.196 + gst_query_parse_duration(query, &formt, NULL);
1.197 + if (formt == GST_FORMAT_BYTES) {
1.198 + gint64 size = myth->content_size;
1.199 +
1.200 + gst_query_set_duration(query, GST_FORMAT_BYTES, 10);
1.201 + GST_DEBUG_OBJECT(myth, "SIZE %" G_GINT64_FORMAT, size);
1.202 + res = TRUE;
1.203 + } else if (formt == GST_FORMAT_TIME) {
1.204 + res = gst_pad_query_default(pad, query);
1.205 }
1.206 - default:
1.207 - {
1.208 - res = gst_pad_query_default(pad, query);
1.209 - break;
1.210 - }
1.211 + break;
1.212 + default:
1.213 + res = gst_pad_query_default(pad, query);
1.214 + break;
1.215 }
1.216
1.217 gst_object_unref(myth);
1.218 @@ -1117,17 +1063,21 @@
1.219 case GST_STATE_CHANGE_NULL_TO_READY:
1.220 break;
1.221 case GST_STATE_CHANGE_READY_TO_PAUSED:
1.222 + if (!src->uri_name) {
1.223 + GST_WARNING_OBJECT (src, "Invalid location");
1.224 + return ret;
1.225 + }
1.226 + break;
1.227 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
1.228 - if (src->live_tv) {
1.229 - if (!gmyth_recorder_send_frontend_ready_command
1.230 - (src->spawn_livetv->recorder))
1.231 - GST_WARNING_OBJECT(src,
1.232 - "Couldn't send the FRONTEND_READY message to the backend!");
1.233 - else
1.234 - GST_DEBUG_OBJECT(src,
1.235 - "FRONTEND_READY was sent to the backend");
1.236 - }
1.237 - break;
1.238 + if (src->live_tv) {
1.239 + if (!gmyth_recorder_send_frontend_ready_command
1.240 + (src->spawn_livetv->recorder))
1.241 + GST_WARNING_OBJECT(src,
1.242 + "Couldn't send the FRONTEND_READY message to the backend!");
1.243 + else
1.244 + GST_DEBUG_OBJECT(src, "FRONTEND_READY was sent to the backend");
1.245 + }
1.246 + break;
1.247 default:
1.248 break;
1.249 }
1.250 @@ -1160,73 +1110,46 @@
1.251
1.252 GST_OBJECT_LOCK(mythtvsrc);
1.253 switch (prop_id) {
1.254 - case PROP_LOCATION:
1.255 - {
1.256 - if (!g_value_get_string(value)) {
1.257 - GST_WARNING("location property cannot be NULL");
1.258 - break;
1.259 - }
1.260 + case PROP_LOCATION:
1.261 + if (!g_value_get_string(value)) {
1.262 + GST_WARNING("location property cannot be NULL");
1.263 + break;
1.264 + }
1.265
1.266 - if (mythtvsrc->uri_name != NULL) {
1.267 - g_free(mythtvsrc->uri_name);
1.268 - mythtvsrc->uri_name = NULL;
1.269 - }
1.270 - mythtvsrc->uri_name = g_value_dup_string(value);
1.271 + if (mythtvsrc->uri_name != NULL) {
1.272 + g_free(mythtvsrc->uri_name);
1.273 + mythtvsrc->uri_name = NULL;
1.274 + }
1.275 + mythtvsrc->uri_name = g_value_dup_string(value);
1.276 + break;
1.277 + case PROP_GMYTHTV_VERSION:
1.278 + mythtvsrc->mythtv_version = g_value_get_int(value);
1.279 + break;
1.280 + case PROP_GMYTHTV_LIVEID:
1.281 + mythtvsrc->live_tv_id = g_value_get_int(value);
1.282 + break;
1.283 + case PROP_GMYTHTV_LIVE:
1.284 + mythtvsrc->live_tv = g_value_get_boolean(value);
1.285 + break;
1.286 + case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.287 + mythtvsrc->enable_timing_position = g_value_get_boolean(value);
1.288 + break;
1.289 + case PROP_GMYTHTV_LIVE_CHAINID:
1.290 + if (!g_value_get_string(value)) {
1.291 + GST_WARNING_OBJECT(object, "MythTV Live chainid property cannot be NULL");
1.292 + break;
1.293 + }
1.294
1.295 - break;
1.296 - }
1.297 -#ifndef GST_DISABLE_GST_DEBUG
1.298 - case PROP_GMYTHTV_DBG:
1.299 - {
1.300 - mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean(value);
1.301 - break;
1.302 - }
1.303 -#endif
1.304 - case PROP_GMYTHTV_VERSION:
1.305 - {
1.306 - mythtvsrc->mythtv_version = g_value_get_int(value);
1.307 - break;
1.308 - }
1.309 - case PROP_GMYTHTV_LIVEID:
1.310 - {
1.311 - mythtvsrc->live_tv_id = g_value_get_int(value);
1.312 - break;
1.313 - }
1.314 - case PROP_GMYTHTV_LIVE:
1.315 - {
1.316 - mythtvsrc->live_tv = g_value_get_boolean(value);
1.317 - break;
1.318 - }
1.319 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.320 - {
1.321 - mythtvsrc->enable_timing_position = g_value_get_boolean(value);
1.322 - break;
1.323 - }
1.324 - case PROP_GMYTHTV_LIVE_CHAINID:
1.325 - {
1.326 - if (!g_value_get_string(value)) {
1.327 - GST_WARNING("MythTV Live chainid property cannot be NULL");
1.328 - break;
1.329 - }
1.330 -
1.331 - if (mythtvsrc->live_chain_id != NULL) {
1.332 - g_free(mythtvsrc->live_chain_id);
1.333 - mythtvsrc->live_chain_id = NULL;
1.334 - }
1.335 - mythtvsrc->live_chain_id = g_value_dup_string(value);
1.336 - break;
1.337 - }
1.338 - case PROP_GMYTHTV_CHANNEL_NUM:
1.339 - {
1.340 - mythtvsrc->channel_name = g_value_dup_string(value);
1.341 - break;
1.342 - }
1.343 - case PROP_GMYTHTV_MAX_TRY:
1.344 - {
1.345 - mythtvsrc->max_try = g_value_get_int(value);
1.346 - break;
1.347 - }
1.348 - default:
1.349 + if (mythtvsrc->live_chain_id != NULL) {
1.350 + g_free(mythtvsrc->live_chain_id);
1.351 + mythtvsrc->live_chain_id = NULL;
1.352 + }
1.353 + mythtvsrc->live_chain_id = g_value_dup_string(value);
1.354 + break;
1.355 + case PROP_GMYTHTV_CHANNEL_NUM:
1.356 + mythtvsrc->channel_name = g_value_dup_string(value);
1.357 + break;
1.358 + default:
1.359 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1.360 break;
1.361 }
1.362 @@ -1242,48 +1165,27 @@
1.363
1.364 GST_OBJECT_LOCK(mythtvsrc);
1.365 switch (prop_id) {
1.366 - case PROP_LOCATION:
1.367 - {
1.368 - g_value_set_string(value, mythtvsrc->uri_name);
1.369 - break;
1.370 - }
1.371 -#ifndef GST_DISABLE_GST_DEBUG
1.372 - case PROP_GMYTHTV_DBG:
1.373 - g_value_set_boolean(value, mythtvsrc->mythtv_msgs_dbg);
1.374 + case PROP_LOCATION:
1.375 + g_value_set_string(value, mythtvsrc->uri_name);
1.376 break;
1.377 -#endif
1.378 - case PROP_GMYTHTV_VERSION:
1.379 - {
1.380 - g_value_set_int(value, mythtvsrc->mythtv_version);
1.381 - break;
1.382 - }
1.383 - case PROP_GMYTHTV_LIVEID:
1.384 - {
1.385 - g_value_set_int(value, mythtvsrc->live_tv_id);
1.386 - break;
1.387 - }
1.388 - case PROP_GMYTHTV_LIVE:
1.389 + case PROP_GMYTHTV_VERSION:
1.390 + g_value_set_int(value, mythtvsrc->mythtv_version);
1.391 + break;
1.392 + case PROP_GMYTHTV_LIVEID:
1.393 + g_value_set_int(value, mythtvsrc->live_tv_id);
1.394 + break;
1.395 + case PROP_GMYTHTV_LIVE:
1.396 g_value_set_boolean(value, mythtvsrc->live_tv);
1.397 break;
1.398 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.399 + case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.400 g_value_set_boolean(value, mythtvsrc->enable_timing_position);
1.401 break;
1.402 - case PROP_GMYTHTV_LIVE_CHAINID:
1.403 - {
1.404 - g_value_set_string(value, mythtvsrc->live_chain_id);
1.405 - break;
1.406 - }
1.407 - case PROP_GMYTHTV_CHANNEL_NUM:
1.408 - {
1.409 - g_value_set_string(value, mythtvsrc->channel_name);
1.410 - break;
1.411 - }
1.412 - case PROP_GMYTHTV_MAX_TRY:
1.413 - {
1.414 - g_value_set_int(value, mythtvsrc->max_try);
1.415 - break;
1.416 - }
1.417 -
1.418 + case PROP_GMYTHTV_LIVE_CHAINID:
1.419 + g_value_set_string(value, mythtvsrc->live_chain_id);
1.420 + break;
1.421 + case PROP_GMYTHTV_CHANNEL_NUM:
1.422 + g_value_set_string(value, mythtvsrc->channel_name);
1.423 + break;
1.424 default:
1.425 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1.426 break;