1.1 --- a/gmyth-stream/gmemcoder/configure.ac Wed Jul 04 21:53:29 2007 +0100
1.2 +++ b/gmyth-stream/gmemcoder/configure.ac Thu Jul 05 13:43:24 2007 +0100
1.3 @@ -60,6 +60,16 @@
1.4 AC_SUBST(GLIB_CFLAGS)
1.5 AC_SUBST(GLIB_LIBS)
1.6
1.7 +## Check for GnomeVFS ##########################################################
1.8 +###############################################################################
1.9 +PKG_CHECK_MODULES(GVFS, gnome-vfs-2.0, HAVE_GVFS=yes,HAVE_GVFS=no)
1.10 +if test "x$HAVE_GVFS" = "xno"; then
1.11 + AC_MSG_ERROR(you need gnome-vfs-2.0 installed)
1.12 +fi
1.13 +AC_SUBST(GVFS_CFLAGS)
1.14 +AC_SUBST(GVFS_LIBS)
1.15 +
1.16 +
1.17 ## Check for gst-base #########################################################
1.18 ###############################################################################
1.19 PKG_CHECK_MODULES(GST, [gstreamer-base-0.10])
2.1 --- a/gmyth-stream/gmemcoder/src/Makefile.am Wed Jul 04 21:53:29 2007 +0100
2.2 +++ b/gmyth-stream/gmemcoder/src/Makefile.am Thu Jul 05 13:43:24 2007 +0100
2.3 @@ -8,10 +8,12 @@
2.4
2.5 gmencoder_LDADD = \
2.6 $(GLIB_LIBS) \
2.7 - $(GST_LIBS)
2.8 + $(GST_LIBS) \
2.9 + $(GVFS_LIBS)
2.10
2.11 AM_CPPFLAGS = \
2.12 $(GLIB_CFLAGS) \
2.13 - $(GST_CFLAGS)
2.14 + $(GST_CFLAGS) \
2.15 + $(GVFS_CFLAGS)
2.16
2.17 CLEANFILES =
3.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.c Wed Jul 04 21:53:29 2007 +0100
3.2 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Thu Jul 05 13:43:24 2007 +0100
3.3 @@ -10,6 +10,7 @@
3.4 #include <string.h>
3.5 #include <sys/types.h>
3.6 #include <sys/socket.h>
3.7 +#include <libgnomevfs/gnome-vfs.h>
3.8
3.9 #include "gmencoder.h"
3.10
3.11 @@ -42,11 +43,13 @@
3.12 GstElement *vbin;
3.13 GstElement *sink;
3.14 GstElement *src;
3.15 +
3.16 + GnomeVFSHandle *handle;
3.17 +
3.18 gboolean ready;
3.19 SetupInfo *info;
3.20 GstClockTime videot;
3.21 GstClockTime audiot;
3.22 - gint fd;
3.23 gint sources;
3.24 gint tick_id;
3.25 gint64 duration;
3.26 @@ -666,10 +669,10 @@
3.27
3.28 if (priv->pipe != NULL) {
3.29 // TODO: fixe pipeline dispose
3.30 - gst_element_set_state (priv->pipe, GST_STATE_NULL);
3.31 + //gst_element_set_state (priv->pipe, GST_STATE_NULL);
3.32 // g_debug ("SETING STATE TO NULL: OK");
3.33 // gst_element_set_state (priv->pipe, GST_STATE_NULL);
3.34 - gst_object_unref (priv->pipe);
3.35 + //gst_object_unref (priv->pipe);
3.36 //gst_object_unref(priv->src);
3.37 priv->src = NULL;
3.38 priv->pipe = NULL;
3.39 @@ -714,8 +717,6 @@
3.40 vp = gst_element_factory_make("concatmux", "vp");
3.41 gst_bin_add_many(GST_BIN(pipe), ap, vp, NULL);
3.42 #endif
3.43 - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
3.44 -
3.45 mux =
3.46 gst_element_factory_make((mux_name ? mux_name : "ffmux_mpeg"),
3.47 "mux");
3.48 @@ -725,20 +726,12 @@
3.49 queue = gst_element_factory_make("queue", "queueu_sink");
3.50
3.51
3.52 -#ifdef USE_MANUAL_SINK
3.53 sink = gst_element_factory_make("fakesink", "sink");
3.54 g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL);
3.55 g_signal_connect (G_OBJECT (sink),
3.56 "handoff",
3.57 G_CALLBACK (_buffer_arrive_cb),
3.58 self);
3.59 -#else
3.60 - sink = gst_element_factory_make("fdsink", "sink");
3.61 - if (sink == NULL)
3.62 - goto error;
3.63 -
3.64 - g_object_set(G_OBJECT(sink), "fd", priv->fd, "sync", FALSE, NULL);
3.65 -#endif
3.66
3.67 abin = _create_audio_bin(audio_encode, audio_encode_prop, audio_rate);
3.68 if (abin == NULL)
3.69 @@ -929,36 +922,21 @@
3.70 static gboolean
3.71 _open_output(GMencoder * self, const gchar * uri)
3.72 {
3.73 - gboolean ret = TRUE;
3.74 gchar **i;
3.75 + GnomeVFSResult result;
3.76 GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
3.77
3.78 i = g_strsplit(uri, "://", 0);
3.79 if (strcmp(i[0], "fd") == 0) {
3.80 - priv->fd = atoi(i[1]);
3.81 - } else if (strcmp(i[0], "file") == 0) {
3.82 - if (g_file_test (i[1], G_FILE_TEST_EXISTS)) {
3.83 - if (unlink (i[1]) != 0) {
3.84 - g_warning ("Fail to write in : %s", uri);
3.85 - ret = FALSE;
3.86 - goto done;
3.87 - }
3.88 - }
3.89 - priv->fd = open(i[1], O_WRONLY | O_CREAT | O_TRUNC,
3.90 - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
3.91 + result = gnome_vfs_open_fd (&priv->handle, atoi(i[1]));
3.92 + } else {
3.93 + result = gnome_vfs_open (&priv->handle, uri,
3.94 + GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_TRUNCATE);
3.95
3.96 - if (priv->fd == -1) {
3.97 - g_warning ("Fail to open : %s", uri);
3.98 - ret = FALSE;
3.99 - }
3.100 - } else {
3.101 - g_warning("Output uri not supported");
3.102 - ret = FALSE;
3.103 }
3.104
3.105 -done:
3.106 g_strfreev(i);
3.107 - return ret;
3.108 + return (result == GNOME_VFS_OK);
3.109 }
3.110
3.111 static gboolean
3.112 @@ -1108,11 +1086,12 @@
3.113
3.114 #ifdef USE_MANUAL_SINK
3.115 static gboolean
3.116 -_send_buffer (gint fd, gpointer buff, gint size)
3.117 +_send_buffer (GnomeVFSHandle *handle, gpointer buff, gint size)
3.118 {
3.119 - gboolean ret = TRUE;
3.120 gchar *msg;
3.121 GByteArray *b_send;
3.122 + GnomeVFSResult result;
3.123 + GnomeVFSFileSize bytes_written;
3.124
3.125 b_send = g_byte_array_new ();
3.126 msg = g_strdup_printf ("%x\r\n", size);
3.127 @@ -1125,11 +1104,10 @@
3.128 b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar));
3.129 g_free (msg);
3.130
3.131 - if (send (fd, b_send->data, b_send->len, MSG_MORE) <= 0)
3.132 - ret = FALSE;
3.133 + result = gnome_vfs_write (handle, b_send->data, b_send->len, &bytes_written);
3.134 g_byte_array_free (b_send, TRUE);
3.135
3.136 - return ret;
3.137 + return (result == GNOME_VFS_OK);
3.138 }
3.139
3.140 static void
3.141 @@ -1138,12 +1116,17 @@
3.142 GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self);
3.143
3.144 if (priv->send_chunked) {
3.145 + GnomeVFSFileSize bytes_written;
3.146 gchar *end_msg;
3.147 end_msg = g_strdup ("0\r\n\r\n");
3.148 - write (priv->fd, (const guint8*) end_msg, strlen(end_msg) * sizeof(gchar));
3.149 + gnome_vfs_write (priv->handle,
3.150 + (const guint8*) end_msg,
3.151 + strlen(end_msg) * sizeof(gchar),
3.152 + &bytes_written);
3.153 g_free (end_msg);
3.154 }
3.155 }
3.156 +
3.157 static void
3.158 _buffer_arrive_cb (GstElement* object,
3.159 GstBuffer* buff,
3.160 @@ -1152,11 +1135,20 @@
3.161 {
3.162 GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data);
3.163
3.164 +
3.165 if (priv->send_chunked) {
3.166 - if (_send_buffer (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE)
3.167 + if (_send_buffer (priv->handle, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE)
3.168 goto error;
3.169 } else {
3.170 - if (write (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) < 0)
3.171 + GnomeVFSResult result;
3.172 + GnomeVFSFileSize bytes_written;
3.173 +
3.174 + result = gnome_vfs_write (priv->handle,
3.175 + GST_BUFFER_DATA (buff),
3.176 + GST_BUFFER_SIZE (buff),
3.177 + &bytes_written);
3.178 +
3.179 + if (result != GNOME_VFS_OK)
3.180 goto error;
3.181 }
3.182
3.183 @@ -1167,7 +1159,8 @@
3.184 g_source_remove(priv->tick_id);
3.185 priv->tick_id = 0;
3.186 }
3.187 - g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Error on socket");
3.188 + g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Fail to write on socket");
3.189 + gst_element_set_state (priv->pipe, GST_STATE_PAUSED);
3.190 }
3.191 #endif
3.192
4.1 --- a/gmyth-stream/gmemcoder/src/main.c Wed Jul 04 21:53:29 2007 +0100
4.2 +++ b/gmyth-stream/gmemcoder/src/main.c Thu Jul 05 13:43:24 2007 +0100
4.3 @@ -31,7 +31,7 @@
4.4
4.5
4.6
4.7 -static gboolean
4.8 +static gboolean
4.9 _quit(gpointer data)
4.10 {
4.11 //g_object_unref(data);