2007-09-03 20:07:17 +00:00
|
|
|
/*
|
|
|
|
* GStreamer MythTV Plug-in
|
2007-01-12 19:02:37 +00:00
|
|
|
* Copyright (C) <2006> Rosfran Borges <rosfran.borges@indt.org.br>
|
2007-09-03 20:07:17 +00:00
|
|
|
* Copyright (C) <2007> Renato Filho <renato.filho@indt.org.br>
|
|
|
|
* This library is free software; you can
|
|
|
|
* redistribute it and/or modify it under the terms of the GNU Library
|
|
|
|
* General Public License as published by the Free Software Foundation;
|
|
|
|
* either version 2 of the License, or (at your option) any later version.
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
|
|
|
|
* General Public License for more details. You should have received a copy
|
|
|
|
* of the GNU Library General Public License along with this library; if
|
|
|
|
* not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite
|
|
|
|
* 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:element-mythtvsrc
|
2008-06-13 11:59:23 +00:00
|
|
|
* @see_also: nuvdemux
|
2007-01-12 19:02:37 +00:00
|
|
|
*
|
2007-09-03 20:07:17 +00:00
|
|
|
* MythTVSrc allows to access a remote MythTV backend streaming Video/Audio server,
|
|
|
|
* and to render audio and video content through a TCP/IP connection to a specific
|
|
|
|
* port on this server, and based on a known MythTV protocol that is based on
|
|
|
|
* some message passing, such as REQUEST_BLOCK on a specified number of bytes, to get
|
|
|
|
* some chunk of remote file data.
|
|
|
|
* You should pass the information aboute the remote MythTV backend server
|
2008-06-13 11:59:23 +00:00
|
|
|
* through the #GstMythtvSrc:location property.
|
|
|
|
*
|
|
|
|
* <refsect2>
|
2007-09-03 20:07:17 +00:00
|
|
|
* <title>Examples</title>
|
|
|
|
* <para>
|
|
|
|
* If you want to get the LiveTV content (set channel, TV tuner, RemoteEncoder,
|
2008-06-13 11:59:23 +00:00
|
|
|
* Recorder), use the following URI:
|
|
|
|
* <programlisting>
|
2007-09-03 20:07:17 +00:00
|
|
|
* myth://xxx.xxx.xxx.xxx:6543/livetv?channel=BBC
|
|
|
|
* </programlisting>
|
2007-01-12 19:02:37 +00:00
|
|
|
*
|
2008-06-13 11:59:23 +00:00
|
|
|
* This URI will configure the Recorder instance (used to change the channel,
|
|
|
|
* start the TV multimedia content transmition, etc.), using
|
2007-09-03 20:07:17 +00:00
|
|
|
* the IP address (xxx.xxx.xxx.xxx) and port number (6543) of the MythTV backend
|
|
|
|
* server, and setting the channel name to "BBC".
|
|
|
|
*
|
|
|
|
* To get a already recorded the MythTV NUV file, put the following URI:
|
|
|
|
* <programlisting>
|
|
|
|
* myth://xxx.xxx.xxx.xxx:6543/filename.nuv
|
|
|
|
* </programlisting>
|
|
|
|
*
|
|
|
|
* Another possible way to use the LiveTV content, and just in the case you want to
|
|
|
|
* use the mysql database, put the location URI in the following format:
|
2008-06-13 11:59:23 +00:00
|
|
|
* <programlisting>
|
2007-09-03 20:07:17 +00:00
|
|
|
* myth://mythtv:mythtv@xxx.xxx.xxx.xxx:6543/?mythconverg&channel=9
|
|
|
|
* </programlisting>
|
2007-01-12 19:02:37 +00:00
|
|
|
*
|
|
|
|
* Where the first field is the protocol (myth), the second and third are user
|
|
|
|
* name (mythtv) and password (mythtv), then backend host name and port number,
|
|
|
|
* and the last field is the database name (mythconverg).
|
2007-09-03 20:07:17 +00:00
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
2007-01-12 19:02:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstmythtvsrc.h"
|
2007-09-03 20:07:17 +00:00
|
|
|
#include <gmyth/gmyth_file.h>
|
2007-01-12 19:02:37 +00:00
|
|
|
#include <gmyth/gmyth_file_transfer.h>
|
2007-09-03 20:07:17 +00:00
|
|
|
#include <gmyth/gmyth_file_local.h>
|
2007-01-12 19:02:37 +00:00
|
|
|
#include <gmyth/gmyth_livetv.h>
|
|
|
|
|
|
|
|
#include <gmyth/gmyth_socket.h>
|
|
|
|
#include <gmyth/gmyth_tvchain.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (mythtvsrc_debug);
|
2007-09-03 20:07:17 +00:00
|
|
|
#define GST_GMYTHTV_ID_NUM 1
|
|
|
|
#define GST_GMYTHTV_CHANNEL_DEFAULT_NUM (-1)
|
2007-09-29 19:36:34 +00:00
|
|
|
#define GMYTHTV_VERSION_DEFAULT 30
|
2007-09-03 20:07:17 +00:00
|
|
|
#define GMYTHTV_TRANSFER_MAX_WAITS 100
|
|
|
|
#define GMYTHTV_TRANSFER_MAX_RESENDS 2
|
|
|
|
#define GMYTHTV_TRANSFER_MAX_BUFFER (128*1024)
|
|
|
|
#define READ_SIZE (14*1024)
|
|
|
|
#define READ_SIZE_LIVETV (80*1024)
|
|
|
|
#define GST_FLOW_ERROR_NO_DATA (-101)
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_STATIC_CAPS_ANY);
|
2007-01-12 19:02:37 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_LOCATION,
|
|
|
|
PROP_GMYTHTV_VERSION,
|
|
|
|
PROP_GMYTHTV_LIVE,
|
|
|
|
PROP_GMYTHTV_LIVEID,
|
|
|
|
PROP_GMYTHTV_LIVE_CHAINID,
|
|
|
|
PROP_GMYTHTV_ENABLE_TIMING_POSITION,
|
|
|
|
PROP_GMYTHTV_CHANNEL_NUM
|
|
|
|
};
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
static void gst_mythtv_src_clear (GstMythtvSrc * mythtv_src);
|
|
|
|
|
2007-01-12 19:02:37 +00:00
|
|
|
static void gst_mythtv_src_finalize (GObject * gobject);
|
|
|
|
|
|
|
|
static GstFlowReturn gst_mythtv_src_create (GstPushSrc * psrc,
|
|
|
|
GstBuffer ** outbuf);
|
|
|
|
|
|
|
|
static gboolean gst_mythtv_src_start (GstBaseSrc * bsrc);
|
|
|
|
static gboolean gst_mythtv_src_stop (GstBaseSrc * bsrc);
|
|
|
|
static gboolean gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size);
|
|
|
|
static gboolean gst_mythtv_src_is_seekable (GstBaseSrc * push_src);
|
|
|
|
|
2008-05-20 09:36:56 +00:00
|
|
|
static GstFlowReturn gst_mythtv_src_do_seek (GstBaseSrc * base,
|
2007-01-12 19:02:37 +00:00
|
|
|
GstSegment * segment);
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_mythtv_src_change_state (GstElement * element, GstStateChange transition);
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
static void gst_mythtv_src_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_mythtv_src_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
static void gst_mythtv_src_uri_handler_init (gpointer g_iface,
|
|
|
|
gpointer iface_data);
|
|
|
|
|
2008-05-20 09:36:56 +00:00
|
|
|
#if 0
|
2007-01-12 19:02:37 +00:00
|
|
|
static gboolean gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query);
|
|
|
|
static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event);
|
2008-05-20 09:36:56 +00:00
|
|
|
#endif
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
static GMythFileReadResult do_read_request_response (GstMythtvSrc * src,
|
|
|
|
guint size, GByteArray * data_ptr);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
_urihandler_init (GType type)
|
|
|
|
{
|
|
|
|
static const GInterfaceInfo urihandler_info = {
|
|
|
|
gst_mythtv_src_uri_handler_init,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0, "MythTV src");
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstPushSrc,
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_TYPE_PUSH_SRC, _urihandler_init)
|
|
|
|
static void gst_mythtv_src_base_init (gpointer g_class)
|
2007-01-12 19:02:37 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&srctemplate));
|
|
|
|
|
2010-03-18 16:30:26 +00:00
|
|
|
gst_element_class_set_details_simple (element_class, "MythTV client source",
|
|
|
|
"Source/Network",
|
|
|
|
"Control and receive data as a client over the network "
|
|
|
|
"via raw socket connections using the MythTV protocol",
|
|
|
|
"Rosfran Borges <rosfran.borges@indt.org.br>, "
|
|
|
|
"Renato Filho <renato.filho@indt.org.br>");
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
element_class->change_state = gst_mythtv_src_change_state;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mythtv_src_class_init (GstMythtvSrcClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstPushSrcClass *gstpushsrc_class;
|
|
|
|
GstBaseSrcClass *gstbasesrc_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
|
|
|
gstpushsrc_class = (GstPushSrcClass *) klass;
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_mythtv_src_set_property;
|
|
|
|
gobject_class->get_property = gst_mythtv_src_get_property;
|
|
|
|
gobject_class->finalize = gst_mythtv_src_finalize;
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_LOCATION,
|
|
|
|
g_param_spec_string ("location", "Location",
|
|
|
|
"The location. In the form:"
|
|
|
|
"\n\t\t\tmyth://a.com/file.nuv"
|
2007-09-29 19:36:34 +00:00
|
|
|
"\n\t\t\tmyth://a.com:23223/file.nuv"
|
|
|
|
"\n\t\t\tmyth://a.com/?channel=123"
|
|
|
|
"\n\t\t\tmyth://a.com/?channel=Channel%203"
|
2007-01-12 19:02:37 +00:00
|
|
|
"\n\t\t\ta.com/file.nuv - default scheme 'myth'",
|
2010-10-19 13:23:23 +00:00
|
|
|
"", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_GMYTHTV_VERSION,
|
|
|
|
g_param_spec_int ("mythtv-version", "mythtv-version",
|
2010-10-19 13:23:23 +00:00
|
|
|
"Change MythTV version", 26, 30, 26,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_GMYTHTV_LIVEID,
|
|
|
|
g_param_spec_int ("mythtv-live-id", "mythtv-live-id",
|
|
|
|
"Change MythTV version",
|
2010-10-19 13:23:23 +00:00
|
|
|
0, 200, GST_GMYTHTV_ID_NUM,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
|
|
|
|
g_param_spec_string ("mythtv-live-chainid", "mythtv-live-chainid",
|
2010-10-19 13:23:23 +00:00
|
|
|
"Sets the MythTV chain ID (from TV Chain)", "",
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_GMYTHTV_LIVE,
|
|
|
|
g_param_spec_boolean ("mythtv-live", "mythtv-live",
|
2010-10-19 13:23:23 +00:00
|
|
|
"Enable MythTV Live TV content streaming", FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
|
|
|
|
g_param_spec_boolean ("mythtv-enable-timing-position",
|
|
|
|
"mythtv-enable-timing-position",
|
2007-09-03 20:07:17 +00:00
|
|
|
"Enable MythTV Live TV content size continuous updating",
|
2010-10-19 13:23:23 +00:00
|
|
|
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
|
2007-09-03 20:07:17 +00:00
|
|
|
g_param_spec_string ("mythtv-channel", "mythtv-channel",
|
2010-10-19 13:23:23 +00:00
|
|
|
"Change MythTV channel number", "",
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2008-05-20 09:36:56 +00:00
|
|
|
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_mythtv_src_start);
|
|
|
|
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_mythtv_src_stop);
|
|
|
|
gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_mythtv_src_get_size);
|
|
|
|
gstbasesrc_class->is_seekable =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mythtv_src_is_seekable);
|
|
|
|
gstbasesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_mythtv_src_do_seek);
|
|
|
|
gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_mythtv_src_create);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
|
|
|
|
"MythTV Client Source");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mythtv_src_init (GstMythtvSrc * this, GstMythtvSrcClass * g_class)
|
|
|
|
{
|
2007-09-03 20:07:17 +00:00
|
|
|
this->file = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
this->unique_setup = FALSE;
|
|
|
|
this->mythtv_version = GMYTHTV_VERSION_DEFAULT;
|
|
|
|
this->state = GST_MYTHTV_SRC_FILE_TRANSFER;
|
|
|
|
this->bytes_read = 0;
|
|
|
|
this->prev_content_size = 0;
|
|
|
|
this->content_size = 0;
|
|
|
|
this->read_offset = 0;
|
|
|
|
this->content_size_last = 0;
|
|
|
|
this->live_tv = FALSE;
|
|
|
|
this->enable_timing_position = FALSE;
|
|
|
|
this->update_prog_chain = FALSE;
|
|
|
|
this->user_agent = g_strdup ("mythtvsrc");
|
|
|
|
this->update_prog_chain = FALSE;
|
2007-09-03 20:07:17 +00:00
|
|
|
this->channel_name = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
this->eos = FALSE;
|
|
|
|
this->wait_to_transfer = 0;
|
2007-09-03 20:07:17 +00:00
|
|
|
this->spawn_livetv = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_BYTES);
|
2008-05-20 09:36:56 +00:00
|
|
|
#if 0
|
2007-01-12 19:02:37 +00:00
|
|
|
gst_pad_set_event_function (GST_BASE_SRC_PAD (GST_BASE_SRC (this)),
|
|
|
|
gst_mythtv_src_handle_event);
|
2008-05-20 09:36:56 +00:00
|
|
|
#endif
|
|
|
|
#if 0
|
2007-01-12 19:02:37 +00:00
|
|
|
gst_pad_set_query_function (GST_BASE_SRC_PAD (GST_BASE_SRC (this)),
|
|
|
|
gst_mythtv_src_handle_query);
|
2008-05-20 09:36:56 +00:00
|
|
|
#endif
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-09-03 20:07:17 +00:00
|
|
|
gst_mythtv_src_clear (GstMythtvSrc * mythtv_src)
|
2007-01-12 19:02:37 +00:00
|
|
|
{
|
2007-09-03 20:07:17 +00:00
|
|
|
mythtv_src->unique_setup = FALSE;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2008-05-20 09:36:56 +00:00
|
|
|
#if 0
|
2007-09-03 20:07:17 +00:00
|
|
|
if (mythtv_src->spawn_livetv) {
|
|
|
|
g_object_unref (mythtv_src->spawn_livetv);
|
|
|
|
mythtv_src->spawn_livetv = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (mythtv_src->file) {
|
|
|
|
g_object_unref (mythtv_src->file);
|
|
|
|
mythtv_src->file = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (mythtv_src->backend_info) {
|
|
|
|
g_object_unref (mythtv_src->backend_info);
|
|
|
|
mythtv_src->backend_info = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
2008-05-20 09:36:56 +00:00
|
|
|
#endif
|
2007-09-03 20:07:17 +00:00
|
|
|
}
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
static void
|
|
|
|
gst_mythtv_src_finalize (GObject * gobject)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *this = GST_MYTHTV_SRC (gobject);
|
|
|
|
|
|
|
|
gst_mythtv_src_clear (this);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
if (this->uri_name) {
|
|
|
|
g_free (this->uri_name);
|
2007-09-03 20:07:17 +00:00
|
|
|
this->uri_name = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this->user_agent) {
|
|
|
|
g_free (this->user_agent);
|
2007-09-03 20:07:17 +00:00
|
|
|
this->user_agent = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (gobject);
|
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
static GMythFileReadResult
|
2007-01-12 19:02:37 +00:00
|
|
|
do_read_request_response (GstMythtvSrc * src, guint size, GByteArray * data_ptr)
|
|
|
|
{
|
|
|
|
gint read = 0;
|
|
|
|
guint sizetoread = size;
|
|
|
|
gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
|
2007-09-03 20:07:17 +00:00
|
|
|
GMythFileReadResult result;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_LOG_OBJECT (src, "Starting: Reading %d bytes...", sizetoread);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
result = GMYTH_FILE_READ_OK;
|
|
|
|
/*
|
|
|
|
* Loop sending the Myth File Transfer request: Retry whilst
|
|
|
|
* authentication fails and we supply it.
|
|
|
|
*/
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
while (sizetoread == size && --max_iters > 0) {
|
2007-09-03 20:07:17 +00:00
|
|
|
/*
|
|
|
|
* if ( gmyth_backend_info_is_local_file(src->backend_info) )
|
|
|
|
*/
|
|
|
|
if (IS_GMYTH_FILE_LOCAL (src->file))
|
|
|
|
result = gmyth_file_local_read (GMYTH_FILE_LOCAL (src->file),
|
|
|
|
data_ptr, sizetoread, src->live_tv);
|
|
|
|
else if (IS_GMYTH_FILE_TRANSFER (src->file))
|
|
|
|
result = gmyth_file_transfer_read (GMYTH_FILE_TRANSFER (src->file),
|
|
|
|
data_ptr, sizetoread, src->live_tv);
|
|
|
|
|
|
|
|
if (data_ptr->len > 0) {
|
|
|
|
read += data_ptr->len;
|
|
|
|
sizetoread -= data_ptr->len;
|
|
|
|
} else if (data_ptr->len <= 0) {
|
2007-01-12 19:02:37 +00:00
|
|
|
if (src->live_tv == FALSE) {
|
2007-09-03 20:07:17 +00:00
|
|
|
result = GMYTH_FILE_READ_EOF;
|
2007-01-12 19:02:37 +00:00
|
|
|
goto eos;
|
|
|
|
} else {
|
2007-09-03 20:07:17 +00:00
|
|
|
if (result == GMYTH_FILE_READ_ERROR) { /* -314 */
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_INFO_OBJECT (src, "[LiveTV] FileTransfer READ_ERROR!");
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
goto done;
|
|
|
|
}
|
2007-09-03 20:07:17 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* else if (data_ptr->len == 0) goto done;
|
|
|
|
*/
|
2007-01-12 19:02:37 +00:00
|
|
|
if (read == sizetoread)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if ((read < 0 && !src->live_tv) || max_iters == 0) {
|
|
|
|
result = GMYTH_FILE_READ_EOF;
|
2007-01-12 19:02:37 +00:00
|
|
|
goto eos;
|
2007-09-03 20:07:17 +00:00
|
|
|
}
|
2007-01-12 19:02:37 +00:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
eos:
|
|
|
|
src->eos = TRUE;
|
|
|
|
|
|
|
|
done:
|
2008-05-20 09:36:56 +00:00
|
|
|
GST_LOG_OBJECT (src, "Finished read: result %d", result);
|
2007-09-03 20:07:17 +00:00
|
|
|
return result;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_mythtv_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *src;
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2007-09-03 20:07:17 +00:00
|
|
|
GByteArray *buffer;
|
|
|
|
GMythFileReadResult result = GMYTH_FILE_READ_OK;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
src = GST_MYTHTV_SRC (psrc);
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
buffer = g_byte_array_new ();
|
|
|
|
if (src->live_tv)
|
|
|
|
result = do_read_request_response (src, READ_SIZE_LIVETV, buffer);
|
|
|
|
else
|
|
|
|
result = do_read_request_response (src, READ_SIZE, buffer);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (result == GMYTH_FILE_READ_ERROR)
|
|
|
|
goto read_error;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
*outbuf = gst_buffer_new ();
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_BUFFER_SIZE (*outbuf) = buffer->len;
|
2008-02-22 06:33:49 +00:00
|
|
|
GST_BUFFER_MALLOCDATA (*outbuf) = buffer->data;
|
2007-01-12 19:02:37 +00:00
|
|
|
GST_BUFFER_DATA (*outbuf) = GST_BUFFER_MALLOCDATA (*outbuf);
|
|
|
|
GST_BUFFER_OFFSET (*outbuf) = src->read_offset;
|
|
|
|
GST_BUFFER_OFFSET_END (*outbuf) =
|
|
|
|
src->read_offset + GST_BUFFER_SIZE (*outbuf);
|
|
|
|
|
|
|
|
src->read_offset += GST_BUFFER_SIZE (*outbuf);
|
|
|
|
src->bytes_read += GST_BUFFER_SIZE (*outbuf);
|
|
|
|
|
2008-02-22 06:33:49 +00:00
|
|
|
g_byte_array_free (buffer, FALSE);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) {
|
|
|
|
GstPad *peer;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
peer = gst_pad_get_peer (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)));
|
|
|
|
gst_pad_send_event (peer,
|
|
|
|
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
gst_object_unref (peer);
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (src->eos || (!src->live_tv && (src->bytes_read >= src->content_size)))
|
|
|
|
ret = GST_FLOW_UNEXPECTED;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2008-05-20 09:36:56 +00:00
|
|
|
GST_LOG_OBJECT (src, "Create finished: %d", ret);
|
2007-09-03 20:07:17 +00:00
|
|
|
return ret;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
read_error:
|
2009-11-05 22:03:51 +00:00
|
|
|
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
|
|
|
|
("Could not read any bytes (%d, %s)", result, src->uri_name));
|
2007-09-03 20:07:17 +00:00
|
|
|
return GST_FLOW_ERROR;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mythtv_src_do_seek (GstBaseSrc * base, GstSegment * segment)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *src = GST_MYTHTV_SRC (base);
|
|
|
|
gint64 new_offset = -1;
|
|
|
|
gint64 actual_seek = segment->start;
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_LOG_OBJECT (src, "seek, segment: %" GST_SEGMENT_FORMAT, segment);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2008-02-20 16:04:32 +00:00
|
|
|
if (segment->format != GST_FORMAT_BYTES) {
|
|
|
|
ret = FALSE;
|
2007-01-12 19:02:37 +00:00
|
|
|
goto done;
|
|
|
|
}
|
2009-11-05 22:03:51 +00:00
|
|
|
GST_LOG_OBJECT (src, "actual_seek = %" G_GINT64_FORMAT ", read_offset = "
|
|
|
|
"%" G_GINT64_FORMAT, actual_seek, src->read_offset);
|
2007-09-03 20:07:17 +00:00
|
|
|
/*
|
|
|
|
* verify if it needs to seek
|
|
|
|
*/
|
2007-01-12 19:02:37 +00:00
|
|
|
if (src->read_offset != actual_seek) {
|
2007-09-03 20:07:17 +00:00
|
|
|
if (IS_GMYTH_FILE_LOCAL (src->file))
|
|
|
|
new_offset = gmyth_file_local_seek (GMYTH_FILE_LOCAL (src->file),
|
|
|
|
segment->start, G_SEEK_SET);
|
|
|
|
else if (IS_GMYTH_FILE_TRANSFER (src->file))
|
|
|
|
new_offset = gmyth_file_transfer_seek (GMYTH_FILE_TRANSFER (src->file),
|
2008-02-20 16:04:32 +00:00
|
|
|
segment->start, G_SEEK_SET);
|
2007-01-12 19:02:37 +00:00
|
|
|
if (G_UNLIKELY (new_offset < 0)) {
|
|
|
|
ret = FALSE;
|
2007-09-03 20:07:17 +00:00
|
|
|
if (!src->live_tv)
|
2007-01-12 19:02:37 +00:00
|
|
|
goto eos;
|
|
|
|
}
|
|
|
|
|
|
|
|
src->read_offset = new_offset;
|
|
|
|
|
|
|
|
if (ret == FALSE) {
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_INFO_OBJECT (src, "Failed to set the SEEK on segment!");
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
eos:
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "EOS found on seeking!!!");
|
|
|
|
return FALSE;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
/*
|
|
|
|
* create a socket for connecting to remote server
|
|
|
|
*/
|
2007-01-12 19:02:37 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mythtv_src_start (GstBaseSrc * bsrc)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
|
|
|
|
|
|
|
|
GString *chain_id_local = NULL;
|
2007-01-28 13:01:02 +00:00
|
|
|
GMythURI *gmyth_uri = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
gboolean ret = TRUE;
|
2008-05-20 09:36:56 +00:00
|
|
|
GstBaseSrc *basesrc;
|
2007-09-03 20:07:17 +00:00
|
|
|
GstMessage *msg;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
if (src->unique_setup == FALSE) {
|
|
|
|
src->unique_setup = TRUE;
|
|
|
|
} else {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-01-28 13:01:02 +00:00
|
|
|
gmyth_uri = gmyth_uri_new_with_value (src->uri_name);
|
2007-01-12 19:02:37 +00:00
|
|
|
src->backend_info = gmyth_backend_info_new_with_uri (src->uri_name);
|
2007-09-03 20:07:17 +00:00
|
|
|
src->live_tv = gmyth_uri_is_livetv (gmyth_uri);
|
|
|
|
|
|
|
|
if (src->live_tv) {
|
|
|
|
gchar *ch = gmyth_uri_get_channel_name (gmyth_uri);
|
2008-07-08 13:28:51 +00:00
|
|
|
src->spawn_livetv = gmyth_livetv_new (src->backend_info);
|
2007-01-28 13:01:02 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (ch != NULL)
|
|
|
|
src->channel_name = ch;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (src->channel_name != NULL) {
|
|
|
|
gboolean result;
|
2007-01-28 13:01:02 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
result = gmyth_livetv_channel_name_setup (src->spawn_livetv,
|
|
|
|
src->channel_name);
|
|
|
|
if (result == FALSE) {
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_INFO_OBJECT (src, "LiveTV setup felt down on error");
|
2007-01-12 19:02:37 +00:00
|
|
|
ret = FALSE;
|
|
|
|
goto init_failed;
|
|
|
|
}
|
|
|
|
} else {
|
2007-09-03 20:07:17 +00:00
|
|
|
if (gmyth_livetv_setup (src->spawn_livetv) == FALSE) {
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_INFO_OBJECT (src, "LiveTV setup felt down on error");
|
2007-01-12 19:02:37 +00:00
|
|
|
ret = FALSE;
|
|
|
|
goto init_failed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
src->file =
|
|
|
|
GMYTH_FILE (gmyth_livetv_create_file_transfer (src->spawn_livetv));
|
|
|
|
if (NULL == src->file) {
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_INFO_OBJECT (src, "[LiveTV] FileTransfer equals to NULL");
|
2007-01-12 19:02:37 +00:00
|
|
|
ret = FALSE;
|
|
|
|
goto init_failed;
|
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
/*
|
|
|
|
* Check if the file is local to this specific client renderer
|
|
|
|
*/
|
|
|
|
if (gmyth_uri_is_local_file (gmyth_uri))
|
|
|
|
ret = gmyth_file_local_open (GMYTH_FILE_LOCAL (src->file));
|
|
|
|
else
|
|
|
|
ret = gmyth_file_transfer_open (GMYTH_FILE_TRANSFER (src->file),
|
|
|
|
(src->spawn_livetv->uri != NULL ?
|
|
|
|
gmyth_uri_get_path (src->spawn_livetv->uri) :
|
|
|
|
src->spawn_livetv->proginfo->pathname->str));
|
|
|
|
/*
|
|
|
|
* sets the mythtvsrc "location" property
|
|
|
|
*/
|
|
|
|
g_object_set (src, "location", gmyth_file_get_uri (src->file), NULL);
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
GST_INFO_OBJECT (src,
|
|
|
|
"Error: couldn't open the FileTransfer from LiveTV source!");
|
|
|
|
g_object_unref (src->file);
|
|
|
|
src->file = NULL;
|
|
|
|
goto init_failed;
|
|
|
|
}
|
|
|
|
} /* If live-tv */
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Check if the file is local to this specific client renderer,
|
|
|
|
* and tries to open a local connection
|
|
|
|
*/
|
|
|
|
if (gmyth_uri_is_local_file (gmyth_uri)) {
|
|
|
|
src->file = GMYTH_FILE (gmyth_file_local_new (src->backend_info));
|
|
|
|
ret = gmyth_file_local_open (GMYTH_FILE_LOCAL (src->file));
|
|
|
|
} else {
|
|
|
|
src->file = GMYTH_FILE (gmyth_file_transfer_new (src->backend_info));
|
|
|
|
ret =
|
|
|
|
gmyth_file_transfer_open (GMYTH_FILE_TRANSFER (src->file),
|
|
|
|
src->uri_name);
|
|
|
|
}
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (NULL == src->file) {
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_INFO_OBJECT (src, "FileTransfer is NULL");
|
2007-01-12 19:02:37 +00:00
|
|
|
goto init_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret == FALSE) {
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_INFO_OBJECT (src,
|
|
|
|
"MythTV FileTransfer request failed when setting up socket connection!");
|
2007-01-12 19:02:37 +00:00
|
|
|
goto begin_req_failed;
|
|
|
|
}
|
|
|
|
|
2009-11-05 22:03:51 +00:00
|
|
|
GST_INFO_OBJECT (src, "MythTV FileTransfer filesize = %" G_GINT64_FORMAT ", "
|
|
|
|
"content_size = %" G_GINT64_FORMAT, gmyth_file_get_filesize (src->file),
|
|
|
|
src->content_size);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
src->content_size = gmyth_file_get_filesize (src->file);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2012-09-03 18:25:52 +00:00
|
|
|
msg = gst_message_new_duration_changed (GST_OBJECT (src));
|
2007-09-03 20:07:17 +00:00
|
|
|
gst_element_post_message (GST_ELEMENT (src), msg);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
src->do_start = FALSE;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2008-05-20 09:36:56 +00:00
|
|
|
basesrc = GST_BASE_SRC_CAST (src);
|
|
|
|
gst_segment_set_duration (&basesrc->segment, GST_FORMAT_BYTES,
|
|
|
|
src->content_size);
|
|
|
|
gst_element_post_message (GST_ELEMENT (src),
|
2012-09-03 18:25:52 +00:00
|
|
|
gst_message_new_duration_changed (GST_OBJECT (src)));
|
2008-05-20 09:36:56 +00:00
|
|
|
#if 0
|
2007-01-12 19:02:37 +00:00
|
|
|
gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
|
2007-09-03 20:07:17 +00:00
|
|
|
gst_event_new_new_segment (TRUE, 1.0,
|
2008-02-20 16:04:32 +00:00
|
|
|
GST_FORMAT_BYTES, 0, src->content_size, 0));
|
2008-05-20 09:36:56 +00:00
|
|
|
#endif
|
2007-01-12 19:02:37 +00:00
|
|
|
done:
|
2007-09-03 20:07:17 +00:00
|
|
|
if (gmyth_uri != NULL) {
|
|
|
|
g_object_unref (gmyth_uri);
|
|
|
|
gmyth_uri = NULL;
|
|
|
|
}
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
if (chain_id_local != NULL) {
|
|
|
|
g_string_free (chain_id_local, TRUE);
|
|
|
|
chain_id_local = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
/*
|
|
|
|
* ERRORS
|
|
|
|
*/
|
2007-01-12 19:02:37 +00:00
|
|
|
init_failed:
|
2007-09-03 20:07:17 +00:00
|
|
|
if (gmyth_uri != NULL) {
|
|
|
|
g_object_unref (gmyth_uri);
|
|
|
|
gmyth_uri = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
if (src->spawn_livetv != NULL) {
|
|
|
|
g_object_unref (src->spawn_livetv);
|
|
|
|
src->spawn_livetv = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_ELEMENT_ERROR (src, LIBRARY, INIT,
|
|
|
|
(NULL),
|
|
|
|
("Could not initialize MythTV library (%i, %s)", ret, src->uri_name));
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
gst_mythtv_src_clear (src);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
return FALSE;
|
2007-01-12 19:02:37 +00:00
|
|
|
begin_req_failed:
|
2007-09-03 20:07:17 +00:00
|
|
|
if (gmyth_uri != NULL) {
|
|
|
|
g_object_unref (gmyth_uri);
|
|
|
|
gmyth_uri = NULL;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_ELEMENT_ERROR (src, LIBRARY, INIT,
|
|
|
|
(NULL),
|
|
|
|
("Could not begin request sent to MythTV server (%i, %s)",
|
|
|
|
ret, src->uri_name));
|
|
|
|
return FALSE;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_LOG_OBJECT (src,
|
|
|
|
"Differs from previous content size: %d (max.: %d)",
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
abs (src->content_size - src->prev_content_size),
|
2007-01-12 19:02:37 +00:00
|
|
|
GMYTHTV_TRANSFER_MAX_BUFFER);
|
|
|
|
|
|
|
|
if (src->live_tv) {
|
|
|
|
ret = FALSE;
|
|
|
|
} else if (src->live_tv && src->enable_timing_position
|
|
|
|
&& (abs (src->content_size - src->bytes_read) <
|
|
|
|
GMYTHTV_TRANSFER_MAX_BUFFER)) {
|
2007-09-03 20:07:17 +00:00
|
|
|
gint64 new_offset;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
new_offset = gmyth_recorder_get_file_position (src->spawn_livetv->recorder);
|
2007-01-12 19:02:37 +00:00
|
|
|
if (new_offset > 0 && new_offset > src->content_size) {
|
|
|
|
src->content_size = new_offset;
|
|
|
|
} else if (new_offset < src->content_size) {
|
|
|
|
src->update_prog_chain = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = src->content_size;
|
2009-11-05 22:03:51 +00:00
|
|
|
GST_LOG_OBJECT (src, "Content size = %" G_GINT64_FORMAT, src->content_size);
|
2007-01-12 19:02:37 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
/*
|
|
|
|
* close the socket and associated resources used both to recover from
|
|
|
|
* errors and go to NULL state
|
|
|
|
*/
|
2007-01-12 19:02:37 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mythtv_src_stop (GstBaseSrc * bsrc)
|
|
|
|
{
|
2007-09-03 20:07:17 +00:00
|
|
|
GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
gst_mythtv_src_clear (src);
|
2007-01-12 19:02:37 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-05-20 09:36:56 +00:00
|
|
|
#if 0
|
2010-03-21 20:39:18 +00:00
|
|
|
static gint64
|
|
|
|
gst_mythtv_src_get_position (GstMythtvSrc * src)
|
|
|
|
{
|
|
|
|
gint64 size_tmp = 0;
|
|
|
|
guint max_tries = 2;
|
|
|
|
|
|
|
|
if (src->live_tv == TRUE &&
|
|
|
|
(abs (src->content_size - src->bytes_read) <
|
|
|
|
GMYTHTV_TRANSFER_MAX_BUFFER)) {
|
|
|
|
|
|
|
|
get_file_pos:
|
|
|
|
g_usleep (10);
|
|
|
|
size_tmp = gmyth_recorder_get_file_position (src->spawn_livetv->recorder);
|
|
|
|
if (size_tmp > (src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER))
|
|
|
|
src->content_size = size_tmp;
|
|
|
|
else if (size_tmp > 0 && --max_tries > 0)
|
|
|
|
goto get_file_pos;
|
|
|
|
GST_LOG_OBJECT (src, "file_position = %" G_GINT64_FORMAT, size_tmp);
|
|
|
|
/*
|
|
|
|
* sets the last content size amount before it can be updated
|
|
|
|
*/
|
|
|
|
src->prev_content_size = src->content_size;
|
|
|
|
}
|
|
|
|
return src->content_size;
|
|
|
|
}
|
|
|
|
|
2007-01-12 19:02:37 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *src = GST_MYTHTV_SRC (GST_PAD_PARENT (pad));
|
|
|
|
gint64 cont_size = 0;
|
2007-09-03 20:07:17 +00:00
|
|
|
gboolean ret = TRUE;
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
if (src->live_tv) {
|
|
|
|
cont_size = gst_mythtv_src_get_position (src);
|
|
|
|
if (cont_size > src->content_size) {
|
|
|
|
src->content_size = cont_size;
|
|
|
|
src->eos = FALSE;
|
|
|
|
} else {
|
|
|
|
src->eos = TRUE;
|
|
|
|
gst_element_set_state (GST_ELEMENT (src), GST_STATE_NULL);
|
|
|
|
gst_element_set_locked_state (GST_ELEMENT (src), FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = gst_pad_event_default (pad, event);
|
|
|
|
}
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "HANDLE EVENT %d", ret);
|
2007-01-12 19:02:37 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2008-05-20 09:36:56 +00:00
|
|
|
#endif
|
2007-01-12 19:02:37 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mythtv_src_is_seekable (GstBaseSrc * push_src)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-05-20 09:36:56 +00:00
|
|
|
#if 0
|
2007-01-12 19:02:37 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query)
|
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
|
|
|
GstMythtvSrc *myth = GST_MYTHTV_SRC (gst_pad_get_parent (pad));
|
|
|
|
GstFormat formt;
|
|
|
|
|
2007-09-03 20:07:17 +00:00
|
|
|
|
2007-01-12 19:02:37 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_POSITION:
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
gst_query_parse_position (query, &formt, NULL);
|
2007-01-12 19:02:37 +00:00
|
|
|
if (formt == GST_FORMAT_BYTES) {
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
gst_query_set_position (query, formt, myth->read_offset);
|
|
|
|
GST_DEBUG_OBJECT (myth, "POS %" G_GINT64_FORMAT, myth->read_offset);
|
|
|
|
res = TRUE;
|
2007-01-12 19:02:37 +00:00
|
|
|
} else if (formt == GST_FORMAT_TIME) {
|
|
|
|
res = gst_pad_query_default (pad, query);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_QUERY_DURATION:
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
gst_query_parse_duration (query, &formt, NULL);
|
2007-01-12 19:02:37 +00:00
|
|
|
if (formt == GST_FORMAT_BYTES) {
|
2007-09-03 20:07:17 +00:00
|
|
|
gint64 size = myth->content_size;
|
|
|
|
|
|
|
|
gst_query_set_duration (query, GST_FORMAT_BYTES, 10);
|
|
|
|
GST_DEBUG_OBJECT (myth, "SIZE %" G_GINT64_FORMAT, size);
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
res = TRUE;
|
2007-01-12 19:02:37 +00:00
|
|
|
} else if (formt == GST_FORMAT_TIME) {
|
|
|
|
res = gst_pad_query_default (pad, query);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = gst_pad_query_default (pad, query);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (myth);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2008-05-20 09:36:56 +00:00
|
|
|
#endif
|
2007-01-12 19:02:37 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_mythtv_src_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
|
|
|
|
GstMythtvSrc *src = GST_MYTHTV_SRC (element);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2007-09-03 20:07:17 +00:00
|
|
|
if (!src->uri_name) {
|
|
|
|
GST_WARNING_OBJECT (src, "Invalid location");
|
|
|
|
return ret;
|
|
|
|
}
|
2007-01-12 19:02:37 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
|
|
|
if (src->live_tv) {
|
2007-09-03 20:07:17 +00:00
|
|
|
if (!gmyth_recorder_send_frontend_ready_command
|
|
|
|
(src->spawn_livetv->recorder))
|
2007-01-12 19:02:37 +00:00
|
|
|
GST_WARNING_OBJECT (src,
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
"Couldn't send the FRONTEND_READY message to the backend!");
|
2007-01-12 19:02:37 +00:00
|
|
|
else
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "FRONTEND_READY was sent to the backend");
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2007-09-03 20:07:17 +00:00
|
|
|
if (ret == GST_STATE_CHANGE_FAILURE) {
|
2007-01-12 19:02:37 +00:00
|
|
|
return ret;
|
2007-09-03 20:07:17 +00:00
|
|
|
}
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2007-09-03 20:07:17 +00:00
|
|
|
gst_mythtv_src_clear (src);
|
2007-01-12 19:02:37 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mythtv_src_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC (object);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (mythtvsrc);
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_LOCATION:
|
|
|
|
if (!g_value_get_string (value)) {
|
|
|
|
GST_WARNING ("location property cannot be NULL");
|
2007-01-17 17:29:04 +00:00
|
|
|
break;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mythtvsrc->uri_name != NULL) {
|
|
|
|
g_free (mythtvsrc->uri_name);
|
|
|
|
mythtvsrc->uri_name = NULL;
|
|
|
|
}
|
|
|
|
mythtvsrc->uri_name = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_VERSION:
|
|
|
|
mythtvsrc->mythtv_version = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_LIVEID:
|
|
|
|
mythtvsrc->live_tv_id = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_LIVE:
|
|
|
|
mythtvsrc->live_tv = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
|
|
|
|
mythtvsrc->enable_timing_position = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_LIVE_CHAINID:
|
|
|
|
if (!g_value_get_string (value)) {
|
2007-09-03 20:07:17 +00:00
|
|
|
GST_WARNING_OBJECT (object,
|
|
|
|
"MythTV Live chainid property cannot be NULL");
|
2007-01-17 17:29:04 +00:00
|
|
|
break;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mythtvsrc->live_chain_id != NULL) {
|
|
|
|
g_free (mythtvsrc->live_chain_id);
|
|
|
|
mythtvsrc->live_chain_id = NULL;
|
|
|
|
}
|
|
|
|
mythtvsrc->live_chain_id = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_CHANNEL_NUM:
|
2007-09-03 20:07:17 +00:00
|
|
|
mythtvsrc->channel_name = g_value_dup_string (value);
|
2007-01-12 19:02:37 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
|
|
|
|
GST_OBJECT_UNLOCK (mythtvsrc);
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mythtv_src_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC (object);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (mythtvsrc);
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_LOCATION:
|
2007-09-03 20:07:17 +00:00
|
|
|
g_value_set_string (value, mythtvsrc->uri_name);
|
2007-01-12 19:02:37 +00:00
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_VERSION:
|
|
|
|
g_value_set_int (value, mythtvsrc->mythtv_version);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_LIVEID:
|
|
|
|
g_value_set_int (value, mythtvsrc->live_tv_id);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_LIVE:
|
|
|
|
g_value_set_boolean (value, mythtvsrc->live_tv);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
|
|
|
|
g_value_set_boolean (value, mythtvsrc->enable_timing_position);
|
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_LIVE_CHAINID:
|
2007-09-03 20:07:17 +00:00
|
|
|
g_value_set_string (value, mythtvsrc->live_chain_id);
|
2007-01-12 19:02:37 +00:00
|
|
|
break;
|
|
|
|
case PROP_GMYTHTV_CHANNEL_NUM:
|
2007-09-03 20:07:17 +00:00
|
|
|
g_value_set_string (value, mythtvsrc->channel_name);
|
2007-01-12 19:02:37 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (mythtvsrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
|
|
|
return gst_element_register (plugin, "mythtvsrc", GST_RANK_NONE,
|
|
|
|
GST_TYPE_MYTHTV_SRC);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2012-04-05 16:02:56 +00:00
|
|
|
mythtv,
|
2007-01-12 19:02:37 +00:00
|
|
|
"lib MythTV src",
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|
2007-01-12 19:02:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*** GSTURIHANDLER INTERFACE *************************************************/
|
ext/mythtv/gstmythtvsrc.c: Clean up a bit, mostly the debug statements; fix deadlock in _set_property() in the error ...
Original commit message from CVS:
* ext/mythtv/gstmythtvsrc.c: (do_read_request_response),
(gst_mythtv_src_create), (gst_mythtv_src_get_position),
(gst_mythtv_src_do_seek), (gst_mythtv_src_start),
(gst_mythtv_src_next_program_chain), (gst_mythtv_src_get_size),
(gst_mythtv_src_handle_event), (gst_mythtv_src_handle_query),
(gst_mythtv_src_change_state), (gst_mythtv_src_set_property),
(gst_mythtv_src_uri_get_type):
Clean up a bit, mostly the debug statements; fix deadlock in
_set_property() in the error cases; fix up query function.
2007-01-13 12:37:55 +00:00
|
|
|
static guint
|
|
|
|
gst_mythtv_src_uri_get_type (void)
|
2007-01-12 19:02:37 +00:00
|
|
|
{
|
|
|
|
return GST_URI_SRC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar **
|
|
|
|
gst_mythtv_src_uri_get_protocols (void)
|
|
|
|
{
|
2010-03-22 12:16:33 +00:00
|
|
|
static const gchar *protocols[] = { "myth", "myths", NULL };
|
2007-01-12 19:02:37 +00:00
|
|
|
|
2010-03-22 12:16:33 +00:00
|
|
|
return (gchar **) protocols;
|
2007-01-12 19:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar *
|
|
|
|
gst_mythtv_src_uri_get_uri (GstURIHandler * handler)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
|
|
|
|
|
|
|
|
return src->uri_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mythtv_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
|
|
|
|
{
|
|
|
|
GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
|
|
|
|
|
|
|
|
gchar *protocol;
|
|
|
|
|
|
|
|
protocol = gst_uri_get_protocol (uri);
|
2007-09-03 20:07:17 +00:00
|
|
|
if ((strcmp (protocol, "myth") != 0)
|
|
|
|
&& (strcmp (protocol, "myths") != 0)) {
|
2007-01-12 19:02:37 +00:00
|
|
|
g_free (protocol);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
g_free (protocol);
|
|
|
|
g_object_set (src, "location", uri, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
|
|
|
|
{
|
|
|
|
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
|
|
|
|
|
|
|
|
iface->get_type = gst_mythtv_src_uri_get_type;
|
|
|
|
iface->get_protocols = gst_mythtv_src_uri_get_protocols;
|
|
|
|
iface->get_uri = gst_mythtv_src_uri_get_uri;
|
|
|
|
iface->set_uri = gst_mythtv_src_uri_set_uri;
|
|
|
|
}
|