diff -r d9c6cce2b167 -r 14680616e7f8 gst-gmyth/mythsrc/gstmythtvsrc.c --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Fri May 18 21:15:39 2007 +0100 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Fri May 18 21:28:42 2007 +0100 @@ -393,12 +393,12 @@ data_ptr, sizetoread, src->live_tv); else if ( IS_GMYTH_FILE_TRANSFER(src->file) ) result = gmyth_file_transfer_read ( GMYTH_FILE_TRANSFER(src->file), - data_ptr, sizetoread, src->live_tv); + data_ptr, sizetoread, src->live_tv ); if (data_ptr->len > 0) { read += data_ptr->len; sizetoread -= data_ptr->len; - } else if (data_ptr->len < 0) { + } else if (data_ptr->len <= 0) { if (src->live_tv == FALSE) { result = GMYTH_FILE_READ_EOF; goto eos; @@ -408,20 +408,21 @@ goto done; } else if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) { /* -315 */ GST_INFO_OBJECT (src, - "[LiveTV] FileTransfer - Go to the next program chain!"); + "[LiveTV] FileTransfer - Go to athe next program chain!"); + src->update_prog_chain = TRUE; continue; } goto done; } - } else if (data_ptr->len == 0) - goto done; + } /* else if (data_ptr->len == 0) + goto done;*/ if (read == sizetoread) goto done; } - if ((read < 0 && !src->live_tv) || max_iters == 0){ + if ((read < 0 && !src->live_tv) || max_iters == 0) { result = GMYTH_FILE_READ_EOF; goto eos; } @@ -450,13 +451,11 @@ if (G_UNLIKELY (src->update_prog_chain)) goto change_progchain; - /* GST_DEBUG_OBJECT (src, "offset = %" G_GUINT64_FORMAT ", size = %d...", src->read_offset, MAX_READ_SIZE); GST_DEBUG_OBJECT (src, "Create: buffer_remain: %d, buffer_size = %d.", (gint) src->buffer_remain, src->bytes_queue->len); - */ program_chain_changed: /* just get from the byte array, no network effort... */ @@ -474,6 +473,25 @@ result = do_read_request_response (src, buffer_size_inter, buffer); + /* got the next program info? */ + if (G_UNLIKELY (src->update_prog_chain)) { + if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) { + if (buffer != NULL) { + g_byte_array_free (buffer, TRUE); + buffer = NULL; + } + goto program_chain_changed; + } else if (result == GMYTH_FILE_READ_OK) { + /* remove wasteful, NUV file header data */ + buffer = g_byte_array_remove_range( buffer, 0, 512 ); + /* TODO: need to send a new segment event to NUVDemux? */ + gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0)); + + /* goto change_progchain; */ + } + } + if (G_UNLIKELY (buffer->len < 0)) { if (buffer != NULL) { @@ -487,10 +505,10 @@ goto read_error; } else if (G_UNLIKELY (read == 0)) { - if (buffer != NULL) { - g_byte_array_free (buffer, TRUE); - buffer = NULL; - } + if (buffer != NULL) { + g_byte_array_free (buffer, TRUE); + buffer = NULL; + } if (!src->live_tv) goto done; @@ -498,15 +516,6 @@ goto program_chain_changed; } - if (G_UNLIKELY (src->update_prog_chain)) - { - if (buffer != NULL) { - g_byte_array_free (buffer, TRUE); - buffer = NULL; - } - goto change_progchain; - } - src->bytes_queue = g_byte_array_append (src->bytes_queue, buffer->data, buffer->len); if (buffer->len > buffer_size_inter) @@ -527,7 +536,6 @@ "OFFSET = %llu, CONTENT SIZE = %llu.", read, src->bytes_read, src->read_offset, src->content_size); */ - } guint buffer_size = @@ -535,9 +543,6 @@ *outbuf = gst_buffer_new (); - /* gets the first buffer_size bytes from the byte array buffer variable */ - /* guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); */ - /* GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d", (buffer_size_inter == @@ -594,11 +599,9 @@ (NULL), ("Seek failed, go to the next program info... (%i, %s)", read, src->uri_name)); -/* - TODO: need to send a new segment event to NUVDemux? +/* TODO: need to send a new segment event to NUVDemux? */ 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)); -*/ goto program_chain_changed; }