[svn r774] Fixed problem with transcode after adding chunck feature trunk
authorrenatofilho
Tue Jul 03 13:53:26 2007 +0100 (2007-07-03)
branchtrunk
changeset 768b405295259f3
parent 767 372e7c8135b9
child 769 1603bc7804da
[svn r774] Fixed problem with transcode after adding chunck feature
gmyth-stream/gmemcoder/src/gmencoder.c
gmyth-stream/gmemcoder/src/gmencoder.h
gmyth-stream/gmemcoder/src/main.c
gmyth-stream/server/0.3/lib/request_handler.py
gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py
     1.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.c	Mon Jul 02 09:18:52 2007 +0100
     1.2 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c	Tue Jul 03 13:53:26 2007 +0100
     1.3 @@ -51,6 +51,7 @@
     1.4      gint            sources;
     1.5      gint            tick_id;
     1.6      gint64          duration;
     1.7 +    gboolean        send_chunked;
     1.8  #ifdef USE_MANUAL_SINK
     1.9      GByteArray	    *queue;
    1.10  #endif
    1.11 @@ -464,6 +465,7 @@
    1.12  
    1.13  gboolean 
    1.14  g_mencoder_setup_stream(GMencoder * self,
    1.15 +			gboolean chunked,
    1.16                          const gchar * mux_name,
    1.17                          const gchar * video_encode,
    1.18                          gchar ** video_encode_prop,
    1.19 @@ -487,6 +489,7 @@
    1.20          return FALSE;
    1.21  
    1.22      priv->sources = 0;
    1.23 +    priv->send_chunked = chunked;
    1.24      priv->pipe = _create_pipeline(self,
    1.25                                    video_encode,
    1.26                                    mux_name,
    1.27 @@ -902,7 +905,8 @@
    1.28      i = g_strsplit(uri, "://", 0);
    1.29      if (strcmp(i[0], "fd") == 0) {
    1.30          priv->fd = atoi(i[1]);
    1.31 -	fcntl (priv->fd, F_SETFL, O_ASYNC);
    1.32 +	if (priv->send_chunked)
    1.33 +	    fcntl (priv->fd, F_SETFL, O_ASYNC);
    1.34      } else if (strcmp(i[0], "file") == 0) {
    1.35          if (g_file_test (i[1], G_FILE_TEST_EXISTS)) {
    1.36              if (unlink (i[1]) != 0) {
    1.37 @@ -1134,9 +1138,14 @@
    1.38  
    1.39      priv->queue = g_byte_array_append (priv->queue, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff));
    1.40      while (priv->queue->len >= BUFFER_SIZE) {
    1.41 -    	//g_usleep (0.2 * G_USEC_PER_SEC);	
    1.42 -	if (_send_buffer (priv->fd, priv->queue->data, BUFFER_SIZE) == FALSE)
    1.43 -            goto error;
    1.44 +    	//g_usleep (0.2 * G_USEC_PER_SEC);
    1.45 +    	if (priv->send_chunked) {	
    1.46 +	    if (_send_buffer (priv->fd, priv->queue->data, BUFFER_SIZE) == FALSE)
    1.47 +                goto error;
    1.48 +	} else {
    1.49 +	    if (write (priv->fd, priv->queue->data, BUFFER_SIZE) == -1)
    1.50 +                goto error;
    1.51 +	}
    1.52          priv->queue = g_byte_array_remove_range (priv->queue, 0, BUFFER_SIZE);
    1.53      }
    1.54      return;
     2.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.h	Mon Jul 02 09:18:52 2007 +0100
     2.2 +++ b/gmyth-stream/gmemcoder/src/gmencoder.h	Tue Jul 03 13:53:26 2007 +0100
     2.3 @@ -35,6 +35,7 @@
     2.4  GMencoder      *g_mencoder_new(void);
     2.5  
     2.6  gboolean        g_mencoder_setup_stream(GMencoder * self,
     2.7 +					gboolean chunked,
     2.8                                          const gchar * mux_name,
     2.9                                          const gchar * video_encode,
    2.10                                          gchar ** video_encode_prop,
     3.1 --- a/gmyth-stream/gmemcoder/src/main.c	Mon Jul 02 09:18:52 2007 +0100
     3.2 +++ b/gmyth-stream/gmemcoder/src/main.c	Tue Jul 03 13:53:26 2007 +0100
     3.3 @@ -26,6 +26,7 @@
     3.4  static double   audio_rate = 0.0;
     3.5  static gchar   *mux_name = NULL;
     3.6  static gchar   *output_uri = NULL;
     3.7 +static gboolean chunked = FALSE;
     3.8  
     3.9  
    3.10  
    3.11 @@ -121,6 +122,9 @@
    3.12          {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri,
    3.13           "Uri to output", NULL},
    3.14  
    3.15 +	{"chunked", 'c', 0, G_OPTION_ARG_NONE, &chunked, 
    3.16 +         "Send package chunked", NULL},
    3.17 +
    3.18          {NULL}
    3.19      };
    3.20  
    3.21 @@ -162,7 +166,7 @@
    3.22          vopts = NULL;
    3.23  
    3.24      
    3.25 -    ret = g_mencoder_setup_stream(coder, mux_name,
    3.26 +    ret = g_mencoder_setup_stream(coder, chunked, mux_name,
    3.27                                    video_encode, vopts, video_fps,
    3.28                                    video_rate, video_width, video_height,
    3.29                                    audio_encode, aopts, audio_rate, output_uri);
     4.1 --- a/gmyth-stream/server/0.3/lib/request_handler.py	Mon Jul 02 09:18:52 2007 +0100
     4.2 +++ b/gmyth-stream/server/0.3/lib/request_handler.py	Tue Jul 03 13:53:26 2007 +0100
     4.3 @@ -336,6 +336,7 @@
     4.4  
     4.5          self.send_response(200)
     4.6          self.send_header("Content-Type", obj.get_mimetype())
     4.7 +	self.send_header("Cache-Control","no-cache")
     4.8  
     4.9          if (obj.name == "gmencoder"):
    4.10              self.send_header("Transfer-Encoding", "chunked")
     5.1 --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Mon Jul 02 09:18:52 2007 +0100
     5.2 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Tue Jul 03 13:53:26 2007 +0100
     5.3 @@ -60,6 +60,7 @@
     5.4              self._insert_param("-o", "file://%s" % path)
     5.5          else:
     5.6              self._insert_param ("-o", "fd://%d" % outfd.fileno())
     5.7 +            self.opts.append ("-c") 
     5.8  
     5.9          cmd = " ".join(self.opts)
    5.10          self.log.info(self.tid, "GMencoder: %s" % cmd)