1.1 --- a/gmyth-stream/server/lib/request_handler.py Thu Aug 30 13:46:59 2007 +0100
1.2 +++ b/gmyth-stream/server/lib/request_handler.py Fri Aug 31 18:31:09 2007 +0100
1.3 @@ -425,10 +425,6 @@
1.4 self.send_response(200)
1.5 self.send_header("Content-Type", obj.get_mimetype())
1.6 self.send_header("Cache-Control","no-cache")
1.7 -
1.8 - if (obj.name == "gmencoder"):
1.9 - self.send_header("Transfer-Encoding", "chunked")
1.10 -
1.11 self.end_headers()
1.12
1.13 if body:
1.14 @@ -443,9 +439,9 @@
1.15
1.16 self.server.add_transcoders(self, obj)
1.17 if obj.start(self.wfile):
1.18 - self.transcoders_log.info (test_tid, "OK")
1.19 + self.transcoders_log.info(test_tid, "OK")
1.20 else:
1.21 - self.transcoders_log.info (test_tid, "Fail")
1.22 + self.transcoders_log.info(test_tid, "Fail")
1.23
1.24 self.server.del_transcoders(self, obj)
1.25 files.TranscodedFile("", self.query)
2.1 --- a/gmyth-stream/server/lib/transcoder.py Thu Aug 30 13:46:59 2007 +0100
2.2 +++ b/gmyth-stream/server/lib/transcoder.py Fri Aug 31 18:31:09 2007 +0100
2.3 @@ -42,7 +42,7 @@
2.4 pass
2.5 # stop()
2.6
2.7 - def get_legth (self):
2.8 + def get_length (self):
2.9 pass
2.10 # get_leght ()
2.11
3.1 --- a/gmyth-stream/server/plugins/transcoders/gmencoder.py Thu Aug 30 13:46:59 2007 +0100
3.2 +++ b/gmyth-stream/server/plugins/transcoders/gmencoder.py Fri Aug 31 18:31:09 2007 +0100
3.3 @@ -64,7 +64,6 @@
3.4 self._insert_param("-o", "file://%s" % path)
3.5 else:
3.6 self._insert_param ("-o", "fd://%d" % outfd.fileno())
3.7 - self.opts.append ("-c")
3.8
3.9 cmd = " ".join(self.opts)
3.10 self.log.info(self.tid, "GMencoder: %s" % cmd)
3.11 @@ -84,8 +83,9 @@
3.12 try:
3.13 if not outfile:
3.14 p = select.poll()
3.15 - p.register (outfd, select.POLLNVAL | select.POLLERR | select.POLLHUP | select.POLLIN )
3.16 -
3.17 + p.register (outfd, select.POLLNVAL | select.POLLERR |
3.18 + select.POLLHUP)
3.19 + tries = 0
3.20 while (self.proc and self.proc.poll() == None):
3.21 r, w, x = select.select([self.proc.stdout], [], [], 1)
3.22 if self.proc.stdout in r:
3.23 @@ -93,12 +93,17 @@
3.24 if (progress.find ("PROGRESS") >= 0):
3.25 self.status = progress.split (":")[1]
3.26 elif (progress.find ("Erro") >= 0):
3.27 - return False
3.28 + self.log.error(self.tid, "Detected problem @ gmencoder:"
3.29 + " %s" % progress)
3.30 + if tries < 50:
3.31 + tries += 1
3.32 + else:
3.33 + return False
3.34
3.35 if not outfile:
3.36 ret = p.poll(0)
3.37 if ret:
3.38 - self.log.info(self.tid, "Lost connection")
3.39 + self.log.info(self.tid, "* Lost connection *")
3.40 self.stop ()
3.41 return False
3.42
4.1 --- a/gmyth/samples/gmyth_cat.c Thu Aug 30 13:46:59 2007 +0100
4.2 +++ b/gmyth/samples/gmyth_cat.c Fri Aug 31 18:31:09 2007 +0100
4.3 @@ -1,4 +1,3 @@
4.4 -
4.5 #ifdef HAVE_CONFIG_H
4.6 #include "config.h"
4.7 #endif
4.8 @@ -12,6 +11,12 @@
4.9 #include "gmyth_util.h"
4.10 #include "gmyth_common.h"
4.11
4.12 +
4.13 +static GMainLoop *main_loop = NULL;
4.14 +static GAsyncQueue *data_queue = NULL;
4.15 +static GThread *producer_thread = NULL;
4.16 +static gboolean program_end = FALSE;
4.17 +
4.18 typedef struct {
4.19 GMythBackendInfo *b_info;
4.20 char *filename;
4.21 @@ -99,13 +104,60 @@
4.22 return TRUE;
4.23 }
4.24
4.25 +static gpointer
4.26 +_async_data_producer_cb (gpointer data)
4.27 +{
4.28 + gint file_transf_ret;
4.29 + GMythFileTransfer *gmyth_file;
4.30 + GArray *array = NULL;
4.31 +
4.32 + gmyth_file = (GMythFileTransfer *) data;
4.33 +
4.34 + array = g_array_new(FALSE, TRUE, sizeof(gchar));
4.35 + file_transf_ret = gmyth_file_transfer_read (GMYTH_FILE_TRANSFER(gmyth_file),
4.36 + (GByteArray *) array, 64000, TRUE);
4.37 +
4.38 + while ((file_transf_ret == GMYTH_FILE_READ_OK) ||
4.39 + (file_transf_ret == GMYTH_FILE_READ_NEXT_PROG_CHAIN) ||
4.40 + program_end == FALSE) {
4.41 +
4.42 + g_async_queue_push (data_queue, array);
4.43 +
4.44 + array = g_array_new(FALSE, TRUE, sizeof(gchar));
4.45 + file_transf_ret = gmyth_file_transfer_read (GMYTH_FILE_TRANSFER(gmyth_file),
4.46 + (GByteArray *) array, 64000, TRUE);
4.47 + }
4.48 +
4.49 + gmyth_file_transfer_close(gmyth_file);
4.50 + program_end = TRUE;
4.51 +
4.52 + return NULL;
4.53 +}
4.54 +
4.55 +static gboolean
4.56 +_sync_data_consumer_cb (gpointer data)
4.57 +{
4.58 + if (g_async_queue_length (data_queue) > 0) {
4.59 + GArray *data = g_async_queue_try_pop (data_queue);
4.60 +
4.61 + if (data != NULL) {
4.62 + fwrite(data->data, sizeof (gchar) , data->len, stdout);
4.63 + fflush(stdout);
4.64 + g_array_free (data, TRUE);
4.65 + }
4.66 + }
4.67 +
4.68 + if (program_end == TRUE && g_async_queue_length (data_queue) == 0) {
4.69 + return FALSE;
4.70 + }
4.71 +
4.72 + return TRUE;
4.73 +}
4.74 +
4.75 static gboolean
4.76 _cat_recorded_file(cat_options_t * options)
4.77 {
4.78 - GArray *array = NULL;
4.79 GMythFileTransfer *transfer;
4.80 - guint64 size = 0,
4.81 - total = 0;
4.82
4.83 g_return_val_if_fail(options != NULL, FALSE);
4.84 g_return_val_if_fail(options->b_info != NULL, FALSE);
4.85 @@ -123,48 +175,15 @@
4.86 return FALSE;
4.87 }
4.88
4.89 - size = gmyth_file_transfer_get_filesize(transfer);
4.90 - fprintf(stderr, "Size:%" G_GUINT64_FORMAT "\n", size);
4.91 -
4.92 - array = g_array_new(FALSE, TRUE, sizeof(gchar));
4.93 -
4.94 - while (total != size) {
4.95 - GMythFileReadResult res;
4.96 -
4.97 - res = gmyth_file_transfer_read(transfer, (GByteArray *) array,
4.98 - (size - total) >
4.99 - 64000 ? 64000 : (size - total),
4.100 - FALSE);
4.101 - if ((res != GMYTH_FILE_READ_OK) && (res != GMYTH_FILE_READ_EOF)) {
4.102 - g_array_free(array, TRUE);
4.103 - g_printerr("Error while reading the file: aborting!!\n");
4.104 - break;
4.105 - }
4.106 -
4.107 - fwrite(array->data, array->len, 1, stdout);
4.108 - fflush(stdout);
4.109 -
4.110 - total += array->len;
4.111 - fprintf(stderr, "%" G_GUINT64_FORMAT "\n", total);
4.112 - g_array_remove_range(array, 0, array->len);
4.113 - // usleep(300000);
4.114 - }
4.115 -
4.116 - gmyth_file_transfer_close(transfer);
4.117 - g_array_free(array, TRUE);
4.118 - g_object_unref(transfer);
4.119 -
4.120 - return TRUE;
4.121 + producer_thread = g_thread_create (_async_data_producer_cb, transfer, TRUE, NULL);
4.122 + return TRUE;
4.123 }
4.124
4.125 -static gboolean
4.126 +static gboolean
4.127 _cat_channel(cat_options_t * options)
4.128 {
4.129 GMythLiveTV *livetv = NULL;
4.130 GMythFile *gmyth_file = NULL;
4.131 - GArray *array = NULL;
4.132 -
4.133 - gint file_transf_ret;
4.134
4.135 g_return_val_if_fail(options != NULL, FALSE);
4.136 g_return_val_if_fail(options->b_info != NULL, FALSE);
4.137 @@ -193,25 +212,30 @@
4.138 return FALSE;
4.139 }
4.140
4.141 - array = g_array_new(FALSE, TRUE, sizeof(gchar));
4.142 + producer_thread = g_thread_create (_async_data_producer_cb, gmyth_file, TRUE, NULL);
4.143 + return TRUE;
4.144 +}
4.145
4.146 - while (((file_transf_ret = gmyth_file_transfer_read
4.147 - (GMYTH_FILE_TRANSFER(gmyth_file),
4.148 - (GByteArray *) array, 64000, TRUE)) == GMYTH_FILE_READ_OK) ||
4.149 - file_transf_ret == GMYTH_FILE_READ_NEXT_PROG_CHAIN) {
4.150
4.151 - fwrite(array->data, sizeof(gpointer), array->len, stdout);
4.152 - fflush(stdout);
4.153 - g_array_remove_range(array, 0, array->len);
4.154 +static gboolean
4.155 +_cat_loop (cat_options_t *options)
4.156 +{
4.157 + gboolean res = FALSE;
4.158
4.159 - g_main_context_iteration(g_main_context_default(), FALSE);
4.160 + data_queue = g_async_queue_new();
4.161 +
4.162 + if (options->filename)
4.163 + res = _cat_recorded_file(options);
4.164 + else if (options->channel)
4.165 + res = _cat_channel(options);
4.166 + else {
4.167 + g_printerr
4.168 + ("Argument invalid. You must specify --filename or --channel.\n"
4.169 + "Type --help for more information.\n");
4.170 }
4.171
4.172 - g_array_free(array, TRUE);
4.173 - g_object_unref(gmyth_file);
4.174 - g_object_unref(livetv);
4.175 -
4.176 - return TRUE;
4.177 + g_idle_add (_sync_data_consumer_cb, NULL);
4.178 + return res;
4.179 }
4.180
4.181 int
4.182 @@ -224,6 +248,8 @@
4.183 if (!g_thread_supported())
4.184 g_thread_init(NULL);
4.185
4.186 + main_loop = g_main_loop_new (NULL, FALSE);
4.187 +
4.188 options = _cat_options_new();
4.189 res = _parse_args(argc, argv, options);
4.190 if (!res) {
4.191 @@ -231,16 +257,11 @@
4.192 return 1;
4.193 }
4.194
4.195 - if (options->filename)
4.196 - res = _cat_recorded_file(options);
4.197 - else if (options->channel)
4.198 - res = _cat_channel(options);
4.199 - else
4.200 - g_printerr
4.201 - ("Argument invalid. You must specify --filename or --channel.\n"
4.202 - "Type --help for more information.\n");
4.203 + if (!_cat_loop (options))
4.204 + return 1;
4.205 +
4.206 + g_main_loop_run (main_loop);
4.207
4.208 _cat_options_free(options);
4.209 -
4.210 return 0;
4.211 }
5.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Thu Aug 30 13:46:59 2007 +0100
5.2 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Fri Aug 31 18:31:09 2007 +0100
5.3 @@ -88,7 +88,7 @@
5.4 #define GMYTHTV_TRANSFER_MAX_RESENDS 2
5.5 #define GMYTHTV_TRANSFER_MAX_BUFFER (128*1024)
5.6 #define READ_SIZE (14*1024)
5.7 -#define READ_SIZE_LIVETV (30*1024)
5.8 +#define READ_SIZE_LIVETV (80*1024)
5.9 #define GST_FLOW_ERROR_NO_DATA (-101)
5.10
5.11 static const GstElementDetails gst_mythtv_src_details =