|
From: <mo...@us...> - 2007-08-31 17:31:08
|
Revision: 843
http://gmyth.svn.sourceforge.net/gmyth/?rev=843&view=rev
Author: morphbr
Date: 2007-08-31 10:31:09 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
- Updated "chunked" bug on gmencoder
- Updated "poll" bug on gmencoder
- Updated wrong method name on transcoder
- Updated request_handler error message
- New version of gmyth_cat
Modified Paths:
--------------
trunk/gmyth/samples/gmyth_cat.c
trunk/gmyth-stream/server/lib/request_handler.py
trunk/gmyth-stream/server/lib/transcoder.py
trunk/gmyth-stream/server/plugins/transcoders/gmencoder.py
trunk/gst-gmyth/mythsrc/gstmythtvsrc.c
Modified: trunk/gmyth/samples/gmyth_cat.c
===================================================================
--- trunk/gmyth/samples/gmyth_cat.c 2007-08-30 12:46:59 UTC (rev 842)
+++ trunk/gmyth/samples/gmyth_cat.c 2007-08-31 17:31:09 UTC (rev 843)
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -12,6 +11,12 @@
#include "gmyth_util.h"
#include "gmyth_common.h"
+
+static GMainLoop *main_loop = NULL;
+static GAsyncQueue *data_queue = NULL;
+static GThread *producer_thread = NULL;
+static gboolean program_end = FALSE;
+
typedef struct {
GMythBackendInfo *b_info;
char *filename;
@@ -99,13 +104,60 @@
return TRUE;
}
+static gpointer
+_async_data_producer_cb (gpointer data)
+{
+ gint file_transf_ret;
+ GMythFileTransfer *gmyth_file;
+ GArray *array = NULL;
+
+ gmyth_file = (GMythFileTransfer *) data;
+
+ array = g_array_new(FALSE, TRUE, sizeof(gchar));
+ file_transf_ret = gmyth_file_transfer_read (GMYTH_FILE_TRANSFER(gmyth_file),
+ (GByteArray *) array, 64000, TRUE);
+
+ while ((file_transf_ret == GMYTH_FILE_READ_OK) ||
+ (file_transf_ret == GMYTH_FILE_READ_NEXT_PROG_CHAIN) ||
+ program_end == FALSE) {
+
+ g_async_queue_push (data_queue, array);
+
+ array = g_array_new(FALSE, TRUE, sizeof(gchar));
+ file_transf_ret = gmyth_file_transfer_read (GMYTH_FILE_TRANSFER(gmyth_file),
+ (GByteArray *) array, 64000, TRUE);
+ }
+
+ gmyth_file_transfer_close(gmyth_file);
+ program_end = TRUE;
+
+ return NULL;
+}
+
+static gboolean
+_sync_data_consumer_cb (gpointer data)
+{
+ if (g_async_queue_length (data_queue) > 0) {
+ GArray *data = g_async_queue_try_pop (data_queue);
+
+ if (data != NULL) {
+ fwrite(data->data, sizeof (gchar) , data->len, stdout);
+ fflush(stdout);
+ g_array_free (data, TRUE);
+ }
+ }
+
+ if (program_end == TRUE && g_async_queue_length (data_queue) == 0) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static gboolean
_cat_recorded_file(cat_options_t * options)
{
- GArray *array = NULL;
GMythFileTransfer *transfer;
- guint64 size = 0,
- total = 0;
g_return_val_if_fail(options != NULL, FALSE);
g_return_val_if_fail(options->b_info != NULL, FALSE);
@@ -123,49 +175,16 @@
return FALSE;
}
- size = gmyth_file_transfer_get_filesize(transfer);
- fprintf(stderr, "Size:%" G_GUINT64_FORMAT "\n", size);
-
- array = g_array_new(FALSE, TRUE, sizeof(gchar));
-
- while (total != size) {
- GMythFileReadResult res;
-
- res = gmyth_file_transfer_read(transfer, (GByteArray *) array,
- (size - total) >
- 64000 ? 64000 : (size - total),
- FALSE);
- if ((res != GMYTH_FILE_READ_OK) && (res != GMYTH_FILE_READ_EOF)) {
- g_array_free(array, TRUE);
- g_printerr("Error while reading the file: aborting!!\n");
- break;
- }
-
- fwrite(array->data, array->len, 1, stdout);
- fflush(stdout);
-
- total += array->len;
- fprintf(stderr, "%" G_GUINT64_FORMAT "\n", total);
- g_array_remove_range(array, 0, array->len);
- // usleep(300000);
- }
-
- gmyth_file_transfer_close(transfer);
- g_array_free(array, TRUE);
- g_object_unref(transfer);
-
- return TRUE;
+ producer_thread = g_thread_create (_async_data_producer_cb, transfer, TRUE, NULL);
+ return TRUE;
}
-static gboolean
+static gboolean
_cat_channel(cat_options_t * options)
{
GMythLiveTV *livetv = NULL;
GMythFile *gmyth_file = NULL;
- GArray *array = NULL;
- gint file_transf_ret;
-
g_return_val_if_fail(options != NULL, FALSE);
g_return_val_if_fail(options->b_info != NULL, FALSE);
g_return_val_if_fail(options->channel != NULL, FALSE);
@@ -193,25 +212,30 @@
return FALSE;
}
- array = g_array_new(FALSE, TRUE, sizeof(gchar));
+ producer_thread = g_thread_create (_async_data_producer_cb, gmyth_file, TRUE, NULL);
+ return TRUE;
+}
- while (((file_transf_ret = gmyth_file_transfer_read
- (GMYTH_FILE_TRANSFER(gmyth_file),
- (GByteArray *) array, 64000, TRUE)) == GMYTH_FILE_READ_OK) ||
- file_transf_ret == GMYTH_FILE_READ_NEXT_PROG_CHAIN) {
- fwrite(array->data, sizeof(gpointer), array->len, stdout);
- fflush(stdout);
- g_array_remove_range(array, 0, array->len);
+static gboolean
+_cat_loop (cat_options_t *options)
+{
+ gboolean res = FALSE;
- g_main_context_iteration(g_main_context_default(), FALSE);
+ data_queue = g_async_queue_new();
+
+ if (options->filename)
+ res = _cat_recorded_file(options);
+ else if (options->channel)
+ res = _cat_channel(options);
+ else {
+ g_printerr
+ ("Argument invalid. You must specify --filename or --channel.\n"
+ "Type --help for more information.\n");
}
- g_array_free(array, TRUE);
- g_object_unref(gmyth_file);
- g_object_unref(livetv);
-
- return TRUE;
+ g_idle_add (_sync_data_consumer_cb, NULL);
+ return res;
}
int
@@ -224,6 +248,8 @@
if (!g_thread_supported())
g_thread_init(NULL);
+ main_loop = g_main_loop_new (NULL, FALSE);
+
options = _cat_options_new();
res = _parse_args(argc, argv, options);
if (!res) {
@@ -231,16 +257,11 @@
return 1;
}
- if (options->filename)
- res = _cat_recorded_file(options);
- else if (options->channel)
- res = _cat_channel(options);
- else
- g_printerr
- ("Argument invalid. You must specify --filename or --channel.\n"
- "Type --help for more information.\n");
+ if (!_cat_loop (options))
+ return 1;
+ g_main_loop_run (main_loop);
+
_cat_options_free(options);
-
return 0;
}
Modified: trunk/gmyth-stream/server/lib/request_handler.py
===================================================================
--- trunk/gmyth-stream/server/lib/request_handler.py 2007-08-30 12:46:59 UTC (rev 842)
+++ trunk/gmyth-stream/server/lib/request_handler.py 2007-08-31 17:31:09 UTC (rev 843)
@@ -425,10 +425,6 @@
self.send_response(200)
self.send_header("Content-Type", obj.get_mimetype())
self.send_header("Cache-Control","no-cache")
-
- if (obj.name == "gmencoder"):
- self.send_header("Transfer-Encoding", "chunked")
-
self.end_headers()
if body:
@@ -443,9 +439,9 @@
self.server.add_transcoders(self, obj)
if obj.start(self.wfile):
- self.transcoders_log.info (test_tid, "OK")
+ self.transcoders_log.info(test_tid, "OK")
else:
- self.transcoders_log.info (test_tid, "Fail")
+ self.transcoders_log.info(test_tid, "Fail")
self.server.del_transcoders(self, obj)
files.TranscodedFile("", self.query)
Modified: trunk/gmyth-stream/server/lib/transcoder.py
===================================================================
--- trunk/gmyth-stream/server/lib/transcoder.py 2007-08-30 12:46:59 UTC (rev 842)
+++ trunk/gmyth-stream/server/lib/transcoder.py 2007-08-31 17:31:09 UTC (rev 843)
@@ -42,7 +42,7 @@
pass
# stop()
- def get_legth (self):
+ def get_length (self):
pass
# get_leght ()
Modified: trunk/gmyth-stream/server/plugins/transcoders/gmencoder.py
===================================================================
--- trunk/gmyth-stream/server/plugins/transcoders/gmencoder.py 2007-08-30 12:46:59 UTC (rev 842)
+++ trunk/gmyth-stream/server/plugins/transcoders/gmencoder.py 2007-08-31 17:31:09 UTC (rev 843)
@@ -64,7 +64,6 @@
self._insert_param("-o", "file://%s" % path)
else:
self._insert_param ("-o", "fd://%d" % outfd.fileno())
- self.opts.append ("-c")
cmd = " ".join(self.opts)
self.log.info(self.tid, "GMencoder: %s" % cmd)
@@ -84,8 +83,9 @@
try:
if not outfile:
p = select.poll()
- p.register (outfd, select.POLLNVAL | select.POLLERR | select.POLLHUP | select.POLLIN )
-
+ p.register (outfd, select.POLLNVAL | select.POLLERR |
+ select.POLLHUP)
+ tries = 0
while (self.proc and self.proc.poll() == None):
r, w, x = select.select([self.proc.stdout], [], [], 1)
if self.proc.stdout in r:
@@ -93,12 +93,17 @@
if (progress.find ("PROGRESS") >= 0):
self.status = progress.split (":")[1]
elif (progress.find ("Erro") >= 0):
- return False
+ self.log.error(self.tid, "Detected problem @ gmencoder:"
+ " %s" % progress)
+ if tries < 50:
+ tries += 1
+ else:
+ return False
if not outfile:
ret = p.poll(0)
if ret:
- self.log.info(self.tid, "Lost connection")
+ self.log.info(self.tid, "* Lost connection *")
self.stop ()
return False
Modified: trunk/gst-gmyth/mythsrc/gstmythtvsrc.c
===================================================================
--- trunk/gst-gmyth/mythsrc/gstmythtvsrc.c 2007-08-30 12:46:59 UTC (rev 842)
+++ trunk/gst-gmyth/mythsrc/gstmythtvsrc.c 2007-08-31 17:31:09 UTC (rev 843)
@@ -88,7 +88,7 @@
#define GMYTHTV_TRANSFER_MAX_RESENDS 2
#define GMYTHTV_TRANSFER_MAX_BUFFER (128*1024)
#define READ_SIZE (14*1024)
-#define READ_SIZE_LIVETV (30*1024)
+#define READ_SIZE_LIVETV (80*1024)
#define GST_FLOW_ERROR_NO_DATA (-101)
static const GstElementDetails gst_mythtv_src_details =
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|