[svn r290] Removed some LiveTV function setup calls from the _start method.
1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Mon Jan 22 18:37:42 2007 +0000
1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Mon Jan 22 21:03:08 2007 +0000
1.3 @@ -1,27 +1,31 @@
1.4 -/* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2 -*- */
1.5 /* GStreamer MythTV Plug-in
1.6 * Copyright (C) <2006> Rosfran Borges <rosfran.borges@indt.org.br>
1.7 *
1.8 * This library is free software; you can redistribute it and/or
1.9 - * modify it under the terms of the GNU Library Lesser General
1.10 - * Public License as published by the Free Software Foundation; either
1.11 + * modify it under the terms of the GNU Library General Public
1.12 + * License as published by the Free Software Foundation; either
1.13 * version 2 of the License, or (at your option) any later version.
1.14 *
1.15 * This library is distributed in the hope that it will be useful,
1.16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.18 - * Library General Public License for more
1.19 + * Library General Public License for more details.
1.20 + *
1.21 + * You should have received a copy of the GNU Library General Public
1.22 + * License along with this library; if not, write to the
1.23 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1.24 + * Boston, MA 02111-1307, USA.
1.25 */
1.26 - /**
1.27 - * When using the LiveTV content, put the location URI in the following
1.28 - * format:
1.29 - *
1.30 - * myth://mythtv:mythtv@xxx.xxx.xxx.xxx:6543/?mythconverg
1.31 - *
1.32 - * Where the first field is the protocol (myth), the second and third are user
1.33 - * name (mythtv) and password (mythtv), then backend host name and port number,
1.34 - * and the last field is the database name (mythconverg).
1.35 - */
1.36 +/**
1.37 + * When using the LiveTV content, put the location URI in the following
1.38 + * format:
1.39 + *
1.40 + * myth://mythtv:mythtv@xxx.xxx.xxx.xxx:6543/?mythconverg
1.41 + *
1.42 + * Where the first field is the protocol (myth), the second and third are user
1.43 + * name (mythtv) and password (mythtv), then backend host name and port number,
1.44 + * and the last field is the database name (mythconverg).
1.45 + */
1.46
1.47 #ifdef HAVE_CONFIG_H
1.48 #include "config.h"
1.49 @@ -40,48 +44,42 @@
1.50 GST_DEBUG_CATEGORY_STATIC (mythtvsrc_debug);
1.51 #define GST_CAT_DEFAULT mythtvsrc_debug
1.52
1.53 -#define GST_GMYTHTV_ID_NUM 1
1.54 +#define GST_GMYTHTV_ID_NUM 1
1.55
1.56 -#define GST_GMYTHTV_CHANNEL_DEFAULT_NUM -1
1.57 +#define GST_GMYTHTV_CHANNEL_DEFAULT_NUM (-1)
1.58
1.59 -#define GMYTHTV_VERSION_DEFAULT 30
1.60 -
1.61 -#define GMYTHTV_TRANSFER_MAX_WAITS 100
1.62 +#define GMYTHTV_VERSION_DEFAULT 30
1.63
1.64 -#define GMYTHTV_TRANSFER_MAX_RESENDS 2
1.65 +#define GMYTHTV_TRANSFER_MAX_WAITS 100
1.66
1.67 -#define GMYTHTV_TRANSFER_MAX_BUFFER 128*1024
1.68 -//( 32*1024 )
1.69 +#define GMYTHTV_TRANSFER_MAX_RESENDS 2
1.70
1.71 -/* 4*1024 ??? */
1.72 -#define MAX_READ_SIZE 4*1024
1.73 -//( 32*1024 )
1.74 +#define GMYTHTV_TRANSFER_MAX_BUFFER (128*1024)
1.75
1.76 -#define GST_FLOW_ERROR_NO_DATA -101
1.77 +#define MAX_READ_SIZE (4*1024)
1.78
1.79 -#define REQUEST_MAX_SIZE 64*1024
1.80 +#define GST_FLOW_ERROR_NO_DATA (-101)
1.81
1.82 -#define INTERNAL_BUFFER_SIZE 90*1024
1.83 +#define REQUEST_MAX_SIZE (64*1024)
1.84
1.85 -/* stablish a maximum iteration value to the IS_RECORDING message */
1.86 -static guint wait_to_transfer = 0;
1.87 +#define INTERNAL_BUFFER_SIZE (90*1024)
1.88
1.89 static const GstElementDetails gst_mythtv_src_details =
1.90 -GST_ELEMENT_DETAILS ( "MythTV client source",
1.91 +GST_ELEMENT_DETAILS ("MythTV client source",
1.92 "Source/Network",
1.93 - "Control and receive data as a client over the network via raw socket connections using the MythTV protocol",
1.94 - "Rosfran Borges <rosfran.borges@indt.org.br>" );
1.95 + "Control and receive data as a client over the network "
1.96 + "via raw socket connections using the MythTV protocol",
1.97 + "Rosfran Borges <rosfran.borges@indt.org.br>");
1.98
1.99 -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ( "src",
1.100 +static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
1.101 GST_PAD_SRC,
1.102 GST_PAD_ALWAYS,
1.103 - GST_STATIC_CAPS ("video/x-nuv") );
1.104 -
1.105 + GST_STATIC_CAPS ("video/x-nuv"));
1.106 +
1.107 enum
1.108 {
1.109 PROP_0,
1.110 PROP_LOCATION,
1.111 - PROP_URI,
1.112 #ifndef GST_DISABLE_GST_DEBUG
1.113 PROP_GMYTHTV_DBG,
1.114 #endif
1.115 @@ -95,21 +93,18 @@
1.116
1.117 static void gst_mythtv_src_finalize (GObject * gobject);
1.118
1.119 -static GstFlowReturn gst_mythtv_src_create ( GstPushSrc* psrc, GstBuffer** outbuf );
1.120 +static GstFlowReturn gst_mythtv_src_create (GstPushSrc * psrc,
1.121 + GstBuffer ** outbuf);
1.122
1.123 static gboolean gst_mythtv_src_start (GstBaseSrc * bsrc);
1.124 static gboolean gst_mythtv_src_stop (GstBaseSrc * bsrc);
1.125 static gboolean gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size);
1.126 -static gboolean gst_mythtv_src_is_seekable( GstBaseSrc *push_src );
1.127 +static gboolean gst_mythtv_src_is_seekable (GstBaseSrc * push_src);
1.128
1.129 -/*
1.130 -static void gst_mythtv_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
1.131 - GstClockTime * start, GstClockTime * end);
1.132 -*/
1.133 +static gboolean gst_mythtv_src_do_seek (GstBaseSrc * base,
1.134 + GstSegment * segment);
1.135
1.136 -static gboolean gst_mythtv_src_do_seek( GstBaseSrc *base, GstSegment *segment );
1.137 -
1.138 -static gboolean gst_mythtv_src_next_program_chain ( GstMythtvSrc *src );
1.139 +static gboolean gst_mythtv_src_next_program_chain (GstMythtvSrc * src);
1.140
1.141 static GstStateChangeReturn
1.142 gst_mythtv_src_change_state (GstElement * element, GstStateChange transition);
1.143 @@ -119,15 +114,15 @@
1.144 static void gst_mythtv_src_get_property (GObject * object, guint prop_id,
1.145 GValue * value, GParamSpec * pspec);
1.146
1.147 -static void gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data);
1.148 +static void gst_mythtv_src_uri_handler_init (gpointer g_iface,
1.149 + gpointer iface_data);
1.150
1.151 static gboolean gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query);
1.152
1.153 static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event);
1.154
1.155 -static gint do_read_request_response (GstMythtvSrc * src, guint size, GByteArray *data_ptr);
1.156 -
1.157 -GStaticRecMutex th_mutex = G_STATIC_REC_MUTEX_INIT;
1.158 +static gint do_read_request_response (GstMythtvSrc * src, guint size,
1.159 + GByteArray * data_ptr);
1.160
1.161 static void
1.162 _urihandler_init (GType type)
1.163 @@ -140,31 +135,29 @@
1.164
1.165 g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
1.166
1.167 - GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
1.168 - "MythTV src");
1.169 + GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0, "MythTV src");
1.170 }
1.171
1.172 GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstPushSrc,
1.173 GST_TYPE_PUSH_SRC, _urihandler_init)
1.174 -
1.175 -static void
1.176 -gst_mythtv_src_base_init (gpointer g_class)
1.177 +
1.178 + static void gst_mythtv_src_base_init (gpointer g_class)
1.179 {
1.180 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
1.181
1.182 gst_element_class_add_pad_template (element_class,
1.183 gst_static_pad_template_get (&srctemplate));
1.184 -
1.185 +
1.186 gst_element_class_set_details (element_class, &gst_mythtv_src_details);
1.187 -
1.188 +
1.189 element_class->change_state = gst_mythtv_src_change_state;
1.190 -
1.191 +
1.192 }
1.193
1.194 static void
1.195 gst_mythtv_src_class_init (GstMythtvSrcClass * klass)
1.196 {
1.197 - GObjectClass *gobject_class;
1.198 + GObjectClass *gobject_class;
1.199 GstPushSrcClass *gstpushsrc_class;
1.200 GstBaseSrcClass *gstbasesrc_class;
1.201
1.202 @@ -177,74 +170,63 @@
1.203 gobject_class->finalize = gst_mythtv_src_finalize;
1.204
1.205 g_object_class_install_property
1.206 - (gobject_class, PROP_LOCATION,
1.207 - g_param_spec_string ("location", "Location",
1.208 - "The location. In the form:"
1.209 - "\n\t\t\tmyth://a.com/file.nuv"
1.210 - "\n\t\t\tmyth://a.com:23223/file.nuv "
1.211 - "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
1.212 - "", G_PARAM_READWRITE));
1.213 + (gobject_class, PROP_LOCATION,
1.214 + g_param_spec_string ("location", "Location",
1.215 + "The location. In the form:"
1.216 + "\n\t\t\tmyth://a.com/file.nuv"
1.217 + "\n\t\t\tmyth://a.com:23223/file.nuv "
1.218 + "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
1.219 + "", G_PARAM_READWRITE));
1.220
1.221 g_object_class_install_property
1.222 - (gobject_class, PROP_URI,
1.223 - g_param_spec_string ("uri", "Uri",
1.224 - "The location in form of a URI (deprecated; use location)",
1.225 - "", G_PARAM_READWRITE));
1.226 + (gobject_class, PROP_GMYTHTV_VERSION,
1.227 + g_param_spec_int ("mythtv-version", "mythtv-version",
1.228 + "Change MythTV version", 26, 30, 26, G_PARAM_READWRITE));
1.229
1.230 g_object_class_install_property
1.231 - (gobject_class, PROP_GMYTHTV_VERSION,
1.232 - g_param_spec_int ("mythtv-version", "mythtv-version",
1.233 - "Change MythTV version",
1.234 - 26, 30, 26, G_PARAM_READWRITE));
1.235 + (gobject_class, PROP_GMYTHTV_LIVEID,
1.236 + g_param_spec_int ("mythtv-live-id", "mythtv-live-id",
1.237 + "Change MythTV version",
1.238 + 0, 200, GST_GMYTHTV_ID_NUM, G_PARAM_READWRITE));
1.239
1.240 g_object_class_install_property
1.241 - (gobject_class, PROP_GMYTHTV_LIVEID,
1.242 - g_param_spec_int ("mythtv-live-id", "mythtv-live-id",
1.243 - "Change MythTV version",
1.244 - 0, 200, GST_GMYTHTV_ID_NUM, G_PARAM_READWRITE));
1.245 + (gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
1.246 + g_param_spec_string ("mythtv-live-chainid", "mythtv-live-chainid",
1.247 + "Sets the MythTV chain ID (from TV Chain)", "", G_PARAM_READWRITE));
1.248
1.249 g_object_class_install_property
1.250 - (gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
1.251 - g_param_spec_string ("mythtv-live-chainid", "mythtv-live-chainid",
1.252 - "Sets the MythTV chain ID (from TV Chain)",
1.253 - "", G_PARAM_READWRITE));
1.254 + (gobject_class, PROP_GMYTHTV_LIVE,
1.255 + g_param_spec_boolean ("mythtv-live", "mythtv-live",
1.256 + "Enable MythTV Live TV content streaming", FALSE, G_PARAM_READWRITE));
1.257
1.258 g_object_class_install_property
1.259 - (gobject_class, PROP_GMYTHTV_LIVE,
1.260 - g_param_spec_boolean ("mythtv-live", "mythtv-live",
1.261 - "Enable MythTV Live TV content streaming",
1.262 - FALSE, G_PARAM_READWRITE));
1.263 + (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
1.264 + g_param_spec_boolean ("mythtv-enable-timing-position",
1.265 + "mythtv-enable-timing-position",
1.266 + "Enable MythTV Live TV content size continuous updating", FALSE,
1.267 + G_PARAM_READWRITE));
1.268
1.269 g_object_class_install_property
1.270 - (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
1.271 - g_param_spec_boolean ("mythtv-enable-timing-position", "mythtv-enable-timing-position",
1.272 - "Enable MythTV Live TV content size continuous updating",
1.273 - FALSE, G_PARAM_READWRITE));
1.274 -
1.275 - g_object_class_install_property
1.276 - (gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
1.277 - g_param_spec_int ("mythtv-channel", "mythtv-channel",
1.278 - "Change MythTV channel number",
1.279 - -1, 99999, GST_GMYTHTV_CHANNEL_DEFAULT_NUM, G_PARAM_READWRITE));
1.280 + (gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
1.281 + g_param_spec_int ("mythtv-channel", "mythtv-channel",
1.282 + "Change MythTV channel number",
1.283 + -1, 99999, GST_GMYTHTV_CHANNEL_DEFAULT_NUM, G_PARAM_READWRITE));
1.284
1.285 #ifndef GST_DISABLE_GST_DEBUG
1.286 g_object_class_install_property
1.287 - (gobject_class, PROP_GMYTHTV_DBG,
1.288 - g_param_spec_boolean ("mythtv-debug", "mythtv-debug",
1.289 - "Enable MythTV debug messages",
1.290 - FALSE, G_PARAM_READWRITE));
1.291 + (gobject_class, PROP_GMYTHTV_DBG,
1.292 + g_param_spec_boolean ("mythtv-debug", "mythtv-debug",
1.293 + "Enable MythTV debug messages", FALSE, G_PARAM_READWRITE));
1.294 #endif
1.295
1.296 gstbasesrc_class->start = gst_mythtv_src_start;
1.297 gstbasesrc_class->stop = gst_mythtv_src_stop;
1.298 gstbasesrc_class->get_size = gst_mythtv_src_get_size;
1.299 gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable;
1.300 -
1.301 - //gstbasesrc_class->get_times = gst_mythtv_src_get_times;
1.302 -
1.303 +
1.304 gstbasesrc_class->do_seek = gst_mythtv_src_do_seek;
1.305 gstpushsrc_class->create = gst_mythtv_src_create;
1.306 -
1.307 +
1.308 GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
1.309 "MythTV Client Source");
1.310 }
1.311 @@ -257,11 +239,11 @@
1.312 this->unique_setup = FALSE;
1.313
1.314 this->mythtv_version = GMYTHTV_VERSION_DEFAULT;
1.315 -
1.316 +
1.317 this->state = GST_MYTHTV_SRC_FILE_TRANSFER;
1.318
1.319 this->bytes_read = 0;
1.320 -
1.321 +
1.322 this->prev_content_size = 0;
1.323
1.324 this->content_size = 0;
1.325 @@ -270,30 +252,28 @@
1.326 this->content_size_last = 0;
1.327
1.328 this->live_tv = FALSE;
1.329 -
1.330 +
1.331 this->enable_timing_position = FALSE;
1.332 - this->update_prog_chain = FALSE;
1.333 + this->update_prog_chain = FALSE;
1.334
1.335 this->user_agent = g_strdup ("mythtvsrc");
1.336 this->mythtv_caps = NULL;
1.337 this->update_prog_chain = FALSE;
1.338 -
1.339 +
1.340 this->channel_num = GST_GMYTHTV_CHANNEL_DEFAULT_NUM;
1.341 -
1.342 +
1.343 this->eos = FALSE;
1.344 -
1.345 +
1.346 this->bytes_queue = NULL;
1.347 -
1.348 - this->th_mutex = NULL;
1.349 -
1.350 - gst_base_src_set_format( GST_BASE_SRC( this ), GST_FORMAT_BYTES );
1.351
1.352 - /* gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE ); */
1.353 -
1.354 - gst_pad_set_event_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
1.355 - gst_mythtv_src_handle_event );
1.356 - gst_pad_set_query_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
1.357 - gst_mythtv_src_handle_query );
1.358 + this->wait_to_transfer = 0;
1.359 +
1.360 + gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_BYTES);
1.361 +
1.362 + gst_pad_set_event_function (GST_BASE_SRC_PAD (GST_BASE_SRC (this)),
1.363 + gst_mythtv_src_handle_event);
1.364 + gst_pad_set_query_function (GST_BASE_SRC_PAD (GST_BASE_SRC (this)),
1.365 + gst_mythtv_src_handle_query);
1.366
1.367 }
1.368
1.369 @@ -316,7 +296,7 @@
1.370 g_object_unref (this->spawn_livetv);
1.371 this->spawn_livetv = NULL;
1.372 }
1.373 -
1.374 +
1.375 if (this->backend_info) {
1.376 g_object_unref (this->backend_info);
1.377 this->backend_info = NULL;
1.378 @@ -330,8 +310,8 @@
1.379 g_free (this->user_agent);
1.380 }
1.381
1.382 - if ( this->bytes_queue ) {
1.383 - g_byte_array_free( this->bytes_queue, TRUE );
1.384 + if (this->bytes_queue) {
1.385 + g_byte_array_free (this->bytes_queue, TRUE);
1.386 this->bytes_queue = NULL;
1.387 }
1.388
1.389 @@ -339,55 +319,51 @@
1.390 }
1.391
1.392 static gint
1.393 -do_read_request_response (GstMythtvSrc * src, guint size, GByteArray *data_ptr)
1.394 +do_read_request_response (GstMythtvSrc * src, guint size, GByteArray * data_ptr)
1.395 {
1.396 gint read = 0;
1.397 guint sizetoread = size;
1.398 gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
1.399 -
1.400 - GST_LOG_OBJECT( src, "Starting: [%s] Reading %d bytes...\n", __FUNCTION__, sizetoread );
1.401 +
1.402 + GST_LOG_OBJECT (src, "Starting: Reading %d bytes...", sizetoread);
1.403
1.404 /* Loop sending the Myth File Transfer request:
1.405 * Retry whilst authentication fails and we supply it. */
1.406 gint len = 0;
1.407 -
1.408 - while ( sizetoread == size && --max_iters > 0) {
1.409
1.410 - len = gmyth_file_transfer_read( src->file_transfer,
1.411 - data_ptr, sizetoread, TRUE );
1.412 + while (sizetoread == size && --max_iters > 0) {
1.413
1.414 - if ( len > 0 ) {
1.415 + len = gmyth_file_transfer_read (src->file_transfer,
1.416 + data_ptr, sizetoread, TRUE);
1.417 +
1.418 + if (len > 0) {
1.419 read += len;
1.420 sizetoread -= len;
1.421 - }
1.422 - else if ( len < 0 )
1.423 - {
1.424 + } else if (len < 0) {
1.425
1.426 - if ( src->live_tv == FALSE )
1.427 - {
1.428 - read = -1;
1.429 - goto eos;
1.430 - }
1.431 - else
1.432 - {
1.433 - if ( len == GMYTHTV_FILE_TRANSFER_READ_ERROR ) { /* -314 */
1.434 - GST_INFO_OBJECT( src, "[%s] [LiveTV] FileTransfer READ_ERROR!\n", __FUNCTION__ );
1.435 - goto done;
1.436 - } else if ( len == GMYTHTV_FILE_TRANSFER_NEXT_PROG_CHAIN ) { /* -315 */
1.437 - GST_INFO_OBJECT( src, "[%s] [LiveTV] FileTransfer - Go to the next program chain!\n", __FUNCTION__ );
1.438 - continue;
1.439 - }
1.440 - goto done;
1.441 + if (src->live_tv == FALSE) {
1.442 + read = -1;
1.443 + goto eos;
1.444 + } else {
1.445 + if (len == GMYTHTV_FILE_TRANSFER_READ_ERROR) { /* -314 */
1.446 + GST_INFO_OBJECT (src, "[LiveTV] FileTransfer READ_ERROR!");
1.447 + goto done;
1.448 + } else if (len == GMYTHTV_FILE_TRANSFER_NEXT_PROG_CHAIN) { /* -315 */
1.449 + GST_INFO_OBJECT (src,
1.450 + "[LiveTV] FileTransfer - Go to the next program chain!");
1.451 + continue;
1.452 + }
1.453 + goto done;
1.454 }
1.455
1.456 - } else if ( len == 0 )
1.457 - goto done;
1.458 + } else if (len == 0)
1.459 + goto done;
1.460
1.461 - if ( read == sizetoread )
1.462 + if (read == sizetoread)
1.463 goto done;
1.464 }
1.465
1.466 - if ( ( read < 0 && !src->live_tv ) || max_iters == 0 )
1.467 + if ((read < 0 && !src->live_tv) || max_iters == 0)
1.468 goto eos;
1.469
1.470 goto done;
1.471 @@ -400,108 +376,117 @@
1.472 }
1.473
1.474 static GstFlowReturn
1.475 -gst_mythtv_src_create ( GstPushSrc* psrc, GstBuffer** outbuf )
1.476 +gst_mythtv_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
1.477 {
1.478 GstMythtvSrc *src;
1.479 GstFlowReturn ret = GST_FLOW_OK;
1.480 gint read = -1;
1.481
1.482 - src = GST_MYTHTV_SRC ( psrc );
1.483 + src = GST_MYTHTV_SRC (psrc);
1.484
1.485 /* The caller should know the number of bytes and not read beyond EOS. */
1.486 - if ( G_UNLIKELY (src->eos) )
1.487 + if (G_UNLIKELY (src->eos))
1.488 goto eos;
1.489 - if ( G_UNLIKELY (src->update_prog_chain) )
1.490 + if (G_UNLIKELY (src->update_prog_chain))
1.491 goto change_progchain;
1.492
1.493 - //g_static_rec_mutex_lock( &th_mutex );
1.494 - GST_DEBUG_OBJECT( src, "[%s] offset = %llu, size = %d...\n", __FUNCTION__,
1.495 - src->read_offset, MAX_READ_SIZE );
1.496 + GST_DEBUG_OBJECT (src, "offset = %" G_GUINT64_FORMAT ", size = %d...",
1.497 + src->read_offset, MAX_READ_SIZE);
1.498
1.499 - GST_DEBUG_OBJECT ( src, "[%s]\t\tCreate: buffer_remain: %d, buffer_size = %d.\n", __FUNCTION__,
1.500 - (gint) src->buffer_remain, src->bytes_queue->len );
1.501 + GST_DEBUG_OBJECT (src, "Create: buffer_remain: %d, buffer_size = %d.",
1.502 + (gint) src->buffer_remain, src->bytes_queue->len);
1.503
1.504 /* just get from the byte array, no network effort... */
1.505 - if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE ) {
1.506 - //( ( INTERNAL_BUFFER_SIZE - src->buffer_remain ) >= REQUEST_MAX_SIZE ) ) {
1.507 - GByteArray *buffer = NULL;
1.508 - guint buffer_size_inter = ( INTERNAL_BUFFER_SIZE - src->buffer_remain );
1.509 - if ( buffer_size_inter > REQUEST_MAX_SIZE )
1.510 - buffer_size_inter = REQUEST_MAX_SIZE;
1.511 -
1.512 - buffer = g_byte_array_new();
1.513 + if ((src->buffer_remain = src->bytes_queue->len) < MAX_READ_SIZE) {
1.514 + GByteArray *buffer = NULL;
1.515 + guint buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain);
1.516
1.517 - read = do_read_request_response( src, buffer_size_inter, buffer );
1.518 + if (buffer_size_inter > REQUEST_MAX_SIZE)
1.519 + buffer_size_inter = REQUEST_MAX_SIZE;
1.520 +
1.521 + buffer = g_byte_array_new ();
1.522 +
1.523 + read = do_read_request_response (src, buffer_size_inter, buffer);
1.524
1.525 if (G_UNLIKELY (read < 0)) {
1.526 - if ( src->live_tv )
1.527 - goto change_progchain;
1.528 + if (src->live_tv)
1.529 + goto change_progchain;
1.530 else
1.531 - goto read_error;
1.532 - } else if (G_UNLIKELY (read == 0))
1.533 - {
1.534 - if (!src->live_tv )
1.535 - goto eos;
1.536 - else
1.537 - goto done;
1.538 + goto read_error;
1.539 + } else if (G_UNLIKELY (read == 0)) {
1.540 + if (!src->live_tv)
1.541 + goto eos;
1.542 + else
1.543 + goto done;
1.544 }
1.545
1.546 - if ( G_UNLIKELY (src->update_prog_chain) )
1.547 + if (G_UNLIKELY (src->update_prog_chain))
1.548 goto change_progchain;
1.549 -
1.550 - src->bytes_queue = g_byte_array_append( src->bytes_queue, buffer->data, read );
1.551 - if ( read > buffer_size_inter )
1.552 - GST_WARNING_OBJECT( src, "\n\n\n[%s]\t\tINCREASED buffer size! Backend sent more than we ask him... (%d)\n\n\n",
1.553 - __FUNCTION__, abs( read - buffer_size_inter ) );
1.554 +
1.555 + src->bytes_queue =
1.556 + g_byte_array_append (src->bytes_queue, buffer->data, read);
1.557 + if (read > buffer_size_inter)
1.558 + GST_WARNING_OBJECT (src,
1.559 + "INCREASED buffer size! Backend sent more than we ask him... (%d)",
1.560 + abs (read - buffer_size_inter));
1.561
1.562 src->buffer_remain += read;
1.563
1.564 - if ( buffer != NULL ) {
1.565 - g_byte_array_free( buffer, TRUE );
1.566 - buffer = NULL;
1.567 + if (buffer != NULL) {
1.568 + g_byte_array_free (buffer, TRUE);
1.569 + buffer = NULL;
1.570 }
1.571 -
1.572 - GST_DEBUG_OBJECT( src, "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
1.573 - "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read,
1.574 - src->read_offset, src->content_size );
1.575 -
1.576 +
1.577 + GST_DEBUG_OBJECT (src,
1.578 + "BYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "
1.579 + "OFFSET = %llu, CONTENT SIZE = %llu.", read,
1.580 + src->bytes_read, src->read_offset, src->content_size);
1.581 +
1.582 }
1.583 -
1.584 - guint buffer_size = ( src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
1.585 -
1.586 - *outbuf = gst_buffer_new( );
1.587 -
1.588 - /* gets the first buffer_size bytes from the byte array buffer variable */
1.589 +
1.590 + guint buffer_size =
1.591 + (src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
1.592 +
1.593 + *outbuf = gst_buffer_new ();
1.594 +
1.595 + /* gets the first buffer_size bytes from the byte array buffer variable */
1.596 /* guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); */
1.597
1.598 - GST_DEBUG_OBJECT( src, "[%s] read from network? %s!, buffer_remain = %d\n", __FUNCTION__,
1.599 - read == -1 ? "NO, got from buffer" : "YES, go see the backend's log file", src->buffer_remain );
1.600 + GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d",
1.601 + (read ==
1.602 + -1) ? "NO, got from buffer" : "YES, go see the backend's log file",
1.603 + src->buffer_remain);
1.604
1.605 GST_BUFFER_SIZE (*outbuf) = buffer_size;
1.606 - GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) );
1.607 - GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf );
1.608 - g_memmove( GST_BUFFER_DATA( (*outbuf) ), src->bytes_queue->data, GST_BUFFER_SIZE(*outbuf) );
1.609 + GST_BUFFER_MALLOCDATA (*outbuf) = g_malloc0 (GST_BUFFER_SIZE (*outbuf));
1.610 + GST_BUFFER_DATA (*outbuf) = GST_BUFFER_MALLOCDATA (*outbuf);
1.611 + g_memmove (GST_BUFFER_DATA ((*outbuf)), src->bytes_queue->data,
1.612 + GST_BUFFER_SIZE (*outbuf));
1.613 GST_BUFFER_OFFSET (*outbuf) = src->read_offset;
1.614 - GST_BUFFER_OFFSET_END (*outbuf) = src->read_offset + GST_BUFFER_SIZE (*outbuf);
1.615 + GST_BUFFER_OFFSET_END (*outbuf) =
1.616 + src->read_offset + GST_BUFFER_SIZE (*outbuf);
1.617
1.618 src->buffer_remain -= GST_BUFFER_SIZE (*outbuf);
1.619
1.620 src->read_offset += GST_BUFFER_SIZE (*outbuf);
1.621 src->bytes_read += GST_BUFFER_SIZE (*outbuf);
1.622 - GST_DEBUG_OBJECT( src, "[%s]\t\tBuffer output with size: %d\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf) );
1.623 -
1.624 + GST_DEBUG_OBJECT (src, "Buffer output with size: %d",
1.625 + GST_BUFFER_SIZE (*outbuf));
1.626 +
1.627 /* flushs the newly buffer got from byte array */
1.628 - src->bytes_queue = g_byte_array_remove_range( src->bytes_queue, 0, buffer_size );
1.629 + src->bytes_queue =
1.630 + g_byte_array_remove_range (src->bytes_queue, 0, buffer_size);
1.631
1.632 - GST_DEBUG_OBJECT( src, "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
1.633 - "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf),
1.634 - GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) );
1.635 + GST_DEBUG_OBJECT (src, "Got buffer: BUFFER --->SIZE = %d, OFFSET = %llu, "
1.636 + "OFFSET_END = %llu.", GST_BUFFER_SIZE (*outbuf),
1.637 + GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf));
1.638
1.639 - GST_DEBUG_OBJECT( src, "[%s]\tCONTENT_SIZE = %llu, BYTES_READ = %llu.\n", __FUNCTION__,
1.640 - src->content_size, src->bytes_read );
1.641 -
1.642 - if ( G_UNLIKELY (src->eos) || ( !src->live_tv && ( src->bytes_read >= src->content_size ) ) )
1.643 - goto eos;
1.644 + GST_DEBUG_OBJECT (src, "CONTENT_SIZE = %llu, BYTES_READ = %llu.",
1.645 + src->content_size, src->bytes_read);
1.646 +
1.647 + if (G_UNLIKELY (src->eos) || (!src->live_tv
1.648 + && (src->bytes_read >= src->content_size)))
1.649 + goto eos;
1.650
1.651 done:
1.652 {
1.653 @@ -521,23 +506,22 @@
1.654 read_error:
1.655 {
1.656 GST_ELEMENT_ERROR (src, RESOURCE, READ,
1.657 - (NULL), ("Could not read any bytes (%i, %s)", read,
1.658 - src->uri_name));
1.659 + (NULL), ("Could not read any bytes (%i, %s)", read, src->uri_name));
1.660 return GST_FLOW_ERROR;
1.661 }
1.662 change_progchain:
1.663 {
1.664 GST_ELEMENT_ERROR (src, RESOURCE, READ,
1.665 - (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
1.666 - src->uri_name));
1.667 + (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
1.668 + src->uri_name));
1.669
1.670 - gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
1.671 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
1.672 + gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
1.673 + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0));
1.674 /* go to the next program chain */
1.675 src->unique_setup = FALSE;
1.676 src->update_prog_chain = TRUE;
1.677
1.678 - gst_mythtv_src_next_program_chain( src );
1.679 + gst_mythtv_src_next_program_chain (src);
1.680
1.681 return GST_FLOW_ERROR_NO_DATA;
1.682 }
1.683 @@ -545,75 +529,74 @@
1.684 }
1.685
1.686 gint64
1.687 -gst_mythtv_src_get_position ( GstMythtvSrc* src )
1.688 +gst_mythtv_src_get_position (GstMythtvSrc * src)
1.689 {
1.690
1.691 gint64 size_tmp = 0;
1.692 guint max_tries = 2;
1.693 - if (src->live_tv == TRUE && ( abs( src->content_size - src->bytes_read ) <
1.694 - GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
1.695
1.696 -get_file_pos:
1.697 - g_usleep( 10 );
1.698 - size_tmp = gmyth_recorder_get_file_position( src->spawn_livetv->recorder );
1.699 - if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) )
1.700 + if (src->live_tv == TRUE && (abs (src->content_size - src->bytes_read) <
1.701 + GMYTHTV_TRANSFER_MAX_BUFFER)) {
1.702 +
1.703 + get_file_pos:
1.704 + g_usleep (10);
1.705 + size_tmp = gmyth_recorder_get_file_position (src->spawn_livetv->recorder);
1.706 + if (size_tmp > (src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER))
1.707 src->content_size = size_tmp;
1.708 - else if ( size_tmp > 0 && --max_tries > 0 )
1.709 + else if (size_tmp > 0 && --max_tries > 0)
1.710 goto get_file_pos;
1.711 - GST_LOG_OBJECT( src, "\t[%s]\tGET_POSITION: file_position = %lld\n",
1.712 - __FUNCTION__, size_tmp );
1.713 + GST_LOG_OBJECT (src, "GET_POSITION: file_position = %lld", size_tmp);
1.714 /* sets the last content size amount before it can be updated */
1.715 src->prev_content_size = src->content_size;
1.716 }
1.717
1.718 - return src->content_size;
1.719 + return src->content_size;
1.720
1.721 }
1.722
1.723 static gboolean
1.724 -gst_mythtv_src_do_seek( GstBaseSrc *base, GstSegment *segment )
1.725 +gst_mythtv_src_do_seek (GstBaseSrc * base, GstSegment * segment)
1.726 {
1.727 - GstMythtvSrc *src = GST_MYTHTV_SRC( base );
1.728 + GstMythtvSrc *src = GST_MYTHTV_SRC (base);
1.729 gint64 new_offset = -1;
1.730 gint64 actual_seek = segment->start;
1.731 gboolean ret = TRUE;
1.732
1.733 - GST_LOG_OBJECT( src, "[%s]DO Seek called! (start = %lld, stop = %lld)\n", __FUNCTION__,
1.734 - segment->start, segment->stop );
1.735 + GST_LOG_OBJECT (src, "seek, segment: %" GST_SEGMENT_FORMAT, segment);
1.736
1.737 - if ( segment->format == GST_FORMAT_TIME )
1.738 - {
1.739 - goto done;
1.740 - //actual_seek = ( ( segment->start / 1000 ) * 28 ) * 4000;
1.741 + if (segment->format == GST_FORMAT_TIME) {
1.742 + goto done;
1.743 }
1.744 - GST_LOG_OBJECT( src, "[%s]Trying to seek at the value (actual_seek = %lld, read_offset = %lld)\n", __FUNCTION__, actual_seek, src->read_offset );
1.745 + GST_LOG_OBJECT (src,
1.746 + "Trying to seek at the value (actual_seek = %lld, read_offset = %lld)",
1.747 + actual_seek, src->read_offset);
1.748 /* verify if it needs to seek */
1.749 - if ( src->read_offset != actual_seek )
1.750 - {
1.751 + if (src->read_offset != actual_seek) {
1.752
1.753 - new_offset = gmyth_file_transfer_seek( src->file_transfer, segment->start, SEEK_SET );
1.754 + new_offset =
1.755 + gmyth_file_transfer_seek (src->file_transfer, segment->start, SEEK_SET);
1.756
1.757 - GST_LOG_OBJECT( src, "[%s] Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.\n",
1.758 - __FUNCTION__, segment->start, src->read_offset, new_offset );
1.759 - if ( G_UNLIKELY (new_offset < 0 ) )
1.760 - {
1.761 + GST_LOG_OBJECT (src,
1.762 + "Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.",
1.763 + segment->start, src->read_offset, new_offset);
1.764 + if (G_UNLIKELY (new_offset < 0)) {
1.765 ret = FALSE;
1.766 - if ( src->live_tv )
1.767 - goto change_progchain;
1.768 + if (src->live_tv)
1.769 + goto change_progchain;
1.770 else
1.771 - goto eos;
1.772 + goto eos;
1.773 }
1.774
1.775 src->read_offset = new_offset;
1.776
1.777 - if ( ret == FALSE ) {
1.778 - GST_INFO_OBJECT( src, "[%s] Failed to set the SEEK on segment!\n", __FUNCTION__ );
1.779 + if (ret == FALSE) {
1.780 + GST_INFO_OBJECT (src, "Failed to set the SEEK on segment!");
1.781 }
1.782
1.783 }
1.784
1.785 done:
1.786 - return ret;
1.787 + return ret;
1.788
1.789 eos:
1.790 {
1.791 @@ -624,16 +607,16 @@
1.792 change_progchain:
1.793 {
1.794 GST_ELEMENT_ERROR (src, RESOURCE, READ,
1.795 - (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
1.796 - src->uri_name));
1.797 + (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
1.798 + src->uri_name));
1.799
1.800 - gst_pad_push_event ( GST_BASE_SRC_PAD (base),
1.801 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
1.802 + gst_pad_push_event (GST_BASE_SRC_PAD (base),
1.803 + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0));
1.804 /* go to the next program chain */
1.805 src->unique_setup = FALSE;
1.806 src->update_prog_chain = TRUE;
1.807
1.808 - gst_mythtv_src_next_program_chain( src );
1.809 + gst_mythtv_src_next_program_chain (src);
1.810
1.811 return TRUE;
1.812 }
1.813 @@ -642,7 +625,7 @@
1.814
1.815 /* create a socket for connecting to remote server */
1.816 static gboolean
1.817 -gst_mythtv_src_start ( GstBaseSrc * bsrc )
1.818 +gst_mythtv_src_start (GstBaseSrc * bsrc)
1.819 {
1.820 GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
1.821
1.822 @@ -650,7 +633,7 @@
1.823
1.824 gboolean ret = TRUE;
1.825
1.826 - if ( G_UNLIKELY (src->update_prog_chain) )
1.827 + if (G_UNLIKELY (src->update_prog_chain))
1.828 goto change_progchain;
1.829
1.830 if (src->unique_setup == FALSE) {
1.831 @@ -659,135 +642,125 @@
1.832 goto done;
1.833 }
1.834
1.835 - src->backend_info = gmyth_backend_info_new_with_uri( src->uri_name );
1.836 - if ( src->live_tv ) {
1.837 - src->spawn_livetv = gmyth_livetv_new( );
1.838 + GMythURI *gmyth_uri = gmyth_uri_new_with_value( src->uri_name );
1.839 +
1.840 + src->backend_info = gmyth_backend_info_new_with_uri (src->uri_name);
1.841 + /* testing UPnP... */
1.842 + /* gmyth_backend_info_set_hostname( src->backend_info, NULL ); */
1.843 + if ( src->live_tv || gmyth_uri_is_livetv( gmyth_uri ) ) {
1.844 + src->spawn_livetv = gmyth_livetv_new ();
1.845
1.846 - if ( src->channel_num != GST_GMYTHTV_CHANNEL_DEFAULT_NUM )
1.847 - {
1.848 - if ( gmyth_livetv_channel_setup( src->spawn_livetv, src->channel_num, src->backend_info ) == FALSE ) {
1.849 - GST_INFO_OBJECT( src, "[%s] LiveTV setup felt down on error!!\n", __FUNCTION__ );
1.850 - ret = FALSE;
1.851 - goto init_failed;
1.852 - }
1.853 + gint ch = gmyth_uri_get_channel_num( gmyth_uri );
1.854 + if ( ch != -1 )
1.855 + src->channel_num = ch;
1.856 +
1.857 + if (src->channel_num != GST_GMYTHTV_CHANNEL_DEFAULT_NUM) {
1.858 + if (gmyth_livetv_channel_setup (src->spawn_livetv, src->channel_num,
1.859 + src->backend_info) == FALSE) {
1.860 + GST_INFO_OBJECT (src, "LiveTV setup felt down on error");
1.861 + ret = FALSE;
1.862 + goto init_failed;
1.863 + }
1.864 } else {
1.865 - if ( gmyth_livetv_setup( src->spawn_livetv, src->backend_info ) == FALSE ) {
1.866 - GST_INFO_OBJECT( src, "[%s] LiveTV setup felt down on error!!\n", __FUNCTION__ );
1.867 - ret = FALSE;
1.868 - goto init_failed;
1.869 - }
1.870 + if (gmyth_livetv_setup (src->spawn_livetv, src->backend_info) == FALSE) {
1.871 + GST_INFO_OBJECT (src, "LiveTV setup felt down on error");
1.872 + ret = FALSE;
1.873 + goto init_failed;
1.874 + }
1.875 }
1.876
1.877 - src->file_transfer = gmyth_livetv_create_file_transfer(src->spawn_livetv);
1.878 -
1.879 - if (NULL == src->file_transfer )
1.880 - {
1.881 - GST_INFO_OBJECT( src, "[%s] [LiveTV] FileTransfer equals to NULL!!!\n", __FUNCTION__ );
1.882 - ret = FALSE;
1.883 - goto init_failed;
1.884 - }
1.885 - /*
1.886 - chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
1.887 - if ( chain_id_local != NULL ) {
1.888 - src->live_chain_id = g_strdup( chain_id_local->str );
1.889 - GST_INFO_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
1.890 + src->file_transfer = gmyth_livetv_create_file_transfer (src->spawn_livetv);
1.891 +
1.892 + if (NULL == src->file_transfer) {
1.893 + GST_INFO_OBJECT (src, "[LiveTV] FileTransfer equals to NULL");
1.894 + ret = FALSE;
1.895 + goto init_failed;
1.896 }
1.897 -
1.898 - src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
1.899 - GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
1.900 - */
1.901 } else {
1.902 -
1.903 - src->file_transfer = gmyth_file_transfer_new( src->backend_info );
1.904
1.905 - ret = gmyth_file_transfer_open( src->file_transfer, src->uri_name );
1.906 -
1.907 - }
1.908 + src->file_transfer = gmyth_file_transfer_new (src->backend_info);
1.909
1.910 - if ( NULL == src->file_transfer )
1.911 - {
1.912 - GST_INFO_OBJECT( src, "[%s] FileTransfer equals to NULL!!!\n", __FUNCTION__ );
1.913 - goto init_failed;
1.914 - }
1.915 - /*GST_INFO_OBJECT( src, "[%s] uri = %s.\n", __FUNCTION__, src->spawn_livetv->file_transfer );*/
1.916 -
1.917 - if ( src->live_tv == TRUE && ret == TRUE ) {
1.918 - /* loop finished, set the max tries variable to zero again... */
1.919 - wait_to_transfer = 0;
1.920 -
1.921 - while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
1.922 - ( gmyth_livetv_is_recording( src->spawn_livetv ) == FALSE ) )
1.923 - g_usleep( 500 );
1.924 -
1.925 - /* IS_RECORDING again, just like the MythTV backend does... */
1.926 - gmyth_livetv_is_recording( src->spawn_livetv );
1.927 -
1.928 - sleep( 9 );
1.929 + ret = gmyth_file_transfer_open (src->file_transfer, src->uri_name);
1.930
1.931 }
1.932
1.933 - if ( ret == FALSE ) {
1.934 -#ifndef GST_DISABLE_GST_DEBUG
1.935 - if ( src->mythtv_msgs_dbg )
1.936 - GST_INFO_OBJECT( src, "MythTV FileTransfer request failed when setting up socket connection!\n" );
1.937 + if (NULL == src->file_transfer) {
1.938 + GST_INFO_OBJECT (src, "FileTransfer is NULL");
1.939 + goto init_failed;
1.940 + }
1.941 + /*GST_INFO_OBJECT( src, "uri = %s", src->spawn_livetv->file_transfer); */
1.942 +
1.943 + if (ret == FALSE) {
1.944 +#ifndef GST_DISABLE_GST_DEBUG
1.945 + if (src->mythtv_msgs_dbg)
1.946 + GST_INFO_OBJECT (src,
1.947 + "MythTV FileTransfer request failed when setting up socket connection!");
1.948 #endif
1.949 goto begin_req_failed;
1.950 }
1.951 -
1.952 - GST_INFO_OBJECT( src, "MythTV FileTransfer filesize = %lld, content_size = %lld!\n",
1.953 - src->file_transfer->filesize, src->content_size );
1.954 +
1.955 + GST_INFO_OBJECT (src,
1.956 + "MythTV FileTransfer filesize = %lld, content_size = %lld!",
1.957 + src->file_transfer->filesize, src->content_size);
1.958
1.959 src->content_size = src->file_transfer->filesize;
1.960
1.961 src->do_start = FALSE;
1.962 -
1.963 +
1.964 /* this is used for the buffer cache */
1.965 - src->bytes_queue = g_byte_array_sized_new( INTERNAL_BUFFER_SIZE );
1.966 + src->bytes_queue = g_byte_array_sized_new (INTERNAL_BUFFER_SIZE);
1.967 src->buffer_remain = 0;
1.968
1.969 - gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
1.970 - gst_event_new_new_segment ( TRUE, 1.0, GST_FORMAT_TIME, 0, src->content_size, 0 ) );
1.971 + gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
1.972 + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0,
1.973 + src->content_size, 0));
1.974
1.975 done:
1.976 + if ( gmyth_uri != NULL )
1.977 + {
1.978 + g_object_unref( gmyth_uri );
1.979 + gmyth_uri = NULL;
1.980 + }
1.981
1.982 - if ( chain_id_local != NULL )
1.983 - {
1.984 - g_string_free( chain_id_local, TRUE );
1.985 - chain_id_local = NULL;
1.986 - }
1.987 -
1.988 + if (chain_id_local != NULL) {
1.989 + g_string_free (chain_id_local, TRUE);
1.990 + chain_id_local = NULL;
1.991 + }
1.992 +
1.993 return TRUE;
1.994
1.995 /* ERRORS */
1.996 init_failed:
1.997 {
1.998 - if (src->spawn_livetv != NULL )
1.999 - g_object_unref( src->spawn_livetv );
1.1000 + if (src->spawn_livetv != NULL)
1.1001 + g_object_unref (src->spawn_livetv);
1.1002
1.1003 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1.1004 - (NULL), ("Could not initialize MythTV library (%i, %s)", ret, src->uri_name));
1.1005 + (NULL), ("Could not initialize MythTV library (%i, %s)", ret,
1.1006 + src->uri_name));
1.1007 return FALSE;
1.1008 }
1.1009 begin_req_failed:
1.1010 {
1.1011 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1.1012 - (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret, src->uri_name));
1.1013 + (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret,
1.1014 + src->uri_name));
1.1015 return FALSE;
1.1016 }
1.1017 change_progchain:
1.1018 {
1.1019 GST_ELEMENT_ERROR (src, RESOURCE, READ,
1.1020 - (NULL), ("Seek failed, go to the next program info... (%s)",
1.1021 - src->uri_name));
1.1022 + (NULL), ("Seek failed, go to the next program info... (%s)",
1.1023 + src->uri_name));
1.1024
1.1025 - gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
1.1026 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
1.1027 + gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
1.1028 + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0));
1.1029
1.1030 - // go to the next program chain
1.1031 + /* go to the next program chain */
1.1032 src->unique_setup = FALSE;
1.1033 src->update_prog_chain = TRUE;
1.1034
1.1035 - gst_mythtv_src_next_program_chain( src );
1.1036 + gst_mythtv_src_next_program_chain (src);
1.1037
1.1038 return TRUE;
1.1039 }
1.1040 @@ -795,22 +768,22 @@
1.1041
1.1042 /* create a new socket for connecting to the next program chain */
1.1043 static gboolean
1.1044 -gst_mythtv_src_next_program_chain ( GstMythtvSrc *src )
1.1045 +gst_mythtv_src_next_program_chain (GstMythtvSrc * src)
1.1046 {
1.1047 GString *chain_id_local = NULL;
1.1048
1.1049 gboolean ret = TRUE;
1.1050
1.1051 - if ( !src->live_tv )
1.1052 + if (!src->live_tv)
1.1053 goto init_failed;
1.1054 -
1.1055 +
1.1056 if (src->unique_setup == FALSE) {
1.1057 src->unique_setup = TRUE;
1.1058 } else {
1.1059 goto done;
1.1060 }
1.1061 -
1.1062 - GST_PAD_STREAM_LOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) );
1.1063 +
1.1064 + GST_PAD_STREAM_LOCK (GST_BASE_SRC_PAD (GST_BASE_SRC (src)));
1.1065
1.1066 if (src->file_transfer) {
1.1067 g_object_unref (src->file_transfer);
1.1068 @@ -820,100 +793,100 @@
1.1069 if (src->uri_name) {
1.1070 g_free (src->uri_name);
1.1071 }
1.1072 -
1.1073 - if ( src->backend_info == NULL )
1.1074 - src->backend_info = gmyth_backend_info_new_with_uri( src->uri_name );
1.1075
1.1076 - if ( src->live_tv ) {
1.1077 - if ( gmyth_livetv_next_program_chain( src->spawn_livetv ) == FALSE ) {
1.1078 - GST_INFO_OBJECT( src, "\n\n[%s]\t\tFailed to go to the next program chain!!!\n\n", __FUNCTION__ );
1.1079 + if (src->backend_info == NULL)
1.1080 + src->backend_info = gmyth_backend_info_new_with_uri (src->uri_name);
1.1081 +
1.1082 + if (src->live_tv) {
1.1083 + if (gmyth_livetv_next_program_chain (src->spawn_livetv) == FALSE) {
1.1084 + GST_INFO_OBJECT (src, "Failed to go to the next program chain!");
1.1085 ret = FALSE;
1.1086 goto init_failed;
1.1087 }
1.1088 /* set up the uri variable */
1.1089 - src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str );
1.1090 - chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
1.1091 - if ( chain_id_local != NULL ) {
1.1092 - src->live_chain_id = g_strdup( chain_id_local->str );
1.1093 - GST_DEBUG_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
1.1094 + src->uri_name = g_strdup (src->spawn_livetv->proginfo->pathname->str);
1.1095 + chain_id_local = gmyth_tvchain_get_id (src->spawn_livetv->tvchain);
1.1096 + if (chain_id_local != NULL) {
1.1097 + src->live_chain_id = g_strdup (chain_id_local->str);
1.1098 + GST_DEBUG_OBJECT (src, "Local chain ID = %s", src->live_chain_id);
1.1099 }
1.1100 src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
1.1101 - GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
1.1102 + GST_LOG_OBJECT (src, "LiveTV id = %d, URI path = %s",
1.1103 + src->live_tv_id, src->uri_name);
1.1104 }
1.1105
1.1106 - src->file_transfer = gmyth_file_transfer_new(src->backend_info);
1.1107 + src->file_transfer = gmyth_file_transfer_new (src->backend_info);
1.1108
1.1109 - if ( src->file_transfer == NULL ) {
1.1110 + if (src->file_transfer == NULL) {
1.1111 goto init_failed;
1.1112 }
1.1113 -
1.1114 - ret = gmyth_file_transfer_open( src->file_transfer, src->uri_name );
1.1115 +
1.1116 + ret = gmyth_file_transfer_open (src->file_transfer, src->uri_name);
1.1117
1.1118 /* sets the Playback monitor connection */
1.1119 - //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
1.1120
1.1121 - if ( src->live_tv == TRUE && ret == TRUE ) {
1.1122 + if (src->live_tv == TRUE && ret == TRUE) {
1.1123 /* loop finished, set the max tries variable to zero again... */
1.1124 - wait_to_transfer = 0;
1.1125 + src->wait_to_transfer = 0;
1.1126
1.1127 - g_usleep( 200 );
1.1128 + g_usleep (200);
1.1129
1.1130 - while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
1.1131 - ( gmyth_livetv_is_recording( src->spawn_livetv ) == FALSE ) )
1.1132 - g_usleep( 1000 );
1.1133 + while (src->wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
1.1134 + (gmyth_livetv_is_recording (src->spawn_livetv) == FALSE))
1.1135 + g_usleep (1000);
1.1136 }
1.1137
1.1138 /* sets the FileTransfer instance connection (video/audio download) */
1.1139 - //ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
1.1140
1.1141 - if ( ret == FALSE ) {
1.1142 -#ifndef GST_DISABLE_GST_DEBUG
1.1143 - if ( src->mythtv_msgs_dbg )
1.1144 - GST_ERROR_OBJECT( src, "MythTV FileTransfer request failed when setting up socket connection!\n" );
1.1145 + if (ret == FALSE) {
1.1146 +#ifndef GST_DISABLE_GST_DEBUG
1.1147 + if (src->mythtv_msgs_dbg)
1.1148 + GST_ERROR_OBJECT (src,
1.1149 + "MythTV FileTransfer request failed when setting up socket connection!");
1.1150 #endif
1.1151 goto begin_req_failed;
1.1152 }
1.1153 src->content_size_last = src->content_size;
1.1154
1.1155 src->content_size = src->file_transfer->filesize;
1.1156 - if ( src->live_tv ) {
1.1157 - wait_to_transfer = 0;
1.1158 - while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS && src->content_size < GMYTHTV_TRANSFER_MAX_BUFFER )
1.1159 - src->content_size = gst_mythtv_src_get_position( src );
1.1160 + if (src->live_tv) {
1.1161 + src->wait_to_transfer = 0;
1.1162 + while (src->wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
1.1163 + src->content_size < GMYTHTV_TRANSFER_MAX_BUFFER)
1.1164 + src->content_size = gst_mythtv_src_get_position (src);
1.1165 }
1.1166
1.1167 - src->read_offset = 0;
1.1168 -
1.1169 - if ( src->bytes_queue != NULL ) {
1.1170 - g_byte_array_free( src->bytes_queue, TRUE );
1.1171 + src->read_offset = 0;
1.1172 +
1.1173 + if (src->bytes_queue != NULL) {
1.1174 + g_byte_array_free (src->bytes_queue, TRUE);
1.1175 }
1.1176 -
1.1177 - src->bytes_queue = g_byte_array_sized_new( INTERNAL_BUFFER_SIZE );
1.1178 -
1.1179 - //gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
1.1180 - // gst_event_new_new_segment ( TRUE, 1.0, GST_FORMAT_TIME, 0, src->content_size, 0 ) );
1.1181 -
1.1182 +
1.1183 + src->bytes_queue = g_byte_array_sized_new (INTERNAL_BUFFER_SIZE);
1.1184 +
1.1185 done:
1.1186 - src->update_prog_chain = FALSE;
1.1187 -
1.1188 - GST_PAD_STREAM_UNLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) );
1.1189 -
1.1190 + src->update_prog_chain = FALSE;
1.1191 +
1.1192 + GST_PAD_STREAM_UNLOCK (GST_BASE_SRC_PAD (GST_BASE_SRC (src)));
1.1193 +
1.1194 return TRUE;
1.1195
1.1196 /* ERRORS */
1.1197 init_failed:
1.1198 {
1.1199 - if (src->spawn_livetv != NULL )
1.1200 - g_object_unref( src->spawn_livetv );
1.1201 + if (src->spawn_livetv != NULL)
1.1202 + g_object_unref (src->spawn_livetv);
1.1203
1.1204 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1.1205 - (NULL), ("Could not initialize MythTV library (%i, %s)", ret, src->uri_name));
1.1206 + (NULL), ("Could not initialize MythTV library (%i, %s)", ret,
1.1207 + src->uri_name));
1.1208 return FALSE;
1.1209 }
1.1210 begin_req_failed:
1.1211 {
1.1212 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1.1213 - (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret, src->uri_name));
1.1214 + (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret,
1.1215 + src->uri_name));
1.1216 return FALSE;
1.1217 }
1.1218
1.1219 @@ -924,26 +897,30 @@
1.1220 {
1.1221 GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
1.1222 gboolean ret = TRUE;
1.1223 - GST_LOG_OBJECT( src, "[%s] Differs from previous content size: %d (max.: %d)\n", __FUNCTION__,
1.1224 - abs( src->content_size - src->prev_content_size ), GMYTHTV_TRANSFER_MAX_BUFFER );
1.1225 -
1.1226 - if ( src->live_tv ) {
1.1227 - ret = FALSE;
1.1228 - } else if ( src->live_tv && src->enable_timing_position && ( abs( src->content_size - src->bytes_read ) <
1.1229 - GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
1.1230 -
1.1231 - gint64 new_offset = gmyth_recorder_get_file_position( src->spawn_livetv->recorder );
1.1232 - if ( new_offset > 0 && new_offset > src->content_size ) {
1.1233 - src->content_size = new_offset;
1.1234 - } else if ( new_offset < src->content_size ) {
1.1235 - src->update_prog_chain = TRUE;
1.1236 - }
1.1237 +
1.1238 + GST_LOG_OBJECT (src, "Differs from previous content size: %d (max.: %d)",
1.1239 + abs (src->content_size - src->prev_content_size),
1.1240 + GMYTHTV_TRANSFER_MAX_BUFFER);
1.1241 +
1.1242 + if (src->live_tv) {
1.1243 + ret = FALSE;
1.1244 + } else if (src->live_tv && src->enable_timing_position
1.1245 + && (abs (src->content_size - src->bytes_read) <
1.1246 + GMYTHTV_TRANSFER_MAX_BUFFER)) {
1.1247 +
1.1248 + gint64 new_offset =
1.1249 + gmyth_recorder_get_file_position (src->spawn_livetv->recorder);
1.1250 + if (new_offset > 0 && new_offset > src->content_size) {
1.1251 + src->content_size = new_offset;
1.1252 + } else if (new_offset < src->content_size) {
1.1253 + src->update_prog_chain = TRUE;
1.1254 + }
1.1255
1.1256 }
1.1257
1.1258 *size = src->content_size;
1.1259 - GST_LOG_OBJECT( src, "[%s] Content size = %lld\n", __FUNCTION__, src->content_size );
1.1260 -
1.1261 + GST_LOG_OBJECT (src, "Content size = %lld", src->content_size);
1.1262 +
1.1263 return ret;
1.1264
1.1265 }
1.1266 @@ -981,18 +958,18 @@
1.1267
1.1268 switch (GST_EVENT_TYPE (event)) {
1.1269 case GST_EVENT_EOS:
1.1270 - GST_WARNING_OBJECT( src, "[%s] Got EOS event!!!\n", __FUNCTION__ );
1.1271 + GST_WARNING_OBJECT (src, "Got EOS event");
1.1272
1.1273 - if ( src->live_tv ) {
1.1274 - cont_size = gst_mythtv_src_get_position (src);
1.1275 - if ( cont_size > src->content_size ) {
1.1276 - src->content_size = cont_size;
1.1277 - src->eos = FALSE;
1.1278 - } else {
1.1279 - src->eos = TRUE;
1.1280 - gst_element_set_state ( GST_ELEMENT (src), GST_STATE_NULL );
1.1281 - gst_element_set_locked_state ( GST_ELEMENT (src), FALSE );
1.1282 - }
1.1283 + if (src->live_tv) {
1.1284 + cont_size = gst_mythtv_src_get_position (src);
1.1285 + if (cont_size > src->content_size) {
1.1286 + src->content_size = cont_size;
1.1287 + src->eos = FALSE;
1.1288 + } else {
1.1289 + src->eos = TRUE;
1.1290 + gst_element_set_state (GST_ELEMENT (src), GST_STATE_NULL);
1.1291 + gst_element_set_locked_state (GST_ELEMENT (src), FALSE);
1.1292 + }
1.1293 }
1.1294 break;
1.1295 default:
1.1296 @@ -1003,7 +980,7 @@
1.1297 }
1.1298
1.1299 static gboolean
1.1300 -gst_mythtv_src_is_seekable( GstBaseSrc *push_src )
1.1301 +gst_mythtv_src_is_seekable (GstBaseSrc * push_src)
1.1302 {
1.1303 return TRUE;
1.1304 }
1.1305 @@ -1018,15 +995,13 @@
1.1306 switch (GST_QUERY_TYPE (query)) {
1.1307 case GST_QUERY_POSITION:
1.1308 {
1.1309 - gint64 pos = -1;
1.1310 - gst_query_parse_position (query, &formt, &pos );
1.1311 - res = TRUE;
1.1312 - if ( formt == GST_FORMAT_BYTES ) {
1.1313 - gst_query_set_position (query, formt, pos = myth->read_offset );
1.1314 - GST_DEBUG_OBJECT (myth, "POS %lld (BYTES).\n", pos );
1.1315 - } else if ( formt == GST_FORMAT_TIME ) {
1.1316 - GST_DEBUG_OBJECT (myth, "POS %lld (TIME).\n", pos );
1.1317 - res = gst_pad_query_default(pad, query);
1.1318 + gst_query_parse_position (query, &formt, NULL);
1.1319 + if (formt == GST_FORMAT_BYTES) {
1.1320 + gst_query_set_position (query, formt, myth->read_offset);
1.1321 + GST_DEBUG_OBJECT (myth, "POS %" G_GINT64_FORMAT, myth->read_offset);
1.1322 + res = TRUE;
1.1323 + } else if (formt == GST_FORMAT_TIME) {
1.1324 + res = gst_pad_query_default (pad, query);
1.1325 }
1.1326 break;
1.1327 }
1.1328 @@ -1034,29 +1009,28 @@
1.1329 {
1.1330 #if 0
1.1331 if (myth->duration != 0) {
1.1332 - gint64 total;
1.1333 - gint64 fps;
1.1334 + gint64 total;
1.1335 + gint64 fps;
1.1336
1.1337 - fps = nuv->h->i_fpsn / nuv->h->i_fpsd;
1.1338 - total = gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps);
1.1339 + fps = nuv->h->i_fpsn / nuv->h->i_fpsd;
1.1340 + total =
1.1341 + gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps);
1.1342 }
1.1343 #endif
1.1344 - gint64 dur = -1;
1.1345 - gst_query_parse_duration ( query, &formt, &dur );
1.1346 - if ( formt == GST_FORMAT_BYTES ) {
1.1347 - gst_query_set_duration (query, formt, dur = myth->content_size);
1.1348 - GST_DEBUG_OBJECT (myth, "DURATION %lld (BYTES).\n", dur );
1.1349 - } else if ( formt == GST_FORMAT_TIME ) {
1.1350 - GST_DEBUG_OBJECT (myth, "DURATION %lld (TIME).\n", dur );
1.1351 - gst_query_ref(query);
1.1352 - res = gst_pad_query_default(pad, query);
1.1353 - }
1.1354 - res = TRUE;
1.1355 +
1.1356 + gst_query_parse_duration (query, &formt, NULL);
1.1357 + if (formt == GST_FORMAT_BYTES) {
1.1358 + gst_query_set_duration (query, formt, myth->content_size);
1.1359 + GST_DEBUG_OBJECT (myth, "SIZE %" G_GINT64_FORMAT, myth->content_size);
1.1360 + res = TRUE;
1.1361 + } else if (formt == GST_FORMAT_TIME) {
1.1362 + res = gst_pad_query_default (pad, query);
1.1363 + }
1.1364 break;
1.1365 }
1.1366 default:
1.1367 {
1.1368 - res = gst_pad_query_default(pad, query);
1.1369 + res = gst_pad_query_default (pad, query);
1.1370 break;
1.1371 }
1.1372 }
1.1373 @@ -1069,26 +1043,23 @@
1.1374 static GstStateChangeReturn
1.1375 gst_mythtv_src_change_state (GstElement * element, GstStateChange transition)
1.1376 {
1.1377 - GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;//GST_STATE_CHANGE_NO_PREROLL;
1.1378 + GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
1.1379 GstMythtvSrc *src = GST_MYTHTV_SRC (element);
1.1380
1.1381 switch (transition) {
1.1382 case GST_STATE_CHANGE_NULL_TO_READY:
1.1383 - //src->do_start = TRUE;
1.1384 - //src->unique_setup = FALSE;
1.1385 break;
1.1386 case GST_STATE_CHANGE_READY_TO_PAUSED:
1.1387 - GST_INFO_OBJECT( src, "[%s] READY to PAUSED called!\n", __FUNCTION__ );
1.1388 - break;
1.1389 + break;
1.1390 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
1.1391 - GST_INFO_OBJECT( src, "[%s] PAUSED to PLAYING called!\n", __FUNCTION__ );
1.1392 - if ( src->live_tv ) {
1.1393 - if ( !gmyth_recorder_send_frontend_ready_command( src->spawn_livetv->recorder ) )
1.1394 - GST_WARNING_OBJECT( src, "[%s] Couldn't send the FRONTEND_READY message to the backend!", __FUNCTION__ );
1.1395 - else
1.1396 - GST_DEBUG_OBJECT( src, "[%s] Message FRONTEND_READY was sent to the backend!", __FUNCTION__ );
1.1397 + if (src->live_tv) {
1.1398 + if (!gmyth_recorder_send_frontend_ready_command (src->spawn_livetv->
1.1399 + recorder))
1.1400 + GST_WARNING_OBJECT (src,
1.1401 + "Couldn't send the FRONTEND_READY message to the backend!");
1.1402 + else
1.1403 + GST_DEBUG_OBJECT (src, "FRONTEND_READY was sent to the backend");
1.1404 }
1.1405 -
1.1406 break;
1.1407 default:
1.1408 break;
1.1409 @@ -1100,30 +1071,17 @@
1.1410
1.1411 switch (transition) {
1.1412 case GST_STATE_CHANGE_READY_TO_NULL:
1.1413 - GST_INFO_OBJECT( src, "[%s] READY to NULL called!\n", __FUNCTION__ );
1.1414 break;
1.1415 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
1.1416 - GST_INFO_OBJECT( src, "[%s] PLAYING to PAUSED called!\n", __FUNCTION__ );
1.1417 case GST_STATE_CHANGE_PAUSED_TO_READY:
1.1418 - GST_INFO_OBJECT( src, "[%s] PAUSED to READY called!\n", __FUNCTION__ );
1.1419 - if ( src->live_tv ) {
1.1420 - if ( !gmyth_recorder_send_frontend_ready_command( src->spawn_livetv->recorder ) )
1.1421 - GST_WARNING_OBJECT( src, "[%s] Couldn't send the FRONTEND_READY message to the backend!", __FUNCTION__ );
1.1422 - else
1.1423 - GST_DEBUG_OBJECT( src, "[%s] Message FRONTEND_READY was sent to the backend!", __FUNCTION__ );
1.1424 -
1.1425 - /*
1.1426 -
1.1427 - gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
1.1428 - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
1.1429 -
1.1430 - src->read_offset = 0;
1.1431 - src->bytes_read = 0;
1.1432 - src->unique_setup = FALSE;
1.1433 - gst_mythtv_src_next_program_chain( src );
1.1434 - */
1.1435 + if (src->live_tv) {
1.1436 + if (!gmyth_recorder_send_frontend_ready_command (src->spawn_livetv->
1.1437 + recorder))
1.1438 + GST_WARNING_OBJECT (src,
1.1439 + "Couldn't send the FRONTEND_READY message to the backend!");
1.1440 + else
1.1441 + GST_DEBUG_OBJECT (src, "FRONTEND_READY was sent to the backend");
1.1442 }
1.1443 -
1.1444 break;
1.1445 default:
1.1446 break;
1.1447 @@ -1140,75 +1098,73 @@
1.1448
1.1449 GST_OBJECT_LOCK (mythtvsrc);
1.1450 switch (prop_id) {
1.1451 - case PROP_URI:
1.1452 case PROP_LOCATION:
1.1453 - {
1.1454 - if (!g_value_get_string (value)) {
1.1455 - GST_WARNING ("location property cannot be NULL");
1.1456 - goto done;
1.1457 - }
1.1458 -
1.1459 - if (mythtvsrc->uri_name != NULL) {
1.1460 - g_free (mythtvsrc->uri_name);
1.1461 - mythtvsrc->uri_name = NULL;
1.1462 - }
1.1463 - mythtvsrc->uri_name = g_value_dup_string (value);
1.1464 -
1.1465 + {
1.1466 + if (!g_value_get_string (value)) {
1.1467 + GST_WARNING ("location property cannot be NULL");
1.1468 break;
1.1469 }
1.1470 +
1.1471 + if (mythtvsrc->uri_name != NULL) {
1.1472 + g_free (mythtvsrc->uri_name);
1.1473 + mythtvsrc->uri_name = NULL;
1.1474 + }
1.1475 + mythtvsrc->uri_name = g_value_dup_string (value);
1.1476 +
1.1477 + break;
1.1478 + }
1.1479 #ifndef GST_DISABLE_GST_DEBUG
1.1480 case PROP_GMYTHTV_DBG:
1.1481 - {
1.1482 - mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean (value);
1.1483 + {
1.1484 + mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean (value);
1.1485 + break;
1.1486 + }
1.1487 +#endif
1.1488 + case PROP_GMYTHTV_VERSION:
1.1489 + {
1.1490 + mythtvsrc->mythtv_version = g_value_get_int (value);
1.1491 + break;
1.1492 + }
1.1493 + case PROP_GMYTHTV_LIVEID:
1.1494 + {
1.1495 + mythtvsrc->live_tv_id = g_value_get_int (value);
1.1496 + break;
1.1497 + }
1.1498 + case PROP_GMYTHTV_LIVE:
1.1499 + {
1.1500 + mythtvsrc->live_tv = g_value_get_boolean (value);
1.1501 + break;
1.1502 + }
1.1503 + case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.1504 + {
1.1505 + mythtvsrc->enable_timing_position = g_value_get_boolean (value);
1.1506 + break;
1.1507 + }
1.1508 + case PROP_GMYTHTV_LIVE_CHAINID:
1.1509 + {
1.1510 + if (!g_value_get_string (value)) {
1.1511 + GST_WARNING ("MythTV Live chainid property cannot be NULL");
1.1512 break;
1.1513 }
1.1514 -#endif
1.1515 - case PROP_GMYTHTV_VERSION:
1.1516 - {
1.1517 - mythtvsrc->mythtv_version = g_value_get_int (value);
1.1518 - break;
1.1519 +
1.1520 + if (mythtvsrc->live_chain_id != NULL) {
1.1521 + g_free (mythtvsrc->live_chain_id);
1.1522 + mythtvsrc->live_chain_id = NULL;
1.1523 }
1.1524 - case PROP_GMYTHTV_LIVEID:
1.1525 - {
1.1526 - mythtvsrc->live_tv_id = g_value_get_int (value);
1.1527 - break;
1.1528 - }
1.1529 - case PROP_GMYTHTV_LIVE:
1.1530 - {
1.1531 - mythtvsrc->live_tv = g_value_get_boolean (value);
1.1532 - break;
1.1533 - }
1.1534 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.1535 - {
1.1536 - mythtvsrc->enable_timing_position = g_value_get_boolean (value);
1.1537 - break;
1.1538 - }
1.1539 - case PROP_GMYTHTV_LIVE_CHAINID:
1.1540 - {
1.1541 - if (!g_value_get_string (value)) {
1.1542 - GST_WARNING ("MythTV Live chainid property cannot be NULL");
1.1543 - goto done;
1.1544 - }
1.1545 -
1.1546 - if (mythtvsrc->live_chain_id != NULL) {
1.1547 - g_free (mythtvsrc->live_chain_id);
1.1548 - mythtvsrc->live_chain_id = NULL;
1.1549 - }
1.1550 - mythtvsrc->live_chain_id = g_value_dup_string (value);
1.1551 - break;
1.1552 - }
1.1553 + mythtvsrc->live_chain_id = g_value_dup_string (value);
1.1554 + break;
1.1555 + }
1.1556 case PROP_GMYTHTV_CHANNEL_NUM:
1.1557 - {
1.1558 - mythtvsrc->channel_num = g_value_get_int (value);
1.1559 - break;
1.1560 - }
1.1561 + {
1.1562 + mythtvsrc->channel_num = g_value_get_int (value);
1.1563 + break;
1.1564 + }
1.1565 default:
1.1566 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1.1567 break;
1.1568 }
1.1569 +
1.1570 GST_OBJECT_UNLOCK (mythtvsrc);
1.1571 -done:
1.1572 - return;
1.1573 }
1.1574
1.1575 static void
1.1576 @@ -1219,59 +1175,58 @@
1.1577
1.1578 GST_OBJECT_LOCK (mythtvsrc);
1.1579 switch (prop_id) {
1.1580 - case PROP_URI:
1.1581 case PROP_LOCATION:
1.1582 - {
1.1583 - gchar *str = g_strdup( "" );
1.1584 + {
1.1585 + gchar *str = g_strdup ("");
1.1586
1.1587 - if ( mythtvsrc->uri_name == NULL ) {
1.1588 - g_free (mythtvsrc->uri_name);
1.1589 - mythtvsrc->uri_name = NULL;
1.1590 - } else {
1.1591 - str = g_strdup( mythtvsrc->uri_name );
1.1592 - }
1.1593 - g_value_set_string ( value, str );
1.1594 - break;
1.1595 + if (mythtvsrc->uri_name == NULL) {
1.1596 + g_free (mythtvsrc->uri_name);
1.1597 + mythtvsrc->uri_name = NULL;
1.1598 + } else {
1.1599 + str = g_strdup (mythtvsrc->uri_name);
1.1600 }
1.1601 + g_value_set_string (value, str);
1.1602 + break;
1.1603 + }
1.1604 #ifndef GST_DISABLE_GST_DEBUG
1.1605 case PROP_GMYTHTV_DBG:
1.1606 - g_value_set_boolean ( value, mythtvsrc->mythtv_msgs_dbg );
1.1607 + g_value_set_boolean (value, mythtvsrc->mythtv_msgs_dbg);
1.1608 break;
1.1609 #endif
1.1610 case PROP_GMYTHTV_VERSION:
1.1611 - {
1.1612 - g_value_set_int ( value, mythtvsrc->mythtv_version );
1.1613 - break;
1.1614 - }
1.1615 + {
1.1616 + g_value_set_int (value, mythtvsrc->mythtv_version);
1.1617 + break;
1.1618 + }
1.1619 case PROP_GMYTHTV_LIVEID:
1.1620 - {
1.1621 - g_value_set_int ( value, mythtvsrc->live_tv_id );
1.1622 - break;
1.1623 - }
1.1624 + {
1.1625 + g_value_set_int (value, mythtvsrc->live_tv_id);
1.1626 + break;
1.1627 + }
1.1628 case PROP_GMYTHTV_LIVE:
1.1629 - g_value_set_boolean ( value, mythtvsrc->live_tv );
1.1630 + g_value_set_boolean (value, mythtvsrc->live_tv);
1.1631 break;
1.1632 case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1.1633 - g_value_set_boolean ( value, mythtvsrc->enable_timing_position );
1.1634 + g_value_set_boolean (value, mythtvsrc->enable_timing_position);
1.1635 break;
1.1636 case PROP_GMYTHTV_LIVE_CHAINID:
1.1637 - {
1.1638 - gchar *str = g_strdup( "" );
1.1639 + {
1.1640 + gchar *str = g_strdup ("");
1.1641
1.1642 - if ( mythtvsrc->live_chain_id == NULL ) {
1.1643 - g_free (mythtvsrc->live_chain_id);
1.1644 - mythtvsrc->live_chain_id = NULL;
1.1645 - } else {
1.1646 - str = g_strdup( mythtvsrc->live_chain_id );
1.1647 - }
1.1648 - g_value_set_string ( value, str );
1.1649 - break;
1.1650 + if (mythtvsrc->live_chain_id == NULL) {
1.1651 + g_free (mythtvsrc->live_chain_id);
1.1652 + mythtvsrc->live_chain_id = NULL;
1.1653 + } else {
1.1654 + str = g_strdup (mythtvsrc->live_chain_id);
1.1655 }
1.1656 + g_value_set_string (value, str);
1.1657 + break;
1.1658 + }
1.1659 case PROP_GMYTHTV_CHANNEL_NUM:
1.1660 - {
1.1661 - g_value_set_int ( value, mythtvsrc->channel_num );
1.1662 - break;
1.1663 - }
1.1664 + {
1.1665 + g_value_set_int (value, mythtvsrc->channel_num);
1.1666 + break;
1.1667 + }
1.1668 default:
1.1669 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1.1670 break;
1.1671 @@ -1279,11 +1234,6 @@
1.1672 GST_OBJECT_UNLOCK (mythtvsrc);
1.1673 }
1.1674
1.1675 -/* entry point to initialize the plug-in
1.1676 - * initialize the plug-in itself
1.1677 - * register the element factories and pad templates
1.1678 - * register the features
1.1679 - */
1.1680 static gboolean
1.1681 plugin_init (GstPlugin * plugin)
1.1682 {
1.1683 @@ -1291,23 +1241,21 @@
1.1684 GST_TYPE_MYTHTV_SRC);
1.1685 }
1.1686
1.1687 -/* this is the structure that gst-register looks for
1.1688 - * so keep the name plugin_desc, or you cannot get your plug-in registered */
1.1689 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
1.1690 GST_VERSION_MINOR,
1.1691 "mythtv",
1.1692 "lib MythTV src",
1.1693 - plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
1.1694 + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
1.1695
1.1696
1.1697 /*** GSTURIHANDLER INTERFACE *************************************************/
1.1698 - static guint
1.1699 +static guint
1.1700 gst_mythtv_src_uri_get_type (void)
1.1701 {
1.1702 return GST_URI_SRC;
1.1703 }
1.1704
1.1705 - static gchar **
1.1706 +static gchar **
1.1707 gst_mythtv_src_uri_get_protocols (void)
1.1708 {
1.1709 static gchar *protocols[] = { "myth", "myths", NULL };
1.1710 @@ -1315,7 +1263,7 @@
1.1711 return protocols;
1.1712 }
1.1713
1.1714 - static const gchar *
1.1715 +static const gchar *
1.1716 gst_mythtv_src_uri_get_uri (GstURIHandler * handler)
1.1717 {
1.1718 GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
1.1719 @@ -1323,7 +1271,7 @@
1.1720 return src->uri_name;
1.1721 }
1.1722
1.1723 - static gboolean
1.1724 +static gboolean
1.1725 gst_mythtv_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
1.1726 {
1.1727 GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
1.1728 @@ -1341,7 +1289,7 @@
1.1729 return TRUE;
1.1730 }
1.1731
1.1732 - static void
1.1733 +static void
1.1734 gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
1.1735 {
1.1736 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
1.1737 @@ -1352,12 +1300,10 @@
1.1738 iface->set_uri = gst_mythtv_src_uri_set_uri;
1.1739 }
1.1740
1.1741 - void
1.1742 +void
1.1743 size_header_handler (void *userdata, const char *value)
1.1744 {
1.1745 GstMythtvSrc *src = GST_MYTHTV_SRC (userdata);
1.1746
1.1747 - //src->content_size = g_ascii_strtoull (value, NULL, 10);
1.1748 -
1.1749 GST_DEBUG_OBJECT (src, "content size = %lld bytes", src->content_size);
1.1750 }
2.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.h Mon Jan 22 18:37:42 2007 +0000
2.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.h Mon Jan 22 21:03:08 2007 +0000
2.3 @@ -1,4 +1,3 @@
2.4 -/* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2 -*- */
2.5 /* GStreamer
2.6 * Copyright (C) <2006> Rosfran Borges <rosfran.borges@indt.org.br>
2.7 *
2.8 @@ -10,7 +9,12 @@
2.9 * This library is distributed in the hope that it will be useful,
2.10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2.12 - * Library General Public License for more
2.13 + * Library General Public License for more details.
2.14 + *
2.15 + * You should have received a copy of the GNU Library General Public
2.16 + * License along with this library; if not, write to the
2.17 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
2.18 + * Boston, MA 02111-1307, USA.
2.19 */
2.20
2.21 #ifndef __GST_MYTHTV_SRC_H__
2.22 @@ -77,7 +81,6 @@
2.23
2.24 gint64 read_offset;
2.25
2.26 - /* added by melunko (buffer cache) */
2.27 gint buffer_remain;
2.28
2.29 gboolean eos;
2.30 @@ -105,10 +108,16 @@
2.31
2.32 GByteArray *bytes_queue;
2.33
2.34 +#ifndef GST_DISABLE_GST_DEBUG
2.35 /* enable Myth TV debug messages */
2.36 gboolean mythtv_msgs_dbg;
2.37 +#endif
2.38
2.39 gboolean update_prog_chain;
2.40 +
2.41 + /* stablish a maximum iteration value to the IS_RECORDING message */
2.42 + guint wait_to_transfer;
2.43 +
2.44 };
2.45
2.46 struct _GstMythtvSrcClass {