diff -r 43f66895cc86 -r a4fb2dd520ba gmyth-stream/gmemcoder/src/gmencoder.c --- a/gmyth-stream/gmemcoder/src/gmencoder.c Tue May 08 14:59:15 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Wed May 16 00:16:07 2007 +0100 @@ -46,6 +46,7 @@ GstClockTime audiot; gint fd; gint sources; + gint tick_id; }; enum { @@ -100,6 +101,8 @@ const gchar* audio_encode, gchar** audio_encode_prop, guint audio_rate); +static gboolean _tick_cb (gpointer data); + @@ -604,6 +607,8 @@ g_return_if_fail (priv->ready == FALSE); priv->ready = TRUE; gst_element_set_state (priv->pipe, GST_STATE_PLAYING); + + priv->tick_id = g_timeout_add (500, _tick_cb, self); } void @@ -622,6 +627,11 @@ GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (self); g_debug ("g_mencoder_close_stream"); + if (priv->tick_id != 0) { + g_source_remove (priv->tick_id); + priv->tick_id = 0; + } + if (priv->pipe != NULL) { gst_element_set_state (priv->pipe, GST_STATE_NULL); gst_object_unref (priv->pipe); @@ -631,6 +641,8 @@ priv->sink = NULL; } priv->ready = FALSE; + + } static GstElement* @@ -937,8 +949,11 @@ priv->ready = FALSE; g_signal_emit (user_data, g_mencoder_signals[EOS], 0); break; + default: + { break; + } } return TRUE; } @@ -985,3 +1000,20 @@ g_warning ("Unknown Type"); //priv->ready = FALSE; } + +static gboolean +_tick_cb (gpointer user_data) +{ + GstFormat format = GST_FORMAT_TIME; + gint64 cur = 0; + gint64 duration = 0; + + GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE (user_data); + + if (gst_element_query_duration (priv->pipe, &format, &duration)) { + gst_element_query_position (priv->pipe, &format, &cur); + g_print ("PROGRESS:%lli%\n", (100 * cur) / duration); + } + + return TRUE; +}