pidgin.vv: 74fbda39: Implement functions to register and unre...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Wed Feb 4 19:20:27 EST 2009


-----------------------------------------------------------------
Revision: 74fbda391dc83de12c1b07902b833104635899da
Ancestor: 398a4a3861f7eaf401b092a666b8899287ec070c
Author: maiku at soc.pidgin.im
Date: 2009-02-03T22:37:24
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/74fbda391dc83de12c1b07902b833104635899da

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

ChangeLog: 

Implement functions to register and unregister media elements for use in 
allowing plugins and GUIs to alter the pipeline.

-------------- next part --------------
============================================================
--- libpurple/mediamanager.c	bd8bbab65a636cde7d76faa09710c2f3e1f1e0ac
+++ libpurple/mediamanager.c	2f5c3098b0b030170b62fb82f47198e0b66a790a
@@ -39,6 +39,7 @@ struct _PurpleMediaManagerPrivate
 struct _PurpleMediaManagerPrivate
 {
 	GList *medias;
+	GList *elements;
 };
 
 #define PURPLE_MEDIA_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA_MANAGER, PurpleMediaManagerPrivate))
@@ -123,6 +124,8 @@ purple_media_manager_finalize (GObject *
 			g_list_delete_link(priv->medias, priv->medias)) {
 		g_object_unref(priv->medias->data);
 	}
+	for (; priv->elements; priv->elements =
+			g_list_delete_link(priv->elements, priv->elements));
 	parent_class->finalize(media);
 }
 
@@ -225,4 +228,56 @@ purple_media_manager_get_element(PurpleM
 	return ret;
 }
 
+PurpleMediaElementInfo *
+purple_media_manager_get_element_info(PurpleMediaManager *manager,
+		const gchar *id)
+{
+	GList *iter;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager), NULL);
+
+	iter = manager->priv->elements;
+
+	for (; iter; iter = g_list_next(iter)) {
+		PurpleMediaElementInfo *info = iter->data;
+		if (!strcmp(info->id, id))
+			return info;
+	}
+
+	return NULL;
+}
+
+gboolean
+purple_media_manager_register_element(PurpleMediaManager *manager,
+		PurpleMediaElementInfo *info)
+{
+	g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager), FALSE);
+	g_return_val_if_fail(info != NULL, FALSE);
+
+	if (purple_media_manager_get_element_info(manager, info->id) != NULL)
+		return FALSE;
+
+	manager->priv->elements =
+			g_list_prepend(manager->priv->elements, info);
+	return TRUE;
+}
+
+gboolean
+purple_media_manager_unregister_element(PurpleMediaManager *manager,
+		const gchar *id)
+{
+	PurpleMediaElementInfo *info;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager), FALSE);
+
+	info = purple_media_manager_get_element_info(manager, id);
+
+	if (info == NULL)
+		return FALSE;
+
+	manager->priv->elements = g_list_remove(
+			manager->priv->elements, info);
+	return TRUE;
+}
+
 #endif  /* USE_VV */
============================================================
--- libpurple/mediamanager.h	409bd7e9a50c30262cccb7365e277d9bfba4df79
+++ libpurple/mediamanager.h	cb1ec9bd4df19e95752f0e2c13024ef0742cd413
@@ -50,6 +50,8 @@ typedef struct _PurpleMediaManagerPrivat
 typedef struct _PurpleMediaManagerClass PurpleMediaManagerClass;
 /** @copydoc _PurpleMediaManagerPrivate */
 typedef struct _PurpleMediaManagerPrivate PurpleMediaManagerPrivate;
+/** @copydoc _PurpleMediaElementInfo */
+typedef struct _PurpleMediaElementInfo PurpleMediaElementInfo;
 
 /** The media manager class. */
 struct _PurpleMediaManagerClass
@@ -64,6 +66,11 @@ struct _PurpleMediaManager
 	PurpleMediaManagerPrivate *priv; /**< Private data for the manager. */
 };
 
+struct _PurpleMediaElementInfo
+{
+	const gchar *id;
+};
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -131,6 +138,12 @@ GstElement *purple_media_manager_get_ele
 GstElement *purple_media_manager_get_element(PurpleMediaManager *manager,
 		PurpleMediaSessionType type);
 
+PurpleMediaElementInfo *purple_media_manager_get_element_info(
+		PurpleMediaManager *manager, const gchar *name);
+gboolean purple_media_manager_register_element(PurpleMediaManager *manager,
+		PurpleMediaElementInfo *info);
+gboolean purple_media_manager_unregister_element(PurpleMediaManager *manager,
+		const gchar *name);
 /*}@*/
 
 #ifdef __cplusplus
============================================================
--- pidgin/gtkmedia.c	a0d4df73e95968bd7733bfa07aafbf2170a59fe7
+++ pidgin/gtkmedia.c	2d533c03d25538e9c3aa16aea374af2d62c9903d
@@ -785,11 +785,38 @@ pidgin_media_new_cb(PurpleMediaManager *
 	return TRUE;
 }
 
+static PurpleMediaElementInfo default_video_src =
+{
+	"pidgindefaultvideosrc",	/* id */
+};
+
+static PurpleMediaElementInfo default_video_sink =
+{
+	"pidgindefaultvideosink",	/* id */
+};
+
+static PurpleMediaElementInfo default_audio_src =
+{
+	"pidgindefaultaudiosrc",	/* id */
+};
+
+static PurpleMediaElementInfo default_audio_sink =
+{
+	"pidgindefaultaudiosink",	/* id */
+};
+
 void
 pidgin_medias_init(void)
 {
-	g_signal_connect(G_OBJECT(purple_media_manager_get()), "init-media",
+	PurpleMediaManager *manager = purple_media_manager_get();
+	g_signal_connect(G_OBJECT(manager), "init-media",
 			 G_CALLBACK(pidgin_media_new_cb), NULL);
+
+	purple_debug_info("gtkmedia", "Registering media element types\n");
+	purple_media_manager_register_element(manager, &default_video_src);
+	purple_media_manager_register_element(manager, &default_video_sink);
+	purple_media_manager_register_element(manager, &default_audio_src);
+	purple_media_manager_register_element(manager, &default_audio_sink);
 }
 
 #endif  /* USE_VV */


More information about the Commits mailing list