# HG changeset patch # User renatofilho # Date 1183639404 -3600 # Node ID a4529d0f8ede3f6157fcdabd4dfadff4b2f8f6b1 # Parent fcca44a5124392297ca3fd430413273fa30632ba [svn r792] fixed bug on live diff -r fcca44a51243 -r a4529d0f8ede gmyth-stream/gmemcoder/configure.ac --- a/gmyth-stream/gmemcoder/configure.ac Wed Jul 04 21:53:29 2007 +0100 +++ b/gmyth-stream/gmemcoder/configure.ac Thu Jul 05 13:43:24 2007 +0100 @@ -60,6 +60,16 @@ AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) +## Check for GnomeVFS ########################################################## +############################################################################### +PKG_CHECK_MODULES(GVFS, gnome-vfs-2.0, HAVE_GVFS=yes,HAVE_GVFS=no) +if test "x$HAVE_GVFS" = "xno"; then + AC_MSG_ERROR(you need gnome-vfs-2.0 installed) +fi +AC_SUBST(GVFS_CFLAGS) +AC_SUBST(GVFS_LIBS) + + ## Check for gst-base ######################################################### ############################################################################### PKG_CHECK_MODULES(GST, [gstreamer-base-0.10]) diff -r fcca44a51243 -r a4529d0f8ede gmyth-stream/gmemcoder/src/Makefile.am --- a/gmyth-stream/gmemcoder/src/Makefile.am Wed Jul 04 21:53:29 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/Makefile.am Thu Jul 05 13:43:24 2007 +0100 @@ -8,10 +8,12 @@ gmencoder_LDADD = \ $(GLIB_LIBS) \ - $(GST_LIBS) + $(GST_LIBS) \ + $(GVFS_LIBS) AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ - $(GST_CFLAGS) + $(GST_CFLAGS) \ + $(GVFS_CFLAGS) CLEANFILES = diff -r fcca44a51243 -r a4529d0f8ede gmyth-stream/gmemcoder/src/gmencoder.c --- a/gmyth-stream/gmemcoder/src/gmencoder.c Wed Jul 04 21:53:29 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Thu Jul 05 13:43:24 2007 +0100 @@ -10,6 +10,7 @@ #include #include #include +#include #include "gmencoder.h" @@ -42,11 +43,13 @@ GstElement *vbin; GstElement *sink; GstElement *src; + + GnomeVFSHandle *handle; + gboolean ready; SetupInfo *info; GstClockTime videot; GstClockTime audiot; - gint fd; gint sources; gint tick_id; gint64 duration; @@ -666,10 +669,10 @@ if (priv->pipe != NULL) { // TODO: fixe pipeline dispose - gst_element_set_state (priv->pipe, GST_STATE_NULL); + //gst_element_set_state (priv->pipe, GST_STATE_NULL); // g_debug ("SETING STATE TO NULL: OK"); // gst_element_set_state (priv->pipe, GST_STATE_NULL); - gst_object_unref (priv->pipe); + //gst_object_unref (priv->pipe); //gst_object_unref(priv->src); priv->src = NULL; priv->pipe = NULL; @@ -714,8 +717,6 @@ vp = gst_element_factory_make("concatmux", "vp"); gst_bin_add_many(GST_BIN(pipe), ap, vp, NULL); #endif - GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - mux = gst_element_factory_make((mux_name ? mux_name : "ffmux_mpeg"), "mux"); @@ -725,20 +726,12 @@ queue = gst_element_factory_make("queue", "queueu_sink"); -#ifdef USE_MANUAL_SINK sink = gst_element_factory_make("fakesink", "sink"); g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL); g_signal_connect (G_OBJECT (sink), "handoff", G_CALLBACK (_buffer_arrive_cb), self); -#else - sink = gst_element_factory_make("fdsink", "sink"); - if (sink == NULL) - goto error; - - g_object_set(G_OBJECT(sink), "fd", priv->fd, "sync", FALSE, NULL); -#endif abin = _create_audio_bin(audio_encode, audio_encode_prop, audio_rate); if (abin == NULL) @@ -929,36 +922,21 @@ static gboolean _open_output(GMencoder * self, const gchar * uri) { - gboolean ret = TRUE; gchar **i; + GnomeVFSResult result; GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); i = g_strsplit(uri, "://", 0); if (strcmp(i[0], "fd") == 0) { - priv->fd = atoi(i[1]); - } else if (strcmp(i[0], "file") == 0) { - if (g_file_test (i[1], G_FILE_TEST_EXISTS)) { - if (unlink (i[1]) != 0) { - g_warning ("Fail to write in : %s", uri); - ret = FALSE; - goto done; - } - } - priv->fd = open(i[1], O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + result = gnome_vfs_open_fd (&priv->handle, atoi(i[1])); + } else { + result = gnome_vfs_open (&priv->handle, uri, + GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_TRUNCATE); - if (priv->fd == -1) { - g_warning ("Fail to open : %s", uri); - ret = FALSE; - } - } else { - g_warning("Output uri not supported"); - ret = FALSE; } -done: g_strfreev(i); - return ret; + return (result == GNOME_VFS_OK); } static gboolean @@ -1108,11 +1086,12 @@ #ifdef USE_MANUAL_SINK static gboolean -_send_buffer (gint fd, gpointer buff, gint size) +_send_buffer (GnomeVFSHandle *handle, gpointer buff, gint size) { - gboolean ret = TRUE; gchar *msg; GByteArray *b_send; + GnomeVFSResult result; + GnomeVFSFileSize bytes_written; b_send = g_byte_array_new (); msg = g_strdup_printf ("%x\r\n", size); @@ -1125,11 +1104,10 @@ b_send = g_byte_array_append (b_send, (const guint8*) msg, strlen (msg) * sizeof (gchar)); g_free (msg); - if (send (fd, b_send->data, b_send->len, MSG_MORE) <= 0) - ret = FALSE; + result = gnome_vfs_write (handle, b_send->data, b_send->len, &bytes_written); g_byte_array_free (b_send, TRUE); - return ret; + return (result == GNOME_VFS_OK); } static void @@ -1138,12 +1116,17 @@ GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); if (priv->send_chunked) { + GnomeVFSFileSize bytes_written; gchar *end_msg; end_msg = g_strdup ("0\r\n\r\n"); - write (priv->fd, (const guint8*) end_msg, strlen(end_msg) * sizeof(gchar)); + gnome_vfs_write (priv->handle, + (const guint8*) end_msg, + strlen(end_msg) * sizeof(gchar), + &bytes_written); g_free (end_msg); } } + static void _buffer_arrive_cb (GstElement* object, GstBuffer* buff, @@ -1152,11 +1135,20 @@ { GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); + if (priv->send_chunked) { - if (_send_buffer (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE) + if (_send_buffer (priv->handle, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE) goto error; } else { - if (write (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) < 0) + GnomeVFSResult result; + GnomeVFSFileSize bytes_written; + + result = gnome_vfs_write (priv->handle, + GST_BUFFER_DATA (buff), + GST_BUFFER_SIZE (buff), + &bytes_written); + + if (result != GNOME_VFS_OK) goto error; } @@ -1167,7 +1159,8 @@ g_source_remove(priv->tick_id); priv->tick_id = 0; } - g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Error on socket"); + g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Fail to write on socket"); + gst_element_set_state (priv->pipe, GST_STATE_PAUSED); } #endif diff -r fcca44a51243 -r a4529d0f8ede gmyth-stream/gmemcoder/src/main.c --- a/gmyth-stream/gmemcoder/src/main.c Wed Jul 04 21:53:29 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/main.c Thu Jul 05 13:43:24 2007 +0100 @@ -31,7 +31,7 @@ -static gboolean +static gboolean _quit(gpointer data) { //g_object_unref(data);