[svn r533] Change in the API, when dealing with the GMythFile* objects.
1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Apr 11 22:24:39 2007 +0100
1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Apr 12 00:01:16 2007 +0100
1.3 @@ -52,7 +52,9 @@
1.4 #endif
1.5
1.6 #include "gstmythtvsrc.h"
1.7 +#include <gmyth/gmyth_file.h>
1.8 #include <gmyth/gmyth_file_transfer.h>
1.9 +#include <gmyth/gmyth_file_local.h>
1.10 #include <gmyth/gmyth_livetv.h>
1.11
1.12 #include <gmyth/gmyth_socket.h>
1.13 @@ -139,7 +141,7 @@
1.14
1.15 static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event);
1.16
1.17 -static GMythFileTransferReadResult do_read_request_response (GstMythtvSrc * src, guint size,
1.18 +static GMythFileReadResult do_read_request_response (GstMythtvSrc * src, guint size,
1.19 GByteArray * data_ptr);
1.20
1.21 static void
1.22 @@ -303,12 +305,12 @@
1.23 g_object_unref (this->spawn_livetv);
1.24 this->spawn_livetv = NULL;
1.25 }
1.26 -/*
1.27 +
1.28 if (this->file_transfer) {
1.29 g_object_unref (this->file_transfer);
1.30 this->file_transfer = NULL;
1.31 }
1.32 -*/
1.33 +
1.34 if (this->backend_info) {
1.35 g_object_unref (this->backend_info);
1.36 this->backend_info = NULL;
1.37 @@ -330,13 +332,13 @@
1.38 G_OBJECT_CLASS (parent_class)->finalize (gobject);
1.39 }
1.40
1.41 -static GMythFileTransferReadResult
1.42 +static GMythFileReadResult
1.43 do_read_request_response (GstMythtvSrc * src, guint size, GByteArray *data_ptr)
1.44 {
1.45 gint read = 0;
1.46 guint sizetoread = size;
1.47 gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
1.48 - GMythFileTransferReadResult result;
1.49 + GMythFileReadResult result;
1.50
1.51 GST_LOG_OBJECT (src, "Starting: Reading %d bytes...", sizetoread);
1.52
1.53 @@ -344,21 +346,25 @@
1.54 * Retry whilst authentication fails and we supply it. */
1.55
1.56 while (sizetoread == size && --max_iters > 0) {
1.57 - result = gmyth_file_transfer_read (src->file_transfer,
1.58 - data_ptr, sizetoread, src->live_tv);
1.59 + if ( gmyth_backend_info_is_local_file(src->backend_info) )
1.60 + result = gmyth_file_local_read ( GMYTH_FILE_LOCAL(src->file_transfer),
1.61 + data_ptr, sizetoread, src->live_tv);
1.62 + else
1.63 + result = gmyth_file_transfer_read ( GMYTH_FILE_TRANSFER(src->file_transfer),
1.64 + data_ptr, sizetoread, src->live_tv);
1.65
1.66 if (data_ptr->len > 0) {
1.67 read += data_ptr->len;
1.68 sizetoread -= data_ptr->len;
1.69 } else if (data_ptr->len < 0) {
1.70 if (src->live_tv == FALSE) {
1.71 - result = GMYTH_FILE_TRANSFER_READ_EOF;
1.72 + result = GMYTH_FILE_READ_EOF;
1.73 goto eos;
1.74 } else {
1.75 - if (result == GMYTH_FILE_TRANSFER_READ_ERROR) { /* -314 */
1.76 + if (result == GMYTH_FILE_READ_ERROR) { /* -314 */
1.77 GST_INFO_OBJECT (src, "[LiveTV] FileTransfer READ_ERROR!");
1.78 goto done;
1.79 - } else if (result == GMYTH_FILE_TRANSFER_READ_NEXT_PROG_CHAIN) { /* -315 */
1.80 + } else if (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN) { /* -315 */
1.81 GST_INFO_OBJECT (src,
1.82 "[LiveTV] FileTransfer - Go to the next program chain!");
1.83 continue;
1.84 @@ -374,7 +380,7 @@
1.85 }
1.86
1.87 if ((read < 0 && !src->live_tv) || max_iters == 0){
1.88 - result = GMYTH_FILE_TRANSFER_READ_EOF;
1.89 + result = GMYTH_FILE_READ_EOF;
1.90 goto eos;
1.91 }
1.92
1.93 @@ -392,6 +398,7 @@
1.94 {
1.95 GstMythtvSrc *src;
1.96 GstFlowReturn ret = GST_FLOW_OK;
1.97 + guint buffer_size_inter = 0;
1.98
1.99 src = GST_MYTHTV_SRC (psrc);
1.100
1.101 @@ -411,10 +418,10 @@
1.102 /* just get from the byte array, no network effort... */
1.103 if ((src->buffer_remain = src->bytes_queue->len) < MAX_READ_SIZE) {
1.104 GByteArray *buffer;
1.105 - GMythFileTransferReadResult result = GMYTH_FILE_TRANSFER_READ_OK;
1.106 + GMythFileReadResult result = GMYTH_FILE_READ_OK;
1.107
1.108 buffer = NULL;
1.109 - guint buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain);
1.110 + buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain);
1.111
1.112 if (buffer_size_inter > REQUEST_MAX_SIZE)
1.113 buffer_size_inter = REQUEST_MAX_SIZE;
1.114 @@ -430,7 +437,7 @@
1.115 buffer = NULL;
1.116 }
1.117
1.118 - if (src->live_tv || ( result == GMYTH_FILE_TRANSFER_READ_NEXT_PROG_CHAIN ))
1.119 + if (src->live_tv || ( result == GMYTH_FILE_READ_NEXT_PROG_CHAIN ))
1.120 goto change_progchain;
1.121 else
1.122 goto read_error;
1.123 @@ -461,7 +468,7 @@
1.124 if (buffer->len > buffer_size_inter)
1.125 GST_WARNING_OBJECT (src,
1.126 "INCREASED buffer size! Backend sent more than we ask him... (%d)",
1.127 - abs (read - buffer_size_inter));
1.128 + abs (buffer->len - buffer_size_inter));
1.129
1.130 src->buffer_remain += buffer->len;
1.131
1.132 @@ -486,8 +493,8 @@
1.133 /* guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); */
1.134
1.135 GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d",
1.136 - (read ==
1.137 - -1) ? "NO, got from buffer" : "YES, go see the backend's log file",
1.138 + (buffer_size_inter ==
1.139 + 0) ? "NO, got from buffer" : "YES, go see the backend's log file",
1.140 src->buffer_remain);
1.141
1.142 GST_BUFFER_SIZE (*outbuf) = buffer_size;
1.143 @@ -603,9 +610,13 @@
1.144 actual_seek, src->read_offset);
1.145 /* verify if it needs to seek */
1.146 if (src->read_offset != actual_seek) {
1.147 -
1.148 - new_offset =
1.149 - gmyth_file_transfer_seek (src->file_transfer, segment->start, SEEK_SET);
1.150 +
1.151 + if ( gmyth_backend_info_is_local_file(src->backend_info) )
1.152 + new_offset =
1.153 + gmyth_file_local_seek (src->file_transfer, segment->start, G_SEEK_SET);
1.154 + else
1.155 + new_offset =
1.156 + gmyth_file_transfer_seek (src->file_transfer, segment->start, SEEK_SET);
1.157
1.158 GST_LOG_OBJECT (src,
1.159 "Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.",
1.160 @@ -701,11 +712,16 @@
1.161 }
1.162 } else {
1.163
1.164 - src->file_transfer = gmyth_file_transfer_new (src->backend_info);
1.165 + if ( gmyth_uri_is_local_file(gmyth_uri) )
1.166 + {
1.167 + src->file_transfer = gmyth_file_local_new(src->backend_info);
1.168 + ret = gmyth_file_local_open (src->file_transfer);
1.169 + } else {
1.170 + src->file_transfer = gmyth_file_transfer_new(src->backend_info);
1.171 + ret = gmyth_file_transfer_open (src->file_transfer, src->uri_name);
1.172 + }
1.173
1.174 - ret = gmyth_file_transfer_open (src->file_transfer, src->uri_name);
1.175 -
1.176 - }
1.177 + } /* if (else) - recorded FileTransfer */
1.178
1.179 if (NULL == src->file_transfer) {
1.180 GST_INFO_OBJECT (src, "FileTransfer is NULL");
1.181 @@ -724,7 +740,7 @@
1.182
1.183 GST_INFO_OBJECT (src,
1.184 "MythTV FileTransfer filesize = %lld, content_size = %lld!",
1.185 - src->file_transfer->filesize, src->content_size);
1.186 + gmyth_file_transfer_get_filesize( src->file_transfer ), src->content_size);
1.187
1.188 src->content_size = gmyth_file_transfer_get_filesize (src->file_transfer);
1.189
1.190 @@ -1044,15 +1060,7 @@
1.191 switch (prop_id) {
1.192 case PROP_LOCATION:
1.193 {
1.194 - gchar *str = g_strdup ("");
1.195 -
1.196 - if (mythtvsrc->uri_name == NULL) {
1.197 - g_free (mythtvsrc->uri_name);
1.198 - mythtvsrc->uri_name = NULL;
1.199 - } else {
1.200 - str = g_strdup (mythtvsrc->uri_name);
1.201 - }
1.202 - g_value_set_string (value, str);
1.203 + g_value_set_string (value, mythtvsrc->uri_name);
1.204 break;
1.205 }
1.206 #ifndef GST_DISABLE_GST_DEBUG
1.207 @@ -1078,15 +1086,7 @@
1.208 break;
1.209 case PROP_GMYTHTV_LIVE_CHAINID:
1.210 {
1.211 - gchar *str = g_strdup ("");
1.212 -
1.213 - if (mythtvsrc->live_chain_id == NULL) {
1.214 - g_free (mythtvsrc->live_chain_id);
1.215 - mythtvsrc->live_chain_id = NULL;
1.216 - } else {
1.217 - str = g_strdup (mythtvsrc->live_chain_id);
1.218 - }
1.219 - g_value_set_string (value, str);
1.220 + g_value_set_string (value, mythtvsrc->live_chain_id);
1.221 break;
1.222 }
1.223 case PROP_GMYTHTV_CHANNEL_NUM:
2.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.h Wed Apr 11 22:24:39 2007 +0100
2.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.h Thu Apr 12 00:01:16 2007 +0100
2.3 @@ -26,7 +26,9 @@
2.4 #include <stdio.h>
2.5
2.6 #include <gmyth/gmyth_socket.h>
2.7 +#include <gmyth/gmyth_file.h>
2.8 #include <gmyth/gmyth_file_transfer.h>
2.9 +#include <gmyth/gmyth_file_local.h>
2.10 #include <gmyth/gmyth_livetv.h>
2.11 #include <gmyth/gmyth_backendinfo.h>
2.12
2.13 @@ -56,7 +58,7 @@
2.14 GstPushSrc element;
2.15
2.16 /* MythFileTransfer */
2.17 - GMythFileTransfer *file_transfer;
2.18 + GMythFile *file_transfer;
2.19
2.20 GMythLiveTV *spawn_livetv;
2.21