cpw.maiku.media_refactor: d78bdaf7: Start to use the media backend code in P...

maiku at pidgin.im maiku at pidgin.im
Thu Oct 22 22:36:17 EDT 2009


-----------------------------------------------------------------
Revision: d78bdaf73cc5e6b807e5b0eb262ea681a07c0bed
Ancestor: a397d9b0b7a76b624bdea50eaa4b8dc71cd9ae82
Author: maiku at pidgin.im
Date: 2009-10-23T02:11:33
Branch: im.pidgin.cpw.maiku.media_refactor
URL: http://d.pidgin.im/viewmtn/revision/info/d78bdaf73cc5e6b807e5b0eb262ea681a07c0bed

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

ChangeLog: 

Start to use the media backend code in PurpleMedia and PurpleMediaManager.

-------------- next part --------------
============================================================
--- libpurple/media/media.c	7db828aa88c86bd785659c29f1f8b84ae6dc8c89
+++ libpurple/media/media.c	8df8e99c3fbb09314b00448b36690be4f22eab6c
@@ -30,6 +30,8 @@
 
 #include "account.h"
 #include "media.h"
+#include "media/backend-fs2.h"
+#include "media/backend-iface.h"
 #include "mediamanager.h"
 #include "network.h"
 
@@ -108,6 +110,7 @@ struct _PurpleMediaPrivate
 #ifdef USE_VV
 	PurpleMediaManager *manager;
 	PurpleAccount *account;
+	PurpleMediaBackend *backend;
 	FsConference *conference;
 	gchar *conference_type;
 	gboolean initiator;
@@ -341,14 +344,9 @@ purple_media_dispose(GObject *media)
 
 	purple_media_manager_remove_media(priv->manager, PURPLE_MEDIA(media));
 
-	if (priv->confbin) {
-		gst_element_set_locked_state(priv->confbin, TRUE);
-		gst_element_set_state(GST_ELEMENT(priv->confbin),
-				GST_STATE_NULL);
-		gst_bin_remove(GST_BIN(purple_media_manager_get_pipeline(
-				priv->manager)), priv->confbin);
-		priv->confbin = NULL;
-		priv->conference = NULL;
+	if (priv->backend) {
+		g_object_unref(priv->backend);
+		priv->backend = NULL;
 	}
 
 	for (iter = priv->streams; iter; iter = g_list_next(iter)) {
@@ -413,36 +411,6 @@ static void
 }
 
 static void
-purple_media_setup_pipeline(PurpleMedia *media)
-{
-	GstBus *bus;
-	gchar *name;
-	GstElement *pipeline;
-
-	if (media->priv->conference == NULL || media->priv->manager == NULL)
-		return;
-
-	pipeline = purple_media_manager_get_pipeline(media->priv->manager);
-
-	name = g_strdup_printf("conf_%p",
-			media->priv->conference);
-	media->priv->confbin = gst_bin_new(name);
-	g_free(name);
-
-	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
-	g_signal_connect(G_OBJECT(bus), "message",
-			G_CALLBACK(media_bus_call), media);
-	gst_object_unref(bus);
-
-	gst_bin_add(GST_BIN(pipeline),
-			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);
-}
-
-static void
 purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
 	PurpleMedia *media;
@@ -452,10 +420,7 @@ purple_media_set_property (GObject *obje
 
 	switch (prop_id) {
 		case PROP_MANAGER:
-			media->priv->manager = g_value_get_object(value);
-			g_object_ref(media->priv->manager);
-
-			purple_media_setup_pipeline(media);
+			media->priv->manager = g_value_dup_object(value);
 			break;
 		case PROP_ACCOUNT:
 			media->priv->account = g_value_get_pointer(value);
@@ -463,15 +428,19 @@ purple_media_set_property (GObject *obje
 		case PROP_CONFERENCE: {
 			if (media->priv->conference)
 				gst_object_unref(media->priv->conference);
-			media->priv->conference = g_value_get_object(value);
-			gst_object_ref(media->priv->conference);
-
-			purple_media_setup_pipeline(media);
+			media->priv->conference = g_value_dup_object(value);
 			break;
 		}
 		case PROP_CONFERENCE_TYPE:
 			media->priv->conference_type =
 					g_value_dup_string(value);
+			/* Will eventually get this type from the media manager */
+			media->priv->backend = g_object_new(
+					PURPLE_TYPE_MEDIA_BACKEND_FS2,
+					"conference-type",
+					media->priv->conference_type,
+					"media", media,
+					NULL);
 			break;
 		case PROP_INITIATOR:
 			media->priv->initiator = g_value_get_boolean(value);
@@ -1630,6 +1599,30 @@ purple_media_add_stream(PurpleMedia *med
 
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
 
+	if (!purple_media_backend_add_stream(media->priv->backend,
+			sess_id, who, type, initiator, transmitter,
+			num_params, params)) {
+		purple_debug_error("media", "Error adding stream.\n");
+		return FALSE;
+	}
+
+	/* XXX: Temporary call while integrating with backend */
+	if (media->priv->conference == NULL) {
+		GstBus *bus;
+		media->priv->conference =
+				purple_media_backend_fs2_get_conference(
+				PURPLE_MEDIA_BACKEND_FS2(
+				media->priv->backend));
+		media->priv->confbin = GST_ELEMENT_PARENT(
+				media->priv->conference);
+		bus = gst_pipeline_get_bus(GST_PIPELINE(
+				purple_media_manager_get_pipeline(
+				purple_media_manager_get())));
+		g_signal_connect(G_OBJECT(bus), "message",
+				G_CALLBACK(media_bus_call), media);
+		gst_object_unref(bus);
+	}
+
 	session = purple_media_get_session(media, sess_id);
 
 	if (!session) {
============================================================
--- libpurple/mediamanager.c	67c3ee4bb556e36af74dffe13ea9803e9602d6ef
+++ libpurple/mediamanager.c	d6034723c9ed7f7a5b8c6c2b34d3c417c6fd3d3c
@@ -38,7 +38,6 @@
 
 #ifdef USE_VV
 
-#include <gst/farsight/fs-conference-iface.h>
 #include <gst/farsight/fs-element-added-notifier.h>
 #include <gst/interfaces/xoverlay.h>
 
@@ -314,34 +313,15 @@ purple_media_manager_create_media(Purple
 {
 #ifdef USE_VV
 	PurpleMedia *media;
-	FsConference *conference = FS_CONFERENCE(gst_element_factory_make(conference_type, NULL));
-	GstStateChangeReturn ret;
 	gboolean signal_ret;
 
-	if (conference == NULL) {
-		purple_conv_present_error(remote_user, account,
-					  _("Error creating conference."));
-		purple_debug_error("media", "Conference == NULL\n");
-		return NULL;
-	}
-
 	media = PURPLE_MEDIA(g_object_new(purple_media_get_type(),
 			     "manager", manager,
 			     "account", account,
-			     "conference", conference,
+			     "conference-type", conference_type,
 			     "initiator", initiator,
 			     NULL));
 
-	ret = gst_element_set_state(GST_ELEMENT(conference), GST_STATE_PLAYING);
-
-	if (ret == GST_STATE_CHANGE_FAILURE) {
-		purple_conv_present_error(remote_user, account,
-					  _("Error creating conference."));
-		purple_debug_error("media", "Failed to start conference.\n");
-		g_object_unref(media);
-		return NULL;
-	}
-
 	g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0,
 			media, account, remote_user, &signal_ret);
 


More information about the Commits mailing list