[svn r104] Allows to receive buffers with unlimited size when reading data from backend.
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 Lesser General
7 * Public 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 <gmyth/gmyth_file_transfer.h>
22 #include <gmyth/gmyth_livetv.h>
24 #include <gmyth/gmyth_socket.h>
25 #include <gmyth/gmyth_tvchain.h>
27 #include <gmyth/gmyth_context.h>
32 GST_DEBUG_CATEGORY_STATIC (mythtvsrc_debug);
33 #define GST_CAT_DEFAULT mythtvsrc_debug
35 #define GST_GMYTHTV_ID_NUM 1
37 #define GST_GMYTHTV_CHANNEL_NUM 1000
39 #define GMYTHTV_VERSION_DEFAULT 30
41 #define GMYTHTV_TRANSFER_MAX_WAITS 100
43 #define GMYTHTV_TRANSFER_MAX_RESENDS 5
45 #define GMYTHTV_TRANSFER_MAX_BUFFER 128*1024
49 #define MAX_READ_SIZE 4*1024
52 #define GST_FLOW_ERROR_NO_DATA -101
54 #define INTERNAL_BUFFER_SIZE 64*1024
56 /* stablish a maximum iteration value to the IS_RECORDING message */
57 static guint wait_to_transfer = 0;
59 static const GstElementDetails gst_mythtv_src_details =
60 GST_ELEMENT_DETAILS ( "MythTV client source",
62 "Control and receive data as a client over the network via raw socket connections using the MythTV protocol",
63 "Rosfran Borges <rosfran.borges@indt.org.br>" );
65 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ( "src",
68 GST_STATIC_CAPS ("video/x-nuv") );
75 #ifndef GST_DISABLE_GST_DEBUG
81 PROP_GMYTHTV_LIVE_CHAINID,
82 PROP_GMYTHTV_ENABLE_TIMING_POSITION,
83 PROP_GMYTHTV_CHANNEL_NUM
86 static void gst_mythtv_src_finalize (GObject * gobject);
88 //static GstFlowReturn gst_mythtv_src_create (GstBaseSrc * psrc, guint64 offset,
89 // guint size, GstBuffer ** outbuf);
91 static GstFlowReturn gst_mythtv_src_create ( GstPushSrc* psrc, GstBuffer** outbuf );
93 static gboolean gst_mythtv_src_start (GstBaseSrc * bsrc);
94 static gboolean gst_mythtv_src_stop (GstBaseSrc * bsrc);
95 static gboolean gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size);
96 static gboolean gst_mythtv_src_is_seekable( GstBaseSrc *push_src );
98 //static void gst_mythtv_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
99 // GstClockTime * start, GstClockTime * end);
101 static gboolean gst_mythtv_src_do_seek( GstBaseSrc *base, GstSegment *segment );
103 static gboolean gst_mythtv_src_next_program_chain ( GstMythtvSrc *src );
105 static GstStateChangeReturn
106 gst_mythtv_src_change_state (GstElement * element, GstStateChange transition);
108 static void gst_mythtv_src_set_property (GObject * object, guint prop_id,
109 const GValue * value, GParamSpec * pspec);
110 static void gst_mythtv_src_get_property (GObject * object, guint prop_id,
111 GValue * value, GParamSpec * pspec);
113 static void gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data);
115 static gboolean gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query);
117 static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event);
119 static gint do_read_request_response (GstMythtvSrc * src, guint size, GByteArray *data_ptr);
121 GStaticRecMutex th_mutex = G_STATIC_REC_MUTEX_INIT;
124 _urihandler_init (GType type)
126 static const GInterfaceInfo urihandler_info = {
127 gst_mythtv_src_uri_handler_init,
132 g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
134 GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
138 //GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstBaseSrc,
139 // GST_TYPE_BASE_SRC, _urihandler_init)
141 GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstPushSrc,
142 GST_TYPE_PUSH_SRC, _urihandler_init)
145 gst_mythtv_src_base_init (gpointer g_class)
147 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
149 gst_element_class_add_pad_template (element_class,
150 gst_static_pad_template_get (&srctemplate));
152 gst_element_class_set_details (element_class, &gst_mythtv_src_details);
154 element_class->change_state = gst_mythtv_src_change_state;
159 gst_mythtv_src_class_init (GstMythtvSrcClass * klass)
161 GObjectClass *gobject_class;
162 GstPushSrcClass *gstpushsrc_class;
163 GstBaseSrcClass *gstbasesrc_class;
165 gobject_class = (GObjectClass *) klass;
166 gstbasesrc_class = (GstBaseSrcClass *) klass;
167 gstpushsrc_class = (GstPushSrcClass *) klass;
169 gobject_class->set_property = gst_mythtv_src_set_property;
170 gobject_class->get_property = gst_mythtv_src_get_property;
171 gobject_class->finalize = gst_mythtv_src_finalize;
173 g_object_class_install_property
174 (gobject_class, PROP_LOCATION,
175 g_param_spec_string ("location", "Location",
176 "The location. In the form:"
177 "\n\t\t\tmyth://a.com/file.nuv"
178 "\n\t\t\tmyth://a.com:23223/file.nuv "
179 "\n\t\t\ta.com/file.nuv - default scheme 'myth'",
180 "", G_PARAM_READWRITE));
182 g_object_class_install_property
183 (gobject_class, PROP_URI,
184 g_param_spec_string ("uri", "Uri",
185 "The location in form of a URI (deprecated; use location)",
186 "", G_PARAM_READWRITE));
188 g_object_class_install_property
189 (gobject_class, PROP_GMYTHTV_VERSION,
190 g_param_spec_int ("mythtv-version", "mythtv-version",
191 "Change MythTV version",
192 26, 30, 26, G_PARAM_READWRITE));
194 g_object_class_install_property
195 (gobject_class, PROP_GMYTHTV_LIVEID,
196 g_param_spec_int ("mythtv-live-id", "mythtv-live-id",
197 "Change MythTV version",
198 0, 200, GST_GMYTHTV_ID_NUM, G_PARAM_READWRITE));
200 g_object_class_install_property
201 (gobject_class, PROP_GMYTHTV_LIVE_CHAINID,
202 g_param_spec_string ("mythtv-live-chainid", "mythtv-live-chainid",
203 "Sets the MythTV chain ID (from TV Chain)",
204 "", G_PARAM_READWRITE));
206 g_object_class_install_property
207 (gobject_class, PROP_GMYTHTV_LIVE,
208 g_param_spec_boolean ("mythtv-live", "mythtv-live",
209 "Enable MythTV Live TV content streaming",
210 FALSE, G_PARAM_READWRITE));
212 g_object_class_install_property
213 (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION,
214 g_param_spec_boolean ("mythtv-enable-timing-position", "mythtv-enable-timing-position",
215 "Enable MythTV Live TV content size continuous updating",
216 FALSE, G_PARAM_READWRITE));
218 g_object_class_install_property
219 (gobject_class, PROP_GMYTHTV_CHANNEL_NUM,
220 g_param_spec_int ("mythtv-channel", "mythtv-channel",
221 "Change MythTV channel number",
222 0, 99999, GST_GMYTHTV_CHANNEL_NUM, G_PARAM_READWRITE));
224 #ifndef GST_DISABLE_GST_DEBUG
225 g_object_class_install_property
226 (gobject_class, PROP_GMYTHTV_DBG,
227 g_param_spec_boolean ("mythtv-debug", "mythtv-debug",
228 "Enable MythTV debug messages",
229 FALSE, G_PARAM_READWRITE));
232 gstbasesrc_class->start = gst_mythtv_src_start;
233 gstbasesrc_class->stop = gst_mythtv_src_stop;
234 gstbasesrc_class->get_size = gst_mythtv_src_get_size;
235 gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable;
237 //gstbasesrc_class->get_times = gst_mythtv_src_get_times;
239 gstbasesrc_class->do_seek = gst_mythtv_src_do_seek;
240 gstpushsrc_class->create = gst_mythtv_src_create;
242 GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0,
243 "MythTV Client Source");
247 gst_mythtv_src_init (GstMythtvSrc * this, GstMythtvSrcClass * g_class)
249 this->file_transfer = NULL;
251 this->unique_setup = FALSE;
253 this->mythtv_version = GMYTHTV_VERSION_DEFAULT;
255 this->state = GST_MYTHTV_SRC_FILE_TRANSFER;
257 this->bytes_read = 0;
259 this->prev_content_size = 0;
261 this->content_size = 0;
262 this->read_offset = 0;
264 this->content_size_last = 0;
266 this->live_tv = FALSE;
268 this->enable_timing_position = FALSE;
269 this->update_prog_chain = FALSE;
271 this->user_agent = g_strdup ("mythtvsrc");
272 this->mythtv_caps = NULL;
273 this->update_prog_chain = FALSE;
275 this->channel_num = 0;
279 this->bytes_queue = NULL;
281 //this->th_read_ahead = NULL;
283 this->th_mutex = NULL;
285 gst_base_src_set_format( GST_BASE_SRC( this ), GST_FORMAT_BYTES );
287 //gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE );
289 gst_pad_set_event_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
290 gst_mythtv_src_handle_event );
291 gst_pad_set_query_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
292 gst_mythtv_src_handle_query );
297 gst_mythtv_src_finalize (GObject * gobject)
299 GstMythtvSrc *this = GST_MYTHTV_SRC (gobject);
301 if ( this->th_read_ahead != NULL ) {
302 gst_task_stop( this->th_read_ahead );
303 this->th_read_ahead = NULL;
306 if (this->mythtv_caps) {
307 gst_caps_unref (this->mythtv_caps);
308 this->mythtv_caps = NULL;
311 if (this->file_transfer) {
312 g_object_unref (this->file_transfer);
313 this->file_transfer = NULL;
316 if (this->spawn_livetv) {
317 g_object_unref (this->spawn_livetv);
318 this->spawn_livetv = NULL;
321 if (this->uri_name) {
322 g_free (this->uri_name);
325 if (this->user_agent) {
326 g_free (this->user_agent);
329 if ( this->bytes_queue ) {
330 g_byte_array_free( this->bytes_queue, TRUE );
331 this->bytes_queue = NULL;
334 G_OBJECT_CLASS (parent_class)->finalize (gobject);
338 do_read_request_response (GstMythtvSrc * src, guint size, GByteArray *data_ptr)
341 guint sizetoread = size;
342 guint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
344 //*data_ptr = g_malloc0( size );
346 g_print( "Starting: [%s] Reading %d bytes...\n", __FUNCTION__, sizetoread );
348 /* Loop sending the Myth File Transfer request:
349 * Retry whilst authentication fails and we supply it. */
352 while ( sizetoread == size && --max_iters > 0) {
354 len = gmyth_file_transfer_read( src->file_transfer,
355 data_ptr, sizetoread, TRUE );
365 if ( src->live_tv == FALSE )
371 if ( len == GMYTHTV_FILE_TRANSFER_READ_ERROR ) { /* -314 */
372 src->update_prog_chain = TRUE;
380 if ( read == sizetoread )
384 if ( ( read < 0 && !src->live_tv ) || max_iters == 0 )
397 gst_mythtv_src_create ( GstPushSrc* psrc, GstBuffer** outbuf )
400 GstFlowReturn ret = GST_FLOW_OK;
403 src = GST_MYTHTV_SRC ( psrc );
405 /* The caller should know the number of bytes and not read beyond EOS. */
406 if (G_UNLIKELY (src->eos))
408 if ( G_UNLIKELY (src->update_prog_chain) )
409 goto change_progchain;
411 //g_static_rec_mutex_lock( &th_mutex );
412 g_print ( "[%s] offset = %llu, size = %d...\n", __FUNCTION__,
413 src->read_offset, MAX_READ_SIZE );
415 g_print ( "[%s]\t\tCreate: buffer_remain: %d\n", __FUNCTION__,
416 (gint) src->buffer_remain);
418 /* just get from the byte array, no network effort... */
419 if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE ) {
420 guint buffer_size_inter = INTERNAL_BUFFER_SIZE - src->buffer_remain;
421 GByteArray *buffer = g_byte_array_new();
423 read = do_read_request_response( src, buffer_size_inter, buffer );
425 if (G_UNLIKELY (read < 0)) {
427 goto change_progchain;
432 if ( G_UNLIKELY (src->update_prog_chain) )
433 goto change_progchain;
435 src->bytes_queue = g_byte_array_append( src->bytes_queue, g_memdup( buffer->data, read ), read );
437 src->buffer_remain = src->buffer_remain + read;
439 if ( buffer != NULL ) {
440 g_byte_array_free( buffer, TRUE );
444 g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
445 "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read,
446 src->read_offset, src->content_size );
450 guint buffer_size = ( src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
452 /* Create the buffer. */
453 ret = gst_pad_alloc_buffer ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
454 src->read_offset, buffer_size,
455 GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf );
457 if (G_UNLIKELY (ret != GST_FLOW_OK)) {
459 goto change_progchain;
464 /* gets the first buffer_size bytes from the byte array buffer variable */
465 guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size );
467 g_print( "[%s] read from network? %s!, buffer_remain = %d\n", __FUNCTION__,
468 read == -1 ? "NO, got from buffer" : "YES, go see the backend's log file", src->buffer_remain );
470 GST_BUFFER_SIZE (*outbuf) = buffer_size;
471 GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) );
472 GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf );
473 g_memmove( GST_BUFFER_DATA( (*outbuf) ), buf, GST_BUFFER_SIZE(*outbuf) );
474 GST_BUFFER_OFFSET (*outbuf) = src->read_offset;
475 GST_BUFFER_OFFSET_END (*outbuf) = src->read_offset + GST_BUFFER_SIZE (*outbuf);
477 src->buffer_remain -= GST_BUFFER_SIZE (*outbuf);
479 src->read_offset += GST_BUFFER_SIZE (*outbuf);
480 src->bytes_read += GST_BUFFER_SIZE (*outbuf);
481 g_print ( "[%s]\t\tBuffer output with size: %d\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf) );
483 /* flushs the newly buffer got from byte array */
484 src->bytes_queue = g_byte_array_remove_range( src->bytes_queue, 0, buffer_size );
486 g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
487 "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf),
488 GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) );
494 const gchar *reason = gst_flow_get_name (ret);
496 GST_DEBUG_OBJECT (src, "DONE task, reason %s", reason);
501 const gchar *reason = gst_flow_get_name (ret);
503 GST_DEBUG_OBJECT (src, "pausing task, reason %s", reason);
504 return GST_FLOW_UNEXPECTED;
509 GST_ELEMENT_ERROR (src, RESOURCE, READ,
510 (NULL), ("Could not read any bytes (%i, %s)", read,
512 return GST_FLOW_ERROR;
516 GST_ELEMENT_ERROR (src, RESOURCE, READ,
517 (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
520 gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
521 gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
522 // go to the next program chain
523 src->unique_setup = FALSE;
524 src->update_prog_chain = TRUE;
526 gst_mythtv_src_next_program_chain( src );
528 return GST_FLOW_ERROR_NO_DATA;
535 gst_mythtv_src_create ( GstBaseSrc * psrc, guint64 offset, guint size, GstBuffer **outbuf )
538 GstFlowReturn ret = GST_FLOW_OK;
540 gint adapter_size = 0;
541 guint max_adapter_rep = 1;
543 src = GST_MYTHTV_SRC ( psrc );
545 /* The caller should know the number of bytes and not read beyond EOS. */
546 if (G_UNLIKELY (src->eos))
548 if ( G_UNLIKELY (src->update_prog_chain) )
549 goto change_progchain;
551 //g_static_rec_mutex_lock( &th_mutex );
552 g_print ( "[%s] offset = %llu, size = %d...\n", __FUNCTION__, offset, size );
554 g_print ( "[%s]\t\tCreate: buffer_remain: %d\n", __FUNCTION__,
555 (gint) src->buffer_remain);
557 /* just get from the byte array, no network effort... */
558 if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE ) {
559 guint8 *buffer = g_malloc0( INTERNAL_BUFFER_SIZE - src->buffer_remain );
561 read = do_read_request_response( src, 0, INTERNAL_BUFFER_SIZE - src->buffer_remain, &(buffer) );
563 if (G_UNLIKELY (read < 0)) {
565 goto change_progchain;
570 if ( G_UNLIKELY (src->update_prog_chain) )
571 goto change_progchain;
573 src->bytes_queue = g_byte_array_append( src->bytes_queue, buffer, read );
575 src->buffer_remain = src->buffer_remain + read;
577 g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
578 "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read,
579 src->read_offset, src->content_size );
583 guint buffer_size = ( src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
585 /* Create the buffer. */
586 ret = gst_pad_alloc_buffer ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
588 GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf );
590 if (G_UNLIKELY (ret != GST_FLOW_OK)) {
592 goto change_progchain;
597 guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size );
599 g_print( "[%s] read = %d, buffer_remain = %d\n", __FUNCTION__, read, src->buffer_remain );
600 //src->read_offset = offset;
602 GST_BUFFER_SIZE (*outbuf) = buffer_size;
603 GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) );
604 GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf );
605 g_memmove( GST_BUFFER_DATA( (*outbuf) ), buf, GST_BUFFER_SIZE(*outbuf) );
606 GST_BUFFER_OFFSET (*outbuf) = offset;
607 GST_BUFFER_OFFSET_END (*outbuf) = offset + GST_BUFFER_SIZE (*outbuf);
609 src->buffer_remain -= GST_BUFFER_SIZE (*outbuf);
611 src->read_offset += GST_BUFFER_SIZE (*outbuf);
612 src->bytes_read += GST_BUFFER_SIZE (*outbuf);
613 g_print ( "[%s]\t\tBuffer output with size: %d\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf) );
615 /* flushs the newly buffer got from byte array */
616 src->bytes_queue = g_byte_array_remove_range( src->bytes_queue, 0, buffer_size );
618 g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
619 "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf),
620 GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) );
626 const gchar *reason = gst_flow_get_name (ret);
628 GST_DEBUG_OBJECT (src, "DONE task, reason %s", reason);
633 const gchar *reason = gst_flow_get_name (ret);
635 GST_DEBUG_OBJECT (src, "pausing task, reason %s", reason);
636 return GST_FLOW_UNEXPECTED;
641 GST_ELEMENT_ERROR (src, RESOURCE, READ,
642 (NULL), ("Could not read any bytes (%i, %s)", read,
644 return GST_FLOW_ERROR;
648 GST_ELEMENT_ERROR (src, RESOURCE, READ,
649 (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
652 gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
653 gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
654 // go to the next program chain
655 src->unique_setup = FALSE;
656 src->update_prog_chain = TRUE;
658 gst_mythtv_src_next_program_chain( src );
660 return GST_FLOW_ERROR_NO_DATA;
667 gst_mythtv_src_get_position ( GstMythtvSrc* src )
672 if (src->live_tv == TRUE && ( abs( src->content_size - src->bytes_read ) <
673 GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
677 size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer );
678 if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) )
679 src->content_size = size_tmp;
680 else if ( size_tmp > 0 && --max_tries > 0 )
682 g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n",
683 __FUNCTION__, size_tmp );
684 /* sets the last content size amount before it can be updated */
685 src->prev_content_size = src->content_size;
688 return src->content_size;
693 gst_mythtv_src_do_seek( GstBaseSrc *base, GstSegment *segment )
695 GstMythtvSrc *src = GST_MYTHTV_SRC( base );
696 gint64 new_offset = -1;
697 gint64 actual_seek = segment->start;
700 g_print( "[%s]DO Seek called! (start = %lld, stop = %lld)\n", __FUNCTION__, segment->start, segment->stop );
702 if ( segment->format == GST_FORMAT_TIME )
705 //actual_seek = ( ( segment->start / 1000 ) * 28 ) * 4000;
707 g_print( "[%s]Trying to seek at the value (actual_seek = %lld, read_offset = %lld)\n", __FUNCTION__, actual_seek, src->read_offset );
708 /* verify if it needs to seek */
709 if ( src->read_offset != actual_seek )
712 new_offset = gmyth_file_transfer_seek( src->file_transfer, segment->start, SEEK_SET );
714 g_print( "[%s] Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.\n",
715 __FUNCTION__, segment->start, src->read_offset, new_offset );
716 if ( G_UNLIKELY (new_offset < 0 ) )
720 goto change_progchain;
725 src->read_offset = new_offset;
727 if ( ret == FALSE ) {
728 g_print( "[%s] Failed to set the SEEK on segment!\n", __FUNCTION__ );
739 GST_DEBUG_OBJECT (src, "EOS found on seeking!!!");
740 //gst_object_unref( src );
745 GST_ELEMENT_ERROR (src, RESOURCE, READ,
746 (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
749 gst_pad_push_event ( GST_BASE_SRC_PAD (base),
750 gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
751 /* go to the next program chain */
752 src->unique_setup = FALSE;
753 src->update_prog_chain = TRUE;
755 gst_mythtv_src_next_program_chain( src );
764 gst_mythtv_src_read_ahead ( void *data ) {
766 GstMythtvSrc *src = NULL;
768 GstBuffer *outbuf = NULL;
774 src = GST_MYTHTV_SRC( data );
776 //GST_PAD_STREAM_TRYLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) );
779 GST_TASK_WAIT( src->th_read_ahead );
783 outbuf = gst_buffer_new_and_alloc( size );
785 read = do_read_request_response ( src, src->adapter_offset, size, &data );
788 src->read_offset += read;
789 src->bytes_read += read;
792 g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
793 "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read,
794 src->read_offset, src->content_size );
796 GST_BUFFER_SIZE (outbuf) = read;
797 GST_BUFFER_MALLOCDATA( outbuf ) = g_malloc0( GST_BUFFER_SIZE (outbuf) );
798 GST_BUFFER_DATA( outbuf ) = GST_BUFFER_MALLOCDATA( outbuf );
799 g_memmove( GST_BUFFER_DATA( outbuf ), data, read );
800 GST_BUFFER_OFFSET (outbuf) = src->adapter_offset;
801 GST_BUFFER_OFFSET_END (outbuf) = src->adapter_offset + read;
802 g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
803 "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (outbuf),
804 GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf) );
808 gst_adapter_push( src->adapter, outbuf );
810 GST_TASK_SIGNAL( src->th_read_ahead );
812 } while ( read < size );
814 //GST_PAD_STREAM_UNLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) );
820 /* create a socket for connecting to remote server */
822 gst_mythtv_src_start ( GstBaseSrc * bsrc )
824 GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
826 GString *chain_id_local = NULL;
830 if ( G_UNLIKELY (src->update_prog_chain) )
831 goto change_progchain;
833 if (src->unique_setup == FALSE) {
834 src->unique_setup = TRUE;
839 if ( src->live_tv ) {
840 gmyth_context_initialize();
841 src->spawn_livetv = gmyth_livetv_new( );
842 if ( gmyth_livetv_setup( src->spawn_livetv ) == FALSE ) {
847 /* set up the uri variable */
848 src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str );
849 chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
850 if ( chain_id_local != NULL ) {
851 src->live_chain_id = g_strdup( chain_id_local->str );
852 g_print( "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
854 src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
855 g_print ( "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
858 src->file_transfer = gmyth_file_transfer_new( src->live_tv_id,
859 g_string_new( src->uri_name ), -1, src->mythtv_version );
861 if ( src->file_transfer == NULL ) {
865 /* sets the Playback monitor connection */
866 ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
868 if ( src->live_tv == TRUE && ret == TRUE ) {
869 /* loop finished, set the max tries variable to zero again... */
870 wait_to_transfer = 0;
872 while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
873 ( gmyth_file_transfer_is_recording( src->file_transfer ) == FALSE
874 /*|| ( gmyth_file_transfer_get_file_position( src->file_transfer ) < ( src->content_size + 327680 ) )*/ ) )
880 /* sets the FileTransfer instance connection (video/audio download) */
881 ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
883 if ( ret == FALSE ) {
884 #ifndef GST_DISABLE_GST_DEBUG
885 if ( src->mythtv_msgs_dbg )
886 g_printerr( "MythTV FileTransfer request failed when setting up socket connection!\n" );
888 goto begin_req_failed;
891 src->content_size = src->file_transfer->filesize;
893 src->do_start = FALSE;
895 src->bytes_queue = g_byte_array_sized_new( INTERNAL_BUFFER_SIZE );
896 //src->th_read_ahead = gst_task_create( (GstTaskFunction)gst_mythtv_src_read_ahead, src );
897 //gst_task_set_lock( src->th_read_ahead, &th_mutex );
898 //gst_task_start( src->th_read_ahead );
899 src->buffer_remain = 0;
907 if (src->spawn_livetv != NULL )
908 g_object_unref( src->spawn_livetv );
910 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
911 (NULL), ("Could not initialize MythTV library (%i, %s)", ret, src->uri_name));
916 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
917 (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret, src->uri_name));
922 GST_ELEMENT_ERROR (src, RESOURCE, READ,
923 (NULL), ("Seek failed, go to the next program info... (%s)",
926 gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
927 gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
929 // go to the next program chain
930 src->unique_setup = FALSE;
931 src->update_prog_chain = TRUE;
933 gst_mythtv_src_next_program_chain( src );
941 gst_mythtv_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
942 GstClockTime * start, GstClockTime * end)
949 /* create a new socket for connecting to the next program chain */
951 gst_mythtv_src_next_program_chain ( GstMythtvSrc *src )
953 GString *chain_id_local = NULL;
960 if (src->unique_setup == FALSE) {
961 src->unique_setup = TRUE;
966 GST_PAD_STREAM_LOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) );
968 if (src->file_transfer) {
969 g_object_unref (src->file_transfer);
970 src->file_transfer = NULL;
974 g_free (src->uri_name);
977 if ( src->live_tv ) {
978 if ( gmyth_livetv_next_program_chain( src->spawn_livetv ) == FALSE ) {
979 g_print( "\n\n[%s]\t\tFailed to go to the next program chain!!!\n\n", __FUNCTION__ );
983 /* set up the uri variable */
984 src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str );
985 chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
986 if ( chain_id_local != NULL ) {
987 src->live_chain_id = g_strdup( chain_id_local->str );
988 g_print( "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
990 src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
991 g_print ( "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
994 src->file_transfer = gmyth_file_transfer_new( src->live_tv_id,
995 g_string_new( src->uri_name ), -1, src->mythtv_version );
997 if ( src->file_transfer == NULL ) {
1001 /* sets the Playback monitor connection */
1002 ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
1004 if ( src->live_tv == TRUE && ret == TRUE ) {
1005 /* loop finished, set the max tries variable to zero again... */
1006 wait_to_transfer = 0;
1010 while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
1011 ( gmyth_file_transfer_is_recording( src->file_transfer ) == FALSE ) )
1015 /* sets the FileTransfer instance connection (video/audio download) */
1016 ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
1018 if ( ret == FALSE ) {
1019 #ifndef GST_DISABLE_GST_DEBUG
1020 if ( src->mythtv_msgs_dbg )
1021 g_printerr( "MythTV FileTransfer request failed when setting up socket connection!\n" );
1023 goto begin_req_failed;
1025 src->content_size_last = src->content_size;
1028 if ( src->content_size < src->file_transfer->filesize ) {
1029 src->content_size = src->file_transfer->filesize;
1031 //gint64 pos = gst_mythtv_src_get_position(src);
1032 //if ( pos > src->file_transfer->filesize )
1033 // src->content_size = pos;
1038 src->content_size = src->file_transfer->filesize;
1039 if ( src->live_tv ) {
1040 wait_to_transfer = 0;
1041 while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS && src->content_size < GMYTHTV_TRANSFER_MAX_BUFFER )
1042 src->content_size = gst_mythtv_src_get_position( src );
1045 src->read_offset = 0;
1047 if ( src->bytes_queue != NULL ) {
1048 g_byte_array_free( src->bytes_queue, TRUE );
1051 src->bytes_queue = g_byte_array_sized_new( INTERNAL_BUFFER_SIZE );
1054 src->update_prog_chain = FALSE;
1056 GST_PAD_STREAM_UNLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) );
1063 if (src->spawn_livetv != NULL )
1064 g_object_unref( src->spawn_livetv );
1066 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1067 (NULL), ("Could not initialize MythTV library (%i, %s)", ret, src->uri_name));
1072 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1073 (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret, src->uri_name));
1080 gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size)
1082 GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
1083 gboolean ret = TRUE;
1084 g_print( "[%s] Differs from previous content size: %d (max.: %d)\n", __FUNCTION__,
1085 abs( src->content_size - src->prev_content_size ), GMYTHTV_TRANSFER_MAX_BUFFER );
1087 if ( src->live_tv ) {
1089 } else if ( src->live_tv && src->enable_timing_position && ( abs( src->content_size - src->bytes_read ) <
1090 GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
1091 //g_static_mutex_lock( &update_size_mutex );
1093 gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer );
1094 if ( new_offset > 0 && new_offset > src->content_size ) {
1095 src->content_size = new_offset;
1096 } else if ( new_offset < src->content_size ) {
1097 src->update_prog_chain = TRUE;
1100 //g_static_mutex_unlock( &update_size_mutex );
1103 *size = src->content_size;
1104 g_print( "[%s] Content size = %lld\n", __FUNCTION__, src->content_size );
1110 /* close the socket and associated resources
1111 * used both to recover from errors and go to NULL state */
1113 gst_mythtv_src_stop (GstBaseSrc * bsrc)
1117 src = GST_MYTHTV_SRC (bsrc);
1119 if (src->uri_name) {
1120 g_free (src->uri_name);
1121 src->uri_name = NULL;
1124 if (src->mythtv_caps) {
1125 gst_caps_unref (src->mythtv_caps);
1126 src->mythtv_caps = NULL;
1135 gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event)
1137 GstMythtvSrc *src = GST_MYTHTV_SRC (GST_PAD_PARENT (pad));
1138 gint64 cont_size = 0;
1139 gboolean ret = FALSE;
1141 switch (GST_EVENT_TYPE (event)) {
1143 case GST_EVENT_FLUSH_START:
1145 g_print( "\n\n\n[%s]\t\tGot FLUSH_START event!!!\n\n\n", __FUNCTION__ );
1146 cont_size = gst_mythtv_src_get_position (src);
1147 if ( !src->live_tv ) {
1148 if ( cont_size > src->content_size ) {
1149 src->content_size = cont_size;
1153 gst_element_set_state ( GST_ELEMENT (src), GST_STATE_NULL );
1154 gst_element_set_locked_state ( GST_ELEMENT (src), FALSE );
1157 if ( cont_size <= 0 ) {
1158 src->update_prog_chain = TRUE;
1160 src->unique_setup = FALSE;
1161 src->do_start = TRUE;
1165 case GST_EVENT_FLUSH_STOP:
1166 src->do_start = TRUE;
1168 gst_element_set_state (GST_ELEMENT(src), GST_STATE_NULL);
1169 //gst_element_set_locked_state (GST_ELEMENT(src), TRUE);
1173 g_print( "[%s] Got EOS event!!!\n", __FUNCTION__ );
1175 if ( src->live_tv ) {
1176 cont_size = gst_mythtv_src_get_position (src);
1177 if ( cont_size > src->content_size ) {
1178 src->content_size = cont_size;
1182 gst_element_set_state ( GST_ELEMENT (src), GST_STATE_NULL );
1183 gst_element_set_locked_state ( GST_ELEMENT (src), FALSE );
1189 case GST_EVENT_NEWSEGMENT:
1190 g_print( "[%s] Got NEWSEGMENT!!!\n", __FUNCTION__ );
1191 ret = gst_pad_event_default (pad, event);
1193 case GST_EVENT_SEEK:
1195 gst_event_ref( event );
1198 //gboolean update = TRUE;
1200 GstSeekType cur_type, stop_type;
1202 gint64 cur = 0, stop = 0;
1203 gst_event_parse_seek ( event, &rate, &format,
1204 &flags, &cur_type, &cur,
1205 &stop_type, &stop );
1207 g_print( "[%s] Got EVENT_SEEK (pos = %lld)!!!\n", __FUNCTION__, cur );
1208 if ( !( flags & GST_SEEK_FLAG_FLUSH ) ) {
1209 g_print( "[%s] Could get the FLAG_FLUSH message.\n", __FUNCTION__ );
1211 if ( format == GST_FORMAT_TIME && ( ret = gst_pad_event_default (pad, event) ) == FALSE ) {
1212 gst_event_unref( event );
1219 ret = gst_pad_event_default (pad, event);
1226 gst_mythtv_src_is_seekable( GstBaseSrc *push_src )
1232 gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query)
1234 gboolean res = FALSE;
1235 GstMythtvSrc *myth = GST_MYTHTV_SRC (gst_pad_get_parent (pad));
1237 switch (GST_QUERY_TYPE (query)) {
1238 case GST_QUERY_POSITION:
1239 gst_query_set_position (query, GST_FORMAT_BYTES,
1240 myth->read_offset );
1242 GST_DEBUG_OBJECT (myth, "POS %d", myth->read_offset);
1244 case GST_QUERY_DURATION:
1246 if (myth->duration != 0) {
1250 fps = nuv->h->i_fpsn / nuv->h->i_fpsd;
1251 total = gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps);
1253 //gst_query_set_duration (query, GST_FORMAT_TIME, myth->content_size);
1254 GST_DEBUG_OBJECT (myth, "DURATION %d", myth->content_size);
1262 gst_object_unref (myth);
1267 static GstStateChangeReturn
1268 gst_mythtv_src_change_state (GstElement * element, GstStateChange transition)
1270 GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;//GST_STATE_CHANGE_NO_PREROLL;
1271 GstMythtvSrc *src = GST_MYTHTV_SRC (element);
1273 switch (transition) {
1274 case GST_STATE_CHANGE_NULL_TO_READY:
1275 //src->do_start = TRUE;
1276 //src->unique_setup = FALSE;
1278 case GST_STATE_CHANGE_READY_TO_PAUSED:
1279 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
1286 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
1287 if (ret == GST_STATE_CHANGE_FAILURE)
1290 switch (transition) {
1291 case GST_STATE_CHANGE_READY_TO_NULL:
1292 g_print( "[%s] READY to NULL called!\n", __FUNCTION__ );
1294 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
1295 g_print( "[%s] PLAYING to PAUSED called!\n", __FUNCTION__ );
1296 case GST_STATE_CHANGE_PAUSED_TO_READY:
1297 g_print( "[%s] PAUSED to READY called!\n", __FUNCTION__ );
1299 if ( src->live_tv && src->update_prog_chain ) {
1303 gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
1304 gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
1306 src->read_offset = 0;
1307 src->bytes_read = 0;
1308 src->unique_setup = FALSE;
1309 gst_mythtv_src_next_program_chain( src );
1322 gst_mythtv_src_set_property (GObject * object, guint prop_id,
1323 const GValue * value, GParamSpec * pspec)
1325 GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC (object);
1327 GST_OBJECT_LOCK (mythtvsrc);
1332 if (!g_value_get_string (value)) {
1333 GST_WARNING ("location property cannot be NULL");
1337 if (mythtvsrc->uri_name != NULL) {
1338 g_free (mythtvsrc->uri_name);
1339 mythtvsrc->uri_name = NULL;
1341 mythtvsrc->uri_name = g_value_dup_string (value);
1345 #ifndef GST_DISABLE_GST_DEBUG
1346 case PROP_GMYTHTV_DBG:
1348 mythtvsrc->mythtv_msgs_dbg = g_value_get_boolean (value);
1352 case PROP_GMYTHTV_VERSION:
1354 mythtvsrc->mythtv_version = g_value_get_int (value);
1357 case PROP_GMYTHTV_LIVEID:
1359 mythtvsrc->live_tv_id = g_value_get_int (value);
1362 case PROP_GMYTHTV_LIVE:
1364 mythtvsrc->live_tv = g_value_get_boolean (value);
1367 case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1369 mythtvsrc->enable_timing_position = g_value_get_boolean (value);
1372 case PROP_GMYTHTV_LIVE_CHAINID:
1374 if (!g_value_get_string (value)) {
1375 GST_WARNING ("MythTV Live chainid property cannot be NULL");
1379 if (mythtvsrc->live_chain_id != NULL) {
1380 g_free (mythtvsrc->live_chain_id);
1381 mythtvsrc->live_chain_id = NULL;
1383 mythtvsrc->live_chain_id = g_value_dup_string (value);
1386 case PROP_GMYTHTV_CHANNEL_NUM:
1388 mythtvsrc->channel_num = g_value_get_int (value);
1392 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1395 GST_OBJECT_UNLOCK (mythtvsrc);
1401 gst_mythtv_src_get_property (GObject * object, guint prop_id,
1402 GValue * value, GParamSpec * pspec)
1404 GstMythtvSrc *mythtvsrc = GST_MYTHTV_SRC (object);
1406 GST_OBJECT_LOCK (mythtvsrc);
1411 gchar *str = g_strdup( "" );
1413 if ( mythtvsrc->uri_name == NULL ) {
1414 g_free (mythtvsrc->uri_name);
1415 mythtvsrc->uri_name = NULL;
1417 str = g_strdup( mythtvsrc->uri_name );
1419 g_value_set_string ( value, str );
1422 #ifndef GST_DISABLE_GST_DEBUG
1423 case PROP_GMYTHTV_DBG:
1424 g_value_set_boolean ( value, mythtvsrc->mythtv_msgs_dbg );
1427 case PROP_GMYTHTV_VERSION:
1429 g_value_set_int ( value, mythtvsrc->mythtv_version );
1432 case PROP_GMYTHTV_LIVEID:
1434 g_value_set_int ( value, mythtvsrc->live_tv_id );
1437 case PROP_GMYTHTV_LIVE:
1438 g_value_set_boolean ( value, mythtvsrc->live_tv );
1440 case PROP_GMYTHTV_ENABLE_TIMING_POSITION:
1441 g_value_set_boolean ( value, mythtvsrc->enable_timing_position );
1443 case PROP_GMYTHTV_LIVE_CHAINID:
1445 gchar *str = g_strdup( "" );
1447 if ( mythtvsrc->live_chain_id == NULL ) {
1448 g_free (mythtvsrc->live_chain_id);
1449 mythtvsrc->live_chain_id = NULL;
1451 str = g_strdup( mythtvsrc->live_chain_id );
1453 g_value_set_string ( value, str );
1456 case PROP_GMYTHTV_CHANNEL_NUM:
1458 g_value_set_int ( value, mythtvsrc->channel_num );
1462 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1465 GST_OBJECT_UNLOCK (mythtvsrc);
1468 /* entry point to initialize the plug-in
1469 * initialize the plug-in itself
1470 * register the element factories and pad templates
1471 * register the features
1474 plugin_init (GstPlugin * plugin)
1476 return gst_element_register (plugin, "mythtvsrc", GST_RANK_NONE,
1477 GST_TYPE_MYTHTV_SRC);
1480 /* this is the structure that gst-register looks for
1481 * so keep the name plugin_desc, or you cannot get your plug-in registered */
1482 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
1486 plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
1489 /*** GSTURIHANDLER INTERFACE *************************************************/
1491 gst_mythtv_src_uri_get_type (void)
1497 gst_mythtv_src_uri_get_protocols (void)
1499 static gchar *protocols[] = { "myth", "myths", NULL };
1504 static const gchar *
1505 gst_mythtv_src_uri_get_uri (GstURIHandler * handler)
1507 GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
1509 return src->uri_name;
1513 gst_mythtv_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
1515 GstMythtvSrc *src = GST_MYTHTV_SRC (handler);
1519 protocol = gst_uri_get_protocol (uri);
1520 if ((strcmp (protocol, "myth") != 0) && (strcmp (protocol, "myths") != 0)) {
1525 g_object_set (src, "location", uri, NULL);
1531 gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
1533 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
1535 iface->get_type = gst_mythtv_src_uri_get_type;
1536 iface->get_protocols = gst_mythtv_src_uri_get_protocols;
1537 iface->get_uri = gst_mythtv_src_uri_get_uri;
1538 iface->set_uri = gst_mythtv_src_uri_set_uri;
1542 size_header_handler (void *userdata, const char *value)
1544 GstMythtvSrc *src = GST_MYTHTV_SRC (userdata);
1546 //src->content_size = g_ascii_strtoull (value, NULL, 10);
1548 GST_DEBUG_OBJECT (src, "content size = %lld bytes", src->content_size);