changeset 23918:9ff63ec7d869

merge of '3fd2b0bf399bc4820c027060ec6c82ed1ca6ca45' and 'afa3dc92175256438bf5eb8acb7876eddc64ba01'
author Mike Ruprecht <maiku@soc.pidgin.im>
date Wed, 27 Aug 2008 00:12:57 +0000
parents 4a208844bb63 (diff) 9632027d3b50 (current diff)
children 4b8c64deac5e
files libpurple/media.c
diffstat 2 files changed, 28 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntmedia.c	Wed Aug 27 00:08:38 2008 +0000
+++ b/finch/gntmedia.c	Wed Aug 27 00:12:57 2008 +0000
@@ -162,6 +162,10 @@
 static void
 finch_media_finalize (GObject *media)
 {
+	FinchMedia *gntmedia = FINCH_MEDIA(media);
+	purple_debug_info("gntmedia", "finch_media_finalize\n");
+	if (gntmedia->priv->media)
+		g_object_unref(gntmedia->priv->media);
 }
 
 static void
@@ -170,55 +174,9 @@
 	g_signal_emit(gntmedia, finch_media_signals[MESSAGE], 0, msg);
 }
 
-static gboolean
-level_message_cb(GstBus *bus, GstMessage *message, FinchMedia *gntmedia)
-{
-	/* XXX: I am hesitant to just remove this function altogether, because I don't
-	 * know how necessary it is to have a callback to 'message'. If it isn't essential,
-	 * I suppose this should be removed.
-	 */
-	return TRUE;
-#if 0
-	const GstStructure *s;
-	const gchar *name;
-
-	int channels;
-	gdouble rms_db, peak_db, decay_db;
-	gdouble rms;
-	const GValue *list;
-	const GValue *value;
-
-	GstElement *src = GST_ELEMENT(message);
-
-	if (message->type != GST_MESSAGE_ELEMENT)
-		return TRUE;
-
-	s = gst_message_get_structure(message);
-	name = gst_structure_get_name(s);
-
-	if (strcmp(name, "level"))
-		return TRUE;
-
-	list = gst_structure_get_value(s, "rms");
-
-	/* Only bother with the first channel. */
-	value = gst_value_list_get_value(list, 0);
-	rms_db = g_value_get_double(value);
-
-	if (!strcmp(gst_element_get_name(src), "sendlevel"))
-		gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gntmedia->priv->send_progress), pow(10, rms_db / 20) * 5);
-	else
-		gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gntmedia->priv->recv_progress), pow(10, rms_db / 20) * 5);
-
-	return TRUE;
-#endif
-}
-
 static void
 finch_media_ready_cb(PurpleMedia *media, FinchMedia *gntmedia)
 {
-	GstElement *element = purple_media_get_pipeline(media);
-
 	GstElement *sendbin, *sendlevel;
 	GstElement *recvbin, *recvlevel;
 
@@ -233,18 +191,16 @@
 	}
 	g_list_free(sessions);
 
-	g_object_set(gntmedia, "send-level", &sendlevel,
-		     "recv-level", &recvlevel,
+	g_object_set(gntmedia, "send-level", sendlevel,
+		     "recv-level", recvlevel,
 		     NULL);
-
-	gst_bus_add_signal_watch(GST_BUS(gst_pipeline_get_bus(GST_PIPELINE(element))));
-	g_signal_connect(G_OBJECT(gst_pipeline_get_bus(GST_PIPELINE(element))), "message", G_CALLBACK(level_message_cb), gntmedia);
 }
 
 static void
 finch_media_accept_cb(PurpleMedia *media, FinchMedia *gntmedia)
 {
 	GntWidget *parent;
+	GstElement *sendbin = NULL, *recvbin = NULL;
 
 	finch_media_emit_message(gntmedia, _("Call in progress."));
 
@@ -267,6 +223,10 @@
 		parent = parent->parent;
 	gnt_box_readjust(GNT_BOX(parent));
 	gnt_widget_draw(parent);
+
+	purple_media_get_elements(media, &sendbin, &recvbin, NULL, NULL);
+	gst_element_set_state(GST_ELEMENT(sendbin), GST_STATE_PLAYING);
+	gst_element_set_state(GST_ELEMENT(recvbin), GST_STATE_PLAYING);
 }
 
 static void
@@ -282,11 +242,6 @@
 	gnt_box_add_widget(GNT_BOX(gntmedia), gntmedia->priv->calling);
 	gnt_box_add_widget(GNT_BOX(gntmedia), gntmedia->priv->hangup);
 
-	gnt_widget_destroy(gntmedia->priv->accept);
-	gnt_widget_destroy(gntmedia->priv->reject);
-	gntmedia->priv->accept = NULL;
-	gntmedia->priv->reject = NULL;
-
 	parent = GNT_WIDGET(gntmedia);
 	while (parent->parent)
 		parent = parent->parent;
@@ -300,6 +255,8 @@
 	finch_media_emit_message(gntmedia, _("You have ended the call."));
 	finch_conversation_set_info_widget(gntmedia->priv->conv, NULL);
 	gnt_widget_destroy(GNT_WIDGET(gntmedia));
+	/* XXX: This shouldn't have to be here to free the FinchMedia widget */
+	g_object_unref(gntmedia);
 }
 
 static void
@@ -308,6 +265,8 @@
 	finch_media_emit_message(gntmedia, _("The call has been terminated."));
 	finch_conversation_set_info_widget(gntmedia->priv->conv, NULL);
 	gnt_widget_destroy(GNT_WIDGET(gntmedia));
+	/* XXX: This shouldn't have to be here to free the FinchMedia widget */
+	g_object_unref(gntmedia);
 }
 
 static void
@@ -316,6 +275,8 @@
 	finch_media_emit_message(gntmedia, _("You have rejected the call."));
 	finch_conversation_set_info_widget(gntmedia->priv->conv, NULL);
 	gnt_widget_destroy(GNT_WIDGET(gntmedia));
+	/* XXX: This shouldn't have to be here to free the FinchMedia widget */
+	g_object_unref(gntmedia);
 }
 
 static void
@@ -436,10 +397,9 @@
 {
 	PurpleAccount *account = purple_conversation_get_account(conv);
 
-	PurpleMedia *media =
-		purple_prpl_initiate_media(account,
-							purple_conversation_get_name(conv),
-							PURPLE_MEDIA_RECV_AUDIO & PURPLE_MEDIA_SEND_AUDIO);
+	PurpleMedia *media = purple_prpl_initiate_media(account,
+			purple_conversation_get_name(conv),
+			PURPLE_MEDIA_AUDIO);
 
 	if (!media)
 		return PURPLE_CMD_STATUS_FAILED;
--- a/libpurple/media.c	Wed Aug 27 00:08:38 2008 +0000
+++ b/libpurple/media.c	Wed Aug 27 00:12:57 2008 +0000
@@ -822,6 +822,14 @@
 			}
 			g_value_array_free(array);
 		}
+
+		/* Restore autoprobe[-fps] to TRUE. */
+		if (g_object_class_find_property (klass, "autoprobe")) {
+			g_object_set (G_OBJECT (element), "autoprobe", TRUE, NULL);
+			if (g_object_class_find_property (klass, "autoprobe-fps")) {
+				g_object_set (G_OBJECT (element), "autoprobe-fps", TRUE, NULL);
+			}
+		}
 	}
 
 	return ret;