[svn r405] Added check target to the Makefile.am tool; now, you can type 'make check' to run some of the test scripts.
1 /* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2 -*- */
2 /* GStreamer MythTV Plug-in
3 * Copyright (C) <2006> Rosfran Borges <rosfran.borges@indt.org.br>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more
20 #include "gstmythtvsrc.h"
21 #include "myth_file_transfer.h"
22 #include "myth_livetv.h"
24 #include <gmyth/gmyth_socket.h>
25 #include <gmyth/gmyth_tvchain.h>
30 GST_DEBUG_CATEGORY_STATIC (mythtvsrc_debug);
31 #define GST_CAT_DEFAULT mythtvsrc_debug
33 #define GST_MYTHTV_ID_NUM 1
35 #define MYTHTV_VERSION_DEFAULT 30
37 #define MYTHTV_TRANSFER_MAX_WAITS 100
39 #define MYTHTV_TRANSFER_MAX_BUFFER ( 32*1024 )
42 #define MAX_READ_SIZE ( 16*1024 )
44 #define ENABLE_TIMING_POSITION 1
46 /* stablish a maximum iteration value to the IS_RECORDING message */
47 static guint wait_to_transfer = 0;
49 static const GstElementDetails gst_mythtv_src_details =
50 GST_ELEMENT_DETAILS ("MythTV client source",
52 "Control and receive data as a client over the network via raw socket connections using the MythTV protocol",
53 "Rosfran Borges <rosfran.borges@indt.org.br>");
55 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
60 static GstTask *update_size_task = NULL;
62 static GStaticRecMutex update_size_mutex = G_STATIC_REC_MUTEX_INIT;
69 #ifndef GST_DISABLE_GST_DEBUG
75 PROP_MYTHTV_LIVE_CHAINID
78 static void gst_mythtv_src_finalize (GObject * gobject);
80 static GstFlowReturn gst_mythtv_src_create (GstBaseSrc * psrc,
81 guint64 offset, guint size, GstBuffer ** outbuf);
82 static gboolean gst_mythtv_src_start (GstBaseSrc * bsrc);
83 static gboolean gst_mythtv_src_stop (GstBaseSrc * bsrc);
84 static gboolean gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size);
85 static gboolean gst_mythtv_src_is_seekable( GstBaseSrc *base_src );
87 static void gst_mythtv_src_set_property (GObject * object, guint prop_id,
88 const GValue * value, GParamSpec * pspec);
89 static void gst_mythtv_src_get_property (GObject * object, guint prop_id,
90 GValue * value, GParamSpec * pspec);
93 gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data);
96 gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event);
99 _urihandler_init (GType type)
101 static const GInterfaceInfo urihandler_info = {
102 gst_mythtv_src_uri_handler_init,
107 g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
109 GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
113 GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstBaseSrc,
114 GST_TYPE_BASE_SRC, _urihandler_init);
117 gst_mythtv_src_base_init (gpointer g_class)
119 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
121 gst_element_class_add_pad_template (element_class,
122 gst_static_pad_template_get (&srctemplate));
124 gst_element_class_set_details (element_class, &gst_mythtv_src_details);
128 gst_mythtv_src_class_init (GstMythtvSrcClass * klass)
130 GObjectClass *gobject_class;
131 GstBaseSrcClass *gstbasesrc_class;
133 gobject_class = (GObjectClass *) klass;
134 gstbasesrc_class = (GstBaseSrcClass *) klass;
136 gobject_class->set_property = gst_mythtv_src_set_property;
137 gobject_class->get_property = gst_mythtv_src_get_property;
138 gobject_class->finalize = gst_mythtv_src_finalize;
140 g_object_class_install_property
141 (gobject_class, PROP_LOCATION,
142 g_param_spec_string ("location", "Location",
143 "The location. In the form:"
144 "\n\t\t\tmyth://a.com/file.nuv"
145 "\n\t\t\tmyth://a.com:23223/file.nuv "
146 "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
147 "", G_PARAM_READWRITE));
149 g_object_class_install_property
150 (gobject_class, PROP_URI,
151 g_param_spec_string ("uri", "Uri",
152 "The location in form of a URI (deprecated; use location)",
153 "", G_PARAM_READWRITE));
155 g_object_class_install_property
156 (gobject_class, PROP_MYTHTV_VERSION,
157 g_param_spec_int ("mythtv-version", "mythtv-version",
158 "Change Myth TV version",
159 26, 30, 26, G_PARAM_READWRITE));
161 g_object_class_install_property
162 (gobject_class, PROP_MYTHTV_LIVEID,
163 g_param_spec_int ("mythtv-live-id", "mythtv-live-id",
164 "Change Myth TV version",
165 0, 200, GST_MYTHTV_ID_NUM, G_PARAM_READWRITE));
167 g_object_class_install_property
168 (gobject_class, PROP_MYTHTV_LIVE_CHAINID,
169 g_param_spec_string ("mythtv-live-chainid", "mythtv-live-chainid",
170 "Sets the Myth TV chain ID (from TV Chain)",
171 "", G_PARAM_READWRITE));
173 g_object_class_install_property
174 (gobject_class, PROP_MYTHTV_LIVE,
175 g_param_spec_boolean ("mythtv-live", "mythtv-live",
176 "Enable MythTV Live TV content streaming",
177 FALSE, G_PARAM_READWRITE));
179 #ifndef GST_DISABLE_GST_DEBUG
180 g_object_class_install_property
181 (gobject_class, PROP_MYTHTV_DBG,
182 g_param_spec_boolean ("mythtv-debug", "mythtv-debug",
183 "Enable MythTV debug messages",
184 FALSE, G_PARAM_READWRITE));
187 gstbasesrc_class->start = gst_mythtv_src_start;
188 gstbasesrc_class->stop = gst_mythtv_src_stop;
189 gstbasesrc_class->get_size = gst_mythtv_src_get_size;
190 gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable;
192 gstbasesrc_class->create = gst_mythtv_src_create;
194 GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
195 "MythTV Client Source");
199 gst_mythtv_src_init (GstMythtvSrc * this, GstMythtvSrcClass * g_class)
201 this->file_transfer = NULL;
203 this->unique_setup = FALSE;
205 this->mythtv_version = MYTHTV_VERSION_DEFAULT;
207 this->bytes_read = 0;
209 this->content_size = -1;
210 this->read_offset = 0;
212 this->live_tv = FALSE;
214 this->user_agent = g_strdup ("mythtvsrc");
215 this->mythtv_caps = NULL;
217 gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE );
219 gst_pad_set_event_function (GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
220 GST_DEBUG_FUNCPTR (gst_mythtv_src_handle_event));
225 gst_mythtv_src_finalize (GObject * gobject)
227 GstMythtvSrc *this = GST_MYTHTV_SRC (gobject);
229 g_free (this->user_agent);
231 if (this->mythtv_caps) {
232 gst_caps_unref (this->mythtv_caps);
233 this->mythtv_caps = NULL;
236 if (this->file_transfer) {
237 g_object_unref (this->file_transfer);
238 this->file_transfer = NULL;
241 if (this->uri_name) {
242 g_free (this->uri_name);
245 if (this->user_agent) {
246 g_free (this->user_agent);
249 if ( update_size_task != NULL ) {
251 if ( GST_TASK_STATE( update_size_task ) != GST_TASK_STOPPED )
252 gst_task_stop( update_size_task );
254 gst_object_unref( update_size_task );
256 update_size_task = NULL;
260 G_OBJECT_CLASS (parent_class)->finalize (gobject);
265 do_seek( GstMythtvSrc *src, guint64 offset, guint size, GstBuffer *outbuf )
267 guint64 off_uint64 = myth_file_transfer_seek(src->file_transfer, offset, 1);
269 g_print( "[%s] Call MythTV SEEK with offset %llu, got a new one %llu...\n", __FUNCTION__,
270 offset, off_uint64 );
278 do_read_request_response (GstMythtvSrc * src, guint64 offset, guint size, GstBuffer * outbuf)
281 guint sizetoread = size; //GST_BUFFER_SIZE (outbuf);
283 g_print( "[%s] Reading %d bytes...\n", __FUNCTION__, sizetoread );
285 /* Loop sending the request:
286 * Retry whilst authentication fails and we supply it. */
290 //GST_OBJECT_LOCK(src);
292 while ( sizetoread > 0 ) {
294 len = myth_file_transfer_read( src->file_transfer,
295 GST_BUFFER_DATA (outbuf) + read, sizetoread, TRUE );
299 src->read_offset += read;
301 } else if ( len < 0 ) {
304 else if ( len == 0 ) {
305 if ( src->live_tv == FALSE )
312 if ( len == sizetoread )
318 src->bytes_read += read;
320 GST_BUFFER_SIZE (outbuf) = read;
321 } else if ( read <= 0 || len <= 0 ) {
322 if ( src->live_tv == FALSE )
327 //GST_BUFFER_OFFSET (outbuf) = src->read_offset;
329 g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
330 "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read,
331 src->read_offset, src->content_size );
333 //GST_OBJECT_UNLOCK(src);
337 if ( src->live_tv == FALSE )
343 if ( src->bytes_read < src->content_size )
347 //GST_OBJECT_UNLOCK(src);
351 //GST_OBJECT_UNLOCK(src);
357 gst_mythtv_src_create ( GstBaseSrc * psrc, guint64 offset,
358 guint size, GstBuffer **outbuf )
361 GstFlowReturn ret = GST_FLOW_OK;
364 src = GST_MYTHTV_SRC (psrc);
366 //src->do_start = FALSE;
367 src->do_start = FALSE;
368 gst_task_join ( update_size_task );
370 g_print( "[%s]\tBUFFER OFFSET = %llu, BUFFER SIZE = %d.\n", __FUNCTION__, offset,
373 /* The caller should know the number of bytes and not read beyond EOS. */
374 //if (G_UNLIKELY (src->eos))
376 //g_static_rec_mutex_lock( &update_size_mutex );
378 /* Create the buffer. */
379 ret = gst_pad_alloc_buffer ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
380 // GST_BUFFER_OFFSET_NONE, GST_BASE_SRC (psrc)->blocksize,
382 src->mythtv_caps ? src->mythtv_caps :
383 GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf );
385 //if (G_UNLIKELY (ret == GST_FLOW_UNEXPECTED))
388 if (G_UNLIKELY (ret != GST_FLOW_OK))
391 if (G_UNLIKELY (ret == GST_FLOW_ERROR))
394 read = do_read_request_response ( src, offset, size, *outbuf );
396 //g_static_rec_mutex_unlock( &update_size_mutex );
398 src->do_start = TRUE;
399 gst_task_start ( update_size_task );
402 g_static_rec_mutex_lock( &update_size_mutex );
403 src->do_start = FALSE;
404 g_static_rec_mutex_unlock( &update_size_mutex );
405 GST_TASK_SIGNAL( update_size_task );
408 //g_static_rec_mutex_unlock( &update_size_mutex );
411 #if ENABLE_TIMING_POSITION == 1
412 guint64 size_tmp = 0;
413 if (src->live_tv == TRUE) {
417 size_tmp = myth_file_transfer_get_file_position( src->file_transfer );
418 if ( size_tmp > ( src->content_size + MYTHTV_TRANSFER_MAX_BUFFER ) )
419 src->content_size = size_tmp;
422 g_print( "\t[%s]\tGET_POSITION: file_position = %llu\n",
423 __FUNCTION__, size_tmp);
429 //if (G_UNLIKELY (read < 0))
432 if (G_UNLIKELY(src->eos))
441 #if ENABLE_TIMING_POSITION == 1
442 if ( src->live_tv == TRUE ) {
444 guint64 size_tmp = 0;
447 size_tmp = myth_file_transfer_get_file_position( src->file_transfer );
448 if ( size_tmp > ( src->content_size + MYTHTV_TRANSFER_MAX_BUFFER ) )
449 src->content_size = size_tmp;
451 goto get_file_pos_eos;
452 g_print( "\t[%s]\tGET_POSITION: file_position = %llu\n",
453 __FUNCTION__, size_tmp);
459 GST_DEBUG_OBJECT (src, "EOS reached");
460 return GST_FLOW_UNEXPECTED;
465 GST_ELEMENT_ERROR (src, RESOURCE, READ,
466 (NULL), ("Could not read any bytes (%i, %s)", read,
468 return GST_FLOW_ERROR;
473 const gchar *reason = gst_flow_get_name (ret);
475 GST_DEBUG_OBJECT (src, "pausing task, reason %s", reason);
476 return GST_FLOW_UNEXPECTED;
483 /* The following two charset mangling functions were copied from gnomevfssrc.
484 * Preserve them under the unverified assumption that they do something vaguely
488 unicodify (const char *str, int len, ...)
490 char *ret = NULL, *cset;
492 gsize bytes_read, bytes_written;
494 if (g_utf8_validate (str, len, NULL))
495 return g_strndup (str, len >= 0 ? len : strlen (str));
497 va_start (args, len);
498 while ((cset = va_arg (args, char *)) != NULL)
500 if (!strcmp (cset, "locale"))
501 ret = g_locale_to_utf8 (str, len, &bytes_read, &bytes_written, NULL);
503 ret = g_convert (str, len, "UTF-8", cset,
504 &bytes_read, &bytes_written, NULL);
514 gst_mythtv_src_unicodify (const char *str)
516 return unicodify (str, -1, "locale", "ISO-8859-1", NULL);
521 update_size_func( void *mythtv_data )
525 g_return_if_fail( mythtv_data != NULL );
527 src = GST_MYTHTV_SRC ( mythtv_data );
528 if ( src->do_start ) {
529 #if ENABLE_TIMING_POSITION == 1
530 guint64 size_tmp = 0;
531 if (src->live_tv == TRUE) {
534 size_tmp = myth_file_transfer_get_file_position( src->file_transfer );
535 if ( size_tmp > ( src->content_size + MYTHTV_TRANSFER_MAX_BUFFER ) )
536 src->content_size = size_tmp;
539 g_print( "\t[%s]\tGET_POSITION: file_position = %llu\n",
540 __FUNCTION__, size_tmp );
544 gst_task_pause( update_size_task );
545 // src->do_start = FALSE;
546 //GST_TASK_SIGNAL( update_size_task );
550 /* create a socket for connecting to remote server */
552 gst_mythtv_src_start ( GstBaseSrc * bsrc )
554 GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
556 GString *chain_id_local = NULL;
560 if (src->live_tv == TRUE && src->file_transfer != NULL) {
561 guint64 size_tmp = myth_file_transfer_get_file_position( src->file_transfer );
562 if (size_tmp > src->content_size)
563 src->content_size = size_tmp;
564 g_print( "\t[%s]\tGET_POSITION: file_position = %llu\n",
565 __FUNCTION__, size_tmp);
568 if (src->unique_setup == FALSE) {
569 src->unique_setup = TRUE;
574 //GST_OBJECT_LOCK(src);
576 if ( src->live_tv ) {
577 src->spawn_livetv = myth_livetv_new( );
578 if ( myth_livetv_setup( src->spawn_livetv ) == FALSE ) {
582 /* set up the uri variable */
583 src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str );
584 chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
585 if ( chain_id_local != NULL ) {
586 src->live_chain_id = g_strdup( chain_id_local->str );
587 g_print( "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
589 src->live_tv_id = src->spawn_livetv->remote_encoder->recorder_num;
590 g_print ( "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
593 src->file_transfer = myth_file_transfer_new( src->live_tv_id,
594 g_string_new( src->uri_name ), -1, src->mythtv_version );
596 if ( src->file_transfer == NULL ) {
597 //GST_OBJECT_UNLOCK(src);
602 if ( src->live_tv ) {
603 g_print ( "[%s] GST MYTHTVSRC: live_chain_id = %s\n", __FUNCTION__, src->live_chain_id );
604 /* sets the MythSocket to the FileTransfer */
605 //ret = myth_file_transfer_livetv_setup( &(src->file_transfer), src->spawn_livetv->remote_encoder->myth_socket );
607 /* sets the Playback monitor connection */
608 ret = myth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
610 if ( src->live_tv == TRUE && ret == TRUE ) {
611 /* loop finished, set the max tries variable to zero again... */
612 wait_to_transfer = 0;
614 while ( wait_to_transfer++ < MYTHTV_TRANSFER_MAX_WAITS && ( myth_file_transfer_is_recording( src->file_transfer ) == FALSE
615 /*|| ( myth_file_transfer_get_file_position( src->file_transfer ) < ( src->content_size + 327680 ) )*/ ) )
619 /* sets the FileTransfer instance connection (video/audio download) */
620 ret = myth_file_transfer_setup( &(src->file_transfer), src->live_tv );
622 if ( ret == FALSE ) {
623 //GST_OBJECT_UNLOCK(src);
624 #ifndef GST_DISABLE_GST_DEBUG
625 if ( src->mythtv_msgs_dbg )
626 g_printerr( "MythTV FileTransfer request failed when setting up socket connection!\n" );
628 goto begin_req_failed;
631 src->content_size = src->file_transfer->filesize;
633 //GST_OBJECT_UNLOCK(src);
635 update_size_task = gst_task_create( update_size_func, src );
637 gst_task_set_lock( update_size_task, &update_size_mutex );
639 g_print( "[%s] Update Size task = %s\n", __FUNCTION__, gst_task_start( update_size_task ) &&
640 GST_TASK_STATE( update_size_task ) == GST_TASK_STARTED ? "OK !" : "ERROR!!!" );
642 src->do_start = TRUE;
645 const char *str_value;
648 str_value = ne_get_response_header (src->request, "myth-metaint");
650 if ( sscanf (str_value, "%d", &gint_value) == 1 ) {
651 if (src->myth_caps) {
652 gst_caps_unref (src->myth_caps);
653 src->myth_caps = NULL;
655 src->myth_metaint = gint_value;
657 //src->mythtv_caps = gst_caps_new_simple ("application/x-gst_ff-nuv", NULL);
666 if (src->spawn_livetv != NULL )
667 g_object_unref( src->spawn_livetv );
669 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
670 (NULL), ("Could not initialize MythTV library (%i, %s)", ret, src->uri_name));
675 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
676 (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret, src->uri_name));
683 gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size)
686 gboolean ret = FALSE;
688 src = GST_MYTHTV_SRC (bsrc);
690 g_static_rec_mutex_lock( &update_size_mutex );
691 src->do_start = FALSE;
692 g_static_rec_mutex_unlock( &update_size_mutex );
693 GST_TASK_SIGNAL( update_size_task );
698 g_static_rec_mutex_lock( &update_size_mutex );
699 if ( !src->do_start ) {
701 g_print( "[%s] GET SIZE: do_start? == %s\n", __FUNCTION__, src->do_start ? "YES" : "NO" );
703 GST_TASK_WAIT( update_size_task );
705 if (src->content_size <= 0) {
706 g_static_rec_mutex_unlock( &update_size_mutex );
710 *size = src->content_size;
711 src->do_start = FALSE;
713 g_static_rec_mutex_unlock( &update_size_mutex );
717 g_static_rec_mutex_unlock( &update_size_mutex );
728 gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size)
733 src = GST_MYTHTV_SRC (bsrc);
735 if (src->content_size <= 0)
738 *size = src->content_size;
743 /* close the socket and associated resources
744 * used both to recover from errors and go to NULL state */
746 gst_mythtv_src_stop (GstBaseSrc * bsrc)
750 src = GST_MYTHTV_SRC (bsrc);
753 g_free (src->uri_name);
754 src->uri_name = NULL;
757 if (src->mythtv_caps) {
758 gst_caps_unref (src->mythtv_caps);
759 src->mythtv_caps = NULL;
768 gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event)
770 GstMythtvSrc *src = GST_MYTHTV_SRC (GST_PAD_PARENT (pad));
772 switch (GST_EVENT_TYPE (event)) {
773 case GST_EVENT_FLUSH_START:
778 case GST_EVENT_FLUSH_STOP:
779 src->do_start = TRUE;
781 gst_element_set_state (GST_ELEMENT(src), GST_STATE_NULL);
782 //gst_element_set_locked_state (GST_ELEMENT(src), TRUE);
788 //gboolean update = TRUE;
790 GstSeekType cur_type, stop_type;
792 gint64 cur = 0, stop = 0;
793 gst_event_parse_seek ( event, &rate, &format,
794 &flags, &cur_type, &cur,
797 g_print( "[%s] Got EVENT_SEEK.\n", __FUNCTION__ );
798 if ( !( flags & GST_SEEK_FLAG_FLUSH ) ) {
799 g_print( "[%s] Could get the FLAG_FLUSH message.\n", __FUNCTION__ );
801 //gboolean ret = gst_event_parse_new_segment ( event,
802 // &update, &rate, &format, &start, &stop,
804 //GstFlowReturn flow_ret = gst_mythtv_src_create (GST_BASE_SRC( GST_PAD_PARENT( psrc ) ),
805 // cur, stop - cur + 1, GstBuffer)
809 return gst_pad_event_default (pad, event);
812 return gst_pad_event_default (pad, event);
816 gst_mythtv_src_is_seekable( GstBaseSrc *base_src )
822 gst_mythtv_src_set_property (GObject * object, guint prop_id,
823 const GValue * value, GParamSpec * pspec)
825 GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC (object);
827 GST_OBJECT_LOCK (mythtvsrc);
832 if (!g_value_get_string (value)) {
833 GST_WARNING ("location property cannot be NULL");
837 if (mythtvsrc->uri_name != NULL) {
838 g_free (mythtvsrc->uri_name);
839 mythtvsrc->uri_name = NULL;
841 mythtvsrc->uri_name = g_value_dup_string (value);
845 #ifndef GST_DISABLE_GST_DEBUG
846 case PROP_MYTHTV_DBG:
848 mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean (value);
852 case PROP_MYTHTV_VERSION:
854 mythtvsrc->mythtv_version = g_value_get_int (value);
857 case PROP_MYTHTV_LIVEID:
859 mythtvsrc->live_tv_id = g_value_get_int (value);
862 case PROP_MYTHTV_LIVE:
864 mythtvsrc->live_tv = g_value_get_boolean (value);
867 case PROP_MYTHTV_LIVE_CHAINID:
869 if (!g_value_get_string (value)) {
870 GST_WARNING ("MythTV Live chainid property cannot be NULL");
874 if (mythtvsrc->live_chain_id != NULL) {
875 g_free (mythtvsrc->live_chain_id);
876 mythtvsrc->live_chain_id = NULL;
878 mythtvsrc->live_chain_id = g_value_dup_string (value);
884 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
887 GST_OBJECT_UNLOCK (mythtvsrc);
893 gst_mythtv_src_get_property (GObject * object, guint prop_id,
894 GValue * value, GParamSpec * pspec)
896 GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC (object);
898 GST_OBJECT_LOCK (mythtvsrc);
903 gchar *str = g_strdup( "" );
905 if ( mythtvsrc->uri_name == NULL ) {
906 g_free (mythtvsrc->uri_name);
907 mythtvsrc->uri_name = NULL;
909 str = g_strdup( mythtvsrc->uri_name );
911 g_value_set_string ( value, str );
914 #ifndef GST_DISABLE_GST_DEBUG
915 case PROP_MYTHTV_DBG:
916 g_value_set_boolean ( value, mythtvsrc->mythtv_msgs_dbg );
919 case PROP_MYTHTV_VERSION:
921 g_value_set_int ( value, mythtvsrc->mythtv_version );
924 case PROP_MYTHTV_LIVEID:
926 g_value_set_int ( value, mythtvsrc->live_tv_id );
929 case PROP_MYTHTV_LIVE:
930 g_value_set_boolean ( value, mythtvsrc->live_tv );
932 case PROP_MYTHTV_LIVE_CHAINID:
934 gchar *str = g_strdup( "" );
936 if ( mythtvsrc->live_chain_id == NULL ) {
937 g_free (mythtvsrc->live_chain_id);
938 mythtvsrc->live_chain_id = NULL;
940 str = g_strdup( mythtvsrc->live_chain_id );
942 g_value_set_string ( value, str );
946 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
949 GST_OBJECT_UNLOCK (mythtvsrc);
952 /* entry point to initialize the plug-in
953 * initialize the plug-in itself
954 * register the element factories and pad templates
955 * register the features
958 plugin_init (GstPlugin * plugin)
960 return gst_element_register (plugin, "mythtvsrc", GST_RANK_NONE,
961 GST_TYPE_MYTHTV_SRC);
964 /* this is the structure that gst-register looks for
965 * so keep the name plugin_desc, or you cannot get your plug-in registered */
966 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
970 plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
973 /*** GSTURIHANDLER INTERFACE *************************************************/
975 gst_mythtv_src_uri_get_type (void)
981 gst_mythtv_src_uri_get_protocols (void)
983 static gchar *protocols[] = { "myth", "myths", NULL };
989 gst_mythtv_src_uri_get_uri (GstURIHandler * handler)
991 GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
993 return src->uri_name;
997 gst_mythtv_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
999 GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
1003 protocol = gst_uri_get_protocol (uri);
1004 if ((strcmp (protocol, "myth") != 0) && (strcmp (protocol, "myths") != 0)) {
1009 g_object_set (src, "location", uri, NULL);
1015 gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
1017 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
1019 iface->get_type = gst_mythtv_src_uri_get_type;
1020 iface->get_protocols = gst_mythtv_src_uri_get_protocols;
1021 iface->get_uri = gst_mythtv_src_uri_get_uri;
1022 iface->set_uri = gst_mythtv_src_uri_set_uri;
1026 size_header_handler (void *userdata, const char *value)
1028 GstMythtvSrc *src = GST_MYTHTV_SRC (userdata);
1030 //src->content_size = g_ascii_strtoull (value, NULL, 10);
1032 GST_DEBUG_OBJECT (src, "content size = %lld bytes", src->content_size);