# HG changeset patch # User renatofilho # Date 1183467206 -3600 # Node ID b405295259f31e408cfe2a9ee9f2e8cbbde2f6e2 # Parent 372e7c8135b986f528919c2801b895861957afae [svn r774] Fixed problem with transcode after adding chunck feature diff -r 372e7c8135b9 -r b405295259f3 gmyth-stream/gmemcoder/src/gmencoder.c --- a/gmyth-stream/gmemcoder/src/gmencoder.c Mon Jul 02 09:18:52 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Tue Jul 03 13:53:26 2007 +0100 @@ -51,6 +51,7 @@ gint sources; gint tick_id; gint64 duration; + gboolean send_chunked; #ifdef USE_MANUAL_SINK GByteArray *queue; #endif @@ -464,6 +465,7 @@ gboolean g_mencoder_setup_stream(GMencoder * self, + gboolean chunked, const gchar * mux_name, const gchar * video_encode, gchar ** video_encode_prop, @@ -487,6 +489,7 @@ return FALSE; priv->sources = 0; + priv->send_chunked = chunked; priv->pipe = _create_pipeline(self, video_encode, mux_name, @@ -902,7 +905,8 @@ i = g_strsplit(uri, "://", 0); if (strcmp(i[0], "fd") == 0) { priv->fd = atoi(i[1]); - fcntl (priv->fd, F_SETFL, O_ASYNC); + if (priv->send_chunked) + fcntl (priv->fd, F_SETFL, O_ASYNC); } else if (strcmp(i[0], "file") == 0) { if (g_file_test (i[1], G_FILE_TEST_EXISTS)) { if (unlink (i[1]) != 0) { @@ -1134,9 +1138,14 @@ priv->queue = g_byte_array_append (priv->queue, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)); while (priv->queue->len >= BUFFER_SIZE) { - //g_usleep (0.2 * G_USEC_PER_SEC); - if (_send_buffer (priv->fd, priv->queue->data, BUFFER_SIZE) == FALSE) - goto error; + //g_usleep (0.2 * G_USEC_PER_SEC); + if (priv->send_chunked) { + if (_send_buffer (priv->fd, priv->queue->data, BUFFER_SIZE) == FALSE) + goto error; + } else { + if (write (priv->fd, priv->queue->data, BUFFER_SIZE) == -1) + goto error; + } priv->queue = g_byte_array_remove_range (priv->queue, 0, BUFFER_SIZE); } return; diff -r 372e7c8135b9 -r b405295259f3 gmyth-stream/gmemcoder/src/gmencoder.h --- a/gmyth-stream/gmemcoder/src/gmencoder.h Mon Jul 02 09:18:52 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/gmencoder.h Tue Jul 03 13:53:26 2007 +0100 @@ -35,6 +35,7 @@ GMencoder *g_mencoder_new(void); gboolean g_mencoder_setup_stream(GMencoder * self, + gboolean chunked, const gchar * mux_name, const gchar * video_encode, gchar ** video_encode_prop, diff -r 372e7c8135b9 -r b405295259f3 gmyth-stream/gmemcoder/src/main.c --- a/gmyth-stream/gmemcoder/src/main.c Mon Jul 02 09:18:52 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/main.c Tue Jul 03 13:53:26 2007 +0100 @@ -26,6 +26,7 @@ static double audio_rate = 0.0; static gchar *mux_name = NULL; static gchar *output_uri = NULL; +static gboolean chunked = FALSE; @@ -121,6 +122,9 @@ {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri, "Uri to output", NULL}, + {"chunked", 'c', 0, G_OPTION_ARG_NONE, &chunked, + "Send package chunked", NULL}, + {NULL} }; @@ -162,7 +166,7 @@ vopts = NULL; - ret = g_mencoder_setup_stream(coder, mux_name, + ret = g_mencoder_setup_stream(coder, chunked, mux_name, video_encode, vopts, video_fps, video_rate, video_width, video_height, audio_encode, aopts, audio_rate, output_uri); diff -r 372e7c8135b9 -r b405295259f3 gmyth-stream/server/0.3/lib/request_handler.py --- a/gmyth-stream/server/0.3/lib/request_handler.py Mon Jul 02 09:18:52 2007 +0100 +++ b/gmyth-stream/server/0.3/lib/request_handler.py Tue Jul 03 13:53:26 2007 +0100 @@ -336,6 +336,7 @@ 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") diff -r 372e7c8135b9 -r b405295259f3 gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py Mon Jul 02 09:18:52 2007 +0100 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py Tue Jul 03 13:53:26 2007 +0100 @@ -60,6 +60,7 @@ 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)