1.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.c Wed Jul 04 15:25:52 2007 +0100
1.2 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Wed Jul 04 19:37:34 2007 +0100
1.3 @@ -18,7 +18,6 @@
1.4
1.5 // #define SUPPORT_MULT_INPUT 0
1.6 #define USE_MANUAL_SINK
1.7 -#define BUFFER_SIZE (1024 * 64)
1.8
1.9 typedef struct _GMencoderPrivate GMencoderPrivate;
1.10 typedef struct _SetupInfo SetupInfo;
1.11 @@ -52,9 +51,6 @@
1.12 gint tick_id;
1.13 gint64 duration;
1.14 gboolean send_chunked;
1.15 -#ifdef USE_MANUAL_SINK
1.16 - GByteArray *queue;
1.17 -#endif
1.18 };
1.19
1.20 enum {
1.21 @@ -172,9 +168,6 @@
1.22 {
1.23 GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
1.24 priv->info = g_new0(SetupInfo, 1);
1.25 -#ifdef USE_MANUAL_SINK
1.26 - priv->queue = g_byte_array_new ();
1.27 -#endif
1.28 }
1.29
1.30 static void
1.31 @@ -190,9 +183,6 @@
1.32 // TODO: clear vars
1.33 g_mencoder_close_stream(G_MENCODER(object));
1.34 g_free (priv->info);
1.35 -#ifdef USE_MANUAL_SINK
1.36 - g_byte_array_free (priv->queue, TRUE);
1.37 -#endif
1.38 }
1.39
1.40 GMencoder *
1.41 @@ -267,7 +257,7 @@
1.42 if (prop != NULL) {
1.43 for (i = 0; i < g_strv_length(prop); i++) {
1.44 if (prop[i] != NULL) {
1.45 - char **v = g_strsplit(prop[i], "=", 2);
1.46 + char **v = g_strsplit(prop[i], "=", 2);
1.47 if (g_strv_length(v) == 2) {
1.48 _obj_set_prop(G_OBJECT(ret), v[0], v[1]);
1.49 }
1.50 @@ -946,8 +936,6 @@
1.51 i = g_strsplit(uri, "://", 0);
1.52 if (strcmp(i[0], "fd") == 0) {
1.53 priv->fd = atoi(i[1]);
1.54 - if (priv->send_chunked)
1.55 - fcntl (priv->fd, F_SETFL, O_ASYNC);
1.56 } else if (strcmp(i[0], "file") == 0) {
1.57 if (g_file_test (i[1], G_FILE_TEST_EXISTS)) {
1.58 if (unlink (i[1]) != 0) {
1.59 @@ -1034,7 +1022,7 @@
1.60 case GST_MESSAGE_EOS:
1.61 priv->ready = FALSE;
1.62 #ifdef USE_MANUAL_SINK
1.63 - _flush_queue (G_MENCODER (user_data));
1.64 + _flush_queue (G_MENCODER (user_data));
1.65 #endif
1.66 g_signal_emit(user_data, g_mencoder_signals[EOS], 0);
1.67 break;
1.68 @@ -1147,21 +1135,14 @@
1.69 static void
1.70 _flush_queue (GMencoder *self)
1.71 {
1.72 - gchar *end_msg;
1.73 GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
1.74
1.75 - if (BUFFER_SIZE == 0)
1.76 - return;
1.77 -
1.78 - if (priv->queue->len > 0) {
1.79 - _send_buffer (priv->fd, priv->queue->data, priv->queue->len);
1.80 - priv->queue = g_byte_array_remove_range (priv->queue, 0, priv->queue->len);
1.81 + if (priv->send_chunked) {
1.82 + gchar *end_msg;
1.83 + end_msg = g_strdup ("0\r\n\r\n");
1.84 + write (priv->fd, (const guint8*) end_msg, strlen(end_msg) * sizeof(gchar));
1.85 + g_free (end_msg);
1.86 }
1.87 -
1.88 - end_msg = g_strdup ("0\r\n\r\n");
1.89 - write (priv->fd, (const guint8*) end_msg, strlen(end_msg) * sizeof(gchar));
1.90 - g_free (end_msg);
1.91 - return;
1.92 }
1.93 static void
1.94 _buffer_arrive_cb (GstElement* object,
1.95 @@ -1171,26 +1152,14 @@
1.96 {
1.97 GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
1.98
1.99 - if (GST_BUFFER_SIZE (buff) == 0)
1.100 - return;
1.101 -
1.102 - if (BUFFER_SIZE == 0) {
1.103 - if (_send_buffer (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE)
1.104 - goto error;
1.105 - return;
1.106 + if (priv->send_chunked) {
1.107 + if (_send_buffer (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE)
1.108 + goto error;
1.109 + } else {
1.110 + if (write (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) < 0)
1.111 + goto error;
1.112 }
1.113
1.114 - priv->queue = g_byte_array_append (priv->queue, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff));
1.115 - while (priv->queue->len >= BUFFER_SIZE) {
1.116 - if (priv->send_chunked) {
1.117 - if (_send_buffer (priv->fd, priv->queue->data, BUFFER_SIZE) == FALSE)
1.118 - goto error;
1.119 - } else {
1.120 - if (write (priv->fd, priv->queue->data, BUFFER_SIZE) == -1)
1.121 - goto error;
1.122 - }
1.123 - priv->queue = g_byte_array_remove_range (priv->queue, 0, BUFFER_SIZE);
1.124 - }
1.125 return;
1.126
1.127 error:
1.128 @@ -1198,7 +1167,6 @@
1.129 g_source_remove(priv->tick_id);
1.130 priv->tick_id = 0;
1.131 }
1.132 - priv->queue = g_byte_array_remove_range (priv->queue, 0, priv->queue->len);
1.133 g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Error on socket");
1.134 }
1.135 #endif