# HG changeset patch # User rosfran # Date 1161823726 -3600 # Node ID 67e72eadeef2e979c57afb8faeb68cb2d9fd4d76 # Parent 3e490ac963cea755be6fc34e51004825ca3a2e3d [svn r53] LiveTV working fine, adjustments in some GMyth functions dealing with the TVChain. diff -r 3e490ac963ce -r 67e72eadeef2 gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Oct 25 00:26:33 2006 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Oct 26 01:48:46 2006 +0100 @@ -18,8 +18,8 @@ #endif #include "gstmythtvsrc.h" -#include "gmyth_file_transfer.h" -#include "gmyth_livetv.h" +#include +#include #include #include @@ -32,19 +32,17 @@ #define GST_GMYTHTV_ID_NUM 1 -#define GMYTHTV_VERSION_DEFAULT 30 +#define GMYTHTV_VERSION_DEFAULT 30 #define GMYTHTV_TRANSFER_MAX_WAITS 100 -#define GMYTHTV_TRANSFER_MAX_BUFFER 1024*1024 +#define GMYTHTV_TRANSFER_MAX_BUFFER 16*1024 //( 32*1024 ) /* 4*1024 ??? */ #define MAX_READ_SIZE 12*1024 //( 32*1024 ) -#define ENABLE_TIMING_POSITION 0 - /* stablish a maximum iteration value to the IS_RECORDING message */ static guint wait_to_transfer = 0; @@ -58,9 +56,6 @@ GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("video/x-nuv") ); - //GST_STATIC_CAPS_ANY); - -static GThread *update_size_task = NULL; static GStaticMutex update_size_mutex = G_STATIC_MUTEX_INIT; @@ -75,27 +70,30 @@ PROP_GMYTHTV_VERSION, PROP_GMYTHTV_LIVE, PROP_GMYTHTV_LIVEID, - PROP_GMYTHTV_LIVE_CHAINID + PROP_GMYTHTV_LIVE_CHAINID, + PROP_GMYTHTV_ENABLE_TIMING_POSITION }; static void gst_mythtv_src_finalize (GObject * gobject); static GstFlowReturn gst_mythtv_src_create (GstBaseSrc * psrc, guint64 offset, guint size, GstBuffer ** outbuf); -//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 ); -//static gboolean gst_mythtv_new_segment ( GstBaseSrc * psrc ); + +static gboolean gst_mythtv_src_next_program_chain ( GstMythtvSrc *src ); + +static GstStateChangeReturn +gst_mythtv_src_change_state (GstElement * element, GstStateChange transition); 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); -//static GstFlowReturn gst_mythtv_src_chain (GstPad * pad, GstBuffer * buf); - static void gst_mythtv_src_uri_handler_init (gpointer g_iface, gpointer iface_data); static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event); @@ -105,7 +103,7 @@ guint size, GstBuffer **outbuf); //static gboolean gst_mythtv_src_sink_activate_pull (GstPad * srcpad, gboolean active); - static void +static void _urihandler_init (GType type) { static const GInterfaceInfo urihandler_info = { @@ -135,6 +133,8 @@ gst_static_pad_template_get (&srctemplate)); gst_element_class_set_details (element_class, &gst_mythtv_src_details); + + element_class->change_state = gst_mythtv_src_change_state; } static void @@ -146,7 +146,6 @@ 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; @@ -191,6 +190,12 @@ "Enable MythTV Live TV content streaming", FALSE, G_PARAM_READWRITE)); + g_object_class_install_property + (gobject_class, PROP_GMYTHTV_ENABLE_TIMING_POSITION, + g_param_spec_boolean ("mythtv-enable-timing-position", "mythtv-enable-timing-position", + "Enable MythTV Live TV content size continuous updating", + FALSE, G_PARAM_READWRITE)); + #ifndef GST_DISABLE_GST_DEBUG g_object_class_install_property (gobject_class, PROP_GMYTHTV_DBG, @@ -203,10 +208,9 @@ gstbasesrc_class->stop = gst_mythtv_src_stop; gstbasesrc_class->get_size = gst_mythtv_src_get_size; gstbasesrc_class->is_seekable = gst_mythtv_src_is_seekable; - //gstpushsrc_class->newsegment = gst_mythtv_src_new_segment; gstbasesrc_class->create = gst_mythtv_src_create; - + GST_DEBUG_CATEGORY_INIT (mythtvsrc_debug, "mythtvsrc", 0, "MythTV Client Source"); } @@ -222,29 +226,30 @@ this->bytes_read = 0; - this->content_size = -1; + this->content_size = 0; this->read_offset = 0; this->live_tv = FALSE; + + this->enable_timing_position = FALSE; + this->update_prog_chain = FALSE; this->user_agent = g_strdup ("mythtvsrc"); - this->mythtv_caps = NULL; + this->mythtv_caps = NULL; + this->update_prog_chain = FALSE; + + this->eos = FALSE; gst_base_src_set_format( GST_BASE_SRC( this ), GST_FORMAT_BYTES ); gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE ); - //gst_pad_set_chain_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)), - // gst_mythtv_src_chain ); - gst_pad_set_event_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)), gst_mythtv_src_handle_event ); /* gst_pad_set_query_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)), gst_mythtv_src_query ); */ - //gst_pad_set_activatepull_function( GST_BASE_SRC_PAD(GST_BASE_SRC(this)), - // gst_mythtv_src_sink_activate_pull ); } @@ -253,8 +258,6 @@ { GstMythtvSrc *this = GST_MYTHTV_SRC (gobject); - g_free (this->user_agent); - if (this->mythtv_caps) { gst_caps_unref (this->mythtv_caps); this->mythtv_caps = NULL; @@ -265,6 +268,11 @@ this->file_transfer = NULL; } + if (this->spawn_livetv) { + //g_object_unref (this->spawn_livetv); + this->spawn_livetv = NULL; + } + if (this->uri_name) { g_free (this->uri_name); } @@ -280,8 +288,7 @@ do_read_request_response (GstMythtvSrc * src, guint64 offset, guint size, GstBuffer **outbuf) { gint read = 0; - guint sizetoread = size; //GST_BUFFER_SIZE (outbuf); - //GstBuffer *buffer = gst_buffer_new_and_alloc( size ); + guint sizetoread = size; g_print( "Starting: [%s] Reading %d bytes...\n", __FUNCTION__, sizetoread ); @@ -299,43 +306,53 @@ if ( len > 0 ) { read += len; sizetoread -= len; - } else if ( len <= 0 ) { + } + else if ( len <= 0 ) + { - if ( src->live_tv == FALSE ) { - goto done; - } else if ( len == 0 ) { - src->update_prog_chain = TRUE; - goto done; - } else if ( /*src->content_size >= src->read_offset && - abs ( src->content_size - src->read_offset ) <= 1024 ) ||*/ - ( src->content_size <= ( src->read_offset + size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) ) - { -#if ENABLE_TIMING_POSITION == 1 - gint64 size_tmp = 0; - if (src->live_tv == TRUE) { -get_file_pos: - size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); - if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) - src->content_size = size_tmp; - else if ( size_tmp > 0 ) - goto get_file_pos; - g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", - __FUNCTION__, size_tmp ); - } -#else - gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer ); - if ( new_offset > 0 ) { - if ( src->content_size < new_offset ) { - src->content_size = new_offset; - } - } else { - src->update_prog_chain = TRUE; - } -#endif - goto done; - } + if ( src->live_tv == FALSE ) + { + goto done; + } + else + { + if ( len == GMYTHTV_FILE_TRANSFER_READ_ERROR ) { /* -314 */ + src->update_prog_chain = TRUE; + if ( gst_mythtv_src_next_program_chain ( src ) ) + continue; + else + goto done; + } else + if ( src->content_size <= + ( src->read_offset + size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) { + src->update_prog_chain = TRUE; + if ( src->enable_timing_position ) { + gint64 size_tmp = 0; + if (src->live_tv == TRUE) { + get_file_pos: + size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); + if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) + src->content_size = size_tmp; + else if ( size_tmp > 0 ) + goto get_file_pos; + g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", + __FUNCTION__, size_tmp ); + } + } else { + gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer ); + if ( new_offset > 0 ) { + if ( src->content_size < new_offset ) { + src->content_size = new_offset; + } + } else { + src->update_prog_chain = TRUE; + } + } + goto done; + } + } - } + } if ( read == sizetoread ) break; @@ -349,11 +366,9 @@ "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read, src->read_offset, src->content_size ); - //GST_BUFFER_TIMESTAMP( buffer ) = GST_BUFFER_TIMESTAMP ( *outbuf ); GST_BUFFER_SIZE (*outbuf) = read; //GST_BUFFER_SIZE (buffer) = read; GST_BUFFER_OFFSET (*outbuf) = offset; //GST_BUFFER_OFFSET (buffer) = offset; GST_BUFFER_OFFSET_END (*outbuf) = offset + read;//GST_BUFFER_OFFSET_END (buffer) = offset + read; - //memcpy( GST_BUFFER_DATA( *outbuf ), GST_BUFFER_DATA( buffer ), read ); g_print( "Stopping: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\ "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf), @@ -387,7 +402,7 @@ if ( G_UNLIKELY (src->update_prog_chain) ) goto change_progchain; - //GST_OBJECT_LOCK(src); + GST_OBJECT_LOCK(src); if (G_UNLIKELY (src->read_offset != offset)) { gint64 new_offset = gmyth_file_transfer_seek(src->file_transfer, offset, SEEK_SET); @@ -395,13 +410,16 @@ __FUNCTION__, src->read_offset, new_offset ); if (G_UNLIKELY (new_offset < 0 ) )//|| new_offset != src->read_offset)) { { - //GST_OBJECT_UNLOCK(src); - goto change_progchain; + GST_OBJECT_UNLOCK(src); + if ( src->live_tv ) + goto change_progchain; + else + goto eos; } src->read_offset = offset; } - //GST_OBJECT_UNLOCK(src); + GST_OBJECT_UNLOCK(src); /* Create the buffer. */ ret = gst_pad_alloc_buffer (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), @@ -419,20 +437,13 @@ if (G_UNLIKELY (src->update_prog_chain) ) goto change_progchain; - if (G_UNLIKELY (read < 0) || *outbuf == NULL) { - //if ( src->live_tv ) - // goto done; - //else - goto read_error; + if (G_UNLIKELY (read <= 0) || *outbuf == NULL) { + if ( src->live_tv ) + goto change_progchain; + else + goto read_error; } -/* - if (G_UNLIKELY(src->eos)) - goto eos; - else - goto done; -*/ - done: { const gchar *reason = gst_flow_get_name (ret); @@ -458,13 +469,13 @@ change_progchain: { GST_ELEMENT_ERROR (src, RESOURCE, READ, - (NULL), ("Seek failed, go to the next program info... (%i, %s)", read, - src->uri_name)); - // go to the next program chain - src->unique_setup = FALSE; - gst_mythtv_src_start( psrc ); - - return GST_FLOW_OK; + (NULL), ("Seek failed, go to the next program info... (%i, %s)", read, + src->uri_name)); + // go to the next program chain + src->unique_setup = FALSE; + src->update_prog_chain = TRUE; + gst_mythtv_src_next_program_chain( src ); + return -101; } } @@ -481,46 +492,42 @@ g_static_mutex_lock( &update_size_mutex ); if ( src->do_start ) { -#if ENABLE_TIMING_POSITION == 1 - gint64 size_tmp = 0; - if (src->live_tv == TRUE) { -get_file_pos: - g_usleep( 50 ); - size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); - if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) - src->content_size = size_tmp; - else if ( size_tmp > 0 ) - goto get_file_pos; - g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", - __FUNCTION__, size_tmp ); - } -#endif + if ( src->enable_timing_position ) { + gint64 size_tmp = 0; + if (src->live_tv == TRUE) { + get_file_pos: + g_usleep( 50 ); + size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); + if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) + src->content_size = size_tmp; + else if ( size_tmp > 0 ) + goto get_file_pos; + g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", + __FUNCTION__, size_tmp ); + } + } } g_static_mutex_unlock( &update_size_mutex ); } -guint64 +gint64 gst_mythtv_src_get_position ( GstMythtvSrc* src ) { - if ( src->do_start ) { -#if ENABLE_TIMING_POSITION == 1 - gint64 size_tmp = 0; - if (src->live_tv == TRUE) { + gint64 size_tmp = 0; + if (src->live_tv == TRUE) { get_file_pos: - g_usleep( 50 ); - size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); - if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) - src->content_size = size_tmp; - else if ( size_tmp > 0 ) - goto get_file_pos; - g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", - __FUNCTION__, size_tmp ); - } -#endif + g_usleep( 50 ); + size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); + if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) + src->content_size = size_tmp; + else if ( size_tmp > 0 ) + goto get_file_pos; + g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", + __FUNCTION__, size_tmp ); } - + return src->content_size; } @@ -534,6 +541,9 @@ GString *chain_id_local = NULL; gboolean ret = TRUE; + + if ( !src->do_start ) + goto done; if (src->unique_setup == FALSE) { src->unique_setup = TRUE; @@ -547,8 +557,10 @@ src->spawn_livetv = gmyth_livetv_new( ); if ( gmyth_livetv_setup( src->spawn_livetv ) == FALSE ) { ret = FALSE; + GST_OBJECT_UNLOCK( src ); goto init_failed; } + /* set up the uri variable */ src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str ); chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain ); @@ -596,14 +608,8 @@ src->content_size = src->file_transfer->filesize; GST_OBJECT_UNLOCK(src); - if ( src->live_tv ) { - //GError* error; - //update_size_task = g_thread_create( (GThreadFunc)update_size_func, src, FALSE, &error ); - g_print( "[%s] Update Size task = %s\n", __FUNCTION__, update_size_task != NULL ? "OK !" : "ERROR!!!" ); - - } - src->do_start = TRUE; + src->do_start = FALSE; done: return TRUE; @@ -626,6 +632,109 @@ } } +/* create a new socket for connecting to the next program chain */ +static gboolean +gst_mythtv_src_next_program_chain ( GstMythtvSrc *src ) +{ + GString *chain_id_local = NULL; + + gboolean ret = TRUE; + + if ( !src->live_tv ) + goto init_failed; + + if (src->file_transfer) { + g_object_unref (src->file_transfer); + src->file_transfer = NULL; + } + + if (src->uri_name) { + g_free (src->uri_name); + } + + if ( src->live_tv ) { + if ( src->update_prog_chain ) + { + if ( gmyth_livetv_next_program_chain( src->spawn_livetv ) == FALSE ) { + ret = FALSE; + goto init_failed; + } + src->update_prog_chain = FALSE; + } + /* set up the uri variable */ + src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str ); + chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain ); + if ( chain_id_local != NULL ) { + src->live_chain_id = g_strdup( chain_id_local->str ); + g_print( "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id ); + } + src->live_tv_id = src->spawn_livetv->remote_encoder->recorder_num; + g_print ( "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name ); + } + + src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, + g_string_new( src->uri_name ), -1, src->mythtv_version ); + + if ( src->file_transfer == NULL ) { + goto init_failed; + } + + /* sets the Playback monitor connection */ + ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv ); + + if ( src->live_tv == TRUE && ret == TRUE ) { + /* loop finished, set the max tries variable to zero again... */ + wait_to_transfer = 0; + + g_usleep( 500 ); + + while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS && + ( gmyth_file_transfer_is_recording( src->file_transfer ) == FALSE ) ) + g_usleep( 100 ); + } + + /* sets the FileTransfer instance connection (video/audio download) */ + ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv ); + + if ( ret == FALSE ) { +#ifndef GST_DISABLE_GST_DEBUG + if ( src->mythtv_msgs_dbg ) + g_printerr( "MythTV FileTransfer request failed when setting up socket connection!\n" ); +#endif + goto begin_req_failed; + } + + if ( src->content_size < src->file_transfer->filesize ) { + src->content_size = src->file_transfer->filesize; + } else { + gint64 pos = gst_mythtv_src_get_position(src); + if ( pos > src->file_transfer->filesize ) + src->content_size = pos; + } + + src->update_prog_chain = FALSE; + + return TRUE; + + /* ERRORS */ +init_failed: + { + if (src->spawn_livetv != NULL ) + g_object_unref( src->spawn_livetv ); + + GST_ELEMENT_ERROR (src, LIBRARY, INIT, + (NULL), ("Could not initialize MythTV library (%i, %s)", ret, src->uri_name)); + return FALSE; + } +begin_req_failed: + { + GST_ELEMENT_ERROR (src, LIBRARY, INIT, + (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret, src->uri_name)); + return FALSE; + } + +} + #if 0 /* handles queries for location in the stream in the requested format */ static gboolean @@ -703,40 +812,39 @@ if (src->content_size <= 0) { ret= FALSE; } else if ( abs ( src->content_size - src->read_offset ) <= GMYTHTV_TRANSFER_MAX_BUFFER ) { - //g_static_mutex_lock( &update_size_mutex ); - GST_OBJECT_LOCK(src); + //g_static_mutex_lock( &update_size_mutex ); + //GST_OBJECT_LOCK(src); - gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer ); + gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer ); if ( new_offset > 0 ) { if ( src->content_size < new_offset ) { src->content_size = new_offset; } } else { - src->update_prog_chain = TRUE; - src->content_size = 0; + if ( src->live_tv ) + src->update_prog_chain = TRUE; } -#if ENABLE_TIMING_POSITION == 1 - gint64 size_tmp = 0; - if (src->live_tv == TRUE) { -get_file_pos: - g_usleep( 5 ); - size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); - if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) - src->content_size = size_tmp; - else if ( size_tmp > 0 ) - goto get_file_pos; - g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", - __FUNCTION__, size_tmp ); - } -#endif - GST_OBJECT_UNLOCK(src); - //g_static_mutex_unlock( &update_size_mutex ); - + if ( src->enable_timing_position ) { + gint64 size_tmp = 0; + if (src->live_tv == TRUE) { + get_file_pos: + g_usleep( 5 ); + size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); + if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) + src->content_size = size_tmp; + else if ( size_tmp > 0 ) + goto get_file_pos; + g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", + __FUNCTION__, size_tmp ); + } + } + //GST_OBJECT_UNLOCK(src); + //g_static_mutex_unlock( &update_size_mutex ); } *size = src->content_size; - g_print( "[%s] Content size = %llu\n", __FUNCTION__, src->content_size ); + g_print( "[%s] Content size = %lld\n", __FUNCTION__, src->content_size ); return ret; @@ -744,7 +852,7 @@ /* close the socket and associated resources * used both to recover from errors and go to NULL state */ - static gboolean +static gboolean gst_mythtv_src_stop (GstBaseSrc * bsrc) { GstMythtvSrc *src; @@ -770,13 +878,32 @@ gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event) { GstMythtvSrc *src = GST_MYTHTV_SRC (GST_PAD_PARENT (pad)); + gint64 cont_size = 0; switch (GST_EVENT_TYPE (event)) { #if 0 case GST_EVENT_FLUSH_START: - src->eos = FALSE; - break; - //return TRUE; + //src->eos = FALSE; + g_print( "\n\n\n[%s]\t\tGot FLUSH_START event!!!\n\n\n", __FUNCTION__ ); + cont_size = gst_mythtv_src_get_position (src); + if ( !src->live_tv ) { + 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 ); + } + } else { + if ( cont_size <= 0 ) { + src->update_prog_chain = TRUE; + src->eos = TRUE; + src->unique_setup = FALSE; + src->do_start = TRUE; + } + } + break; case GST_EVENT_FLUSH_STOP: src->do_start = TRUE; src->eos = FALSE; @@ -786,7 +913,7 @@ #endif case GST_EVENT_EOS: g_print( "[%s] Got EOS event!!!\n", __FUNCTION__ ); - guint64 cont_size = gst_mythtv_src_get_position (src); + cont_size = gst_mythtv_src_get_position (src); if ( !src->live_tv ) { if ( cont_size > src->content_size ) { src->content_size = cont_size; @@ -841,6 +968,47 @@ return TRUE; } +static GstStateChangeReturn +gst_mythtv_src_change_state (GstElement * element, GstStateChange transition) +{ + GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; + GstMythtvSrc *src = GST_MYTHTV_SRC (element); + + switch (transition) { + case GST_STATE_CHANGE_NULL_TO_READY: + src->content_size = 0; + src->read_offset = 0; + src->bytes_read = 0; + src->do_start = TRUE; + src->unique_setup = FALSE; + src->eos = TRUE; + break; + case GST_STATE_CHANGE_READY_TO_PAUSED: + case GST_STATE_CHANGE_PAUSED_TO_PLAYING: + src->eos = FALSE; + break; + default: + break; + } + + ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + if (ret == GST_STATE_CHANGE_FAILURE) + return ret; + + switch (transition) { + case GST_STATE_CHANGE_READY_TO_NULL: + break; + case GST_STATE_CHANGE_PAUSED_TO_READY: + if ( src->live_tv && src->update_prog_chain ) + gst_mythtv_src_next_program_chain( src ); + break; + default: + break; + } + + return ret; +} + static void gst_mythtv_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -887,6 +1055,11 @@ 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)) { @@ -899,7 +1072,6 @@ mythtvsrc->live_chain_id = NULL; } mythtvsrc->live_chain_id = g_value_dup_string (value); - break; } @@ -952,6 +1124,9 @@ 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: { gchar *str = g_strdup( "" ); diff -r 3e490ac963ce -r 67e72eadeef2 gst-plugins-mythtv/src/gstmythtvsrc.h --- a/gst-plugins-mythtv/src/gstmythtvsrc.h Wed Oct 25 00:26:33 2006 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.h Thu Oct 26 01:48:46 2006 +0100 @@ -21,8 +21,8 @@ #include #include -#include "gmyth_file_transfer.h" -#include "gmyth_livetv.h" +#include +#include G_BEGIN_DECLS @@ -55,11 +55,11 @@ gint mythtv_version; - guint64 content_size; + gint64 content_size; guint64 bytes_read; - guint64 read_offset; + gint64 read_offset; gboolean eos; @@ -68,6 +68,8 @@ gboolean unique_setup; gboolean live_tv; + + gboolean enable_timing_position; gint live_tv_id;