# HG changeset patch # User rosfran # Date 1176332476 -3600 # Node ID 4a604de8eaf5316dffeab7d6a40cae86e875fa77 # Parent eebe6df8aa118ed81db9401bc180e2fc2d8bc9e5 [svn r533] Change in the API, when dealing with the GMythFile* objects. diff -r eebe6df8aa11 -r 4a604de8eaf5 gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Apr 11 22:24:39 2007 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Apr 12 00:01:16 2007 +0100 @@ -52,7 +52,9 @@ #endif #include "gstmythtvsrc.h" +#include #include +#include #include #include @@ -139,7 +141,7 @@ static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event); -static GMythFileTransferReadResult do_read_request_response (GstMythtvSrc * src, guint size, +static GMythFileReadResult do_read_request_response (GstMythtvSrc * src, guint size, GByteArray * data_ptr); static void @@ -303,12 +305,12 @@ g_object_unref (this->spawn_livetv); this->spawn_livetv = NULL; } -/* + if (this->file_transfer) { g_object_unref (this->file_transfer); this->file_transfer = NULL; } -*/ + if (this->backend_info) { g_object_unref (this->backend_info); this->backend_info = NULL; @@ -330,13 +332,13 @@ G_OBJECT_CLASS (parent_class)->finalize (gobject); } -static GMythFileTransferReadResult +static GMythFileReadResult do_read_request_response (GstMythtvSrc * src, guint size, GByteArray *data_ptr) { gint read = 0; guint sizetoread = size; gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS; - GMythFileTransferReadResult result; + GMythFileReadResult result; GST_LOG_OBJECT (src, "Starting: Reading %d bytes...", sizetoread); @@ -344,21 +346,25 @@ * Retry whilst authentication fails and we supply it. */ while (sizetoread == size && --max_iters > 0) { - result = gmyth_file_transfer_read (src->file_transfer, - data_ptr, sizetoread, src->live_tv); + if ( gmyth_backend_info_is_local_file(src->backend_info) ) + result = gmyth_file_local_read ( GMYTH_FILE_LOCAL(src->file_transfer), + data_ptr, sizetoread, src->live_tv); + else + result = gmyth_file_transfer_read ( GMYTH_FILE_TRANSFER(src->file_transfer), + 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) { if (src->live_tv == FALSE) { - result = GMYTH_FILE_TRANSFER_READ_EOF; + result = GMYTH_FILE_READ_EOF; goto eos; } else { - if (result == GMYTH_FILE_TRANSFER_READ_ERROR) { /* -314 */ + if (result == GMYTH_FILE_READ_ERROR) { /* -314 */ GST_INFO_OBJECT (src, "[LiveTV] FileTransfer READ_ERROR!"); goto done; - } else if (result == GMYTH_FILE_TRANSFER_READ_NEXT_PROG_CHAIN) { /* -315 */ + } else if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) { /* -315 */ GST_INFO_OBJECT (src, "[LiveTV] FileTransfer - Go to the next program chain!"); continue; @@ -374,7 +380,7 @@ } if ((read < 0 && !src->live_tv) || max_iters == 0){ - result = GMYTH_FILE_TRANSFER_READ_EOF; + result = GMYTH_FILE_READ_EOF; goto eos; } @@ -392,6 +398,7 @@ { GstMythtvSrc *src; GstFlowReturn ret = GST_FLOW_OK; + guint buffer_size_inter = 0; src = GST_MYTHTV_SRC (psrc); @@ -411,10 +418,10 @@ /* just get from the byte array, no network effort... */ if ((src->buffer_remain = src->bytes_queue->len) < MAX_READ_SIZE) { GByteArray *buffer; - GMythFileTransferReadResult result = GMYTH_FILE_TRANSFER_READ_OK; + GMythFileReadResult result = GMYTH_FILE_READ_OK; buffer = NULL; - guint buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain); + buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain); if (buffer_size_inter > REQUEST_MAX_SIZE) buffer_size_inter = REQUEST_MAX_SIZE; @@ -430,7 +437,7 @@ buffer = NULL; } - if (src->live_tv || ( result == GMYTH_FILE_TRANSFER_READ_NEXT_PROG_CHAIN )) + if (src->live_tv || ( result == GMYTH_FILE_READ_NEXT_PROG_CHAIN )) goto change_progchain; else goto read_error; @@ -461,7 +468,7 @@ if (buffer->len > buffer_size_inter) GST_WARNING_OBJECT (src, "INCREASED buffer size! Backend sent more than we ask him... (%d)", - abs (read - buffer_size_inter)); + abs (buffer->len - buffer_size_inter)); src->buffer_remain += buffer->len; @@ -486,8 +493,8 @@ /* guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); */ GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d", - (read == - -1) ? "NO, got from buffer" : "YES, go see the backend's log file", + (buffer_size_inter == + 0) ? "NO, got from buffer" : "YES, go see the backend's log file", src->buffer_remain); GST_BUFFER_SIZE (*outbuf) = buffer_size; @@ -603,9 +610,13 @@ actual_seek, src->read_offset); /* verify if it needs to seek */ if (src->read_offset != actual_seek) { - - new_offset = - gmyth_file_transfer_seek (src->file_transfer, segment->start, SEEK_SET); + + if ( gmyth_backend_info_is_local_file(src->backend_info) ) + new_offset = + gmyth_file_local_seek (src->file_transfer, segment->start, G_SEEK_SET); + else + new_offset = + gmyth_file_transfer_seek (src->file_transfer, segment->start, SEEK_SET); GST_LOG_OBJECT (src, "Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.", @@ -701,11 +712,16 @@ } } else { - src->file_transfer = gmyth_file_transfer_new (src->backend_info); + if ( gmyth_uri_is_local_file(gmyth_uri) ) + { + src->file_transfer = gmyth_file_local_new(src->backend_info); + ret = gmyth_file_local_open (src->file_transfer); + } else { + src->file_transfer = gmyth_file_transfer_new(src->backend_info); + ret = gmyth_file_transfer_open (src->file_transfer, src->uri_name); + } - ret = gmyth_file_transfer_open (src->file_transfer, src->uri_name); - - } + } /* if (else) - recorded FileTransfer */ if (NULL == src->file_transfer) { GST_INFO_OBJECT (src, "FileTransfer is NULL"); @@ -724,7 +740,7 @@ GST_INFO_OBJECT (src, "MythTV FileTransfer filesize = %lld, content_size = %lld!", - src->file_transfer->filesize, src->content_size); + gmyth_file_transfer_get_filesize( src->file_transfer ), src->content_size); src->content_size = gmyth_file_transfer_get_filesize (src->file_transfer); @@ -1044,15 +1060,7 @@ switch (prop_id) { case PROP_LOCATION: { - gchar *str = g_strdup (""); - - if (mythtvsrc->uri_name == NULL) { - g_free (mythtvsrc->uri_name); - mythtvsrc->uri_name = NULL; - } else { - str = g_strdup (mythtvsrc->uri_name); - } - g_value_set_string (value, str); + g_value_set_string (value, mythtvsrc->uri_name); break; } #ifndef GST_DISABLE_GST_DEBUG @@ -1078,15 +1086,7 @@ break; case PROP_GMYTHTV_LIVE_CHAINID: { - gchar *str = g_strdup (""); - - if (mythtvsrc->live_chain_id == NULL) { - g_free (mythtvsrc->live_chain_id); - mythtvsrc->live_chain_id = NULL; - } else { - str = g_strdup (mythtvsrc->live_chain_id); - } - g_value_set_string (value, str); + g_value_set_string (value, mythtvsrc->live_chain_id); break; } case PROP_GMYTHTV_CHANNEL_NUM: diff -r eebe6df8aa11 -r 4a604de8eaf5 gst-plugins-mythtv/src/gstmythtvsrc.h --- a/gst-plugins-mythtv/src/gstmythtvsrc.h Wed Apr 11 22:24:39 2007 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.h Thu Apr 12 00:01:16 2007 +0100 @@ -26,7 +26,9 @@ #include #include +#include #include +#include #include #include @@ -56,7 +58,7 @@ GstPushSrc element; /* MythFileTransfer */ - GMythFileTransfer *file_transfer; + GMythFile *file_transfer; GMythLiveTV *spawn_livetv;