pidgin.vv: 3f14ad69: Have all media sessions use a single pip...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sat Jan 31 00:40:29 EST 2009


-----------------------------------------------------------------
Revision: 3f14ad697ec671727f1f36001b1042dab0c26e05
Ancestor: b1f78f7a0182066a48414e2907c9d606a4363225
Author: maiku at soc.pidgin.im
Date: 2009-01-31T05:19:16
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/3f14ad697ec671727f1f36001b1042dab0c26e05

Modified files:
        libpurple/media.c libpurple/mediamanager.c pidgin/gtkmedia.c

ChangeLog: 

Have all media sessions use a single pipeline.
This temporarily breaks the audio levels.

-------------- next part --------------
============================================================
--- libpurple/media.c	9386a2980ee11135fc5a28fbdc00ae2bc8e205f1
+++ libpurple/media.c	2b59709555690b7d98e2e6846dcdbfab6277f297
@@ -92,7 +92,7 @@ struct _PurpleMediaPrivate
 	GList *streams;		/* PurpleMediaStream table */
 
 	GstElement *pipeline;
-	
+	GstElement *confbin;
 };
 
 #define PURPLE_MEDIA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA, PurpleMediaPrivate))
@@ -270,13 +270,12 @@ purple_media_dispose(GObject *media)
 	purple_media_manager_remove_media(purple_media_manager_get(),
 			PURPLE_MEDIA(media));
 
-	if (priv->pipeline) {
-		GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(priv->pipeline));
-		gst_bus_remove_signal_watch(bus);
-		gst_object_unref(bus);
-		gst_element_set_state(priv->pipeline, GST_STATE_NULL);
-		gst_object_unref(priv->pipeline);
-		priv->pipeline = NULL;
+	if (priv->confbin) {
+		gst_element_set_state(GST_ELEMENT(priv->confbin),
+				GST_STATE_NULL);
+		gst_bin_remove(GST_BIN(priv->pipeline), priv->confbin);
+		priv->confbin = NULL;
+		priv->conference = NULL;
 	}
 
 	for (iter = priv->streams; iter; iter = g_list_next(iter)) {
@@ -324,8 +323,6 @@ purple_media_finalize(GObject *media)
 		g_hash_table_destroy(priv->sessions);
 	}
 
-	gst_object_unref(priv->conference);
-
 	G_OBJECT_CLASS(parent_class)->finalize(media);
 }
 
