maiku.vv: 02acccad: Removed several PurpleMedia functions th...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sun Aug 31 23:30:30 EDT 2008


-----------------------------------------------------------------
Revision: 02acccad66e0b515ba3778e5a4a5165cc16ba9fb
Ancestor: 72eee5a8eb953a0288ff1c62f9d44f2110e0d227
Author: maiku at soc.pidgin.im
Date: 2008-08-31T22:46:16
Branch: im.pidgin.maiku.vv
URL: http://d.pidgin.im/viewmtn/revision/info/02acccad66e0b515ba3778e5a4a5165cc16ba9fb

Modified files:
        libpurple/media.c libpurple/media.h pidgin/gtkprefs.c

ChangeLog: 

Removed several PurpleMedia functions that now seem unnecessary:
 * purple_media_get_device_name
 * purple_media_get_element
 * purple_media_element_set_device
 * purple_media_element_set_device_from_name (didn't exist)

-------------- next part --------------
============================================================
--- libpurple/media.c	2bcf57927b7f6f3e44faad930d37fc95851dc301
+++ libpurple/media.c	5ec1e4456334216b7b6b091062e2c4c4e35e2b15
@@ -750,21 +750,6 @@ purple_media_got_accept(PurpleMedia *med
     g_signal_emit(media, purple_media_signals[GOT_ACCEPT], 0);
 }
 
-gchar*
-purple_media_get_device_name(GstElement *element, const gchar *device)
-{
-	gchar *name;
-
-	GstElementFactory *factory = gst_element_get_factory(element);
-	GstElement *temp = gst_element_factory_create(factory, "tmp_src");
-
-	g_object_set(G_OBJECT (temp), "device", device, NULL);
-	g_object_get(G_OBJECT (temp), "device-name", &name, NULL);
-	gst_object_unref(temp);
-
-	return name;
-}
-
 GList*
 purple_media_get_devices(GstElement *element)
 {
@@ -807,12 +792,10 @@ purple_media_get_devices(GstElement *ele
 		if (array != NULL) {
 			for (n = 0 ; n < array->n_values ; n++) {
 				GValue *device = g_value_array_get_nth (array, n);
-				gst_element_set_state (element, GST_STATE_NULL);
 				
 				ret = g_list_append(ret, g_value_dup_string(device));
 
-				name = purple_media_get_device_name(GST_ELEMENT(element),
-						g_value_get_string(device));
+				g_object_get(G_OBJECT(element), "device-name", &name, NULL);
 				purple_debug_info("media", "Found source '%s' (%s) - device '%s' (%s)\n",
 						  longname, GST_PLUGIN_FEATURE (factory)->name,
 						  name, g_value_get_string(device));
@@ -833,12 +816,6 @@ purple_media_get_devices(GstElement *ele
 	return ret;
 }
 
-void
-purple_media_element_set_device(GstElement *element, const gchar *device)
-{
-	g_object_set(G_OBJECT(element), "device", device, NULL);
-}
-
 gchar *
 purple_media_element_get_device(GstElement *element)
 {
@@ -847,20 +824,6 @@ purple_media_element_get_device(GstEleme
 	return device;
 }
 
-GstElement *
-purple_media_get_element(const gchar *factory_name)
-{
-	GstElementFactory *factory = gst_element_factory_find(factory_name);
-	GstElement *element;
-
-	if (factory == NULL)
-		return NULL;
-
-	element = gst_element_factory_create(factory, NULL);
-	gst_object_unref(factory);
-	return element;
-}
-
 void
 purple_media_audio_init_src(GstElement **sendbin, GstElement **sendlevel)
 {
@@ -886,21 +849,8 @@ purple_media_audio_init_src(GstElement *
 	gst_element_add_pad(*sendbin, ghost);
 	g_object_set(G_OBJECT(*sendlevel), "message", TRUE, NULL);
 
-	/* set current audio device on "src"... */
-	if (audio_device) {
-		GList *devices = purple_media_get_devices(src);
-		GList *dev = devices;
-		purple_debug_info("media", "Setting device of GstElement src to %s\n",
-				audio_device);
-		for (; dev ; dev = dev->next) {
-			gchar *device = (gchar *) dev->data;
-			char *name = purple_media_get_device_name(src, device);
-			if (strcmp(name, audio_device) == 0) {
-				purple_media_element_set_device(src, device);
-			}
-			g_free(name);
-		}
-	}
+	if (audio_device != NULL && strcmp(audio_device, ""))
+		g_object_set(G_OBJECT(src), "device", audio_device, NULL);
 }
 
 void
@@ -945,21 +895,8 @@ purple_media_video_init_src(GstElement *
 	gst_bin_add(GST_BIN(*sendbin), local_sink);
 	gst_element_link(queue, local_sink);
 
-	/* set current video device on "src"... */
-	if (video_device) {
-		GList *devices = purple_media_get_devices(src);
-		GList *dev = devices;
-		purple_debug_info("media", "Setting device of GstElement src to %s\n",
-				video_device);
-		for (; dev ; dev = dev->next) {
-			gchar *device = (gchar *) dev->data;
-			char *name = purple_media_get_device_name(src, device);
-			if (strcmp(name, video_device) == 0) {
-				purple_media_element_set_device(src, device);
-			}
-			g_free(name);
-		}
-	}
+	if (video_device != NULL && strcmp(video_device, ""))
+		g_object_set(G_OBJECT(src), "device", video_device, NULL);
 }
 
 void
============================================================
--- libpurple/media.h	ec07949cb9cf8449f33bcf16b475edcffa43d662
+++ libpurple/media.h	1f5b85519f4c4f950563bff8d3e932590f41b309
@@ -285,17 +285,6 @@ void purple_media_got_accept(PurpleMedia
 void purple_media_got_accept(PurpleMedia *media);
 
 /**
- * Gets the name of a device.
- *
- * @param element The plugin the device is from.
- * @param device The device data to retreive the name from.
- *
- * @return The name of the device.
- */
-gchar *purple_media_get_device_name(GstElement *element,
-				    const gchar *device);
-
-/**
  * Enumerates a list of devices.
  *
  * @param element The plugin from which to enumerate devices.
@@ -305,23 +294,6 @@ GList *purple_media_get_devices(GstEleme
 GList *purple_media_get_devices(GstElement *element);
 
 /**
- * Sets the device to be used with the particular plugin.
- *
- * @param element The plugin to set the device on.
- * @param device The device to set the plugin to.
- */
-void purple_media_element_set_device(GstElement *element, const gchar *device);
-
-/**
- * Sets the device from the given name.
- *
- * @param element The plugin to set the device on.
- * @param name The name of the device to set the plugin to.
- */
-void purple_media_element_set_device_from_name(GstElement *element,
-					       const gchar *name);
-
-/**
  * Gets the device the plugin is currently set to.
  *
  * @param element The plugin to retrieve the device from.
@@ -331,15 +303,6 @@ gchar *purple_media_element_get_device(G
 gchar *purple_media_element_get_device(GstElement *element);
 
 /**
- * Creates an element from a factory name.
- *
- * @param factory_name Name of the factory to create an element from.
- *
- * @return The element that was created, NULL if it couldn't find the factory.
- */
-GstElement *purple_media_get_element(const gchar *factory_name);
-
-/**
  * Creates a default audio source.
  *
  * @param sendbin Set to the newly created audio source.
============================================================
--- pidgin/gtkprefs.c	ad2b201a7d8b7e97aef45ee70563ceb6d0cd2f90
+++ pidgin/gtkprefs.c	12dee598c148be73cae4fa2b7f2b8f8b9a0e57ba
@@ -2030,7 +2030,8 @@ get_device_items(const GstElement *eleme
 	GList *ret = NULL;
 
 	for(; devices ; devices = devices->next) {
-		gchar *name = purple_media_get_device_name(GST_ELEMENT(element), devices->data);
+		gchar *name;
+		g_object_get(G_OBJECT(element), "device-name", &name, NULL);
 		ret = g_list_append(ret, name);
 		ret = g_list_append(ret, g_strdup(devices->data));
 	}
@@ -2121,7 +2122,7 @@ media_plugin_changed_cb(const gchar *nam
 	GtkWidget *preview_button = NULL;
 	const char *plugin = value;
 	const char *device = purple_prefs_get_string("/purple/media/video/device");
-	GstElement *video = purple_media_get_element(plugin);
+	GstElement *video = gst_element_factory_make(plugin, NULL);
 	GList *video_items = NULL;
 	GList *list;
 
@@ -2229,8 +2230,8 @@ media_page()
 	const char *plugin = purple_prefs_get_string("/purple/media/video/plugin");
 	const char *device = purple_prefs_get_string("/purple/media/video/device");
 
-	GstElement *video = purple_media_get_element(plugin);
-	GstElement *audio = purple_media_get_element("alsasrc");
+	GstElement *video = gst_element_factory_make(plugin, NULL);
+	GstElement *audio = gst_element_factory_make("alsasrc", NULL);
 
 	GList *video_items = NULL;
 	GList *audio_items = NULL;


More information about the Commits mailing list