1.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Fri May 18 21:15:39 2007 +0100
1.2 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Fri May 18 22:45:49 2007 +0100
1.3 @@ -393,12 +393,12 @@
1.4 data_ptr, sizetoread, src->live_tv);
1.5 else if ( IS_GMYTH_FILE_TRANSFER(src->file) )
1.6 result = gmyth_file_transfer_read ( GMYTH_FILE_TRANSFER(src->file),
1.7 - data_ptr, sizetoread, src->live_tv);
1.8 + data_ptr, sizetoread, src->live_tv );
1.9
1.10 if (data_ptr->len > 0) {
1.11 read += data_ptr->len;
1.12 sizetoread -= data_ptr->len;
1.13 - } else if (data_ptr->len < 0) {
1.14 + } else if (data_ptr->len <= 0) {
1.15 if (src->live_tv == FALSE) {
1.16 result = GMYTH_FILE_READ_EOF;
1.17 goto eos;
1.18 @@ -408,20 +408,21 @@
1.19 goto done;
1.20 } else if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) { /* -315 */
1.21 GST_INFO_OBJECT (src,
1.22 - "[LiveTV] FileTransfer - Go to the next program chain!");
1.23 + "[LiveTV] FileTransfer - Go to athe next program chain!");
1.24 + src->update_prog_chain = TRUE;
1.25 continue;
1.26 }
1.27 goto done;
1.28 }
1.29
1.30 - } else if (data_ptr->len == 0)
1.31 - goto done;
1.32 + } /* else if (data_ptr->len == 0)
1.33 + goto done;*/
1.34
1.35 if (read == sizetoread)
1.36 goto done;
1.37 }
1.38
1.39 - if ((read < 0 && !src->live_tv) || max_iters == 0){
1.40 + if ((read < 0 && !src->live_tv) || max_iters == 0) {
1.41 result = GMYTH_FILE_READ_EOF;
1.42 goto eos;
1.43 }
1.44 @@ -450,13 +451,11 @@
1.45 if (G_UNLIKELY (src->update_prog_chain))
1.46 goto change_progchain;
1.47
1.48 - /*
1.49 GST_DEBUG_OBJECT (src, "offset = %" G_GUINT64_FORMAT ", size = %d...",
1.50 src->read_offset, MAX_READ_SIZE);
1.51
1.52 GST_DEBUG_OBJECT (src, "Create: buffer_remain: %d, buffer_size = %d.",
1.53 (gint) src->buffer_remain, src->bytes_queue->len);
1.54 - */
1.55
1.56 program_chain_changed:
1.57 /* just get from the byte array, no network effort... */
1.58 @@ -474,6 +473,25 @@
1.59
1.60 result = do_read_request_response (src, buffer_size_inter, buffer);
1.61
1.62 + /* got the next program info? */
1.63 + if (G_UNLIKELY (src->update_prog_chain)) {
1.64 + if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) {
1.65 + if (buffer != NULL) {
1.66 + g_byte_array_free (buffer, TRUE);
1.67 + buffer = NULL;
1.68 + }
1.69 + goto program_chain_changed;
1.70 + } else if (result == GMYTH_FILE_READ_OK) {
1.71 + /* remove wasteful, NUV file header data */
1.72 + buffer = g_byte_array_remove_range( buffer, 0, 512 );
1.73 + /* TODO: need to send a new segment event to NUVDemux? */
1.74 + gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
1.75 + gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
1.76 +
1.77 + /* goto change_progchain; */
1.78 + }
1.79 + }
1.80 +
1.81 if (G_UNLIKELY (buffer->len < 0)) {
1.82
1.83 if (buffer != NULL) {
1.84 @@ -487,10 +505,10 @@
1.85 goto read_error;
1.86 } else if (G_UNLIKELY (read == 0)) {
1.87
1.88 - if (buffer != NULL) {
1.89 - g_byte_array_free (buffer, TRUE);
1.90 - buffer = NULL;
1.91 - }
1.92 + if (buffer != NULL) {
1.93 + g_byte_array_free (buffer, TRUE);
1.94 + buffer = NULL;
1.95 + }
1.96
1.97 if (!src->live_tv)
1.98 goto done;
1.99 @@ -498,15 +516,6 @@
1.100 goto program_chain_changed;
1.101 }
1.102
1.103 - if (G_UNLIKELY (src->update_prog_chain))
1.104 - {
1.105 - if (buffer != NULL) {
1.106 - g_byte_array_free (buffer, TRUE);
1.107 - buffer = NULL;
1.108 - }
1.109 - goto change_progchain;
1.110 - }
1.111 -
1.112 src->bytes_queue =
1.113 g_byte_array_append (src->bytes_queue, buffer->data, buffer->len);
1.114 if (buffer->len > buffer_size_inter)
1.115 @@ -527,7 +536,6 @@
1.116 "OFFSET = %llu, CONTENT SIZE = %llu.", read,
1.117 src->bytes_read, src->read_offset, src->content_size);
1.118 */
1.119 -
1.120 }
1.121
1.122 guint buffer_size =
1.123 @@ -535,9 +543,6 @@
1.124
1.125 *outbuf = gst_buffer_new ();
1.126
1.127 - /* gets the first buffer_size bytes from the byte array buffer variable */
1.128 - /* guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); */
1.129 -
1.130 /*
1.131 GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d",
1.132 (buffer_size_inter ==
1.133 @@ -594,11 +599,9 @@
1.134 (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
1.135 src->uri_name));
1.136
1.137 -/*
1.138 - TODO: need to send a new segment event to NUVDemux?
1.139 +/* TODO: need to send a new segment event to NUVDemux? */
1.140 gst_pad_push_event (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
1.141 gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0));
1.142 -*/
1.143
1.144 goto program_chain_changed;
1.145 }