1.1 --- a/gst-gmyth/mythsrc/Makefile.am Mon Sep 03 21:14:14 2007 +0100
1.2 +++ b/gst-gmyth/mythsrc/Makefile.am Mon Sep 03 22:11:54 2007 +0100
1.3 @@ -3,7 +3,8 @@
1.4 plugin_LTLIBRARIES = libgstmythtvsrc.la
1.5
1.6 libgstmythtvsrc_la_SOURCES = \
1.7 - gstmythtvsrc.c
1.8 + gstmythtvsrc.c \
1.9 + gstmythtvsrc.h
1.10
1.11 libgstmythtvsrc_la_CFLAGS = \
1.12 $(GST_CFLAGS) \
1.13 @@ -18,6 +19,14 @@
1.14 $(GST_BASE_LIBS) \
1.15 $(GMYTH_LIBS)
1.16
1.17 +gstmythtvsrc.c:
1.18 + cvs -d:pserver:anoncvs@anoncvs.freedesktop.org:/cvs/gstreamer/ co gst-plugins-bad/ext/mythtv/gstmythtvsrc.c
1.19 + mv gst-plugins-bad/ext/mythtv/gstmythtvsrc.c .
1.20 +
1.21 +gstmythtvsrc.h:
1.22 + cvs -d:pserver:anoncvs@anoncvs.freedesktop.org:/cvs/gstreamer/ co gst-plugins-bad/ext/mythtv/gstmythtvsrc.h
1.23 + mv gst-plugins-bad/ext/mythtv/gstmythtvsrc.h .
1.24 +
1.25 noinst_HEADERS = \
1.26 gstmythtvsrc.h
1.27
2.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Mon Sep 03 21:14:14 2007 +0100
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,1085 +0,0 @@
2.4 -/*
2.5 - * GStreamer MythTV Plug-in Copyright (C) <2006> Rosfran Borges
2.6 - * <rosfran.borges@indt.org.br> This library is free software; you can
2.7 - * redistribute it and/or modify it under the terms of the GNU Library
2.8 - * General Public License as published by the Free Software Foundation;
2.9 - * either version 2 of the License, or (at your option) any later version.
2.10 - * This library is distributed in the hope that it will be useful, but
2.11 - * WITHOUT ANY WARRANTY; without even the implied warranty of
2.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
2.13 - * General Public License for more details. You should have received a copy
2.14 - * of the GNU Library General Public License along with this library; if
2.15 - * not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite
2.16 - * 330, Boston, MA 02111-1307, USA.
2.17 - */
2.18 -/**
2.19 - * SECTION:element-mythtvsrc
2.20 - *
2.21 - * <refsect2>
2.22 - * <para>
2.23 - * MythTVSrc allows to access a remote MythTV backend streaming Video/Audio server,
2.24 - * and to render audio and video content through a TCP/IP connection to a specific
2.25 - * port on this server, and based on a known MythTV protocol that is based on
2.26 - * some message passing, such as REQUEST_BLOCK on a specified number of bytes, to get
2.27 - * some chunk of remote file data.
2.28 - * You should pass the information aboute the remote MythTV backend server
2.29 - * through the <link linkend="GstMythTVSrc--location">location</link> property.
2.30 - * </para>
2.31 - * <title>Examples</title>
2.32 - * <para>
2.33 - * If you want to get the LiveTV content (set channel, TV tuner, RemoteEncoder,
2.34 - * Recorder),
2.35 - * put the following URI:
2.36 - *
2.37 - * <programlisting>
2.38 - * myth://xxx.xxx.xxx.xxx:6543/livetv?channel=BBC
2.39 - * </programlisting>
2.40 - *
2.41 - * This URI will say to the gmyth library to configure the Recorder instance (used to
2.42 - * change the channel, start the TV multimedia content transmition, etc.), using
2.43 - * the IP address (xxx.xxx.xxx.xxx) and port number (6543) of the MythTV backend
2.44 - * server, and setting the channel name to "BBC".
2.45 - *
2.46 - * To get a already recorded the MythTV NUV file, put the following URI:
2.47 - *
2.48 - * <programlisting>
2.49 - * myth://xxx.xxx.xxx.xxx:6543/filename.nuv
2.50 - * </programlisting>
2.51 - *
2.52 - * This URI will say to the gmyth library to configure the Recorder instance (used to
2.53 - * change the channel, start the TV multimedia content transmition, etc.), using
2.54 - * the IP address (xxx.xxx.xxx.xxx) and port number (6543) of the MythTV backend
2.55 - * server, and setting the channel name to "BBC".
2.56 - *
2.57 - * Another possible way to use the LiveTV content, and just in the case you want to
2.58 - * use the mysql database, put the location URI in the following format:
2.59 - *
2.60 - * <programlisting>
2.61 - * myth://mythtv:mythtv@xxx.xxx.xxx.xxx:6543/?mythconverg&channel=9
2.62 - * </programlisting>
2.63 - *
2.64 - * Where the first field is the protocol (myth), the second and third are user
2.65 - * name (mythtv) and password (mythtv), then backend host name and port number,
2.66 - * and the last field is the database name (mythconverg).
2.67 - * </para>
2.68 - * </refsect2>
2.69 - */
2.70 -#ifdef HAVE_CONFIG_H
2.71 -#include "config.h"
2.72 -#endif
2.73 -
2.74 -#include "gstmythtvsrc.h"
2.75 -#include <gmyth/gmyth_file.h>
2.76 -#include <gmyth/gmyth_file_transfer.h>
2.77 -#include <gmyth/gmyth_file_local.h>
2.78 -#include <gmyth/gmyth_livetv.h>
2.79 -
2.80 -#include <gmyth/gmyth_socket.h>
2.81 -#include <gmyth/gmyth_tvchain.h>
2.82 -
2.83 -#include <string.h>
2.84 -#include <unistd.h>
2.85 -
2.86 -GST_DEBUG_CATEGORY_STATIC(mythtvsrc_debug);
2.87 -#define GST_GMYTHTV_ID_NUM 1
2.88 -#define GST_GMYTHTV_CHANNEL_DEFAULT_NUM (-1)
2.89 -#define GMYTHTV_VERSION_DEFAULT 30
2.90 -#define GMYTHTV_TRANSFER_MAX_WAITS 100
2.91 -#define GMYTHTV_TRANSFER_MAX_RESENDS 2
2.92 -#define GMYTHTV_TRANSFER_MAX_BUFFER (128*1024)
2.93 -#define READ_SIZE (14*1024)
2.94 -#define READ_SIZE_LIVETV (80*1024)
2.95 -#define GST_FLOW_ERROR_NO_DATA (-101)
2.96 -
2.97 -static const GstElementDetails gst_mythtv_src_details =
2.98 -GST_ELEMENT_DETAILS("MythTV client source",
2.99 - "Source/Network",
2.100 - "Control and receive data as a client over the network "
2.101 - "via raw socket connections using the MythTV protocol",
2.102 - "Rosfran Borges <rosfran.borges@indt.org.br>");
2.103 -
2.104 -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE("src",
2.105 - GST_PAD_SRC,
2.106 - GST_PAD_ALWAYS,
2.107 - GST_STATIC_CAPS_ANY);
2.108 - /*
2.109 - * GST_STATIC_CAPS ("video/x-nuv"));
2.110 - */
2.111 -
2.112 -enum {
2.113 - PROP_0,
2.114 - PROP_LOCATION,
2.115 - PROP_GMYTHTV_VERSION,
2.116 - PROP_GMYTHTV_LIVE,
2.117 - PROP_GMYTHTV_LIVEID,
2.118 - PROP_GMYTHTV_LIVE_CHAINID,
2.119 - PROP_GMYTHTV_ENABLE_TIMING_POSITION,
2.120 - PROP_GMYTHTV_CHANNEL_NUM
2.121 -};
2.122 -
2.123 -static void gst_mythtv_src_clear(GstMythtvSrc * mythtv_src);
2.124 -
2.125 -static void gst_mythtv_src_finalize(GObject * gobject);
2.126 -
2.127 -static GstFlowReturn gst_mythtv_src_create(GstPushSrc * psrc,
2.128 - GstBuffer ** outbuf);
2.129 -
2.130 -static gboolean gst_mythtv_src_start(GstBaseSrc * bsrc);
2.131 -static gboolean gst_mythtv_src_stop(GstBaseSrc * bsrc);
2.132 -static gboolean gst_mythtv_src_get_size(GstBaseSrc * bsrc, guint64 * size);
2.133 -static gboolean gst_mythtv_src_is_seekable(GstBaseSrc * push_src);
2.134 -
2.135 -static gboolean gst_mythtv_src_do_seek(GstBaseSrc * base,
2.136 - GstSegment * segment);
2.137 -
2.138 -static GstStateChangeReturn
2.139 -gst_mythtv_src_change_state(GstElement * element,
2.140 - GstStateChange transition);
2.141 -
2.142 -static void gst_mythtv_src_set_property(GObject * object,
2.143 - guint prop_id,
2.144 - const GValue * value,
2.145 - GParamSpec * pspec);
2.146 -static void gst_mythtv_src_get_property(GObject * object,
2.147 - guint prop_id, GValue * value,
2.148 - GParamSpec * pspec);
2.149 -
2.150 -static void gst_mythtv_src_uri_handler_init(gpointer g_iface,
2.151 - gpointer iface_data);
2.152 -
2.153 -static gboolean gst_mythtv_src_handle_query(GstPad * pad,
2.154 - GstQuery * query);
2.155 -
2.156 -static gboolean gst_mythtv_src_handle_event(GstPad * pad,
2.157 - GstEvent * event);
2.158 -
2.159 -static GMythFileReadResult do_read_request_response(GstMythtvSrc * src,
2.160 - guint size,
2.161 - GByteArray * data_ptr);
2.162 -
2.163 -static void
2.164 -_urihandler_init(GType type)
2.165 -{
2.166 - static const GInterfaceInfo urihandler_info = {
2.167 - gst_mythtv_src_uri_handler_init,
2.168 - NULL,
2.169 - NULL
2.170 - };
2.171 -
2.172 - g_type_add_interface_static(type, GST_TYPE_URI_HANDLER,
2.173 - &urihandler_info);
2.174 -
2.175 - GST_DEBUG_CATEGORY_INIT(mythtvsrc_debug, "mythtvsrc", 0, "MythTV src");
2.176 -}
2.177 -
2.178 -GST_BOILERPLATE_FULL(GstMythtvSrc, gst_mythtv_src, GstPushSrc,
2.179 - GST_TYPE_PUSH_SRC, _urihandler_init)
2.180 - static void gst_mythtv_src_base_init(gpointer g_class)
2.181 -{
2.182 - GstElementClass *element_class = GST_ELEMENT_CLASS(g_class);
2.183 -
2.184 - gst_element_class_add_pad_template(element_class,
2.185 - gst_static_pad_template_get
2.186 - (&srctemplate));
2.187 -
2.188 - gst_element_class_set_details(element_class, &gst_mythtv_src_details);
2.189 -
2.190 - element_class->change_state = gst_mythtv_src_change_state;
2.191 -
2.192 -}
2.193 -
2.194 -static void
2.195 -gst_mythtv_src_class_init(GstMythtvSrcClass * klass)
2.196 -{
2.197 - GObjectClass *gobject_class;
2.198 - GstPushSrcClass *gstpushsrc_class;
2.199 - GstBaseSrcClass *gstbasesrc_class;
2.200 -
2.201 - gobject_class = (GObjectClass *) klass;
2.202 - gstbasesrc_class = (GstBaseSrcClass *) klass;
2.203 - gstpushsrc_class = (GstPushSrcClass *) klass;
2.204 -
2.205 - gobject_class->set_property = gst_mythtv_src_set_property;
2.206 - gobject_class->get_property = gst_mythtv_src_get_property;
2.207 - gobject_class->finalize = gst_mythtv_src_finalize;
2.208 -
2.209 - g_object_class_install_property
2.210 - (gobject_class, PROP_LOCATION,
2.211 - g_param_spec_string("location", "Location",
2.212 - "The location. In the form:"
2.213 - "\n\t\t\tmyth://a.com/file.nuv"
2.214 - "\n\t\t\tmyth://a.com:23223/file.nuv "
2.215 - "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
2.216 - "", G_PARAM_READWRITE));
2.217 -
2.218 - g_object_class_install_property
2.219 - (gobject_class, PROP_GMYTHTV_VERSION,
2.220 - g_param_spec_int("mythtv-version", "mythtv-version",
2.221 - "Change MythTV version", 26, 30, 26,
2.222 - G_PARAM_READWRITE));
2.223 -
2.224 - g_object_class_install_property
2.225 - (gobject_class, PROP_GMYTHTV_LIVEID,
2.226 - g_param_spec_int("mythtv-live-id", "mythtv-live-id",
2.227 - "Change MythTV version",
2.228 - 0, 200, GST_GMYTHTV_ID_NUM, G_PARAM_READWRITE));
2.229 -
2.230 - g_object_class_install_property
2.231 - (gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
2.232 - g_param_spec_string("mythtv-live-chainid", "mythtv-live-chainid",
2.233 - "Sets the MythTV chain ID (from TV Chain)",
2.234 - "", G_PARAM_READWRITE));
2.235 -
2.236 - g_object_class_install_property
2.237 - (gobject_class, PROP_GMYTHTV_LIVE,
2.238 - g_param_spec_boolean("mythtv-live", "mythtv-live",
2.239 - "Enable MythTV Live TV content streaming",
2.240 - FALSE, G_PARAM_READWRITE));
2.241 -
2.242 - g_object_class_install_property
2.243 - (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
2.244 - g_param_spec_boolean("mythtv-enable-timing-position",
2.245 - "mythtv-enable-timing-position",
2.246 - "Enable MythTV Live TV content size continuous updating",
2.247 - FALSE, G_PARAM_READWRITE));
2.248 -
2.249 - g_object_class_install_property
2.250 - (gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
2.251 - g_param_spec_string("mythtv-channel", "mythtv-channel",
2.252 - "Change MythTV channel number",
2.253 - "", G_PARAM_READWRITE));
2.254 -
2.255 - gstbasesrc_class->start = gst_mythtv_src_start;
2.256 - gstbasesrc_class->stop = gst_mythtv_src_stop;
2.257 - gstbasesrc_class->get_size = gst_mythtv_src_get_size;
2.258 - gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable;
2.259 - gstbasesrc_class->do_seek = gst_mythtv_src_do_seek;
2.260 - gstpushsrc_class->create = gst_mythtv_src_create;
2.261 -
2.262 - GST_DEBUG_CATEGORY_INIT(mythtvsrc_debug, "mythtvsrc", 0,
2.263 - "MythTV Client Source");
2.264 -}
2.265 -
2.266 -static void
2.267 -gst_mythtv_src_init(GstMythtvSrc * this, GstMythtvSrcClass * g_class)
2.268 -{
2.269 - this->file = NULL;
2.270 - this->unique_setup = FALSE;
2.271 - this->mythtv_version = GMYTHTV_VERSION_DEFAULT;
2.272 - this->state = GST_MYTHTV_SRC_FILE_TRANSFER;
2.273 - this->bytes_read = 0;
2.274 - this->prev_content_size = 0;
2.275 - this->content_size = 0;
2.276 - this->read_offset = 0;
2.277 - this->content_size_last = 0;
2.278 - this->live_tv = FALSE;
2.279 - this->enable_timing_position = FALSE;
2.280 - this->update_prog_chain = FALSE;
2.281 - this->user_agent = g_strdup("mythtvsrc");
2.282 - this->update_prog_chain = FALSE;
2.283 - this->channel_name = NULL;
2.284 - this->eos = FALSE;
2.285 - this->wait_to_transfer = 0;
2.286 - gst_base_src_set_format(GST_BASE_SRC(this), GST_FORMAT_BYTES);
2.287 - gst_pad_set_event_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
2.288 - gst_mythtv_src_handle_event);
2.289 - gst_pad_set_query_function(GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
2.290 - gst_mythtv_src_handle_query);
2.291 -
2.292 -}
2.293 -
2.294 -static void
2.295 -gst_mythtv_src_clear(GstMythtvSrc * mythtv_src)
2.296 -{
2.297 - mythtv_src->unique_setup = FALSE;
2.298 -
2.299 - if (mythtv_src->spawn_livetv) {
2.300 - g_object_unref(mythtv_src->spawn_livetv);
2.301 - mythtv_src->spawn_livetv = NULL;
2.302 - }
2.303 -
2.304 - if (mythtv_src->file) {
2.305 - g_object_unref(mythtv_src->file);
2.306 - mythtv_src->file = NULL;
2.307 - }
2.308 -
2.309 - if (mythtv_src->backend_info) {
2.310 - g_object_unref(mythtv_src->backend_info);
2.311 - mythtv_src->backend_info = NULL;
2.312 - }
2.313 -}
2.314 -
2.315 -static void
2.316 -gst_mythtv_src_finalize(GObject * gobject)
2.317 -{
2.318 - GstMythtvSrc *this = GST_MYTHTV_SRC(gobject);
2.319 -
2.320 - gst_mythtv_src_clear(this);
2.321 -
2.322 - if (this->uri_name) {
2.323 - g_free(this->uri_name);
2.324 - this->uri_name = NULL;
2.325 - }
2.326 -
2.327 - if (this->user_agent) {
2.328 - g_free(this->user_agent);
2.329 - this->user_agent = NULL;
2.330 - }
2.331 -
2.332 - G_OBJECT_CLASS(parent_class)->finalize(gobject);
2.333 -}
2.334 -
2.335 -static GMythFileReadResult
2.336 -do_read_request_response(GstMythtvSrc * src, guint size,
2.337 - GByteArray * data_ptr)
2.338 -{
2.339 - gint read = 0;
2.340 - guint sizetoread = size;
2.341 - gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
2.342 - GMythFileReadResult result;
2.343 -
2.344 - GST_LOG_OBJECT(src, "Starting: Reading %d bytes...", sizetoread);
2.345 -
2.346 - /*
2.347 - * Loop sending the Myth File Transfer request: Retry whilst
2.348 - * authentication fails and we supply it.
2.349 - */
2.350 -
2.351 - while (sizetoread == size && --max_iters > 0) {
2.352 - /*
2.353 - * if ( gmyth_backend_info_is_local_file(src->backend_info) )
2.354 - */
2.355 - if (IS_GMYTH_FILE_LOCAL(src->file))
2.356 - result = gmyth_file_local_read(GMYTH_FILE_LOCAL(src->file),
2.357 - data_ptr, sizetoread,
2.358 - src->live_tv);
2.359 - else if (IS_GMYTH_FILE_TRANSFER(src->file))
2.360 - result =
2.361 - gmyth_file_transfer_read(GMYTH_FILE_TRANSFER(src->file),
2.362 - data_ptr, sizetoread,
2.363 - src->live_tv);
2.364 -
2.365 - if (data_ptr->len > 0) {
2.366 - read += data_ptr->len;
2.367 - sizetoread -= data_ptr->len;
2.368 - } else if (data_ptr->len <= 0) {
2.369 - if (src->live_tv == FALSE) {
2.370 - result = GMYTH_FILE_READ_EOF;
2.371 - goto eos;
2.372 - } else {
2.373 - if (result == GMYTH_FILE_READ_ERROR) { /* -314 */
2.374 - GST_INFO_OBJECT(src,
2.375 - "[LiveTV] FileTransfer READ_ERROR!");
2.376 - }
2.377 - goto done;
2.378 - }
2.379 - }
2.380 - /*
2.381 - * else if (data_ptr->len == 0) goto done;
2.382 - */
2.383 - if (read == sizetoread)
2.384 - goto done;
2.385 - }
2.386 -
2.387 - if ((read < 0 && !src->live_tv) || max_iters == 0) {
2.388 - result = GMYTH_FILE_READ_EOF;
2.389 - goto eos;
2.390 - }
2.391 -
2.392 - goto done;
2.393 -
2.394 - eos:
2.395 - src->eos = TRUE;
2.396 -
2.397 - done:
2.398 - return result;
2.399 -}
2.400 -
2.401 -static GstFlowReturn
2.402 -gst_mythtv_src_create(GstPushSrc * psrc, GstBuffer ** outbuf)
2.403 -{
2.404 - GstMythtvSrc *src;
2.405 - GstFlowReturn ret = GST_FLOW_OK;
2.406 - GByteArray *buffer;
2.407 - gint buffer_remain = 0;
2.408 - GMythFileReadResult result = GMYTH_FILE_READ_OK;
2.409 - gboolean buffering = FALSE;
2.410 -
2.411 - src = GST_MYTHTV_SRC(psrc);
2.412 -
2.413 - buffer = g_byte_array_new ();
2.414 - if (src->live_tv)
2.415 - result = do_read_request_response(src, READ_SIZE_LIVETV, buffer);
2.416 - else
2.417 - result = do_read_request_response(src, READ_SIZE, buffer);
2.418 -
2.419 - if (result == GMYTH_FILE_READ_ERROR)
2.420 - goto read_error;
2.421 -
2.422 -
2.423 - *outbuf = gst_buffer_new();
2.424 - GST_BUFFER_SIZE(*outbuf) = buffer->len;
2.425 - GST_BUFFER_MALLOCDATA(*outbuf) = g_malloc0(GST_BUFFER_SIZE(*outbuf));
2.426 - GST_BUFFER_DATA(*outbuf) = GST_BUFFER_MALLOCDATA(*outbuf);
2.427 - g_memmove(GST_BUFFER_DATA((*outbuf)), buffer->data,
2.428 - GST_BUFFER_SIZE(*outbuf));
2.429 - GST_BUFFER_OFFSET(*outbuf) = src->read_offset;
2.430 - GST_BUFFER_OFFSET_END(*outbuf) =
2.431 - src->read_offset + GST_BUFFER_SIZE(*outbuf);
2.432 -
2.433 - src->read_offset += GST_BUFFER_SIZE(*outbuf);
2.434 - src->bytes_read += GST_BUFFER_SIZE(*outbuf);
2.435 -
2.436 - g_byte_array_free (buffer, TRUE);
2.437 -
2.438 - if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) {
2.439 - GstPad *peer;
2.440 -
2.441 - peer = gst_pad_get_peer (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)));
2.442 - gst_pad_send_event (peer,
2.443 - gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
2.444 -
2.445 - gst_object_unref (peer);
2.446 - }
2.447 -
2.448 - if (src->eos ||
2.449 - (!src->live_tv && (src->bytes_read >= src->content_size)))
2.450 - ret = GST_FLOW_UNEXPECTED;
2.451 -
2.452 - return ret;
2.453 -
2.454 -read_error:
2.455 - GST_ELEMENT_ERROR(src, RESOURCE, READ,
2.456 - (NULL), ("Could not read any bytes (%i, %s)",
2.457 - read, src->uri_name));
2.458 - return GST_FLOW_ERROR;
2.459 -}
2.460 -
2.461 -gint64
2.462 -gst_mythtv_src_get_position(GstMythtvSrc * src)
2.463 -{
2.464 -
2.465 - gint64 size_tmp = 0;
2.466 - guint max_tries = 2;
2.467 -
2.468 - if (src->live_tv == TRUE && (abs(src->content_size - src->bytes_read) <
2.469 - GMYTHTV_TRANSFER_MAX_BUFFER)) {
2.470 -
2.471 - get_file_pos:
2.472 - g_usleep(10);
2.473 - size_tmp =
2.474 - gmyth_recorder_get_file_position(src->spawn_livetv->recorder);
2.475 - if (size_tmp > (src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER))
2.476 - src->content_size = size_tmp;
2.477 - else if (size_tmp > 0 && --max_tries > 0)
2.478 - goto get_file_pos;
2.479 - GST_LOG_OBJECT(src, "GET_POSITION: file_position = %lld",
2.480 - size_tmp);
2.481 - /*
2.482 - * sets the last content size amount before it can be updated
2.483 - */
2.484 - src->prev_content_size = src->content_size;
2.485 - }
2.486 -
2.487 - return src->content_size;
2.488 -
2.489 -}
2.490 -
2.491 -static gboolean
2.492 -gst_mythtv_src_do_seek(GstBaseSrc * base, GstSegment * segment)
2.493 -{
2.494 - GstMythtvSrc *src = GST_MYTHTV_SRC(base);
2.495 - gint64 new_offset = -1;
2.496 - gint64 actual_seek = segment->start;
2.497 - gboolean ret = TRUE;
2.498 -
2.499 - GST_LOG_OBJECT(src, "seek, segment: %" GST_SEGMENT_FORMAT, segment);
2.500 -
2.501 - if (segment->format == GST_FORMAT_TIME) {
2.502 - goto done;
2.503 - }
2.504 - GST_LOG_OBJECT(src,
2.505 - "Trying to seek at the value (actual_seek = %lld, read_offset = %lld)",
2.506 - actual_seek, src->read_offset);
2.507 - /*
2.508 - * verify if it needs to seek
2.509 - */
2.510 - if (src->read_offset != actual_seek) {
2.511 -
2.512 - /*
2.513 - * if ( gmyth_backend_info_is_local_file(src->backend_info) )
2.514 - */
2.515 - if (IS_GMYTH_FILE_LOCAL(src->file))
2.516 - new_offset =
2.517 - gmyth_file_local_seek(GMYTH_FILE_LOCAL(src->file),
2.518 - segment->start, G_SEEK_SET);
2.519 - else if (IS_GMYTH_FILE_TRANSFER(src->file))
2.520 - new_offset =
2.521 - gmyth_file_transfer_seek(GMYTH_FILE_TRANSFER(src->file),
2.522 - segment->start, SEEK_SET);
2.523 -
2.524 - GST_LOG_OBJECT(src,
2.525 - "Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.",
2.526 - segment->start, src->read_offset, new_offset);
2.527 - if (G_UNLIKELY(new_offset < 0)) {
2.528 - ret = FALSE;
2.529 - if (!src->live_tv)
2.530 - goto eos;
2.531 - }
2.532 -
2.533 - src->read_offset = new_offset;
2.534 -
2.535 - if (ret == FALSE) {
2.536 - GST_INFO_OBJECT(src, "Failed to set the SEEK on segment!");
2.537 - }
2.538 -
2.539 - }
2.540 -
2.541 - done:
2.542 - return ret;
2.543 -
2.544 - eos:
2.545 - {
2.546 - GST_DEBUG_OBJECT(src, "EOS found on seeking!!!");
2.547 - return FALSE;
2.548 - }
2.549 -
2.550 -}
2.551 -
2.552 -/*
2.553 - * create a socket for connecting to remote server
2.554 - */
2.555 -static gboolean
2.556 -gst_mythtv_src_start(GstBaseSrc * bsrc)
2.557 -{
2.558 - GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
2.559 -
2.560 - GString *chain_id_local = NULL;
2.561 - GMythURI *gmyth_uri = NULL;
2.562 - gboolean ret = TRUE;
2.563 - GstMessage *msg;
2.564 -
2.565 - if (src->unique_setup == FALSE) {
2.566 - src->unique_setup = TRUE;
2.567 - } else {
2.568 - goto done;
2.569 - }
2.570 -
2.571 - gmyth_uri = gmyth_uri_new_with_value(src->uri_name);
2.572 - src->backend_info = gmyth_backend_info_new_with_uri(src->uri_name);
2.573 - src->live_tv = gmyth_uri_is_livetv(gmyth_uri);
2.574 -
2.575 - if (src->live_tv) {
2.576 - src->spawn_livetv = gmyth_livetv_new(src->backend_info);
2.577 - gchar *ch = gmyth_uri_get_channel_name(gmyth_uri);
2.578 - if (ch != NULL)
2.579 - src->channel_name = ch;
2.580 -
2.581 - if (src->channel_name != NULL) {
2.582 - gboolean result;
2.583 - result =
2.584 - gmyth_livetv_channel_name_setup(src->spawn_livetv,
2.585 - src->channel_name);
2.586 - if (result == FALSE) {
2.587 - GST_INFO_OBJECT(src, "LiveTV setup felt down on error");
2.588 - ret = FALSE;
2.589 - goto init_failed;
2.590 - }
2.591 -
2.592 - } else {
2.593 - if (gmyth_livetv_setup(src->spawn_livetv) == FALSE) {
2.594 - GST_INFO_OBJECT(src, "LiveTV setup felt down on error");
2.595 - ret = FALSE;
2.596 - goto init_failed;
2.597 - }
2.598 - }
2.599 -
2.600 - /*
2.601 - * testing change channel...
2.602 - */
2.603 - /*
2.604 - * gmyth_recorder_change_channel( src->spawn_livetv->recorder,
2.605 - * CHANNEL_DIRECTION_UP );
2.606 - */
2.607 -
2.608 - src->file =
2.609 - GMYTH_FILE(gmyth_livetv_create_file_transfer
2.610 - (src->spawn_livetv));
2.611 -
2.612 -
2.613 - if (NULL == src->file) {
2.614 - GST_INFO_OBJECT(src, "[LiveTV] FileTransfer equals to NULL");
2.615 - ret = FALSE;
2.616 - goto init_failed;
2.617 - }
2.618 -
2.619 - /*
2.620 - * Check if the file is local to this specific client renderer
2.621 - */
2.622 - if (gmyth_uri_is_local_file(gmyth_uri))
2.623 - ret = gmyth_file_local_open(GMYTH_FILE_LOCAL(src->file));
2.624 - else
2.625 - ret =
2.626 - gmyth_file_transfer_open(GMYTH_FILE_TRANSFER(src->file),
2.627 - src->spawn_livetv->uri !=
2.628 - NULL ? gmyth_uri_get_path(src->
2.629 - spawn_livetv->
2.630 - uri) :
2.631 - src->spawn_livetv->proginfo->
2.632 - pathname->str);
2.633 -
2.634 - /*
2.635 - * sets the mythtvsrc "location" property
2.636 - */
2.637 - g_object_set(src, "location", gmyth_file_get_uri(src->file), NULL);
2.638 -
2.639 - if (!ret) {
2.640 - GST_INFO_OBJECT(src,
2.641 - "Error: couldn't open the FileTransfer from LiveTV source!");
2.642 - g_object_unref(src->file);
2.643 - src->file = NULL;
2.644 - goto init_failed;
2.645 - }
2.646 - } else {
2.647 -
2.648 - /*
2.649 - * Check if the file is local to this specific client renderer,
2.650 - * and tries to open a local connection
2.651 - */
2.652 - if (gmyth_uri_is_local_file(gmyth_uri)) {
2.653 - src->file =
2.654 - GMYTH_FILE(gmyth_file_local_new(src->backend_info));
2.655 - ret = gmyth_file_local_open(GMYTH_FILE_LOCAL(src->file));
2.656 - } else {
2.657 - src->file =
2.658 - GMYTH_FILE(gmyth_file_transfer_new(src->backend_info));
2.659 - ret =
2.660 - gmyth_file_transfer_open(GMYTH_FILE_TRANSFER(src->file),
2.661 - src->uri_name);
2.662 - }
2.663 -
2.664 - } /* if (else) - recorded FileTransfer */
2.665 -
2.666 - if (NULL == src->file) {
2.667 - GST_INFO_OBJECT(src, "FileTransfer is NULL");
2.668 - goto init_failed;
2.669 - }
2.670 - /*
2.671 - * GST_INFO_OBJECT( src, "uri = %s", src->spawn_livetv->file);
2.672 - */
2.673 -
2.674 - if (ret == FALSE) {
2.675 - GST_INFO_OBJECT(src,
2.676 - "MythTV FileTransfer request failed when setting up socket connection!");
2.677 - goto begin_req_failed;
2.678 - }
2.679 -
2.680 - GST_INFO_OBJECT(src,
2.681 - "MythTV FileTransfer filesize = %lld, content_size = %lld!",
2.682 - gmyth_file_get_filesize(src->file), src->content_size);
2.683 -
2.684 - src->content_size = gmyth_file_get_filesize(src->file);
2.685 -
2.686 - msg =
2.687 - gst_message_new_duration(GST_OBJECT(src), GST_FORMAT_BYTES,
2.688 - src->content_size);
2.689 - gst_element_post_message(GST_ELEMENT(src), msg);
2.690 -
2.691 -
2.692 - src->do_start = FALSE;
2.693 -
2.694 - gst_pad_push_event(GST_BASE_SRC_PAD(GST_BASE_SRC(src)),
2.695 - gst_event_new_new_segment(TRUE, 1.0,
2.696 - GST_FORMAT_TIME, 0,
2.697 - src->content_size, 0));
2.698 -
2.699 - done:
2.700 - if (gmyth_uri != NULL) {
2.701 - g_object_unref(gmyth_uri);
2.702 - gmyth_uri = NULL;
2.703 - }
2.704 -
2.705 - if (chain_id_local != NULL) {
2.706 - g_string_free(chain_id_local, TRUE);
2.707 - chain_id_local = NULL;
2.708 - }
2.709 -
2.710 - return TRUE;
2.711 -
2.712 - /*
2.713 - * ERRORS
2.714 - */
2.715 - init_failed:
2.716 - if (gmyth_uri != NULL) {
2.717 - g_object_unref(gmyth_uri);
2.718 - gmyth_uri = NULL;
2.719 - }
2.720 -
2.721 - if (src->spawn_livetv != NULL) {
2.722 - g_object_unref(src->spawn_livetv);
2.723 - src->spawn_livetv = NULL;
2.724 - }
2.725 -
2.726 - GST_ELEMENT_ERROR(src, LIBRARY, INIT,
2.727 - (NULL),
2.728 - ("Could not initialize MythTV library (%i, %s)", ret,
2.729 - src->uri_name));
2.730 -
2.731 -
2.732 - gst_mythtv_src_clear(src);
2.733 -
2.734 - return FALSE;
2.735 - begin_req_failed:
2.736 - if (gmyth_uri != NULL) {
2.737 - g_object_unref(gmyth_uri);
2.738 - gmyth_uri = NULL;
2.739 - }
2.740 -
2.741 - GST_ELEMENT_ERROR(src, LIBRARY, INIT,
2.742 - (NULL),
2.743 - ("Could not begin request sent to MythTV server (%i, %s)",
2.744 - ret, src->uri_name));
2.745 - return FALSE;
2.746 -
2.747 -}
2.748 -
2.749 -static gboolean
2.750 -gst_mythtv_src_get_size(GstBaseSrc * bsrc, guint64 * size)
2.751 -{
2.752 - GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
2.753 - gboolean ret = TRUE;
2.754 -
2.755 - GST_LOG_OBJECT(src,
2.756 - "Differs from previous content size: %d (max.: %d)",
2.757 - abs(src->content_size - src->prev_content_size),
2.758 - GMYTHTV_TRANSFER_MAX_BUFFER);
2.759 -
2.760 - if (src->live_tv) {
2.761 - ret = FALSE;
2.762 - } else if (src->live_tv && src->enable_timing_position
2.763 - && (abs(src->content_size - src->bytes_read) <
2.764 - GMYTHTV_TRANSFER_MAX_BUFFER)) {
2.765 -
2.766 - gint64 new_offset =
2.767 - gmyth_recorder_get_file_position(src->spawn_livetv->recorder);
2.768 - if (new_offset > 0 && new_offset > src->content_size) {
2.769 - src->content_size = new_offset;
2.770 - } else if (new_offset < src->content_size) {
2.771 - src->update_prog_chain = TRUE;
2.772 - }
2.773 -
2.774 - }
2.775 -
2.776 - *size = src->content_size;
2.777 - GST_LOG_OBJECT(src, "Content size = %lld", src->content_size);
2.778 -
2.779 - return ret;
2.780 -
2.781 -}
2.782 -
2.783 -/*
2.784 - * close the socket and associated resources used both to recover from
2.785 - * errors and go to NULL state
2.786 - */
2.787 -static gboolean
2.788 -gst_mythtv_src_stop(GstBaseSrc * bsrc)
2.789 -{
2.790 - GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc);
2.791 -
2.792 - gst_mythtv_src_clear(src);
2.793 - return TRUE;
2.794 -}
2.795 -
2.796 -static gboolean
2.797 -gst_mythtv_src_handle_event(GstPad * pad, GstEvent * event)
2.798 -{
2.799 - GstMythtvSrc *src = GST_MYTHTV_SRC(GST_PAD_PARENT(pad));
2.800 - gint64 cont_size = 0;
2.801 - gboolean ret = TRUE;
2.802 -
2.803 - switch (GST_EVENT_TYPE(event)) {
2.804 - case GST_EVENT_EOS:
2.805 - if (src->live_tv) {
2.806 - cont_size = gst_mythtv_src_get_position(src);
2.807 - if (cont_size > src->content_size) {
2.808 - src->content_size = cont_size;
2.809 - src->eos = FALSE;
2.810 - } else {
2.811 - src->eos = TRUE;
2.812 - gst_element_set_state(GST_ELEMENT(src), GST_STATE_NULL);
2.813 - gst_element_set_locked_state(GST_ELEMENT(src), FALSE);
2.814 - }
2.815 - }
2.816 - break;
2.817 - default:
2.818 - ret = gst_pad_event_default(pad, event);
2.819 - }
2.820 -
2.821 - GST_DEBUG_OBJECT (src, "HANDLE EVENT %d", ret);
2.822 - return ret;
2.823 -}
2.824 -
2.825 -static gboolean
2.826 -gst_mythtv_src_is_seekable(GstBaseSrc * push_src)
2.827 -{
2.828 - return TRUE;
2.829 -}
2.830 -
2.831 -static gboolean
2.832 -gst_mythtv_src_handle_query(GstPad * pad, GstQuery * query)
2.833 -{
2.834 - gboolean res = FALSE;
2.835 - GstMythtvSrc *myth = GST_MYTHTV_SRC(gst_pad_get_parent(pad));
2.836 - GstFormat formt;
2.837 -
2.838 -
2.839 - switch (GST_QUERY_TYPE(query)) {
2.840 - case GST_QUERY_POSITION:
2.841 - gst_query_parse_position(query, &formt, NULL);
2.842 - if (formt == GST_FORMAT_BYTES) {
2.843 - gst_query_set_position(query, formt, myth->read_offset);
2.844 - GST_DEBUG_OBJECT(myth, "POS %" G_GINT64_FORMAT,
2.845 - myth->read_offset);
2.846 - res = TRUE;
2.847 - } else if (formt == GST_FORMAT_TIME) {
2.848 - res = gst_pad_query_default(pad, query);
2.849 - }
2.850 - break;
2.851 - case GST_QUERY_DURATION:
2.852 - gst_query_parse_duration(query, &formt, NULL);
2.853 - if (formt == GST_FORMAT_BYTES) {
2.854 - gint64 size = myth->content_size;
2.855 -
2.856 - gst_query_set_duration(query, GST_FORMAT_BYTES, 10);
2.857 - GST_DEBUG_OBJECT(myth, "SIZE %" G_GINT64_FORMAT, size);
2.858 - res = TRUE;
2.859 - } else if (formt == GST_FORMAT_TIME) {
2.860 - res = gst_pad_query_default(pad, query);
2.861 - }
2.862 - break;
2.863 - default:
2.864 - res = gst_pad_query_default(pad, query);
2.865 - break;
2.866 - }
2.867 -
2.868 - gst_object_unref(myth);
2.869 -
2.870 - return res;
2.871 -}
2.872 -
2.873 -static GstStateChangeReturn
2.874 -gst_mythtv_src_change_state(GstElement * element,
2.875 - GstStateChange transition)
2.876 -{
2.877 - GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
2.878 - GstMythtvSrc *src = GST_MYTHTV_SRC(element);
2.879 -
2.880 - switch (transition) {
2.881 - case GST_STATE_CHANGE_NULL_TO_READY:
2.882 - break;
2.883 - case GST_STATE_CHANGE_READY_TO_PAUSED:
2.884 - if (!src->uri_name) {
2.885 - GST_WARNING_OBJECT (src, "Invalid location");
2.886 - return ret;
2.887 - }
2.888 - break;
2.889 - case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
2.890 - if (src->live_tv) {
2.891 - if (!gmyth_recorder_send_frontend_ready_command
2.892 - (src->spawn_livetv->recorder))
2.893 - GST_WARNING_OBJECT(src,
2.894 - "Couldn't send the FRONTEND_READY message to the backend!");
2.895 - else
2.896 - GST_DEBUG_OBJECT(src, "FRONTEND_READY was sent to the backend");
2.897 - }
2.898 - break;
2.899 - default:
2.900 - break;
2.901 - }
2.902 -
2.903 - ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
2.904 - if (ret == GST_STATE_CHANGE_FAILURE) {
2.905 - return ret;
2.906 - }
2.907 -
2.908 -
2.909 - switch (transition) {
2.910 - case GST_STATE_CHANGE_READY_TO_NULL:
2.911 - gst_mythtv_src_clear(src);
2.912 - break;
2.913 - case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
2.914 - case GST_STATE_CHANGE_PAUSED_TO_READY:
2.915 - break;
2.916 - default:
2.917 - break;
2.918 - }
2.919 -
2.920 - return ret;
2.921 -}
2.922 -
2.923 -static void
2.924 -gst_mythtv_src_set_property(GObject * object, guint prop_id,
2.925 - const GValue * value, GParamSpec * pspec)
2.926 -{
2.927 - GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC(object);
2.928 -
2.929 - GST_OBJECT_LOCK(mythtvsrc);
2.930 - switch (prop_id) {
2.931 - case PROP_LOCATION:
2.932 - if (!g_value_get_string(value)) {
2.933 - GST_WARNING("location property cannot be NULL");
2.934 - break;
2.935 - }
2.936 -
2.937 - if (mythtvsrc->uri_name != NULL) {
2.938 - g_free(mythtvsrc->uri_name);
2.939 - mythtvsrc->uri_name = NULL;
2.940 - }
2.941 - mythtvsrc->uri_name = g_value_dup_string(value);
2.942 - break;
2.943 - case PROP_GMYTHTV_VERSION:
2.944 - mythtvsrc->mythtv_version = g_value_get_int(value);
2.945 - break;
2.946 - case PROP_GMYTHTV_LIVEID:
2.947 - mythtvsrc->live_tv_id = g_value_get_int(value);
2.948 - break;
2.949 - case PROP_GMYTHTV_LIVE:
2.950 - mythtvsrc->live_tv = g_value_get_boolean(value);
2.951 - break;
2.952 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
2.953 - mythtvsrc->enable_timing_position = g_value_get_boolean(value);
2.954 - break;
2.955 - case PROP_GMYTHTV_LIVE_CHAINID:
2.956 - if (!g_value_get_string(value)) {
2.957 - GST_WARNING_OBJECT(object, "MythTV Live chainid property cannot be NULL");
2.958 - break;
2.959 - }
2.960 -
2.961 - if (mythtvsrc->live_chain_id != NULL) {
2.962 - g_free(mythtvsrc->live_chain_id);
2.963 - mythtvsrc->live_chain_id = NULL;
2.964 - }
2.965 - mythtvsrc->live_chain_id = g_value_dup_string(value);
2.966 - break;
2.967 - case PROP_GMYTHTV_CHANNEL_NUM:
2.968 - mythtvsrc->channel_name = g_value_dup_string(value);
2.969 - break;
2.970 - default:
2.971 - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
2.972 - break;
2.973 - }
2.974 -
2.975 - GST_OBJECT_UNLOCK(mythtvsrc);
2.976 -}
2.977 -
2.978 -static void
2.979 -gst_mythtv_src_get_property(GObject * object, guint prop_id,
2.980 - GValue * value, GParamSpec * pspec)
2.981 -{
2.982 - GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC(object);
2.983 -
2.984 - GST_OBJECT_LOCK(mythtvsrc);
2.985 - switch (prop_id) {
2.986 - case PROP_LOCATION:
2.987 - g_value_set_string(value, mythtvsrc->uri_name);
2.988 - break;
2.989 - case PROP_GMYTHTV_VERSION:
2.990 - g_value_set_int(value, mythtvsrc->mythtv_version);
2.991 - break;
2.992 - case PROP_GMYTHTV_LIVEID:
2.993 - g_value_set_int(value, mythtvsrc->live_tv_id);
2.994 - break;
2.995 - case PROP_GMYTHTV_LIVE:
2.996 - g_value_set_boolean(value, mythtvsrc->live_tv);
2.997 - break;
2.998 - case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
2.999 - g_value_set_boolean(value, mythtvsrc->enable_timing_position);
2.1000 - break;
2.1001 - case PROP_GMYTHTV_LIVE_CHAINID:
2.1002 - g_value_set_string(value, mythtvsrc->live_chain_id);
2.1003 - break;
2.1004 - case PROP_GMYTHTV_CHANNEL_NUM:
2.1005 - g_value_set_string(value, mythtvsrc->channel_name);
2.1006 - break;
2.1007 - default:
2.1008 - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
2.1009 - break;
2.1010 - }
2.1011 - GST_OBJECT_UNLOCK(mythtvsrc);
2.1012 -}
2.1013 -
2.1014 -static gboolean
2.1015 -plugin_init(GstPlugin * plugin)
2.1016 -{
2.1017 - return gst_element_register(plugin, "mythtvsrc", GST_RANK_NONE,
2.1018 - GST_TYPE_MYTHTV_SRC);
2.1019 -}
2.1020 -
2.1021 -GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,
2.1022 - GST_VERSION_MINOR,
2.1023 - "mythtv",
2.1024 - "lib MythTV src",
2.1025 - plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,
2.1026 - GST_PACKAGE_ORIGIN);
2.1027 -
2.1028 -
2.1029 -/*** GSTURIHANDLER INTERFACE *************************************************/
2.1030 -static guint
2.1031 -gst_mythtv_src_uri_get_type(void)
2.1032 -{
2.1033 - return GST_URI_SRC;
2.1034 -}
2.1035 -
2.1036 -static gchar **
2.1037 -gst_mythtv_src_uri_get_protocols(void)
2.1038 -{
2.1039 - static gchar *protocols[] = { "myth", "myths", NULL };
2.1040 -
2.1041 - return protocols;
2.1042 -}
2.1043 -
2.1044 -static const gchar *
2.1045 -gst_mythtv_src_uri_get_uri(GstURIHandler * handler)
2.1046 -{
2.1047 - GstMythtvSrc *src = GST_MYTHTV_SRC(handler);
2.1048 -
2.1049 - return src->uri_name;
2.1050 -}
2.1051 -
2.1052 -static gboolean
2.1053 -gst_mythtv_src_uri_set_uri(GstURIHandler * handler, const gchar * uri)
2.1054 -{
2.1055 - GstMythtvSrc *src = GST_MYTHTV_SRC(handler);
2.1056 -
2.1057 - gchar *protocol;
2.1058 -
2.1059 - protocol = gst_uri_get_protocol(uri);
2.1060 - if ((strcmp(protocol, "myth") != 0)
2.1061 - && (strcmp(protocol, "myths") != 0)) {
2.1062 - g_free(protocol);
2.1063 - return FALSE;
2.1064 - }
2.1065 - g_free(protocol);
2.1066 - g_object_set(src, "location", uri, NULL);
2.1067 -
2.1068 - return TRUE;
2.1069 -}
2.1070 -
2.1071 -static void
2.1072 -gst_mythtv_src_uri_handler_init(gpointer g_iface, gpointer iface_data)
2.1073 -{
2.1074 - GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
2.1075 -
2.1076 - iface->get_type = gst_mythtv_src_uri_get_type;
2.1077 - iface->get_protocols = gst_mythtv_src_uri_get_protocols;
2.1078 - iface->get_uri = gst_mythtv_src_uri_get_uri;
2.1079 - iface->set_uri = gst_mythtv_src_uri_set_uri;
2.1080 -}
2.1081 -
2.1082 -void
2.1083 -size_header_handler(void *userdata, const char *value)
2.1084 -{
2.1085 - GstMythtvSrc *src = GST_MYTHTV_SRC(userdata);
2.1086 -
2.1087 - GST_DEBUG_OBJECT(src, "content size = %lld bytes", src->content_size);
2.1088 -}
3.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.h Mon Sep 03 21:14:14 2007 +0100
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,118 +0,0 @@
3.4 -/*
3.5 - * GStreamer Copyright (C) <2006> Rosfran Borges
3.6 - * <rosfran.borges@indt.org.br> This library is free software; you can
3.7 - * redistribute it and/or modify it under the terms of the GNU Library
3.8 - * General Public License as published by the Free Software Foundation;
3.9 - * either version 2 of the License, or (at your option) any later version.
3.10 - * This library is distributed in the hope that it will be useful, but
3.11 - * WITHOUT ANY WARRANTY; without even the implied warranty of
3.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
3.13 - * General Public License for more details. You should have received a copy
3.14 - * of the GNU Library General Public License along with this library; if
3.15 - * not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite
3.16 - * 330, Boston, MA 02111-1307, USA.
3.17 - */
3.18 -
3.19 -#ifndef __GST_MYTHTV_SRC_H__
3.20 -#define __GST_MYTHTV_SRC_H__
3.21 -
3.22 -#include <gst/gst.h>
3.23 -#include <gst/base/gstbasesrc.h>
3.24 -#include <gst/base/gstpushsrc.h>
3.25 -#include <stdio.h>
3.26 -
3.27 -#include <gmyth/gmyth_socket.h>
3.28 -#include <gmyth/gmyth_file.h>
3.29 -#include <gmyth/gmyth_file_transfer.h>
3.30 -#include <gmyth/gmyth_file_local.h>
3.31 -#include <gmyth/gmyth_livetv.h>
3.32 -#include <gmyth/gmyth_backendinfo.h>
3.33 -
3.34 -G_BEGIN_DECLS
3.35 -#define GST_TYPE_MYTHTV_SRC \
3.36 - (gst_mythtv_src_get_type())
3.37 -#define GST_MYTHTV_SRC(obj) \
3.38 - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MYTHTV_SRC,GstMythtvSrc))
3.39 -#define GST_MYTHTV_SRC_CLASS(klass) \
3.40 - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MYTHTV_SRC,GstMythtvSrcClass))
3.41 -#define GST_IS_MYTHTV_SRC(obj) \
3.42 - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MYTHTV_SRC))
3.43 -#define GST_IS_MYTHTV_SRC_CLASS(klass) \
3.44 - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MYTHTV_SRC))
3.45 -typedef struct _GstMythtvSrc GstMythtvSrc;
3.46 -typedef struct _GstMythtvSrcClass GstMythtvSrcClass;
3.47 -
3.48 -typedef enum {
3.49 - GST_MYTHTV_SRC_FILE_TRANSFER,
3.50 - GST_MYTHTV_SRC_NEXT_PROGRAM_CHAIN,
3.51 - GST_MYTHTV_SRC_INVALID_DATA
3.52 -} GstMythtvState;
3.53 -
3.54 -struct _GstMythtvSrc {
3.55 - GstPushSrc element;
3.56 -
3.57 - /*
3.58 - * MythFileTransfer
3.59 - */
3.60 - GMythFile *file;
3.61 -
3.62 - GMythLiveTV *spawn_livetv;
3.63 -
3.64 - GMythBackendInfo *backend_info;
3.65 -
3.66 - GstMythtvState state;
3.67 -
3.68 - gchar *uri_name;
3.69 - gchar *user_agent;
3.70 -
3.71 - gchar *live_chain_id;
3.72 -
3.73 - gint mythtv_version;
3.74 -
3.75 - gint64 content_size;
3.76 -
3.77 - gint64 prev_content_size;
3.78 -
3.79 - gint64 content_size_last;
3.80 -
3.81 - guint64 bytes_read;
3.82 -
3.83 - gint64 read_offset;
3.84 -
3.85 - gboolean eos;
3.86 -
3.87 - gboolean do_start;
3.88 -
3.89 - gboolean unique_setup;
3.90 -
3.91 - gboolean live_tv;
3.92 -
3.93 - gboolean enable_timing_position;
3.94 -
3.95 - gint live_tv_id;
3.96 -
3.97 - gchar *channel_name;
3.98 -
3.99 - guint mode;
3.100 -
3.101 - /*
3.102 - * MythTV capabilities
3.103 - */
3.104 - GstCaps *mythtv_caps;
3.105 -
3.106 - gboolean update_prog_chain;
3.107 -
3.108 - /*
3.109 - * stablish a maximum iteration value to the IS_RECORDING message
3.110 - */
3.111 - guint wait_to_transfer;
3.112 -};
3.113 -
3.114 -struct _GstMythtvSrcClass {
3.115 - GstPushSrcClass parent_class;
3.116 -};
3.117 -
3.118 -GType gst_mythtv_src_get_type(void);
3.119 -
3.120 -G_END_DECLS
3.121 -#endif /* __GST_MYTHTV_SRC_H__ */