changeset 26341:d01fb18be4d2

Move purple_media_get_devices to gtkprefs.c.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sun, 22 Mar 2009 22:34:01 +0000
parents 5e605a489d53
children 0c96ac2ea5f8
files libpurple/media.c libpurple/media.h pidgin/gtkprefs.c
diffstat 3 files changed, 89 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Sun Mar 22 22:14:16 2009 +0000
+++ b/libpurple/media.c	Sun Mar 22 22:34:01 2009 +0000
@@ -38,7 +38,6 @@
 
 #ifdef USE_VV
 
-#include <gst/interfaces/propertyprobe.h>
 #include <gst/farsight/fs-conference-iface.h>
 
 /** @copydoc _PurpleMediaSession */
@@ -1400,77 +1399,6 @@
 	}
 }
 
-GList*
-purple_media_get_devices(const gchar *plugin)
-{
-	GObjectClass *klass;
-	GstPropertyProbe *probe;
-	const GParamSpec *pspec;
-	GstElement *element = gst_element_factory_make(plugin, NULL);
-	GstElementFactory *factory;
-	const gchar *longname = NULL;
-	GList *ret = NULL;
-
-	if (element == NULL)
-		return NULL;
-
-	factory = gst_element_get_factory(element);
-
-	longname = gst_element_factory_get_longname(factory);
-	klass = G_OBJECT_GET_CLASS(element);
-
-	if (!g_object_class_find_property (klass, "device") ||
-			!GST_IS_PROPERTY_PROBE (element) ||
-			!(probe = GST_PROPERTY_PROBE (element)) ||
-			!(pspec = gst_property_probe_get_property (probe, "device"))) {
-		purple_debug_info("media", "Found source '%s' (%s) - no device\n",
-				longname, GST_PLUGIN_FEATURE (factory)->name);
-	} else {
-		gint n;
-		gchar *name;
-		GValueArray *array;
-
-		purple_debug_info("media", "Found devices\n");
-
-		/* Set autoprobe[-fps] to FALSE to avoid delays when probing. */
-		if (g_object_class_find_property (klass, "autoprobe")) {
-			g_object_set (G_OBJECT (element), "autoprobe", FALSE, NULL);
-			if (g_object_class_find_property (klass, "autoprobe-fps")) {
-				g_object_set (G_OBJECT (element), "autoprobe-fps", FALSE, NULL);
-			}
-		}
-
-		array = gst_property_probe_probe_and_get_values (probe, pspec);
-		if (array != NULL) {
-			for (n = 0 ; n < array->n_values ; n++) {
-				GValue *device = g_value_array_get_nth (array, n);
-				
-				ret = g_list_append(ret, g_value_dup_string(device));
-
-				g_object_set(G_OBJECT(element), "device",
-						g_value_get_string(device), NULL);
-				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));
-				g_free(name);
-			}
-			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);
-			}
-		}
-	}
-
-	gst_object_unref(element);
-	return ret;
-}
-
 void
 purple_media_audio_init_src(GstElement **sendbin, GstElement **sendlevel)
 {
--- a/libpurple/media.h	Sun Mar 22 22:14:16 2009 +0000
+++ b/libpurple/media.h	Sun Mar 22 22:34:01 2009 +0000
@@ -427,15 +427,6 @@
 		const gchar *participant);
 
 /**
- * Enumerates a list of devices.
- *
- * @param plugin The name of the GStreamer plugin from which to enumerate devices.
- *
- * @return The list of enumerated devices.
- */
-GList *purple_media_get_devices(const gchar *plugin);
-
-/**
  * Creates a default audio source.
  *
  * @param sendbin Set to the newly created audio source.
--- a/pidgin/gtkprefs.c	Sun Mar 22 22:14:16 2009 +0000
+++ b/pidgin/gtkprefs.c	Sun Mar 22 22:34:01 2009 +0000
@@ -57,6 +57,10 @@
 #include "gtkutils.h"
 #include "pidginstock.h"
 
+#ifdef USE_VV
+#include <gst/interfaces/propertyprobe.h>
+#endif
+
 #define PROXYHOST 0
 #define PROXYPORT 1
 #define PROXYUSER 2
@@ -2401,13 +2405,97 @@
 }
 
 #ifdef USE_VV
+static GList*
+get_devices(const gchar *plugin)
+{
+	GObjectClass *klass;
+	GstPropertyProbe *probe;
+	const GParamSpec *pspec;
+	GstElement *element = gst_element_factory_make(plugin, NULL);
+	GstElementFactory *factory;
+	const gchar *longname = NULL;
+	GList *ret = NULL;
+
+	if (element == NULL)
+		return NULL;
+
+	factory = gst_element_get_factory(element);
+
+	longname = gst_element_factory_get_longname(factory);
+	klass = G_OBJECT_GET_CLASS(element);
+
+	if (!g_object_class_find_property(klass, "device") ||
+			!GST_IS_PROPERTY_PROBE(element) ||
+			!(probe = GST_PROPERTY_PROBE(element)) ||
+			!(pspec = gst_property_probe_get_property(probe,
+					"device"))) {
+		purple_debug_info("media",
+				"Found source '%s' (%s) - no device\n",
+				longname, GST_PLUGIN_FEATURE (factory)->name);
+	} else {
+		gint n;
+		gchar *name;
+		GValueArray *array;
+
+		purple_debug_info("media", "Found devices\n");
+
+		/* Set autoprobe[-fps] to FALSE to avoid delays when probing. */
+		if (g_object_class_find_property (klass, "autoprobe")) {
+			g_object_set(G_OBJECT (element),
+					"autoprobe", FALSE, NULL);
+			if (g_object_class_find_property(klass,
+					"autoprobe-fps")) {
+				g_object_set(G_OBJECT(element),
+						"autoprobe-fps", FALSE, NULL);
+			}
+		}
+
+		array = gst_property_probe_probe_and_get_values(probe, pspec);
+		if (array != NULL) {
+			for (n = 0 ; n < array->n_values ; n++) {
+				GValue *device = g_value_array_get_nth(
+						array, n);
+				
+				ret = g_list_append(ret,
+						g_value_dup_string(device));
+
+				g_object_set(G_OBJECT(element), "device",
+						g_value_get_string(device),
+						NULL);
+				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));
+				g_free(name);
+			}
+			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);
+			}
+		}
+	}
+
+	gst_object_unref(element);
+	return ret;
+}
 
 /* get a GList of pairs name / device */
 static GList *
 get_device_items(const gchar *plugin)
 {
 	GList *ret = NULL;
-	GList *devices = purple_media_get_devices(plugin);
+	GList *devices = get_devices(plugin);
 	GstElement *element = gst_element_factory_make(plugin, NULL);
 
 	if (element == NULL)