diff -r 9ea342c364de -r e594fc21deef gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Nov 15 18:07:23 2006 +0000 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Fri Nov 17 14:46:38 2006 +0000 @@ -36,17 +36,19 @@ #define GMYTHTV_VERSION_DEFAULT 30 -#define GMYTHTV_TRANSFER_MAX_WAITS 100 +#define GMYTHTV_TRANSFER_MAX_WAITS 100 -#define GMYTHTV_TRANSFER_MAX_BUFFER 128*1024 +#define GMYTHTV_TRANSFER_MAX_BUFFER 128*1024 //( 32*1024 ) /* 4*1024 ??? */ -#define MAX_READ_SIZE 2*1024 +#define MAX_READ_SIZE 12*1024 //( 32*1024 ) #define GST_FLOW_ERROR_NO_DATA -101 +#define INTERNAL_BUFFER_SIZE 18*1024 + /* stablish a maximum iteration value to the IS_RECORDING message */ static guint wait_to_transfer = 0; @@ -108,11 +110,12 @@ static gboolean gst_mythtv_src_handle_query (GstPad * pad, GstQuery * query); -//static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event); -//static gboolean gst_mythtv_src_query ( GstPad * pad, GstQuery * query ); +static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event); -static gint do_read_request_response (GstMythtvSrc *src, guint64 offset, - guint size, GstBuffer **outbuf); +static gint do_read_request_response (GstMythtvSrc * src, guint64 offset, + guint size, gint8 **data_ptr); + +GStaticRecMutex th_mutex = G_STATIC_REC_MUTEX_INIT; static void _urihandler_init (GType type) @@ -281,8 +284,8 @@ //gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE ); - // gst_pad_set_event_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)), - // gst_mythtv_src_handle_event ); + 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_handle_query ); @@ -293,11 +296,6 @@ { GstMythtvSrc *this = GST_MYTHTV_SRC (gobject); - if ( this->th_mutex != NULL ) { - g_static_rec_mutex_free( this->th_mutex ); - this->th_mutex = NULL; - } - if ( this->th_read_ahead != NULL ) { gst_task_stop( this->th_read_ahead ); this->th_read_ahead = NULL; @@ -330,7 +328,7 @@ } static gint -do_read_request_response (GstMythtvSrc * src, guint64 offset, guint size, GstBuffer **outbuf) +do_read_request_response (GstMythtvSrc * src, guint64 offset, guint size, gint8 **data_ptr) { gint read = 0; guint sizetoread = size; @@ -340,84 +338,54 @@ /* Loop sending the Myth File Transfer request: * Retry whilst authentication fails and we supply it. */ gint len = 0; - gint8 *data_ptr = g_malloc0( size ); + //*data_ptr = g_malloc0( size ); - GST_OBJECT_LOCK(src); - - while ( sizetoread > 0 ) { + //while ( sizetoread > 0 ) { len = gmyth_file_transfer_read( src->file_transfer, - data_ptr + read, sizetoread, TRUE ); + *data_ptr + offset + read, sizetoread, TRUE ); if ( len > 0 ) { read += len; sizetoread -= len; } - else if ( len <= 0 ) + else if ( len < 0 ) { - read = -1; + read = -1; if ( src->live_tv == FALSE ) { - goto eos; + goto eos; } else { - if ( len == GMYTHTV_FILE_TRANSFER_READ_ERROR ) { /* -314 */ - src->update_prog_chain = TRUE; - goto done; - } else - if ( abs( src->content_size - src->bytes_read ) < GMYTHTV_TRANSFER_MAX_BUFFER ) { - src->update_prog_chain = TRUE; - if ( src->enable_timing_position ) { - gint64 size_tmp = 0; - 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 && src->content_size <= new_offset ) { - src->content_size = new_offset; - } else { - src->update_prog_chain = TRUE; - } - src->prev_content_size = src->content_size; - }*/ - } - goto done; - } + if ( len == GMYTHTV_FILE_TRANSFER_READ_ERROR ) { /* -314 */ + src->update_prog_chain = TRUE; + goto done; + } else if ( abs( src->content_size - src->bytes_read ) < GMYTHTV_TRANSFER_MAX_BUFFER ) { + src->update_prog_chain = TRUE; + if ( src->enable_timing_position ) { + gint64 size_tmp = 0; +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 ); + } + } + goto done; + } } if ( read == sizetoread ) - break; - } + goto done; + //} - if ( read > 0 ) { - src->read_offset += read; - src->bytes_read += read; - - g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\ - "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read, - src->read_offset, src->content_size ); - - GST_BUFFER_SIZE (*outbuf) = read; //GST_BUFFER_SIZE (buffer) = read; - GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) ); - GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf ); - g_memmove( GST_BUFFER_DATA( *outbuf ), data_ptr, 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; - - g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\ - "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf), - GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) ); - - } else if ( !src->live_tv ) + if ( read < 0 && !src->live_tv ) goto eos; goto done; @@ -426,7 +394,6 @@ src->eos = TRUE; done: - GST_OBJECT_UNLOCK(src); return read; } @@ -450,7 +417,7 @@ if ( G_UNLIKELY (src->update_prog_chain) ) goto change_progchain; - g_static_rec_mutex_lock( src->th_mutex ); + g_static_rec_mutex_lock( th_mutexth_mutex ); while ( ( ( adapter_size = gst_adapter_available_fast( src->adapter ) ) < size ) && --max_adapter_rep > 0 ) @@ -459,7 +426,7 @@ GST_TASK_WAIT( src->th_read_ahead ); } - g_static_rec_mutex_unlock( src->th_mutex ); + g_static_rec_mutex_unlock( th_mutexth_mutex ); gint64 new_offset = -1; /* just get from the adapter, no network effort... */ @@ -593,47 +560,133 @@ GstMythtvSrc *src; GstFlowReturn ret = GST_FLOW_OK; gint read = -1; - + gint adapter_size = 0; + guint max_adapter_rep = 1; + src = GST_MYTHTV_SRC ( psrc ); - + /* The caller should know the number of bytes and not read beyond EOS. */ if (G_UNLIKELY (src->eos)) goto eos; if ( G_UNLIKELY (src->update_prog_chain) ) goto change_progchain; + + //g_static_rec_mutex_lock( &th_mutex ); + + while ( src->adapter != NULL && ( ( adapter_size = gst_adapter_available_fast( src->adapter ) ) < MAX_READ_SIZE ) && + --max_adapter_rep > 0 ) + { + g_print ( "[%s] %d - Waiting for read_ahead task...\n", __FUNCTION__, max_adapter_rep ); + //GST_TASK_WAIT( src->th_read_ahead ); + } + + //gst_task_pause( src->th_read_ahead ); + + //g_static_rec_mutex_unlock( &th_mutex ); /* just get from the adapter, no network effort... */ - /* Create the buffer. */ - ret = gst_pad_alloc_buffer ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), - src->read_offset /*GST_BUFFER_OFFSET_NONE*/, MAX_READ_SIZE, - GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf ); + if ( adapter_size > 0 ) + { + //g_static_rec_mutex_lock( &th_mutex ); - if (G_UNLIKELY (ret != GST_FLOW_OK)) { - if ( src->live_tv ) - goto change_progchain; - else - goto done; - } - - read = do_read_request_response ( src, src->read_offset, MAX_READ_SIZE, outbuf ); - - if ( G_UNLIKELY (src->update_prog_chain) ) - goto change_progchain; + *outbuf = gst_adapter_take_buffer( src->adapter, adapter_size ); + // src->read_offset += size; + read = adapter_size; - if (G_UNLIKELY (read <= 0) || *outbuf == NULL) { - if ( src->live_tv ) - goto change_progchain; - else - goto read_error; + gst_adapter_flush( src->adapter, adapter_size ); + //g_static_rec_mutex_unlock( &th_mutex ); + + } else { + guint size = (src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE; + + g_print ( "[%s]\t\tCreate: buffer_offset: %d, buffer_remain: %d\n", __FUNCTION__, + (gint) src->buffer_offset, + (gint) src->buffer_remain); + + /* Create the buffer. */ + ret = gst_pad_alloc_buffer ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), + src->read_offset /*GST_BUFFER_OFFSET_NONE*/, size, + GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf ); + + if (G_UNLIKELY (ret != GST_FLOW_OK)) { + if ( src->live_tv ) + goto change_progchain; + else + goto done; + } + + if (src->buffer_remain < MAX_READ_SIZE) { + gint8 *tmp_buffer = g_malloc0( INTERNAL_BUFFER_SIZE ); // FIXME: DON'T ALLOC EVERY TIME + + memcpy (tmp_buffer, src->buffer + src->buffer_offset, src->buffer_remain); + + read = do_read_request_response( src, 0, INTERNAL_BUFFER_SIZE - src->buffer_remain, &tmp_buffer ); + + if (G_UNLIKELY (read < 0)) { + if ( src->live_tv ) + goto change_progchain; + else + goto read_error; + } + + if ( G_UNLIKELY (src->update_prog_chain) ) + goto change_progchain; + + //len = gmyth_file_transfer_read( src->file_transfer, + // tmp_buffer + src->buffer_remain, INTERNAL_BUFFER_SIZE - src->buffer_remain, TRUE ); + // fixme: handle eos + // fixme: can I deallocate the previous buffer here? + g_memmove( src->buffer + src->buffer_remain, tmp_buffer, read); + src->buffer_offset = 0; + src->buffer_remain = src->buffer_remain + read; + + // g_free( tmp_buffer ); + + } + + g_print( "[%s] read = %d, buffer_remain = %d\n", __FUNCTION__, read, src->buffer_remain ); + + GST_BUFFER_SIZE (*outbuf) = ( src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE; + GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) ); + GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf ); + g_memmove( GST_BUFFER_DATA( (*outbuf) ), src->buffer + src->buffer_offset, GST_BUFFER_SIZE(*outbuf) ); + GST_BUFFER_OFFSET (*outbuf) = src->read_offset; + GST_BUFFER_OFFSET_END (*outbuf) = src->read_offset + GST_BUFFER_SIZE (*outbuf); + + src->buffer_offset += GST_BUFFER_SIZE (*outbuf); + src->buffer_remain -= GST_BUFFER_SIZE (*outbuf); + + src->read_offset += GST_BUFFER_SIZE (*outbuf); + src->bytes_read += GST_BUFFER_SIZE (*outbuf); + g_print ( "[%s]\t\tBuffer output with size: %d\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf) ); + + g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\ + "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read, + src->read_offset, src->content_size ); + + g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\ + "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf), + GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) ); + + /* just get from the adapter, no network effort... */ + } + return ret; + + //g_static_rec_mutex_lock( &th_mutex ); + + //GST_TASK_SIGNAL( src->th_read_ahead ); + + //g_static_rec_mutex_unlock( &th_mutex ); + done: - { + { const gchar *reason = gst_flow_get_name (ret); GST_DEBUG_OBJECT (src, "DONE task, reason %s", reason); - return ret; - } + return ret; + } eos: { const gchar *reason = gst_flow_get_name (ret); @@ -646,23 +699,23 @@ { GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("Could not read any bytes (%i, %s)", read, - src->uri_name)); + src->uri_name)); return GST_FLOW_ERROR; } change_progchain: { GST_ELEMENT_ERROR (src, RESOURCE, READ, - (NULL), ("Seek failed, go to the next program info... (%i, %s)", read, - src->uri_name)); - - gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) ); - // go to the next program chain - src->unique_setup = FALSE; - src->update_prog_chain = TRUE; - - gst_mythtv_src_next_program_chain( src ); - + (NULL), ("Seek failed, go to the next program info... (%i, %s)", read, + src->uri_name)); + + gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) ); + // go to the next program chain + src->unique_setup = FALSE; + src->update_prog_chain = TRUE; + + gst_mythtv_src_next_program_chain( src ); + return GST_FLOW_ERROR_NO_DATA; } @@ -698,13 +751,25 @@ gst_mythtv_src_do_seek( GstBaseSrc *base, GstSegment *segment ) { GstMythtvSrc *src = GST_MYTHTV_SRC( base ); - gint64 new_offset = 0; + gint64 new_offset = -1; + gint64 actual_seek = segment->start; gboolean ret = TRUE; g_print( "[%s]DO Seek called! (start = %lld, stop = %lld)\n", __FUNCTION__, segment->start, segment->stop ); + //g_static_rec_mutex_lock( &th_mutex ); + //GST_TASK_WAIT( src->th_read_ahead ); + + //g_static_rec_mutex_unlock( &th_mutex ); + + if ( segment->format == GST_FORMAT_TIME ) + { + goto done; + //actual_seek = ( ( segment->start / 1000 ) * 28 ) * 4000; + } + g_print( "[%s]Trying to seek at the value (actual_seek = %lld, read_offset = %lld)\n", __FUNCTION__, actual_seek, src->read_offset ); /* verify if it needs to seek */ - if ( src->read_offset != segment->start ) + if ( src->read_offset != actual_seek ) { new_offset = gmyth_file_transfer_seek( src->file_transfer, segment->start, SEEK_SET ); @@ -722,15 +787,27 @@ src->read_offset = new_offset; + //gst_segment_set_seek( segment, segment->rate, GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE, + //GST_SEEK_TYPE_CUR, src->read_offset, GST_SEEK_TYPE_CUR, segment->stop, &ret ); + + if ( ret == FALSE ) { + g_print( "[%s] Failed to set the SEEK on segment!\n", __FUNCTION__ ); + } + } - + //g_static_rec_mutex_lock( &th_mutex ); + + //GST_TASK_SIGNAL( src->th_read_ahead ); + + //g_static_rec_mutex_unlock( &th_mutex ); +done: return ret; eos: { GST_DEBUG_OBJECT (src, "EOS found on seeking!!!"); - gst_object_unref( src ); + //gst_object_unref( src ); return FALSE; } change_progchain: @@ -755,37 +832,58 @@ #if 0 static void gst_mythtv_src_read_ahead ( void *data ) { - - GstMythtvSrc *src = NULL; - - GstBuffer *buffer = NULL; - - guint size = 512; - - gint read = 0; - - src = GST_MYTHTV_SRC( data ); - - GST_PAD_STREAM_TRYLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) ); - - /*if ( gst_adapter_available( src->adapter ) ) && ( read < MAX_READ_SIZE )) */ - do { - buffer = gst_buffer_new_and_alloc( size ); - read += do_read_request_response ( src, src->adapter_offset, size, &buffer ); - - gst_adapter_push( src->adapter, buffer ); - - //gst_buffer_unref( buffer ); - } while ( read < MAX_READ_SIZE ); - - GST_PAD_BLOCK_SIGNAL( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) ); - - GST_PAD_STREAM_UNLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) ); - - gst_object_unref( src ); - - return; + GstMythtvSrc *src = NULL; + + GstBuffer *outbuf = NULL; + + guint size = 5*2048; + gint total = 0; + gint read = -1; + + src = GST_MYTHTV_SRC( data ); + + //GST_PAD_STREAM_TRYLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) ); + + do { + GST_TASK_WAIT( src->th_read_ahead ); + + gint8 *data = NULL; + + outbuf = gst_buffer_new_and_alloc( size ); + + read = do_read_request_response ( src, src->adapter_offset, size, &data ); + + if ( read > 0 ) { + src->read_offset += read; + src->bytes_read += read; + total += read; + + g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\ + "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read, + src->read_offset, src->content_size ); + + GST_BUFFER_SIZE (outbuf) = read; + GST_BUFFER_MALLOCDATA( outbuf ) = g_malloc0( GST_BUFFER_SIZE (outbuf) ); + GST_BUFFER_DATA( outbuf ) = GST_BUFFER_MALLOCDATA( outbuf ); + g_memmove( GST_BUFFER_DATA( outbuf ), data, read ); + GST_BUFFER_OFFSET (outbuf) = src->adapter_offset; + GST_BUFFER_OFFSET_END (outbuf) = src->adapter_offset + read; + g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\ + "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (outbuf), + GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf) ); + + } + + gst_adapter_push( src->adapter, outbuf ); + + GST_TASK_SIGNAL( src->th_read_ahead ); + + } while ( read < size ); + + //GST_PAD_STREAM_UNLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) ); + + return; } #endif @@ -798,7 +896,7 @@ GString *chain_id_local = NULL; gboolean ret = TRUE; - + if ( G_UNLIKELY (src->update_prog_chain) ) goto change_progchain; @@ -808,13 +906,10 @@ goto done; } - //GST_OBJECT_LOCK(src); - if ( src->live_tv ) { src->spawn_livetv = gmyth_livetv_new( ); if ( gmyth_livetv_setup( src->spawn_livetv ) == FALSE ) { ret = FALSE; - //GST_OBJECT_UNLOCK( src ); goto init_failed; } @@ -833,8 +928,6 @@ g_string_new( src->uri_name ), -1, src->mythtv_version ); if ( src->file_transfer == NULL ) { - //GST_OBJECT_UNLOCK(src); - goto init_failed; } @@ -846,7 +939,7 @@ wait_to_transfer = 0; while ( wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS && - ( gmyth_file_transfer_is_recording( src->file_transfer ) == FALSE + ( gmyth_file_transfer_is_recording( src->file_transfer ) == FALSE /*|| ( gmyth_file_transfer_get_file_position( src->file_transfer ) < ( src->content_size + 327680 ) )*/ ) ) g_usleep( 100 ); } @@ -855,7 +948,6 @@ ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv ); if ( ret == FALSE ) { - //GST_OBJECT_UNLOCK(src); #ifndef GST_DISABLE_GST_DEBUG if ( src->mythtv_msgs_dbg ) g_printerr( "MythTV FileTransfer request failed when setting up socket connection!\n" ); @@ -866,16 +958,20 @@ src->content_size = src->file_transfer->filesize; src->do_start = FALSE; - - if ( src->live_tv ) { - //src->adapter = gst_adapter_new(); - //g_static_rec_mutex_init( src->th_mutex ); - //src->th_read_ahead = gst_task_create( (GstTaskFunction)gst_mythtv_src_read_ahead, src ); - } + + //if ( src->live_tv ) { + src->adapter = gst_adapter_new(); + //src->th_read_ahead = gst_task_create( (GstTaskFunction)gst_mythtv_src_read_ahead, src ); + //gst_task_set_lock( src->th_read_ahead, &th_mutex ); + //gst_task_start( src->th_read_ahead ); + // } //gst_pad_push_event ( GST_BASE_SRC_PAD (bsrc), // gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, src->content_size, 0 ) ); - //GST_OBJECT_UNLOCK(src); + src->buffer = g_malloc0 (INTERNAL_BUFFER_SIZE); + src->buffer_offset = 0; + src->buffer_remain = 0; + done: return TRUE; @@ -899,18 +995,18 @@ change_progchain: { GST_ELEMENT_ERROR (src, RESOURCE, READ, - (NULL), ("Seek failed, go to the next program info... (%s)", - src->uri_name)); - - gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)), - gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) ); - - // go to the next program chain - src->unique_setup = FALSE; - src->update_prog_chain = TRUE; - - gst_mythtv_src_next_program_chain( src ); - + (NULL), ("Seek failed, go to the next program info... (%s)", + src->uri_name)); + + gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)), + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) ); + + // go to the next program chain + src->unique_setup = FALSE; + src->update_prog_chain = TRUE; + + gst_mythtv_src_next_program_chain( src ); + return TRUE; } } @@ -1113,12 +1209,12 @@ return TRUE; } -#if 0 static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event) { GstMythtvSrc *src = GST_MYTHTV_SRC (GST_PAD_PARENT (pad)); gint64 cont_size = 0; + gboolean ret = FALSE; switch (GST_EVENT_TYPE (event)) { #if 0 @@ -1166,15 +1262,16 @@ } } else src->eos = TRUE; + ret = TRUE; break; -#if 0 case GST_EVENT_NEWSEGMENT: g_print( "[%s] Got NEWSEGMENT!!!\n", __FUNCTION__ ); - src->eos = FALSE; + ret = gst_pad_event_default (pad, event); break; case GST_EVENT_SEEK: { - g_print( "[%s] Got EVENT_SEEK!!!\n", __FUNCTION__ ); + gst_event_ref( event ); + gdouble rate; //gboolean update = TRUE; GstFormat format; @@ -1185,24 +1282,23 @@ &flags, &cur_type, &cur, &stop_type, &stop ); - g_print( "[%s] Got EVENT_SEEK.\n", __FUNCTION__ ); + g_print( "[%s] Got EVENT_SEEK (pos = %lld)!!!\n", __FUNCTION__, cur ); if ( !( flags & GST_SEEK_FLAG_FLUSH ) ) { g_print( "[%s] Could get the FLAG_FLUSH message.\n", __FUNCTION__ ); } - //gboolean ret = gst_event_parse_new_segment ( event, - // &update, &rate, &format, &start, &stop, - // &position ); - //GstFlowReturn flow_ret = gst_mythtv_src_create (GST_BASE_SRC( GST_PAD_PARENT( psrc ) ), - // cur, stop - cur + 1, GstBuffer) + if ( format == GST_FORMAT_TIME && ( ret = gst_pad_event_default (pad, event) ) == FALSE ) { + gst_event_unref( event ); + break; + } + + break; } -#endif default: - return gst_pad_event_default (pad, event); + ret = gst_pad_event_default (pad, event); } - return gst_pad_event_default (pad, event); + return ret; } -#endif static gboolean gst_mythtv_src_is_seekable( GstBaseSrc *push_src )