1.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Thu Jun 14 18:21:08 2007 +0100
1.2 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Fri Jun 22 16:14:21 2007 +0100
1.3 @@ -1,20 +1,16 @@
1.4 -/* GStreamer MythTV Plug-in
1.5 - * Copyright (C) <2006> Rosfran Borges <rosfran.borges@indt.org.br>
1.6 - *
1.7 - * This library is free software; you can redistribute it and/or
1.8 - * modify it under the terms of the GNU Library General Public
1.9 - * License as published by the Free Software Foundation; either
1.10 - * version 2 of the License, or (at your option) any later version.
1.11 - *
1.12 - * This library is distributed in the hope that it will be useful,
1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.15 - * Library General Public License for more details.
1.16 - *
1.17 - * You should have received a copy of the GNU Library General Public
1.18 - * License along with this library; if not, write to the
1.19 - * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1.20 - * Boston, MA 02111-1307, USA.
1.21 +/*
1.22 + * GStreamer MythTV Plug-in Copyright (C) <2006> Rosfran Borges
1.23 + * <rosfran.borges@indt.org.br> This library is free software; you can
1.24 + * redistribute it and/or modify it under the terms of the GNU Library
1.25 + * General Public License as published by the Free Software Foundation;
1.26 + * either version 2 of the License, or (at your option) any later version.
1.27 + * This library is distributed in the hope that it will be useful, but
1.28 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1.29 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
1.30 + * General Public License for more details. You should have received a copy
1.31 + * of the GNU Library General Public License along with this library; if
1.32 + * not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite
1.33 + * 330, Boston, MA 02111-1307, USA.
1.34 */
1.35 /**
1.36 * SECTION:element-mythtvsrc
1.37 @@ -109,39 +105,40 @@
1.38
1.39 static const GstElementDetails gst_mythtv_src_details =
1.40 GST_ELEMENT_DETAILS("MythTV client source",
1.41 - "Source/Network",
1.42 - "Control and receive data as a client over the network "
1.43 - "via raw socket connections using the MythTV protocol",
1.44 - "Rosfran Borges <rosfran.borges@indt.org.br>");
1.45 + "Source/Network",
1.46 + "Control and receive data as a client over the network "
1.47 + "via raw socket connections using the MythTV protocol",
1.48 + "Rosfran Borges <rosfran.borges@indt.org.br>");
1.49
1.50 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE("src",
1.51 - GST_PAD_SRC,
1.52 - GST_PAD_ALWAYS,
1.53 - GST_STATIC_CAPS_ANY);
1.54 - /* GST_STATIC_CAPS ("video/x-nuv")); */
1.55 + GST_PAD_SRC,
1.56 + GST_PAD_ALWAYS,
1.57 + GST_STATIC_CAPS_ANY);
1.58 + /*
1.59 + * GST_STATIC_CAPS ("video/x-nuv"));
1.60 + */
1.61
1.62 -enum
1.63 -{
1.64 - PROP_0,
1.65 - PROP_LOCATION,
1.66 +enum {
1.67 + PROP_0,
1.68 + PROP_LOCATION,
1.69 #ifndef GST_DISABLE_GST_DEBUG
1.70 - PROP_GMYTHTV_DBG,
1.71 + PROP_GMYTHTV_DBG,
1.72 #endif
1.73 - PROP_GMYTHTV_VERSION,
1.74 - PROP_GMYTHTV_LIVE,
1.75 - PROP_GMYTHTV_LIVEID,
1.76 - PROP_GMYTHTV_LIVE_CHAINID,
1.77 - PROP_GMYTHTV_ENABLE_TIMING_POSITION,
1.78 - PROP_GMYTHTV_CHANNEL_NUM,
1.79 - PROP_GMYTHTV_MAX_TRY
1.80 + PROP_GMYTHTV_VERSION,
1.81 + PROP_GMYTHTV_LIVE,
1.82 + PROP_GMYTHTV_LIVEID,
1.83 + PROP_GMYTHTV_LIVE_CHAINID,
1.84 + PROP_GMYTHTV_ENABLE_TIMING_POSITION,
1.85 + PROP_GMYTHTV_CHANNEL_NUM,
1.86 + PROP_GMYTHTV_MAX_TRY
1.87 };
1.88
1.89 -static void gst_mythtv_src_clear(GstMythtvSrc * mythtv_src);
1.90 +static void gst_mythtv_src_clear(GstMythtvSrc * mythtv_src);
1.91
1.92 -static void gst_mythtv_src_finalize(GObject * gobject);
1.93 +static void gst_mythtv_src_finalize(GObject * gobject);
1.94
1.95 static GstFlowReturn gst_mythtv_src_create(GstPushSrc * psrc,
1.96 - GstBuffer ** outbuf);
1.97 + GstBuffer ** outbuf);
1.98
1.99 static gboolean gst_mythtv_src_start(GstBaseSrc * bsrc);
1.100 static gboolean gst_mythtv_src_stop(GstBaseSrc * bsrc);
1.101 @@ -149,513 +146,527 @@
1.102 static gboolean gst_mythtv_src_is_seekable(GstBaseSrc * push_src);
1.103
1.104 static gboolean gst_mythtv_src_do_seek(GstBaseSrc * base,
1.105 - GstSegment * segment);
1.106 + GstSegment * segment);
1.107
1.108 -static GstStateChangeReturn
1.109 -gst_mythtv_src_change_state(GstElement * element, GstStateChange transition);
1.110 +static GstStateChangeReturn
1.111 +gst_mythtv_src_change_state(GstElement * element,
1.112 + GstStateChange transition);
1.113
1.114 -static void gst_mythtv_src_set_property(GObject * object, guint prop_id,
1.115 - const GValue * value,
1.116 - GParamSpec * pspec);
1.117 -static void gst_mythtv_src_get_property(GObject * object, guint prop_id,
1.118 - GValue * value, GParamSpec * pspec);
1.119 +static void gst_mythtv_src_set_property(GObject * object,
1.120 + guint prop_id,
1.121 + const GValue * value,
1.122 + GParamSpec * pspec);
1.123 +static void gst_mythtv_src_get_property(GObject * object,
1.124 + guint prop_id, GValue * value,
1.125 + GParamSpec * pspec);
1.126
1.127 -static void gst_mythtv_src_uri_handler_init(gpointer g_iface,
1.128 - gpointer iface_data);
1.129 +static void gst_mythtv_src_uri_handler_init(gpointer g_iface,
1.130 + gpointer iface_data);
1.131
1.132 -static gboolean gst_mythtv_src_handle_query(GstPad * pad, GstQuery * query);
1.133 +static gboolean gst_mythtv_src_handle_query(GstPad * pad,
1.134 + GstQuery * query);
1.135
1.136 -static gboolean gst_mythtv_src_handle_event(GstPad * pad, GstEvent * event);
1.137 +static gboolean gst_mythtv_src_handle_event(GstPad * pad,
1.138 + GstEvent * event);
1.139
1.140 static GMythFileReadResult do_read_request_response(GstMythtvSrc * src,
1.141 - guint size,
1.142 - GByteArray * data_ptr);
1.143 + guint size,
1.144 + GByteArray * data_ptr);
1.145
1.146 static void
1.147 _urihandler_init(GType type)
1.148 {
1.149 - static const GInterfaceInfo urihandler_info = {
1.150 - gst_mythtv_src_uri_handler_init,
1.151 - NULL,
1.152 - NULL
1.153 - };
1.154 + static const GInterfaceInfo urihandler_info = {
1.155 + gst_mythtv_src_uri_handler_init,
1.156 + NULL,
1.157 + NULL
1.158 + };
1.159
1.160 - g_type_add_interface_static(type, GST_TYPE_URI_HANDLER, &urihandler_info);
1.161 + g_type_add_interface_static(type, GST_TYPE_URI_HANDLER,
1.162 + &urihandler_info);
1.163
1.164 - GST_DEBUG_CATEGORY_INIT(mythtvsrc_debug, "mythtvsrc", 0, "MythTV src");
1.165 + GST_DEBUG_CATEGORY_INIT(mythtvsrc_debug, "mythtvsrc", 0, "MythTV src");
1.166 }
1.167
1.168 GST_BOILERPLATE_FULL(GstMythtvSrc, gst_mythtv_src, GstPushSrc,
1.169 - GST_TYPE_PUSH_SRC, _urihandler_init)
1.170 - static void gst_mythtv_src_base_init(gpointer g_class)
1.171 + GST_TYPE_PUSH_SRC, _urihandler_init)
1.172 + static void gst_mythtv_src_base_init(gpointer g_class)
1.173 {
1.174 - GstElementClass *element_class = GST_ELEMENT_CLASS(g_class);
1.175 + GstElementClass *element_class = GST_ELEMENT_CLASS(g_class);
1.176
1.177 - gst_element_class_add_pad_template(element_class,
1.178 - gst_static_pad_template_get
1.179 - (&srctemplate));
1.180 + gst_element_class_add_pad_template(element_class,
1.181 + gst_static_pad_template_get
1.182 + (&srctemplate));
1.183
1.184 - gst_element_class_set_details(element_class, &gst_mythtv_src_details);
1.185 + gst_element_class_set_details(element_class, &gst_mythtv_src_details);
1.186
1.187 - element_class->change_state = gst_mythtv_src_change_state;
1.188 + element_class->change_state = gst_mythtv_src_change_state;
1.189
1.190 }
1.191
1.192 static void
1.193 gst_mythtv_src_class_init(GstMythtvSrcClass * klass)
1.194 {
1.195 - GObjectClass *gobject_class;
1.196 - GstPushSrcClass *gstpushsrc_class;
1.197 - GstBaseSrcClass *gstbasesrc_class;
1.198 + GObjectClass *gobject_class;
1.199 + GstPushSrcClass *gstpushsrc_class;
1.200 + GstBaseSrcClass *gstbasesrc_class;
1.201
1.202 - gobject_class = (GObjectClass *) klass;
1.203 - gstbasesrc_class = (GstBaseSrcClass *) klass;
1.204 - gstpushsrc_class = (GstPushSrcClass *) klass;
1.205 + gobject_class = (GObjectClass *) klass;
1.206 + gstbasesrc_class = (GstBaseSrcClass *) klass;
1.207 + gstpushsrc_class = (GstPushSrcClass *) klass;
1.208
1.209 - gobject_class->set_property = gst_mythtv_src_set_property;
1.210 - gobject_class->get_property = gst_mythtv_src_get_property;
1.211 - gobject_class->finalize = gst_mythtv_src_finalize;
1.212 + gobject_class->set_property = gst_mythtv_src_set_property;
1.213 + gobject_class->get_property = gst_mythtv_src_get_property;
1.214 + gobject_class->finalize = gst_mythtv_src_finalize;
1.215
1.216 - g_object_class_install_property
1.217 - (gobject_class, PROP_LOCATION,
1.218 - g_param_spec_string("location", "Location",
1.219 - "The location. In the form:"
1.220 - "\n\t\t\tmyth://a.com/file.nuv"
1.221 - "\n\t\t\tmyth://a.com:23223/file.nuv "
1.222 - "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
1.223 - "", G_PARAM_READWRITE));
1.224 + g_object_class_install_property
1.225 + (gobject_class, PROP_LOCATION,
1.226 + g_param_spec_string("location", "Location",
1.227 + "The location. In the form:"
1.228 + "\n\t\t\tmyth://a.com/file.nuv"
1.229 + "\n\t\t\tmyth://a.com:23223/file.nuv "
1.230 + "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
1.231 + "", G_PARAM_READWRITE));
1.232
1.233 - g_object_class_install_property
1.234 - (gobject_class, PROP_GMYTHTV_VERSION,
1.235 - g_param_spec_int("mythtv-version", "mythtv-version",
1.236 - "Change MythTV version", 26, 30, 26,
1.237 - G_PARAM_READWRITE));
1.238 + g_object_class_install_property
1.239 + (gobject_class, PROP_GMYTHTV_VERSION,
1.240 + g_param_spec_int("mythtv-version", "mythtv-version",
1.241 + "Change MythTV version", 26, 30, 26,
1.242 + G_PARAM_READWRITE));
1.243
1.244 - g_object_class_install_property
1.245 - (gobject_class, PROP_GMYTHTV_LIVEID,
1.246 - g_param_spec_int("mythtv-live-id", "mythtv-live-id",
1.247 - "Change MythTV version",
1.248 - 0, 200, GST_GMYTHTV_ID_NUM, G_PARAM_READWRITE));
1.249 + g_object_class_install_property
1.250 + (gobject_class, PROP_GMYTHTV_LIVEID,
1.251 + g_param_spec_int("mythtv-live-id", "mythtv-live-id",
1.252 + "Change MythTV version",
1.253 + 0, 200, GST_GMYTHTV_ID_NUM, G_PARAM_READWRITE));
1.254
1.255 - g_object_class_install_property
1.256 - (gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
1.257 - g_param_spec_string("mythtv-live-chainid", "mythtv-live-chainid",
1.258 - "Sets the MythTV chain ID (from TV Chain)", "",
1.259 - G_PARAM_READWRITE));
1.260 + g_object_class_install_property
1.261 + (gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
1.262 + g_param_spec_string("mythtv-live-chainid", "mythtv-live-chainid",
1.263 + "Sets the MythTV chain ID (from TV Chain)",
1.264 + "", G_PARAM_READWRITE));
1.265
1.266 - g_object_class_install_property
1.267 - (gobject_class, PROP_GMYTHTV_LIVE,
1.268 - g_param_spec_boolean("mythtv-live", "mythtv-live",
1.269 - "Enable MythTV Live TV content streaming", FALSE,
1.270 - G_PARAM_READWRITE));
1.271 + g_object_class_install_property
1.272 + (gobject_class, PROP_GMYTHTV_LIVE,
1.273 + g_param_spec_boolean("mythtv-live", "mythtv-live",
1.274 + "Enable MythTV Live TV content streaming",
1.275 + FALSE, G_PARAM_READWRITE));
1.276
1.277 - g_object_class_install_property
1.278 - (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
1.279 - g_param_spec_boolean("mythtv-enable-timing-position",
1.280 - "mythtv-enable-timing-position",
1.281 - "Enable MythTV Live TV content size continuous updating",
1.282 - FALSE, G_PARAM_READWRITE));
1.283 + g_object_class_install_property
1.284 + (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
1.285 + g_param_spec_boolean("mythtv-enable-timing-position",
1.286 + "mythtv-enable-timing-position",
1.287 + "Enable MythTV Live TV content size continuous updating",
1.288 + FALSE, G_PARAM_READWRITE));
1.289
1.290 - g_object_class_install_property
1.291 - (gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
1.292 - g_param_spec_string("mythtv-channel", "mythtv-channel",
1.293 - "Change MythTV channel number",
1.294 - "", G_PARAM_READWRITE));
1.295 + g_object_class_install_property
1.296 + (gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
1.297 + g_param_spec_string("mythtv-channel", "mythtv-channel",
1.298 + "Change MythTV channel number",
1.299 + "", G_PARAM_READWRITE));
1.300
1.301 - g_object_class_install_property
1.302 - (gobject_class, PROP_GMYTHTV_MAX_TRY,
1.303 - g_param_spec_int("max-try", "max-try",
1.304 - "Set the max try for get MythTV free recorder",
1.305 - 0, G_MAXINT, 10, G_PARAM_READWRITE));
1.306 + g_object_class_install_property
1.307 + (gobject_class, PROP_GMYTHTV_MAX_TRY,
1.308 + g_param_spec_int("max-try", "max-try",
1.309 + "Set the max try for get MythTV free recorder",
1.310 + 0, G_MAXINT, 10, G_PARAM_READWRITE));
1.311
1.312
1.313 #ifndef GST_DISABLE_GST_DEBUG
1.314 - g_object_class_install_property
1.315 - (gobject_class, PROP_GMYTHTV_DBG,
1.316 - g_param_spec_boolean("mythtv-debug", "mythtv-debug",
1.317 - "Enable MythTV debug messages", FALSE,
1.318 - G_PARAM_READWRITE));
1.319 + g_object_class_install_property
1.320 + (gobject_class, PROP_GMYTHTV_DBG,
1.321 + g_param_spec_boolean("mythtv-debug", "mythtv-debug",
1.322 + "Enable MythTV debug messages", FALSE,
1.323 + G_PARAM_READWRITE));
1.324 #endif
1.325
1.326 - gstbasesrc_class->start = gst_mythtv_src_start;
1.327 - gstbasesrc_class->stop = gst_mythtv_src_stop;
1.328 - gstbasesrc_class->get_size = gst_mythtv_src_get_size;
1.329 - gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable;
1.330 + gstbasesrc_class->start = gst_mythtv_src_start;
1.331 + gstbasesrc_class->stop = gst_mythtv_src_stop;
1.332 + gstbasesrc_class->get_size = gst_mythtv_src_get_size;
1.333 + gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable;
1.334
1.335 - gstbasesrc_class->do_seek = gst_mythtv_src_do_seek;
1.336 - gstpushsrc_class->create = gst_mythtv_src_create;
1.337 + gstbasesrc_class->do_seek = gst_mythtv_src_do_seek;
1.338 + gstpushsrc_class->create = gst_mythtv_src_create;
1.339
1.340 - GST_DEBUG_CATEGORY_INIT(mythtvsrc_debug, "mythtvsrc", 0,
1.341 - "MythTV Client Source");
1.342 + GST_DEBUG_CATEGORY_INIT(mythtvsrc_debug, "mythtvsrc", 0,
1.343 + "MythTV Client Source");
1.344 }
1.345
1.346 static void
1.347 gst_mythtv_src_init(GstMythtvSrc * this, GstMythtvSrcClass * g_class)
1.348 {
1.349 - this->file = NULL;
1.350 + this->file = NULL;
1.351
1.352 - this->unique_setup = FALSE;
1.353 + this->unique_setup = FALSE;
1.354
1.355 - this->mythtv_version = GMYTHTV_VERSION_DEFAULT;
1.356 + this->mythtv_version = GMYTHTV_VERSION_DEFAULT;
1.357
1.358 - this->state = GST_MYTHTV_SRC_FILE_TRANSFER;
1.359 + this->state = GST_MYTHTV_SRC_FILE_TRANSFER;
1.360
1.361 - this->bytes_read = 0;
1.362 + this->bytes_read = 0;
1.363
1.364 - this->prev_content_size = 0;
1.365 + this->prev_content_size = 0;
1.366
1.367 - this->content_size = 0;
1.368 - this->read_offset = 0;
1.369 + this->content_size = 0;
1.370 + this->read_offset = 0;
1.371
1.372 - this->content_size_last = 0;
1.373 + this->content_size_last = 0;
1.374
1.375 - this->live_tv = FALSE;
1.376 + this->live_tv = FALSE;
1.377
1.378 - this->enable_timing_position = FALSE;
1.379 - this->update_prog_chain = FALSE;
1.380 + this->enable_timing_position = FALSE;
1.381 + this->update_prog_chain = FALSE;
1.382
1.383 - this->user_agent = g_strdup("mythtvsrc");
1.384 - this->update_prog_chain = FALSE;
1.385 + this->user_agent = g_strdup("mythtvsrc");
1.386 + this->update_prog_chain = FALSE;
1.387
1.388 - this->channel_name = NULL;
1.389 + this->channel_name = NULL;
1.390
1.391 - this->eos = FALSE;
1.392 + this->eos = FALSE;
1.393
1.394 - this->bytes_queue = NULL;
1.395 + this->bytes_queue = NULL;
1.396
1.397 - this->wait_to_transfer = 0;
1.398 + this->wait_to_transfer = 0;
1.399
1.400 - gst_base_src_set_format(GST_BASE_SRC(this), GST_FORMAT_BYTES);
1.401 + gst_base_src_set_format(GST_BASE_SRC(this), GST_FORMAT_BYTES);
1.402
1.403 - gst_pad_set_event_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
1.404 - gst_mythtv_src_handle_event);
1.405 - gst_pad_set_query_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
1.406 - gst_mythtv_src_handle_query);
1.407 + gst_pad_set_event_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
1.408 + gst_mythtv_src_handle_event);
1.409 + gst_pad_set_query_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
1.410 + gst_mythtv_src_handle_query);
1.411
1.412 }
1.413
1.414 static void
1.415 gst_mythtv_src_clear(GstMythtvSrc * mythtv_src)
1.416 {
1.417 - mythtv_src->unique_setup = FALSE;
1.418 + mythtv_src->unique_setup = FALSE;
1.419
1.420 - if (mythtv_src->spawn_livetv)
1.421 - {
1.422 - g_object_unref(mythtv_src->spawn_livetv);
1.423 - mythtv_src->spawn_livetv = NULL;
1.424 - }
1.425 + if (mythtv_src->spawn_livetv) {
1.426 + g_object_unref(mythtv_src->spawn_livetv);
1.427 + mythtv_src->spawn_livetv = NULL;
1.428 + }
1.429
1.430 - if (mythtv_src->file)
1.431 - {
1.432 - g_object_unref(mythtv_src->file);
1.433 - mythtv_src->file = NULL;
1.434 - }
1.435 + if (mythtv_src->file) {
1.436 + g_object_unref(mythtv_src->file);
1.437 + mythtv_src->file = NULL;
1.438 + }
1.439
1.440 - if (mythtv_src->backend_info)
1.441 - {
1.442 - g_object_unref(mythtv_src->backend_info);
1.443 - mythtv_src->backend_info = NULL;
1.444 - }
1.445 + if (mythtv_src->backend_info) {
1.446 + g_object_unref(mythtv_src->backend_info);
1.447 + mythtv_src->backend_info = NULL;
1.448 + }
1.449
1.450 - if (mythtv_src->bytes_queue)
1.451 - {
1.452 - g_byte_array_free(mythtv_src->bytes_queue, TRUE);
1.453 - mythtv_src->bytes_queue = NULL;
1.454 - }
1.455 + if (mythtv_src->bytes_queue) {
1.456 + g_byte_array_free(mythtv_src->bytes_queue, TRUE);
1.457 + mythtv_src->bytes_queue = NULL;
1.458 + }
1.459 }
1.460
1.461 static void
1.462 gst_mythtv_src_finalize(GObject * gobject)
1.463 {
1.464 - GstMythtvSrc *this = GST_MYTHTV_SRC(gobject);
1.465 + GstMythtvSrc *this = GST_MYTHTV_SRC(gobject);
1.466
1.467 - gst_mythtv_src_clear(this);
1.468 + gst_mythtv_src_clear(this);
1.469
1.470 - if (this->uri_name)
1.471 - {
1.472 - g_free(this->uri_name);
1.473 - this->uri_name = NULL;
1.474 - }
1.475 + if (this->uri_name) {
1.476 + g_free(this->uri_name);
1.477 + this->uri_name = NULL;
1.478 + }
1.479
1.480 - if (this->user_agent)
1.481 - {
1.482 - g_free(this->user_agent);
1.483 - this->user_agent = NULL;
1.484 - }
1.485 + if (this->user_agent) {
1.486 + g_free(this->user_agent);
1.487 + this->user_agent = NULL;
1.488 + }
1.489
1.490 - G_OBJECT_CLASS(parent_class)->finalize(gobject);
1.491 + G_OBJECT_CLASS(parent_class)->finalize(gobject);
1.492 }
1.493
1.494 -static GMythFileReadResult
1.495 +static GMythFileReadResult
1.496 do_read_request_response(GstMythtvSrc * src, guint size,
1.497 - GByteArray * data_ptr)
1.498 + GByteArray * data_ptr)
1.499 {
1.500 - gint read = 0;
1.501 - guint sizetoread = size;
1.502 - gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
1.503 - GMythFileReadResult result;
1.504 + gint read = 0;
1.505 + guint sizetoread = size;
1.506 + gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
1.507 + GMythFileReadResult result;
1.508
1.509 - GST_LOG_OBJECT(src, "Starting: Reading %d bytes...", sizetoread);
1.510 + GST_LOG_OBJECT(src, "Starting: Reading %d bytes...", sizetoread);
1.511
1.512 - /* Loop sending the Myth File Transfer request:
1.513 - * Retry whilst authentication fails and we supply it. */
1.514 + /*
1.515 + * Loop sending the Myth File Transfer request: Retry whilst
1.516 + * authentication fails and we supply it.
1.517 + */
1.518
1.519 - while (sizetoread == size && --max_iters > 0)
1.520 - {
1.521 - /* if ( gmyth_backend_info_is_local_file(src->backend_info) ) */
1.522 - if (IS_GMYTH_FILE_LOCAL(src->file))
1.523 - result = gmyth_file_local_read(GMYTH_FILE_LOCAL(src->file),
1.524 - data_ptr, sizetoread, src->live_tv);
1.525 - else if (IS_GMYTH_FILE_TRANSFER(src->file))
1.526 - result = gmyth_file_transfer_read(GMYTH_FILE_TRANSFER(src->file),
1.527 - data_ptr, sizetoread, src->live_tv);
1.528 + while (sizetoread == size && --max_iters > 0) {
1.529 + /*
1.530 + * if ( gmyth_backend_info_is_local_file(src->backend_info) )
1.531 + */
1.532 + if (IS_GMYTH_FILE_LOCAL(src->file))
1.533 + result = gmyth_file_local_read(GMYTH_FILE_LOCAL(src->file),
1.534 + data_ptr, sizetoread,
1.535 + src->live_tv);
1.536 + else if (IS_GMYTH_FILE_TRANSFER(src->file))
1.537 + result =
1.538 + gmyth_file_transfer_read(GMYTH_FILE_TRANSFER(src->file),
1.539 + data_ptr, sizetoread,
1.540 + src->live_tv);
1.541
1.542 - if (data_ptr->len > 0)
1.543 - {
1.544 - read += data_ptr->len;
1.545 - sizetoread -= data_ptr->len;
1.546 - }
1.547 - else if (data_ptr->len <= 0)
1.548 - {
1.549 - if (src->live_tv == FALSE)
1.550 - {
1.551 - result = GMYTH_FILE_READ_EOF;
1.552 - goto eos;
1.553 - }
1.554 - else
1.555 - {
1.556 - if (result == GMYTH_FILE_READ_ERROR)
1.557 - { /* -314 */
1.558 - GST_INFO_OBJECT(src, "[LiveTV] FileTransfer READ_ERROR!");
1.559 - goto done;
1.560 - }
1.561 - else if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)
1.562 - { /* -315 */
1.563 - GST_INFO_OBJECT(src,
1.564 - "[LiveTV] FileTransfer - Go to athe next program chain!");
1.565 - src->update_prog_chain = TRUE;
1.566 - continue;
1.567 - }
1.568 - goto done;
1.569 - }
1.570 + if (data_ptr->len > 0) {
1.571 + read += data_ptr->len;
1.572 + sizetoread -= data_ptr->len;
1.573 + } else if (data_ptr->len <= 0) {
1.574 + if (src->live_tv == FALSE) {
1.575 + result = GMYTH_FILE_READ_EOF;
1.576 + goto eos;
1.577 + } else {
1.578 + if (result == GMYTH_FILE_READ_ERROR) { /* -314 */
1.579 + GST_INFO_OBJECT(src,
1.580 + "[LiveTV] FileTransfer READ_ERROR!");
1.581 + goto done;
1.582 + } else if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) { /* -315
1.583 + */
1.584 + GST_INFO_OBJECT(src,
1.585 + "[LiveTV] FileTransfer - Go to athe next program chain!");
1.586 + src->update_prog_chain = TRUE;
1.587 + continue;
1.588 + }
1.589 + goto done;
1.590 + }
1.591
1.592 - } /* else if (data_ptr->len == 0)
1.593 - goto done; */
1.594 + }
1.595 + /*
1.596 + * else if (data_ptr->len == 0) goto done;
1.597 + */
1.598 + if (read == sizetoread)
1.599 + goto done;
1.600 + }
1.601
1.602 - if (read == sizetoread)
1.603 - goto done;
1.604 - }
1.605 + if ((read < 0 && !src->live_tv) || max_iters == 0) {
1.606 + result = GMYTH_FILE_READ_EOF;
1.607 + goto eos;
1.608 + }
1.609
1.610 - if ((read < 0 && !src->live_tv) || max_iters == 0)
1.611 - {
1.612 - result = GMYTH_FILE_READ_EOF;
1.613 - goto eos;
1.614 - }
1.615 + goto done;
1.616
1.617 - goto done;
1.618 + eos:
1.619 + src->eos = TRUE;
1.620
1.621 -eos:
1.622 - src->eos = TRUE;
1.623 -
1.624 -done:
1.625 - return result;
1.626 + done:
1.627 + return result;
1.628 }
1.629
1.630 -static GstFlowReturn
1.631 +static GstFlowReturn
1.632 gst_mythtv_src_create(GstPushSrc * psrc, GstBuffer ** outbuf)
1.633 {
1.634 - GstMythtvSrc *src;
1.635 - GstFlowReturn ret = GST_FLOW_OK;
1.636 - guint buffer_size_inter = 0;
1.637 + GstMythtvSrc *src;
1.638 + GstFlowReturn ret = GST_FLOW_OK;
1.639 + guint buffer_size_inter = 0;
1.640
1.641 - src = GST_MYTHTV_SRC(psrc);
1.642 + src = GST_MYTHTV_SRC(psrc);
1.643
1.644 - /* The caller should know the number of bytes and not read beyond EOS. */
1.645 - if (G_UNLIKELY(src->eos))
1.646 - goto eos;
1.647 - GST_DEBUG_OBJECT(src, "offset = %" G_GUINT64_FORMAT ", size = %d...",
1.648 - src->read_offset, MAX_READ_SIZE);
1.649 + /*
1.650 + * The caller should know the number of bytes and not read beyond EOS.
1.651 + */
1.652 + if (G_UNLIKELY(src->eos))
1.653 + goto eos;
1.654 + GST_DEBUG_OBJECT(src, "offset = %" G_GUINT64_FORMAT ", size = %d...",
1.655 + src->read_offset, MAX_READ_SIZE);
1.656
1.657 - GST_DEBUG_OBJECT(src, "Create: buffer_remain: %d, buffer_size = %d.",
1.658 - (gint) src->buffer_remain, src->bytes_queue->len);
1.659 + GST_DEBUG_OBJECT(src, "Create: buffer_remain: %d, buffer_size = %d.",
1.660 + (gint) src->buffer_remain, src->bytes_queue->len);
1.661
1.662 -program_chain_changed:
1.663 - /* just get from the byte array, no network effort... */
1.664 - if ((src->buffer_remain = src->bytes_queue->len) < MAX_READ_SIZE)
1.665 - {
1.666 - GByteArray *buffer;
1.667 - GMythFileReadResult result = GMYTH_FILE_READ_OK;
1.668 + program_chain_changed:
1.669 + /*
1.670 + * just get from the byte array, no network effort...
1.671 + */
1.672 + if ((src->buffer_remain = src->bytes_queue->len) < MAX_READ_SIZE) {
1.673 + GByteArray *buffer;
1.674 + GMythFileReadResult result = GMYTH_FILE_READ_OK;
1.675
1.676 - buffer = NULL;
1.677 - buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain);
1.678 + buffer = NULL;
1.679 + buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain);
1.680
1.681 - if (buffer_size_inter > REQUEST_MAX_SIZE)
1.682 - buffer_size_inter = REQUEST_MAX_SIZE;
1.683 + if (buffer_size_inter > REQUEST_MAX_SIZE)
1.684 + buffer_size_inter = REQUEST_MAX_SIZE;
1.685
1.686 - buffer = g_byte_array_new();
1.687 + buffer = g_byte_array_new();
1.688
1.689 - result = do_read_request_response(src, buffer_size_inter, buffer);
1.690 + result = do_read_request_response(src, buffer_size_inter, buffer);
1.691
1.692 - /* got the next program info? */
1.693 - if (G_UNLIKELY(src->update_prog_chain)
1.694 - || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN))
1.695 - {
1.696 - GST_DEBUG_OBJECT(src, "Update PROGRAM CHAIN!!! buffer_size = %d.",
1.697 - src->bytes_queue->len);
1.698 - gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(psrc)),
1.699 - gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM,
1.700 - NULL));
1.701 -/*
1.702 - gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
1.703 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
1.704 -*/
1.705 - src->update_prog_chain = FALSE;
1.706 - src->eos = FALSE;
1.707 + /*
1.708 + * got the next program info?
1.709 + */
1.710 + if (G_UNLIKELY(src->update_prog_chain)
1.711 + || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)) {
1.712 + GST_DEBUG_OBJECT(src,
1.713 + "Update PROGRAM CHAIN!!! buffer_size = %d.",
1.714 + src->bytes_queue->len);
1.715 + gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(psrc)),
1.716 + gst_event_new_custom
1.717 + (GST_EVENT_CUSTOM_DOWNSTREAM, NULL));
1.718 + /*
1.719 + * gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
1.720 + * gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0,
1.721 + * -1, 0));
1.722 + */
1.723 + src->update_prog_chain = FALSE;
1.724 + src->eos = FALSE;
1.725
1.726 - if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)
1.727 - {
1.728 - /*
1.729 - if (buffer != NULL) {
1.730 - g_byte_array_free (buffer, TRUE);
1.731 - buffer = NULL;
1.732 - }
1.733 - goto program_chain_changed; */
1.734 - }
1.735 - else if (result == GMYTH_FILE_READ_OK)
1.736 - {
1.737 - /* remove wasteful, NUV file header data */
1.738 - /* buffer = g_byte_array_remove_range( buffer, 0, 512 ); */
1.739 - /* TODO: need to send a new segment event to NUVDemux? */
1.740 - //gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
1.741 - // gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
1.742 + if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) {
1.743 + /*
1.744 + * if (buffer != NULL) { g_byte_array_free (buffer, TRUE);
1.745 + * buffer = NULL; } goto program_chain_changed;
1.746 + */
1.747 + } else if (result == GMYTH_FILE_READ_OK) {
1.748 + /*
1.749 + * remove wasteful, NUV file header data
1.750 + */
1.751 + /*
1.752 + * buffer = g_byte_array_remove_range( buffer, 0, 512 );
1.753 + */
1.754 + /*
1.755 + * TODO: need to send a new segment event to NUVDemux?
1.756 + */
1.757 + // gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC
1.758 + // (psrc)),
1.759 + // gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES,
1.760 + // 0, -1, 0));
1.761
1.762 - /* goto change_progchain; */
1.763 - }
1.764 + /*
1.765 + * goto change_progchain;
1.766 + */
1.767 + }
1.768
1.769 - } /* */
1.770 + }
1.771 + /*
1.772 + */
1.773 + if (G_UNLIKELY(buffer->len < 0)) {
1.774
1.775 - if (G_UNLIKELY(buffer->len < 0))
1.776 - {
1.777 + if (buffer != NULL) {
1.778 + g_byte_array_free(buffer, TRUE);
1.779 + buffer = NULL;
1.780 + }
1.781
1.782 - if (buffer != NULL)
1.783 - {
1.784 - g_byte_array_free(buffer, TRUE);
1.785 - buffer = NULL;
1.786 - }
1.787 + if (src->live_tv
1.788 + || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN))
1.789 + goto change_progchain;
1.790 + else
1.791 + goto read_error;
1.792 + } else if (G_UNLIKELY(buffer->len == 0)) {
1.793
1.794 - if (src->live_tv || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN))
1.795 - goto change_progchain;
1.796 - else
1.797 - goto read_error;
1.798 - }
1.799 - else if (G_UNLIKELY(buffer->len == 0))
1.800 - {
1.801 + if (buffer != NULL) {
1.802 + g_byte_array_free(buffer, TRUE);
1.803 + buffer = NULL;
1.804 + }
1.805
1.806 - if (buffer != NULL)
1.807 - {
1.808 - g_byte_array_free(buffer, TRUE);
1.809 - buffer = NULL;
1.810 - }
1.811 + if (!src->live_tv)
1.812 + goto done;
1.813 + else
1.814 + goto program_chain_changed;
1.815 + }
1.816
1.817 - if (!src->live_tv)
1.818 - goto done;
1.819 - else
1.820 - goto program_chain_changed;
1.821 - }
1.822 + src->bytes_queue =
1.823 + g_byte_array_append(src->bytes_queue, buffer->data,
1.824 + buffer->len);
1.825 + if (buffer->len > buffer_size_inter)
1.826 + GST_WARNING_OBJECT(src,
1.827 + "INCREASED buffer size! Backend sent more than we ask him... (%d)",
1.828 + abs(buffer->len - buffer_size_inter));
1.829
1.830 - src->bytes_queue =
1.831 - g_byte_array_append(src->bytes_queue, buffer->data, buffer->len);
1.832 - if (buffer->len > buffer_size_inter)
1.833 - GST_WARNING_OBJECT(src,
1.834 - "INCREASED buffer size! Backend sent more than we ask him... (%d)",
1.835 - abs(buffer->len - buffer_size_inter));
1.836 + src->buffer_remain += buffer->len;
1.837
1.838 - src->buffer_remain += buffer->len;
1.839 + if (buffer != NULL) {
1.840 + g_byte_array_free(buffer, TRUE);
1.841 + buffer = NULL;
1.842 + }
1.843
1.844 - if (buffer != NULL)
1.845 - {
1.846 - g_byte_array_free(buffer, TRUE);
1.847 - buffer = NULL;
1.848 - }
1.849 + /*
1.850 + * GST_DEBUG_OBJECT (src, "BYTES READ (actual) = %d, BYTES READ
1.851 + * (cumulative) = %llu, " "OFFSET = %llu, CONTENT SIZE = %llu.",
1.852 + * read, src->bytes_read, src->read_offset, src->content_size);
1.853 + */
1.854 + }
1.855
1.856 - /*
1.857 - GST_DEBUG_OBJECT (src,
1.858 - "BYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "
1.859 - "OFFSET = %llu, CONTENT SIZE = %llu.", read,
1.860 - src->bytes_read, src->read_offset, src->content_size);
1.861 - */
1.862 - }
1.863 + guint buffer_size =
1.864 + (src->buffer_remain <
1.865 + MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
1.866
1.867 - guint buffer_size =
1.868 - (src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
1.869 + *outbuf = gst_buffer_new();
1.870
1.871 - *outbuf = gst_buffer_new();
1.872 + /*
1.873 + * GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain =
1.874 + * %d", (buffer_size_inter == 0) ? "NO, got from buffer" : "YES, go
1.875 + * see the backend's log file", src->buffer_remain);
1.876 + */
1.877
1.878 - /*
1.879 - GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d",
1.880 - (buffer_size_inter ==
1.881 - 0) ? "NO, got from buffer" : "YES, go see the backend's log file",
1.882 - src->buffer_remain);
1.883 - */
1.884 + GST_BUFFER_SIZE(*outbuf) = buffer_size;
1.885 + GST_BUFFER_MALLOCDATA(*outbuf) = g_malloc0(GST_BUFFER_SIZE(*outbuf));
1.886 + GST_BUFFER_DATA(*outbuf) = GST_BUFFER_MALLOCDATA(*outbuf);
1.887 + g_memmove(GST_BUFFER_DATA((*outbuf)), src->bytes_queue->data,
1.888 + GST_BUFFER_SIZE(*outbuf));
1.889 + GST_BUFFER_OFFSET(*outbuf) = src->read_offset;
1.890 + GST_BUFFER_OFFSET_END(*outbuf) =
1.891 + src->read_offset + GST_BUFFER_SIZE(*outbuf);
1.892
1.893 - GST_BUFFER_SIZE(*outbuf) = buffer_size;
1.894 - GST_BUFFER_MALLOCDATA(*outbuf) = g_malloc0(GST_BUFFER_SIZE(*outbuf));
1.895 - GST_BUFFER_DATA(*outbuf) = GST_BUFFER_MALLOCDATA(*outbuf);
1.896 - g_memmove(GST_BUFFER_DATA((*outbuf)), src->bytes_queue->data,
1.897 - GST_BUFFER_SIZE(*outbuf));
1.898 - GST_BUFFER_OFFSET(*outbuf) = src->read_offset;
1.899 - GST_BUFFER_OFFSET_END(*outbuf) =
1.900 - src->read_offset + GST_BUFFER_SIZE(*outbuf);
1.901 + src->buffer_remain -= GST_BUFFER_SIZE(*outbuf);
1.902
1.903 - src->buffer_remain -= GST_BUFFER_SIZE(*outbuf);
1.904 + src->read_offset += GST_BUFFER_SIZE(*outbuf);
1.905 + src->bytes_read += GST_BUFFER_SIZE(*outbuf);
1.906 + // GST_DEBUG_OBJECT (src, "Buffer output with size: %d",
1.907 + // GST_BUFFER_SIZE (*outbuf));
1.908
1.909 - src->read_offset += GST_BUFFER_SIZE(*outbuf);
1.910 - src->bytes_read += GST_BUFFER_SIZE(*outbuf);
1.911 - //GST_DEBUG_OBJECT (src, "Buffer output with size: %d",
1.912 - // GST_BUFFER_SIZE (*outbuf));
1.913 + /*
1.914 + * flushs the newly buffer got from byte array
1.915 + */
1.916 + src->bytes_queue =
1.917 + g_byte_array_remove_range(src->bytes_queue, 0, buffer_size);
1.918
1.919 - /* flushs the newly buffer got from byte array */
1.920 - src->bytes_queue =
1.921 - g_byte_array_remove_range(src->bytes_queue, 0, buffer_size);
1.922 + if (G_UNLIKELY(src->eos) || (!src->live_tv
1.923 + && (src->bytes_read >=
1.924 + src->content_size)))
1.925 + goto eos;
1.926
1.927 - if (G_UNLIKELY(src->eos) || (!src->live_tv
1.928 - && (src->bytes_read >= src->content_size)))
1.929 - goto eos;
1.930 + done:
1.931 + {
1.932 + const gchar *reason = gst_flow_get_name(ret);
1.933 + return ret;
1.934 + }
1.935 + eos:
1.936 + {
1.937 + const gchar *reason = gst_flow_get_name(ret);
1.938
1.939 -done:
1.940 - {
1.941 - const gchar *reason = gst_flow_get_name(ret);
1.942 - return ret;
1.943 - }
1.944 -eos:
1.945 - {
1.946 - const gchar *reason = gst_flow_get_name(ret);
1.947 + GST_DEBUG_OBJECT(src, "pausing task, reason %s", reason);
1.948 + return GST_FLOW_UNEXPECTED;
1.949 + }
1.950 + /*
1.951 + * ERRORS
1.952 + */
1.953 + read_error:
1.954 + {
1.955 + GST_ELEMENT_ERROR(src, RESOURCE, READ,
1.956 + (NULL), ("Could not read any bytes (%i, %s)",
1.957 + read, src->uri_name));
1.958 + return GST_FLOW_ERROR;
1.959 + }
1.960 + change_progchain:
1.961 + {
1.962 + GST_ELEMENT_ERROR(src, RESOURCE, READ,
1.963 + (NULL),
1.964 + ("Seek failed, go to the next program info... (%i, %s)",
1.965 + read, src->uri_name));
1.966
1.967 - GST_DEBUG_OBJECT(src, "pausing task, reason %s", reason);
1.968 - return GST_FLOW_UNEXPECTED;
1.969 - }
1.970 - /* ERRORS */
1.971 -read_error:
1.972 - {
1.973 - GST_ELEMENT_ERROR(src, RESOURCE, READ,
1.974 - (NULL), ("Could not read any bytes (%i, %s)", read,
1.975 - src->uri_name));
1.976 - return GST_FLOW_ERROR;
1.977 - }
1.978 -change_progchain:
1.979 - {
1.980 - GST_ELEMENT_ERROR(src, RESOURCE, READ,
1.981 - (NULL),
1.982 - ("Seek failed, go to the next program info... (%i, %s)",
1.983 - read, src->uri_name));
1.984 + /*
1.985 + * TODO: need to send a new segment event to NUVDemux?
1.986 + */
1.987 + gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(psrc)),
1.988 + gst_event_new_new_segment(TRUE, 1.0,
1.989 + GST_FORMAT_TIME, 0,
1.990 + -1, 0));
1.991
1.992 -/* TODO: need to send a new segment event to NUVDemux? */
1.993 - gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(psrc)),
1.994 - gst_event_new_new_segment(TRUE, 1.0, GST_FORMAT_TIME,
1.995 - 0, -1, 0));
1.996 -
1.997 - goto program_chain_changed;
1.998 - }
1.999 + goto program_chain_changed;
1.1000 + }
1.1001
1.1002 }
1.1003
1.1004 @@ -663,709 +674,697 @@
1.1005 gst_mythtv_src_get_position(GstMythtvSrc * src)
1.1006 {
1.1007
1.1008 - gint64 size_tmp = 0;
1.1009 - guint max_tries = 2;
1.1010 + gint64 size_tmp = 0;
1.1011 + guint max_tries = 2;
1.1012
1.1013 - if (src->live_tv == TRUE && (abs(src->content_size - src->bytes_read) <
1.1014 - GMYTHTV_TRANSFER_MAX_BUFFER))
1.1015 - {
1.1016 + if (src->live_tv == TRUE && (abs(src->content_size - src->bytes_read) <
1.1017 + GMYTHTV_TRANSFER_MAX_BUFFER)) {
1.1018
1.1019 - get_file_pos:
1.1020 - g_usleep(10);
1.1021 - size_tmp =
1.1022 - gmyth_recorder_get_file_position(src->spawn_livetv->recorder);
1.1023 - if (size_tmp > (src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER))
1.1024 - src->content_size = size_tmp;
1.1025 - else if (size_tmp > 0 && --max_tries > 0)
1.1026 - goto get_file_pos;
1.1027 - GST_LOG_OBJECT(src, "GET_POSITION: file_position = %lld", size_tmp);
1.1028 - /* sets the last content size amount before it can be updated */
1.1029 - src->prev_content_size = src->content_size;
1.1030 - }
1.1031 + get_file_pos:
1.1032 + g_usleep(10);
1.1033 + size_tmp =
1.1034 + gmyth_recorder_get_file_position(src->spawn_livetv->recorder);
1.1035 + if (size_tmp > (src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER))
1.1036 + src->content_size = size_tmp;
1.1037 + else if (size_tmp > 0 && --max_tries > 0)
1.1038 + goto get_file_pos;
1.1039 + GST_LOG_OBJECT(src, "GET_POSITION: file_position = %lld",
1.1040 + size_tmp);
1.1041 + /*
1.1042 + * sets the last content size amount before it can be updated
1.1043 + */
1.1044 + src->prev_content_size = src->content_size;
1.1045 + }
1.1046
1.1047 - return src->content_size;
1.1048 + return src->content_size;
1.1049
1.1050 }
1.1051
1.1052 -static gboolean
1.1053 +static gboolean
1.1054 gst_mythtv_src_do_seek(GstBaseSrc * base, GstSegment * segment)
1.1055 {
1.1056 - GstMythtvSrc *src = GST_MYTHTV_SRC(base);
1.1057 - gint64 new_offset = -1;
1.1058 - gint64 actual_seek = segment->start;
1.1059 - gboolean ret = TRUE;
1.1060 + GstMythtvSrc *src = GST_MYTHTV_SRC(base);
1.1061 + gint64 new_offset = -1;
1.1062 + gint64 actual_seek = segment->start;
1.1063 + gboolean ret = TRUE;
1.1064
1.1065 - GST_LOG_OBJECT(src, "seek, segment: %" GST_SEGMENT_FORMAT, segment);
1.1066 + GST_LOG_OBJECT(src, "seek, segment: %" GST_SEGMENT_FORMAT, segment);
1.1067
1.1068 - if (segment->format == GST_FORMAT_TIME)
1.1069 - {
1.1070 - goto done;
1.1071 - }
1.1072 - GST_LOG_OBJECT(src,
1.1073 - "Trying to seek at the value (actual_seek = %lld, read_offset = %lld)",
1.1074 - actual_seek, src->read_offset);
1.1075 - /* verify if it needs to seek */
1.1076 - if (src->read_offset != actual_seek)
1.1077 - {
1.1078 + if (segment->format == GST_FORMAT_TIME) {
1.1079 + goto done;
1.1080 + }
1.1081 + GST_LOG_OBJECT(src,
1.1082 + "Trying to seek at the value (actual_seek = %lld, read_offset = %lld)",
1.1083 + actual_seek, src->read_offset);
1.1084 + /*
1.1085 + * verify if it needs to seek
1.1086 + */
1.1087 + if (src->read_offset != actual_seek) {
1.1088
1.1089 - /* if ( gmyth_backend_info_is_local_file(src->backend_info) ) */
1.1090 - if (IS_GMYTH_FILE_LOCAL(src->file))
1.1091 - new_offset =
1.1092 - gmyth_file_local_seek(GMYTH_FILE_LOCAL(src->file), segment->start,
1.1093 - G_SEEK_SET);
1.1094 - else if (IS_GMYTH_FILE_TRANSFER(src->file))
1.1095 - new_offset =
1.1096 - gmyth_file_transfer_seek(GMYTH_FILE_TRANSFER(src->file),
1.1097 - segment->start, SEEK_SET);
1.1098 + /*
1.1099 + * if ( gmyth_backend_info_is_local_file(src->backend_info) )
1.1100 + */
1.1101 + if (IS_GMYTH_FILE_LOCAL(src->file))
1.1102 + new_offset =
1.1103 + gmyth_file_local_seek(GMYTH_FILE_LOCAL(src->file),
1.1104 + segment->start, G_SEEK_SET);
1.1105 + else if (IS_GMYTH_FILE_TRANSFER(src->file))
1.1106 + new_offset =
1.1107 + gmyth_file_transfer_seek(GMYTH_FILE_TRANSFER(src->file),
1.1108 + segment->start, SEEK_SET);
1.1109
1.1110 - GST_LOG_OBJECT(src,
1.1111 - "Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.",
1.1112 - segment->start, src->read_offset, new_offset);
1.1113 - if (G_UNLIKELY(new_offset < 0))
1.1114 - {
1.1115 - ret = FALSE;
1.1116 - if (!src->live_tv)
1.1117 - goto eos;
1.1118 - }
1.1119 + GST_LOG_OBJECT(src,
1.1120 + "Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.",
1.1121 + segment->start, src->read_offset, new_offset);
1.1122 + if (G_UNLIKELY(new_offset < 0)) {
1.1123 + ret = FALSE;
1.1124 + if (!src->live_tv)
1.1125 + goto eos;
1.1126 + }
1.1127
1.1128 - src->read_offset = new_offset;
1.1129 + src->read_offset = new_offset;
1.1130
1.1131 - if (ret == FALSE)
1.1132 - {
1.1133 - GST_INFO_OBJECT(src, "Failed to set the SEEK on segment!");
1.1134 - }
1.1135 + if (ret == FALSE) {
1.1136 + GST_INFO_OBJECT(src, "Failed to set the SEEK on segment!");
1.1137 + }
1.1138
1.1139 - }
1.1140 + }
1.1141
1.1142 -done:
1.1143 - return ret;
1.1144 + done:
1.1145 + return ret;
1.1146
1.1147 -eos:
1.1148 - {
1.1149 - GST_DEBUG_OBJECT(src, "EOS found on seeking!!!");
1.1150 - return FALSE;
1.1151 - }
1.1152 + eos:
1.1153 + {
1.1154 + GST_DEBUG_OBJECT(src, "EOS found on seeking!!!");
1.1155 + return FALSE;
1.1156 + }
1.1157
1.1158 }
1.1159
1.1160 -/* create a socket for connecting to remote server */
1.1161 -static gboolean
1.1162 +/*
1.1163 + * create a socket for connecting to remote server
1.1164 + */
1.1165 +static gboolean
1.1166 gst_mythtv_src_start(GstBaseSrc * bsrc)
1.1167 {
1.1168 - GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
1.1169 + GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
1.1170
1.1171 - GString *chain_id_local = NULL;
1.1172 - GMythURI *gmyth_uri = NULL;
1.1173 - gboolean ret = TRUE;
1.1174 - GstMessage *msg;
1.1175 + GString *chain_id_local = NULL;
1.1176 + GMythURI *gmyth_uri = NULL;
1.1177 + gboolean ret = TRUE;
1.1178 + GstMessage *msg;
1.1179
1.1180 - if (src->unique_setup == FALSE)
1.1181 - {
1.1182 - src->unique_setup = TRUE;
1.1183 - }
1.1184 - else
1.1185 - {
1.1186 - goto done;
1.1187 - }
1.1188 + if (src->unique_setup == FALSE) {
1.1189 + src->unique_setup = TRUE;
1.1190 + } else {
1.1191 + goto done;
1.1192 + }
1.1193
1.1194 - gmyth_uri = gmyth_uri_new_with_value(src->uri_name);
1.1195 - src->backend_info = gmyth_backend_info_new_with_uri(src->uri_name);
1.1196 - src->live_tv = gmyth_uri_is_livetv(gmyth_uri);
1.1197 - /* testing UPnP... */
1.1198 - /* gmyth_backend_info_set_hostname( src->backend_info, NULL ); */
1.1199 - if (src->live_tv)
1.1200 - {
1.1201 - src->spawn_livetv = gmyth_livetv_new(src->backend_info);
1.1202 + gmyth_uri = gmyth_uri_new_with_value(src->uri_name);
1.1203 + src->backend_info = gmyth_backend_info_new_with_uri(src->uri_name);
1.1204 + src->live_tv = gmyth_uri_is_livetv(gmyth_uri);
1.1205 + /*
1.1206 + * testing UPnP...
1.1207 + */
1.1208 + /*
1.1209 + * gmyth_backend_info_set_hostname( src->backend_info, NULL );
1.1210 + */
1.1211 + if (src->live_tv) {
1.1212 + src->spawn_livetv = gmyth_livetv_new(src->backend_info);
1.1213
1.1214 - gchar *ch = gmyth_uri_get_channel_name(gmyth_uri);
1.1215 - if (ch != NULL)
1.1216 - src->channel_name = ch;
1.1217 + gchar *ch = gmyth_uri_get_channel_name(gmyth_uri);
1.1218 + if (ch != NULL)
1.1219 + src->channel_name = ch;
1.1220
1.1221 - if (src->channel_name != NULL)
1.1222 - {
1.1223 - gboolean result;
1.1224 - result =
1.1225 - gmyth_livetv_channel_name_setup(src->spawn_livetv,
1.1226 - src->channel_name);
1.1227 - if (result == FALSE)
1.1228 - {
1.1229 - GST_INFO_OBJECT(src, "LiveTV setup felt down on error");
1.1230 - ret = FALSE;
1.1231 - goto init_failed;
1.1232 - }
1.1233 + if (src->channel_name != NULL) {
1.1234 + gboolean result;
1.1235 + result =
1.1236 + gmyth_livetv_channel_name_setup(src->spawn_livetv,
1.1237 + src->channel_name);
1.1238 + if (result == FALSE) {
1.1239 + GST_INFO_OBJECT(src, "LiveTV setup felt down on error");
1.1240 + ret = FALSE;
1.1241 + goto init_failed;
1.1242 + }
1.1243
1.1244 - }
1.1245 - else
1.1246 - {
1.1247 - if (gmyth_livetv_setup(src->spawn_livetv) == FALSE)
1.1248 - {
1.1249 - GST_INFO_OBJECT(src, "LiveTV setup felt down on error");
1.1250 - ret = FALSE;
1.1251 - goto init_failed;
1.1252 - }
1.1253 - }
1.1254 + } else {
1.1255 + if (gmyth_livetv_setup(src->spawn_livetv) == FALSE) {
1.1256 + GST_INFO_OBJECT(src, "LiveTV setup felt down on error");
1.1257 + ret = FALSE;
1.1258 + goto init_failed;
1.1259 + }
1.1260 + }
1.1261
1.1262 - /* testing change channel... */
1.1263 - /* gmyth_recorder_change_channel( src->spawn_livetv->recorder, CHANNEL_DIRECTION_UP ); */
1.1264 + /*
1.1265 + * testing change channel...
1.1266 + */
1.1267 + /*
1.1268 + * gmyth_recorder_change_channel( src->spawn_livetv->recorder,
1.1269 + * CHANNEL_DIRECTION_UP );
1.1270 + */
1.1271
1.1272 - src->file =
1.1273 - GMYTH_FILE(gmyth_livetv_create_file_transfer(src->spawn_livetv));
1.1274 + src->file =
1.1275 + GMYTH_FILE(gmyth_livetv_create_file_transfer
1.1276 + (src->spawn_livetv));
1.1277
1.1278 - if (NULL == src->file)
1.1279 - {
1.1280 - GST_INFO_OBJECT(src, "[LiveTV] FileTransfer equals to NULL");
1.1281 - ret = FALSE;
1.1282 - goto init_failed;
1.1283 - }
1.1284 + if (NULL == src->file) {
1.1285 + GST_INFO_OBJECT(src, "[LiveTV] FileTransfer equals to NULL");
1.1286 + ret = FALSE;
1.1287 + goto init_failed;
1.1288 + }
1.1289
1.1290 - /* Check if the file is local to this specific client renderer */
1.1291 - if (gmyth_uri_is_local_file(gmyth_uri))
1.1292 - ret = gmyth_file_local_open(GMYTH_FILE_LOCAL(src->file));
1.1293 - else
1.1294 - ret =
1.1295 - gmyth_file_transfer_open(GMYTH_FILE_TRANSFER(src->file),
1.1296 - src->spawn_livetv->uri !=
1.1297 - NULL ? gmyth_uri_get_path(src->
1.1298 - spawn_livetv->
1.1299 - uri) : src->
1.1300 - spawn_livetv->proginfo->pathname->str);
1.1301 + /*
1.1302 + * Check if the file is local to this specific client renderer
1.1303 + */
1.1304 + if (gmyth_uri_is_local_file(gmyth_uri))
1.1305 + ret = gmyth_file_local_open(GMYTH_FILE_LOCAL(src->file));
1.1306 + else
1.1307 + ret =
1.1308 + gmyth_file_transfer_open(GMYTH_FILE_TRANSFER(src->file),
1.1309 + src->spawn_livetv->uri !=
1.1310 + NULL ? gmyth_uri_get_path(src->
1.1311 + spawn_livetv->
1.1312 + uri) :
1.1313 + src->spawn_livetv->proginfo->
1.1314 + pathname->str);
1.1315
1.1316 - /* sets the mythtvsrc "location" property */
1.1317 - g_object_set(src, "location", gmyth_file_get_uri(src->file), NULL);
1.1318 + /*
1.1319 + * sets the mythtvsrc "location" property
1.1320 + */
1.1321 + g_object_set(src, "location", gmyth_file_get_uri(src->file), NULL);
1.1322
1.1323 - if (!ret)
1.1324 - {
1.1325 - GST_INFO_OBJECT(src,
1.1326 - "Error: couldn't open the FileTransfer from LiveTV source!");
1.1327 - g_object_unref(src->file);
1.1328 - src->file = NULL;
1.1329 - goto init_failed;
1.1330 - }
1.1331 - }
1.1332 - else
1.1333 - {
1.1334 + if (!ret) {
1.1335 + GST_INFO_OBJECT(src,
1.1336 + "Error: couldn't open the FileTransfer from LiveTV source!");
1.1337 + g_object_unref(src->file);
1.1338 + src->file = NULL;
1.1339 + goto init_failed;
1.1340 + }
1.1341 + } else {
1.1342
1.1343 - /* Check if the file is local to this specific client renderer, and tries to open
1.1344 - * a local connection
1.1345 - */
1.1346 - if (gmyth_uri_is_local_file(gmyth_uri))
1.1347 - {
1.1348 - src->file = GMYTH_FILE(gmyth_file_local_new(src->backend_info));
1.1349 - ret = gmyth_file_local_open(GMYTH_FILE_LOCAL(src->file));
1.1350 - }
1.1351 - else
1.1352 - {
1.1353 - src->file = GMYTH_FILE(gmyth_file_transfer_new(src->backend_info));
1.1354 - ret =
1.1355 - gmyth_file_transfer_open(GMYTH_FILE_TRANSFER(src->file),
1.1356 - src->uri_name);
1.1357 - }
1.1358 + /*
1.1359 + * Check if the file is local to this specific client renderer,
1.1360 + * and tries to open a local connection
1.1361 + */
1.1362 + if (gmyth_uri_is_local_file(gmyth_uri)) {
1.1363 + src->file =
1.1364 + GMYTH_FILE(gmyth_file_local_new(src->backend_info));
1.1365 + ret = gmyth_file_local_open(GMYTH_FILE_LOCAL(src->file));
1.1366 + } else {
1.1367 + src->file =
1.1368 + GMYTH_FILE(gmyth_file_transfer_new(src->backend_info));
1.1369 + ret =
1.1370 + gmyth_file_transfer_open(GMYTH_FILE_TRANSFER(src->file),
1.1371 + src->uri_name);
1.1372 + }
1.1373
1.1374 - } /* if (else) - recorded FileTransfer */
1.1375 + } /* if (else) - recorded FileTransfer */
1.1376
1.1377 - if (NULL == src->file)
1.1378 - {
1.1379 - GST_INFO_OBJECT(src, "FileTransfer is NULL");
1.1380 - goto init_failed;
1.1381 - }
1.1382 - /*GST_INFO_OBJECT( src, "uri = %s", src->spawn_livetv->file); */
1.1383 + if (NULL == src->file) {
1.1384 + GST_INFO_OBJECT(src, "FileTransfer is NULL");
1.1385 + goto init_failed;
1.1386 + }
1.1387 + /*
1.1388 + * GST_INFO_OBJECT( src, "uri = %s", src->spawn_livetv->file);
1.1389 + */
1.1390
1.1391 - if (ret == FALSE)
1.1392 - {
1.1393 + if (ret == FALSE) {
1.1394 #ifndef GST_DISABLE_GST_DEBUG
1.1395 - if (src->mythtv_msgs_dbg)
1.1396 - GST_INFO_OBJECT(src,
1.1397 - "MythTV FileTransfer request failed when setting up socket connection!");
1.1398 + if (src->mythtv_msgs_dbg)
1.1399 + GST_INFO_OBJECT(src,
1.1400 + "MythTV FileTransfer request failed when setting up socket connection!");
1.1401 #endif
1.1402 - goto begin_req_failed;
1.1403 - }
1.1404 + goto begin_req_failed;
1.1405 + }
1.1406
1.1407 - GST_INFO_OBJECT(src,
1.1408 - "MythTV FileTransfer filesize = %lld, content_size = %lld!",
1.1409 - gmyth_file_get_filesize(src->file), src->content_size);
1.1410 + GST_INFO_OBJECT(src,
1.1411 + "MythTV FileTransfer filesize = %lld, content_size = %lld!",
1.1412 + gmyth_file_get_filesize(src->file), src->content_size);
1.1413
1.1414 - src->content_size = gmyth_file_get_filesize(src->file);
1.1415 + src->content_size = gmyth_file_get_filesize(src->file);
1.1416
1.1417 - msg =
1.1418 - gst_message_new_duration(GST_OBJECT(src), GST_FORMAT_BYTES,
1.1419 - src->content_size);
1.1420 - gst_element_post_message(GST_ELEMENT(src), msg);
1.1421 + msg =
1.1422 + gst_message_new_duration(GST_OBJECT(src), GST_FORMAT_BYTES,
1.1423 + src->content_size);
1.1424 + gst_element_post_message(GST_ELEMENT(src), msg);
1.1425
1.1426
1.1427 - src->do_start = FALSE;
1.1428 + src->do_start = FALSE;
1.1429
1.1430 - /* this is used for the buffer cache */
1.1431 - src->bytes_queue = g_byte_array_sized_new(INTERNAL_BUFFER_SIZE);
1.1432 - src->buffer_remain = 0;
1.1433 + /*
1.1434 + * this is used for the buffer cache
1.1435 + */
1.1436 + src->bytes_queue = g_byte_array_sized_new(INTERNAL_BUFFER_SIZE);
1.1437 + src->buffer_remain = 0;
1.1438
1.1439 - gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(src)),
1.1440 - gst_event_new_new_segment(TRUE, 1.0, GST_FORMAT_TIME, 0,
1.1441 - src->content_size, 0));
1.1442 + gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(src)),
1.1443 + gst_event_new_new_segment(TRUE, 1.0,
1.1444 + GST_FORMAT_TIME, 0,
1.1445 + src->content_size, 0));
1.1446
1.1447 -done:
1.1448 - if (gmyth_uri != NULL)
1.1449 - {
1.1450 - g_object_unref(gmyth_uri);
1.1451 - gmyth_uri = NULL;
1.1452 - }
1.1453 + done:
1.1454 + if (gmyth_uri != NULL) {
1.1455 + g_object_unref(gmyth_uri);
1.1456 + gmyth_uri = NULL;
1.1457 + }
1.1458
1.1459 - if (chain_id_local != NULL)
1.1460 - {
1.1461 - g_string_free(chain_id_local, TRUE);
1.1462 - chain_id_local = NULL;
1.1463 - }
1.1464 + if (chain_id_local != NULL) {
1.1465 + g_string_free(chain_id_local, TRUE);
1.1466 + chain_id_local = NULL;
1.1467 + }
1.1468
1.1469 - return TRUE;
1.1470 + return TRUE;
1.1471
1.1472 - /* ERRORS */
1.1473 -init_failed:
1.1474 - if (gmyth_uri != NULL)
1.1475 - {
1.1476 - g_object_unref(gmyth_uri);
1.1477 - gmyth_uri = NULL;
1.1478 - }
1.1479 + /*
1.1480 + * ERRORS
1.1481 + */
1.1482 + init_failed:
1.1483 + if (gmyth_uri != NULL) {
1.1484 + g_object_unref(gmyth_uri);
1.1485 + gmyth_uri = NULL;
1.1486 + }
1.1487
1.1488 - if (src->spawn_livetv != NULL)
1.1489 - {
1.1490 - g_object_unref(src->spawn_livetv);
1.1491 - src->spawn_livetv = NULL;
1.1492 - }
1.1493 + if (src->spawn_livetv != NULL) {
1.1494 + g_object_unref(src->spawn_livetv);
1.1495 + src->spawn_livetv = NULL;
1.1496 + }
1.1497
1.1498 - GST_ELEMENT_ERROR(src, LIBRARY, INIT,
1.1499 - (NULL), ("Could not initialize MythTV library (%i, %s)",
1.1500 - ret, src->uri_name));
1.1501 + GST_ELEMENT_ERROR(src, LIBRARY, INIT,
1.1502 + (NULL),
1.1503 + ("Could not initialize MythTV library (%i, %s)", ret,
1.1504 + src->uri_name));
1.1505
1.1506
1.1507 - gst_mythtv_src_clear(src);
1.1508 + gst_mythtv_src_clear(src);
1.1509
1.1510 - return FALSE;
1.1511 -begin_req_failed:
1.1512 - if (gmyth_uri != NULL)
1.1513 - {
1.1514 - g_object_unref(gmyth_uri);
1.1515 - gmyth_uri = NULL;
1.1516 - }
1.1517 + return FALSE;
1.1518 + begin_req_failed:
1.1519 + if (gmyth_uri != NULL) {
1.1520 + g_object_unref(gmyth_uri);
1.1521 + gmyth_uri = NULL;
1.1522 + }
1.1523
1.1524 - GST_ELEMENT_ERROR(src, LIBRARY, INIT,
1.1525 - (NULL),
1.1526 - ("Could not begin request sent to MythTV server (%i, %s)",
1.1527 - ret, src->uri_name));
1.1528 - return FALSE;
1.1529 + GST_ELEMENT_ERROR(src, LIBRARY, INIT,
1.1530 + (NULL),
1.1531 + ("Could not begin request sent to MythTV server (%i, %s)",
1.1532 + ret, src->uri_name));
1.1533 + return FALSE;
1.1534
1.1535 }
1.1536
1.1537 -static gboolean
1.1538 +static gboolean
1.1539 gst_mythtv_src_get_size(GstBaseSrc * bsrc, guint64 * size)
1.1540 {
1.1541 - GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
1.1542 - gboolean ret = TRUE;
1.1543 + GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
1.1544 + gboolean ret = TRUE;
1.1545
1.1546 - GST_LOG_OBJECT(src, "Differs from previous content size: %d (max.: %d)",
1.1547 - abs(src->content_size - src->prev_content_size),
1.1548 - GMYTHTV_TRANSFER_MAX_BUFFER);
1.1549 + GST_LOG_OBJECT(src,
1.1550 + "Differs from previous content size: %d (max.: %d)",
1.1551 + abs(src->content_size - src->prev_content_size),
1.1552 + GMYTHTV_TRANSFER_MAX_BUFFER);
1.1553
1.1554 - if (src->live_tv)
1.1555 - {
1.1556 - ret = FALSE;
1.1557 - }
1.1558 - else if (src->live_tv && src->enable_timing_position
1.1559 - && (abs(src->content_size - src->bytes_read) <
1.1560 - GMYTHTV_TRANSFER_MAX_BUFFER))
1.1561 - {
1.1562 + if (src->live_tv) {
1.1563 + ret = FALSE;
1.1564 + } else if (src->live_tv && src->enable_timing_position
1.1565 + && (abs(src->content_size - src->bytes_read) <
1.1566 + GMYTHTV_TRANSFER_MAX_BUFFER)) {
1.1567
1.1568 - gint64 new_offset =
1.1569 - gmyth_recorder_get_file_position(src->spawn_livetv->recorder);
1.1570 - if (new_offset > 0 && new_offset > src->content_size)
1.1571 - {
1.1572 - src->content_size = new_offset;
1.1573 - }
1.1574 - else if (new_offset < src->content_size)
1.1575 - {
1.1576 - src->update_prog_chain = TRUE;
1.1577 - }
1.1578 + gint64 new_offset =
1.1579 + gmyth_recorder_get_file_position(src->spawn_livetv->recorder);
1.1580 + if (new_offset > 0 && new_offset > src->content_size) {
1.1581 + src->content_size = new_offset;
1.1582 + } else if (new_offset < src->content_size) {
1.1583 + src->update_prog_chain = TRUE;
1.1584 + }
1.1585
1.1586 - }
1.1587 + }
1.1588
1.1589 - *size = src->content_size;
1.1590 - GST_LOG_OBJECT(src, "Content size = %lld", src->content_size);
1.1591 + *size = src->content_size;
1.1592 + GST_LOG_OBJECT(src, "Content size = %lld", src->content_size);
1.1593
1.1594 - return ret;
1.1595 + return ret;
1.1596
1.1597 }
1.1598
1.1599 -/* close the socket and associated resources
1.1600 - * used both to recover from errors and go to NULL state */
1.1601 -static gboolean
1.1602 +/*
1.1603 + * close the socket and associated resources used both to recover from
1.1604 + * errors and go to NULL state
1.1605 + */
1.1606 +static gboolean
1.1607 gst_mythtv_src_stop(GstBaseSrc * bsrc)
1.1608 {
1.1609 - GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
1.1610 + GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
1.1611
1.1612 - gst_mythtv_src_clear(src);
1.1613 + gst_mythtv_src_clear(src);
1.1614
1.1615 - /* src->eos = FALSE; */
1.1616 + /*
1.1617 + * src->eos = FALSE;
1.1618 + */
1.1619
1.1620 - return TRUE;
1.1621 + return TRUE;
1.1622 }
1.1623
1.1624 -static gboolean
1.1625 +static gboolean
1.1626 gst_mythtv_src_handle_event(GstPad * pad, GstEvent * event)
1.1627 {
1.1628 - GstMythtvSrc *src = GST_MYTHTV_SRC(GST_PAD_PARENT(pad));
1.1629 - gint64 cont_size = 0;
1.1630 - gboolean ret = FALSE;
1.1631 + GstMythtvSrc *src = GST_MYTHTV_SRC(GST_PAD_PARENT(pad));
1.1632 + gint64 cont_size = 0;
1.1633 + gboolean ret = FALSE;
1.1634
1.1635 - switch (GST_EVENT_TYPE(event))
1.1636 - {
1.1637 - case GST_EVENT_EOS:
1.1638 - GST_WARNING_OBJECT(src, "Got EOS event");
1.1639 + switch (GST_EVENT_TYPE(event)) {
1.1640 + case GST_EVENT_EOS:
1.1641 + GST_WARNING_OBJECT(src, "Got EOS event");
1.1642
1.1643 - if (src->live_tv)
1.1644 - {
1.1645 - cont_size = gst_mythtv_src_get_position(src);
1.1646 - if (cont_size > src->content_size)
1.1647 - {
1.1648 - src->content_size = cont_size;
1.1649 - src->eos = FALSE;
1.1650 - }
1.1651 - else
1.1652 - {
1.1653 - src->eos = TRUE;
1.1654 - gst_element_set_state(GST_ELEMENT(src), GST_STATE_NULL);
1.1655 - gst_element_set_locked_state(GST_ELEMENT(src), FALSE);
1.1656 - }
1.1657 - }
1.1658 - break;
1.1659 - default:
1.1660 - ret = gst_pad_event_default(pad, event);
1.1661 - }
1.1662 + if (src->live_tv) {
1.1663 + cont_size = gst_mythtv_src_get_position(src);
1.1664 + if (cont_size > src->content_size) {
1.1665 + src->content_size = cont_size;
1.1666 + src->eos = FALSE;
1.1667 + } else {
1.1668 + src->eos = TRUE;
1.1669 + gst_element_set_state(GST_ELEMENT(src), GST_STATE_NULL);
1.1670 + gst_element_set_locked_state(GST_ELEMENT(src), FALSE);
1.1671 + }
1.1672 + }
1.1673 + break;
1.1674 + default:
1.1675 + ret = gst_pad_event_default(pad, event);
1.1676 + }
1.1677
1.1678 - return ret;
1.1679 + return ret;
1.1680 }
1.1681
1.1682 -static gboolean
1.1683 +static gboolean
1.1684 gst_mythtv_src_is_seekable(GstBaseSrc * push_src)
1.1685 {
1.1686 - return TRUE;
1.1687 + return TRUE;
1.1688 }
1.1689
1.1690 -static gboolean
1.1691 +static gboolean
1.1692 gst_mythtv_src_handle_query(GstPad * pad, GstQuery * query)
1.1693 {
1.1694 - gboolean res = FALSE;
1.1695 - GstMythtvSrc *myth = GST_MYTHTV_SRC(gst_pad_get_parent(pad));
1.1696 - GstFormat formt;
1.1697 + gboolean res = FALSE;
1.1698 + GstMythtvSrc *myth = GST_MYTHTV_SRC(gst_pad_get_parent(pad));
1.1699 + GstFormat formt;
1.1700
1.1701
1.1702 - switch (GST_QUERY_TYPE(query))
1.1703 - {
1.1704 - case GST_QUERY_POSITION:
1.1705 - {
1.1706 - gst_query_parse_position(query, &formt, NULL);
1.1707 - if (formt == GST_FORMAT_BYTES)
1.1708 - {
1.1709 - gst_query_set_position(query, formt, myth->read_offset);
1.1710 - GST_DEBUG_OBJECT(myth, "POS %" G_GINT64_FORMAT,
1.1711 - myth->read_offset);
1.1712 - res = TRUE;
1.1713 - }
1.1714 - else if (formt == GST_FORMAT_TIME)
1.1715 - {
1.1716 - res = gst_pad_query_default(pad, query);
1.1717 - }
1.1718 - break;
1.1719 - }
1.1720 - case GST_QUERY_DURATION:
1.1721 - {
1.1722 - gst_query_parse_duration(query, &formt, NULL);
1.1723 - if (formt == GST_FORMAT_BYTES)
1.1724 - {
1.1725 - gint64 size = myth->content_size;
1.1726 - gst_query_set_duration(query, GST_FORMAT_BYTES, 10);
1.1727 - GST_DEBUG_OBJECT(myth, "SIZE %" G_GINT64_FORMAT, size);
1.1728 - res = TRUE;
1.1729 - }
1.1730 - else if (formt == GST_FORMAT_TIME)
1.1731 - {
1.1732 - res = gst_pad_query_default(pad, query);
1.1733 - }
1.1734 - break;
1.1735 - }
1.1736 - default:
1.1737 - {
1.1738 - res = gst_pad_query_default(pad, query);
1.1739 - break;
1.1740 - }
1.1741 - }
1.1742 + switch (GST_QUERY_TYPE(query)) {
1.1743 + case GST_QUERY_POSITION:
1.1744 + {
1.1745 + gst_query_parse_position(query, &formt, NULL);
1.1746 + if (formt == GST_FORMAT_BYTES) {
1.1747 + gst_query_set_position(query, formt, myth->read_offset);
1.1748 + GST_DEBUG_OBJECT(myth, "POS %" G_GINT64_FORMAT,
1.1749 + myth->read_offset);
1.1750 + res = TRUE;
1.1751 + } else if (formt == GST_FORMAT_TIME) {
1.1752 + res = gst_pad_query_default(pad, query);
1.1753 + }
1.1754 + break;
1.1755 + }
1.1756 + case GST_QUERY_DURATION:
1.1757 + {
1.1758 + gst_query_parse_duration(query, &formt, NULL);
1.1759 + if (formt == GST_FORMAT_BYTES) {
1.1760 + gint64 size = myth->content_size;
1.1761 + gst_query_set_duration(query, GST_FORMAT_BYTES, 10);
1.1762 + GST_DEBUG_OBJECT(myth, "SIZE %" G_GINT64_FORMAT, size);
1.1763 + res = TRUE;
1.1764 + } else if (formt == GST_FORMAT_TIME) {
1.1765 + res = gst_pad_query_default(pad, query);
1.1766 + }
1.1767 + break;
1.1768 + }
1.1769 + default:
1.1770 + {
1.1771 + res = gst_pad_query_default(pad, query);
1.1772 + break;
1.1773 + }
1.1774 + }
1.1775
1.1776 - gst_object_unref(myth);
1.1777 + gst_object_unref(myth);
1.1778
1.1779 - return res;
1.1780 + return res;
1.1781 }
1.1782
1.1783 -static GstStateChangeReturn
1.1784 -gst_mythtv_src_change_state(GstElement * element, GstStateChange transition)
1.1785 +static GstStateChangeReturn
1.1786 +gst_mythtv_src_change_state(GstElement * element,
1.1787 + GstStateChange transition)
1.1788 {
1.1789 - GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
1.1790 - GstMythtvSrc *src = GST_MYTHTV_SRC(element);
1.1791 + GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
1.1792 + GstMythtvSrc *src = GST_MYTHTV_SRC(element);
1.1793
1.1794 - switch (transition)
1.1795 - {
1.1796 - case GST_STATE_CHANGE_NULL_TO_READY:
1.1797 - break;
1.1798 - case GST_STATE_CHANGE_READY_TO_PAUSED:
1.1799 - case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
1.1800 - if (src->live_tv)
1.1801 - {
1.1802 - if (!gmyth_recorder_send_frontend_ready_command(src->spawn_livetv->
1.1803 - recorder))
1.1804 - GST_WARNING_OBJECT(src,
1.1805 - "Couldn't send the FRONTEND_READY message to the backend!");
1.1806 - else
1.1807 - GST_DEBUG_OBJECT(src, "FRONTEND_READY was sent to the backend");
1.1808 - }
1.1809 - break;
1.1810 - default:
1.1811 - break;
1.1812 - }
1.1813 + switch (transition) {
1.1814 + case GST_STATE_CHANGE_NULL_TO_READY:
1.1815 + break;
1.1816 + case GST_STATE_CHANGE_READY_TO_PAUSED:
1.1817 + case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
1.1818 + if (src->live_tv) {
1.1819 + if (!gmyth_recorder_send_frontend_ready_command
1.1820 + (src->spawn_livetv->recorder))
1.1821 + GST_WARNING_OBJECT(src,
1.1822 + "Couldn't send the FRONTEND_READY message to the backend!");
1.1823 + else
1.1824 + GST_DEBUG_OBJECT(src,
1.1825 + "FRONTEND_READY was sent to the backend");
1.1826 + }
1.1827 + break;
1.1828 + default:
1.1829 + break;
1.1830 + }
1.1831
1.1832
1.1833 - ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
1.1834 - if (ret == GST_STATE_CHANGE_FAILURE)
1.1835 - return ret;
1.1836 + ret =
1.1837 + GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
1.1838 + if (ret == GST_STATE_CHANGE_FAILURE)
1.1839 + return ret;
1.1840
1.1841
1.1842 - switch (transition)
1.1843 - {
1.1844 - case GST_STATE_CHANGE_READY_TO_NULL:
1.1845 - gst_mythtv_src_clear(src);
1.1846 - break;
1.1847 - case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
1.1848 - case GST_STATE_CHANGE_PAUSED_TO_READY:
1.1849 - break;
1.1850 - default:
1.1851 - break;
1.1852 - }
1.1853 + switch (transition) {
1.1854 + case GST_STATE_CHANGE_READY_TO_NULL:
1.1855 + gst_mythtv_src_clear(src);
1.1856 + break;
1.1857 + case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
1.1858 + case GST_STATE_CHANGE_PAUSED_TO_READY:
1.1859 + break;
1.1860 + default:
1.1861 + break;
1.1862 + }
1.1863
1.1864 - return ret;
1.1865 + return ret;
1.1866 }
1.1867
1.1868 static void
1.1869 gst_mythtv_src_set_property(GObject * object, guint prop_id,
1.1870 - const GValue * value, GParamSpec * pspec)
1.1871 + const GValue * value, GParamSpec * pspec)
1.1872 {
1.1873 - GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC(object);
1.1874 + GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC(object);
1.1875
1.1876 - GST_OBJECT_LOCK(mythtvsrc);
1.1877 - switch (prop_id)
1.1878 - {
1.1879 - case PROP_LOCATION:
1.1880 - {
1.1881 - if (!g_value_get_string(value))
1.1882 - {
1.1883 - GST_WARNING("location property cannot be NULL");
1.1884 - break;
1.1885 - }
1.1886 + GST_OBJECT_LOCK(mythtvsrc);
1.1887 + switch (prop_id) {
1.1888 + case PROP_LOCATION:
1.1889 + {
1.1890 + if (!g_value_get_string(value)) {
1.1891 + GST_WARNING("location property cannot be NULL");
1.1892 + break;
1.1893 + }
1.1894
1.1895 - if (mythtvsrc->uri_name != NULL)
1.1896 - {
1.1897 - g_free(mythtvsrc->uri_name);
1.1898 - mythtvsrc->uri_name = NULL;
1.1899 - }
1.1900 - mythtvsrc->uri_name = g_value_dup_string(value);
1.1901 + if (mythtvsrc->uri_name != NULL) {
1.1902 + g_free(mythtvsrc->uri_name);
1.1903 + mythtvsrc->uri_name = NULL;
1.1904 + }
1.1905 + mythtvsrc->uri_name = g_value_dup_string(value);
1.1906
1.1907 - break;
1.1908 - }
1.1909 + break;
1.1910 + }
1.1911 #ifndef GST_DISABLE_GST_DEBUG
1.1912 - case PROP_GMYTHTV_DBG:
1.1913 - {
1.1914 - mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean(value);
1.1915 - break;
1.1916 - }
1.1917 + case PROP_GMYTHTV_DBG:
1.1918 + {
1.1919 + mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean(value);
1.1920 + break;
1.1921 + }
1.1922 #endif
1.1923 - case PROP_GMYTHTV_VERSION:
1.1924 - {
1.1925 - mythtvsrc->mythtv_version = g_value_get_int(value);
1.1926 - break;
1.1927 - }
1.1928 - case PROP_GMYTHTV_LIVEID:
1.1929 - {
1.1930 - mythtvsrc->live_tv_id = g_value_get_int(value);
1.1931 - break;
1.1932 - }
1.1933 - case PROP_GMYTHTV_LIVE:
1.1934 - {
1.1935 - mythtvsrc->live_tv = g_value_get_boolean(value);
1.1936 - break;
1.1937 - }
1.1938 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.1939 - {
1.1940 - mythtvsrc->enable_timing_position = g_value_get_boolean(value);
1.1941 - break;
1.1942 - }
1.1943 - case PROP_GMYTHTV_LIVE_CHAINID:
1.1944 - {
1.1945 - if (!g_value_get_string(value))
1.1946 - {
1.1947 - GST_WARNING("MythTV Live chainid property cannot be NULL");
1.1948 - break;
1.1949 - }
1.1950 + case PROP_GMYTHTV_VERSION:
1.1951 + {
1.1952 + mythtvsrc->mythtv_version = g_value_get_int(value);
1.1953 + break;
1.1954 + }
1.1955 + case PROP_GMYTHTV_LIVEID:
1.1956 + {
1.1957 + mythtvsrc->live_tv_id = g_value_get_int(value);
1.1958 + break;
1.1959 + }
1.1960 + case PROP_GMYTHTV_LIVE:
1.1961 + {
1.1962 + mythtvsrc->live_tv = g_value_get_boolean(value);
1.1963 + break;
1.1964 + }
1.1965 + case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.1966 + {
1.1967 + mythtvsrc->enable_timing_position = g_value_get_boolean(value);
1.1968 + break;
1.1969 + }
1.1970 + case PROP_GMYTHTV_LIVE_CHAINID:
1.1971 + {
1.1972 + if (!g_value_get_string(value)) {
1.1973 + GST_WARNING("MythTV Live chainid property cannot be NULL");
1.1974 + break;
1.1975 + }
1.1976
1.1977 - if (mythtvsrc->live_chain_id != NULL)
1.1978 - {
1.1979 - g_free(mythtvsrc->live_chain_id);
1.1980 - mythtvsrc->live_chain_id = NULL;
1.1981 - }
1.1982 - mythtvsrc->live_chain_id = g_value_dup_string(value);
1.1983 - break;
1.1984 - }
1.1985 - case PROP_GMYTHTV_CHANNEL_NUM:
1.1986 - {
1.1987 - mythtvsrc->channel_name = g_value_dup_string(value);
1.1988 - break;
1.1989 - }
1.1990 - case PROP_GMYTHTV_MAX_TRY:
1.1991 - {
1.1992 - mythtvsrc->max_try = g_value_get_int(value);
1.1993 - break;
1.1994 - }
1.1995 - default:
1.1996 - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1.1997 - break;
1.1998 - }
1.1999 + if (mythtvsrc->live_chain_id != NULL) {
1.2000 + g_free(mythtvsrc->live_chain_id);
1.2001 + mythtvsrc->live_chain_id = NULL;
1.2002 + }
1.2003 + mythtvsrc->live_chain_id = g_value_dup_string(value);
1.2004 + break;
1.2005 + }
1.2006 + case PROP_GMYTHTV_CHANNEL_NUM:
1.2007 + {
1.2008 + mythtvsrc->channel_name = g_value_dup_string(value);
1.2009 + break;
1.2010 + }
1.2011 + case PROP_GMYTHTV_MAX_TRY:
1.2012 + {
1.2013 + mythtvsrc->max_try = g_value_get_int(value);
1.2014 + break;
1.2015 + }
1.2016 + default:
1.2017 + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1.2018 + break;
1.2019 + }
1.2020
1.2021 - GST_OBJECT_UNLOCK(mythtvsrc);
1.2022 + GST_OBJECT_UNLOCK(mythtvsrc);
1.2023 }
1.2024
1.2025 static void
1.2026 gst_mythtv_src_get_property(GObject * object, guint prop_id,
1.2027 - GValue * value, GParamSpec * pspec)
1.2028 + GValue * value, GParamSpec * pspec)
1.2029 {
1.2030 - GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC(object);
1.2031 + GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC(object);
1.2032
1.2033 - GST_OBJECT_LOCK(mythtvsrc);
1.2034 - switch (prop_id)
1.2035 - {
1.2036 - case PROP_LOCATION:
1.2037 - {
1.2038 - g_value_set_string(value, mythtvsrc->uri_name);
1.2039 - break;
1.2040 - }
1.2041 + GST_OBJECT_LOCK(mythtvsrc);
1.2042 + switch (prop_id) {
1.2043 + case PROP_LOCATION:
1.2044 + {
1.2045 + g_value_set_string(value, mythtvsrc->uri_name);
1.2046 + break;
1.2047 + }
1.2048 #ifndef GST_DISABLE_GST_DEBUG
1.2049 - case PROP_GMYTHTV_DBG:
1.2050 - g_value_set_boolean(value, mythtvsrc->mythtv_msgs_dbg);
1.2051 - break;
1.2052 + case PROP_GMYTHTV_DBG:
1.2053 + g_value_set_boolean(value, mythtvsrc->mythtv_msgs_dbg);
1.2054 + break;
1.2055 #endif
1.2056 - case PROP_GMYTHTV_VERSION:
1.2057 - {
1.2058 - g_value_set_int(value, mythtvsrc->mythtv_version);
1.2059 - break;
1.2060 - }
1.2061 - case PROP_GMYTHTV_LIVEID:
1.2062 - {
1.2063 - g_value_set_int(value, mythtvsrc->live_tv_id);
1.2064 - break;
1.2065 - }
1.2066 - case PROP_GMYTHTV_LIVE:
1.2067 - g_value_set_boolean(value, mythtvsrc->live_tv);
1.2068 - break;
1.2069 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.2070 - g_value_set_boolean(value, mythtvsrc->enable_timing_position);
1.2071 - break;
1.2072 - case PROP_GMYTHTV_LIVE_CHAINID:
1.2073 - {
1.2074 - g_value_set_string(value, mythtvsrc->live_chain_id);
1.2075 - break;
1.2076 - }
1.2077 - case PROP_GMYTHTV_CHANNEL_NUM:
1.2078 - {
1.2079 - g_value_set_string(value, mythtvsrc->channel_name);
1.2080 - break;
1.2081 - }
1.2082 - case PROP_GMYTHTV_MAX_TRY:
1.2083 - {
1.2084 - g_value_set_int(value, mythtvsrc->max_try);
1.2085 - break;
1.2086 - }
1.2087 + case PROP_GMYTHTV_VERSION:
1.2088 + {
1.2089 + g_value_set_int(value, mythtvsrc->mythtv_version);
1.2090 + break;
1.2091 + }
1.2092 + case PROP_GMYTHTV_LIVEID:
1.2093 + {
1.2094 + g_value_set_int(value, mythtvsrc->live_tv_id);
1.2095 + break;
1.2096 + }
1.2097 + case PROP_GMYTHTV_LIVE:
1.2098 + g_value_set_boolean(value, mythtvsrc->live_tv);
1.2099 + break;
1.2100 + case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.2101 + g_value_set_boolean(value, mythtvsrc->enable_timing_position);
1.2102 + break;
1.2103 + case PROP_GMYTHTV_LIVE_CHAINID:
1.2104 + {
1.2105 + g_value_set_string(value, mythtvsrc->live_chain_id);
1.2106 + break;
1.2107 + }
1.2108 + case PROP_GMYTHTV_CHANNEL_NUM:
1.2109 + {
1.2110 + g_value_set_string(value, mythtvsrc->channel_name);
1.2111 + break;
1.2112 + }
1.2113 + case PROP_GMYTHTV_MAX_TRY:
1.2114 + {
1.2115 + g_value_set_int(value, mythtvsrc->max_try);
1.2116 + break;
1.2117 + }
1.2118
1.2119 - default:
1.2120 - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1.2121 - break;
1.2122 - }
1.2123 - GST_OBJECT_UNLOCK(mythtvsrc);
1.2124 + default:
1.2125 + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1.2126 + break;
1.2127 + }
1.2128 + GST_OBJECT_UNLOCK(mythtvsrc);
1.2129 }
1.2130
1.2131 -static gboolean
1.2132 +static gboolean
1.2133 plugin_init(GstPlugin * plugin)
1.2134 {
1.2135 - return gst_element_register(plugin, "mythtvsrc", GST_RANK_NONE,
1.2136 - GST_TYPE_MYTHTV_SRC);
1.2137 + return gst_element_register(plugin, "mythtvsrc", GST_RANK_NONE,
1.2138 + GST_TYPE_MYTHTV_SRC);
1.2139 }
1.2140
1.2141 GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,
1.2142 - GST_VERSION_MINOR,
1.2143 - "mythtv",
1.2144 - "lib MythTV src",
1.2145 - plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,
1.2146 - GST_PACKAGE_ORIGIN);
1.2147 + GST_VERSION_MINOR,
1.2148 + "mythtv",
1.2149 + "lib MythTV src",
1.2150 + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,
1.2151 + GST_PACKAGE_ORIGIN);
1.2152
1.2153
1.2154 /*** GSTURIHANDLER INTERFACE *************************************************/
1.2155 -static guint
1.2156 +static guint
1.2157 gst_mythtv_src_uri_get_type(void)
1.2158 {
1.2159 - return GST_URI_SRC;
1.2160 + return GST_URI_SRC;
1.2161 }
1.2162
1.2163 -static gchar **
1.2164 +static gchar **
1.2165 gst_mythtv_src_uri_get_protocols(void)
1.2166 {
1.2167 - static gchar *protocols[] = { "myth", "myths", NULL };
1.2168 + static gchar *protocols[] = { "myth", "myths", NULL };
1.2169
1.2170 - return protocols;
1.2171 + return protocols;
1.2172 }
1.2173
1.2174 static const gchar *
1.2175 gst_mythtv_src_uri_get_uri(GstURIHandler * handler)
1.2176 {
1.2177 - GstMythtvSrc *src = GST_MYTHTV_SRC(handler);
1.2178 + GstMythtvSrc *src = GST_MYTHTV_SRC(handler);
1.2179
1.2180 - return src->uri_name;
1.2181 + return src->uri_name;
1.2182 }
1.2183
1.2184 -static gboolean
1.2185 +static gboolean
1.2186 gst_mythtv_src_uri_set_uri(GstURIHandler * handler, const gchar * uri)
1.2187 {
1.2188 - GstMythtvSrc *src = GST_MYTHTV_SRC(handler);
1.2189 + GstMythtvSrc *src = GST_MYTHTV_SRC(handler);
1.2190
1.2191 - gchar *protocol;
1.2192 + gchar *protocol;
1.2193
1.2194 - protocol = gst_uri_get_protocol(uri);
1.2195 - if ((strcmp(protocol, "myth") != 0) && (strcmp(protocol, "myths") != 0))
1.2196 - {
1.2197 - g_free(protocol);
1.2198 - return FALSE;
1.2199 - }
1.2200 - g_free(protocol);
1.2201 - g_object_set(src, "location", uri, NULL);
1.2202 + protocol = gst_uri_get_protocol(uri);
1.2203 + if ((strcmp(protocol, "myth") != 0)
1.2204 + && (strcmp(protocol, "myths") != 0)) {
1.2205 + g_free(protocol);
1.2206 + return FALSE;
1.2207 + }
1.2208 + g_free(protocol);
1.2209 + g_object_set(src, "location", uri, NULL);
1.2210
1.2211 - return TRUE;
1.2212 + return TRUE;
1.2213 }
1.2214
1.2215 static void
1.2216 gst_mythtv_src_uri_handler_init(gpointer g_iface, gpointer iface_data)
1.2217 {
1.2218 - GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
1.2219 + GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
1.2220
1.2221 - iface->get_type = gst_mythtv_src_uri_get_type;
1.2222 - iface->get_protocols = gst_mythtv_src_uri_get_protocols;
1.2223 - iface->get_uri = gst_mythtv_src_uri_get_uri;
1.2224 - iface->set_uri = gst_mythtv_src_uri_set_uri;
1.2225 + iface->get_type = gst_mythtv_src_uri_get_type;
1.2226 + iface->get_protocols = gst_mythtv_src_uri_get_protocols;
1.2227 + iface->get_uri = gst_mythtv_src_uri_get_uri;
1.2228 + iface->set_uri = gst_mythtv_src_uri_set_uri;
1.2229 }
1.2230
1.2231 void
1.2232 size_header_handler(void *userdata, const char *value)
1.2233 {
1.2234 - GstMythtvSrc *src = GST_MYTHTV_SRC(userdata);
1.2235 + GstMythtvSrc *src = GST_MYTHTV_SRC(userdata);
1.2236
1.2237 - GST_DEBUG_OBJECT(src, "content size = %lld bytes", src->content_size);
1.2238 + GST_DEBUG_OBJECT(src, "content size = %lld bytes", src->content_size);
1.2239 }