@@ -338,12 +335,28 @@ purple_media_set_property (GObject *obje
 	media = PURPLE_MEDIA(object);
 
 	switch (prop_id) {
-		case PROP_CONFERENCE:
+		case PROP_CONFERENCE: {
+			gchar *name;
+
 			if (media->priv->conference)
-				g_object_unref(media->priv->conference);
+				gst_object_unref(media->priv->conference);
 			media->priv->conference = g_value_get_object(value);
-			g_object_ref(media->priv->conference);
+			gst_object_ref(media->priv->conference);
+
+			name = g_strdup_printf("conf_%p",
+					media->priv->conference);
+			media->priv->confbin = gst_bin_new(name);
+			g_free(name);
+			gst_bin_add(GST_BIN(purple_media_get_pipeline(media)),
+					media->priv->confbin);
+			gst_bin_add(GST_BIN(media->priv->confbin),
+					GST_ELEMENT(media->priv->conference));
+
+			gst_element_set_state(GST_ELEMENT(
+					media->priv->confbin),
+					GST_STATE_PLAYING);
 			break;
+		}
 		case PROP_INITIATOR:
 			media->priv->initiator = g_value_get_boolean(value);
 			break;
@@ -981,7 +994,7 @@ purple_media_set_src(PurpleMedia *media,
 	if (session->src)
 		gst_object_unref(session->src);
 	session->src = src;
-	gst_bin_add(GST_BIN(purple_media_get_pipeline(media)),
+	gst_bin_add(GST_BIN(session->media->priv->confbin),
 		    session->src);
 
 	g_object_get(session->session, "sink-pad", &sinkpad, NULL);
@@ -1001,7 +1014,7 @@ purple_media_set_sink(PurpleMedia *media
 	if (stream->sink)
 		gst_object_unref(stream->sink);
 	stream->sink = sink;
-	gst_bin_add(GST_BIN(purple_media_get_pipeline(media)),
+	gst_bin_add(GST_BIN(stream->session->media->priv->confbin),
 		    stream->sink);
 }
 
@@ -1090,7 +1103,7 @@ static gboolean
 }
 
 static gboolean
-media_bus_call(GstBus *bus, GstMessage *msg, gpointer media)
+media_bus_call(GstBus *bus, GstMessage *msg, gpointer dummy)
 {
 	switch(GST_MESSAGE_TYPE(msg)) {
 		case GST_MESSAGE_EOS:
@@ -1112,6 +1125,19 @@ media_bus_call(GstBus *bus, GstMessage *
 			break;
 		}
 		case GST_MESSAGE_ELEMENT: {
+			PurpleMedia *media = NULL;
+			if (FS_IS_CONFERENCE(GST_MESSAGE_SRC(msg))) {
+				GList *iter = purple_media_manager_get_media(
+						purple_media_manager_get());
+				for (; iter; iter = g_list_next(iter)) {
+					if (PURPLE_MEDIA(iter->data)->priv->conference
+							== FS_CONFERENCE(GST_MESSAGE_SRC(msg))) {
+						media = iter->data;
+						break;
+					}
+				}
+			}
+
 			if (gst_structure_has_name(msg->structure, "farsight-error")) {
 				FsError error_no;
 				gst_structure_get_enum(msg->structure, "error-no",
@@ -1189,19 +1215,21 @@ purple_media_get_pipeline(PurpleMedia *m
 GstElement *
 purple_media_get_pipeline(PurpleMedia *media)
 {
-	if (!media->priv->pipeline) {
+	static GstElement *pipeline = NULL;
+
+	if (!pipeline) {
 		GstBus *bus;
-		media->priv->pipeline = gst_pipeline_new(NULL);
+		media->priv->pipeline = pipeline = gst_pipeline_new(NULL);
 		bus = gst_pipeline_get_bus(GST_PIPELINE(media->priv->pipeline));
 		gst_bus_add_signal_watch(GST_BUS(bus));
 		g_signal_connect(G_OBJECT(bus), "message",
-				G_CALLBACK(media_bus_call), media);
+				G_CALLBACK(media_bus_call), NULL);
 		gst_bus_set_sync_handler(bus, gst_bus_sync_signal_handler, NULL);
 		gst_object_unref(bus);
-
-		gst_bin_add(GST_BIN(media->priv->pipeline), GST_ELEMENT(media->priv->conference));
+		gst_element_set_state(pipeline, GST_STATE_PLAYING);
 	}
 
+	media->priv->pipeline = pipeline;
 	return media->priv->pipeline;
 }
 
@@ -1545,7 +1573,7 @@ purple_media_src_pad_added_cb(FsStream *
 		stream->sink = purple_media_manager_get_element(
 			purple_media_manager_get(), type);
 
-	gst_bin_add(GST_BIN(purple_media_get_pipeline(stream->session->media)),
+	gst_bin_add(GST_BIN(stream->session->media->priv->confbin),
 		    stream->sink);
 	sinkpad = gst_element_get_static_pad(stream->sink, "ghostsink");
 	gst_pad_link(srcpad, sinkpad);
============================================================
--- libpurple/mediamanager.c	f1dc415edc2f32c733bbd11bf48002c970b479f9
+++ libpurple/mediamanager.c	bd8bbab65a636cde7d76faa09710c2f3e1f1e0ac
@@ -161,7 +161,7 @@ purple_media_manager_create_media(Purple
 			     "initiator", initiator,
 			     NULL));
 
-	ret = gst_element_set_state(purple_media_get_pipeline(media), GST_STATE_PLAYING);
+	ret = gst_element_set_state(GST_ELEMENT(conference), GST_STATE_PLAYING);
 
 	if (ret == GST_STATE_CHANGE_FAILURE) {
 		purple_conv_present_error(remote_user,
============================================================
--- pidgin/gtkmedia.c	4a4ae6ec6e1617f6274918dbfdccd694639e86ef
+++ pidgin/gtkmedia.c	8ffd886e2707377a7a610b53cfbc2f728c2085aa
@@ -227,25 +227,30 @@ level_message_cb(GstBus *bus, GstMessage
 static gboolean
 level_message_cb(GstBus *bus, GstMessage *message, PidginMedia *gtkmedia)
 {
-	const GstStructure *s;
-	gchar *name;
-
 	gdouble rms_db;
 	gdouble percent;
 	const GValue *list;
 	const GValue *value;
 
 	GstElement *src = GST_ELEMENT(GST_MESSAGE_SRC(message));
+	GtkWidget *progress;
 
 	if (message->type != GST_MESSAGE_ELEMENT)
 		return TRUE;
 
-	s = gst_message_get_structure(message);
+	if (gst_structure_has_name(
+			gst_message_get_structure(message), "level"))
+		return TRUE;
 
-	if (strcmp(gst_structure_get_name(s), "level"))
+	if (src == gtkmedia->priv->send_level)
+		progress = gtkmedia->priv->send_progress;
+	else if (src == gtkmedia->priv->recv_level)
+		progress = gtkmedia->priv->recv_progress;
+	else
 		return TRUE;
 
-	list = gst_structure_get_value(s, "rms");
+	list = gst_structure_get_value(
+			gst_message_get_structure(message), "rms");
 
 	/* Only bother with the first channel. */
 	value = gst_value_list_get_value(list, 0);
@@ -256,13 +261,7 @@ level_message_cb(GstBus *bus, GstMessage
 	if(percent > 1.0)
 		percent = 1.0;
 
-	name = gst_element_get_name(src);
-	if (!strcmp(name, "sendlevel"))	
-		gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtkmedia->priv->send_progress), percent);
-	else
-		gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtkmedia->priv->recv_progress), percent);
-
-	g_free(name);
+	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), percent);
 	return TRUE;
 }
 


More information about the Commits mailing list