maiku.vv: 15795959: Simplified purple_media_get_devices.
maiku at soc.pidgin.im
maiku at soc.pidgin.im
Sun Aug 31 23:30:37 EDT 2008
-----------------------------------------------------------------
Revision: 15795959595eb67365e1c7770e26bd14d7a8365f
Ancestor: 9b5648cbd3137d2757685cdacb98392b442ae309
Author: maiku at soc.pidgin.im
Date: 2008-09-01T03:18:26
Branch: im.pidgin.maiku.vv
URL: http://d.pidgin.im/viewmtn/revision/info/15795959595eb67365e1c7770e26bd14d7a8365f
Modified files:
libpurple/media.c libpurple/media.h pidgin/gtkprefs.c
ChangeLog:
Simplified purple_media_get_devices.
-------------- next part --------------
============================================================
--- libpurple/media.c 9f46e60aab5a966d87b9651d9b5bfda608fb0eec
+++ libpurple/media.c 941cd561f2aa4fe43bbe9dd8cb0df1ac4d7d56e8
@@ -756,18 +756,20 @@ GList*
}
GList*
-purple_media_get_devices(GstElement *element)
+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;
- GstElementFactory *factory =
- gst_element_get_factory(element);
+ if (element == NULL)
+ return NULL;
- GList *ret = NULL;
+ factory = gst_element_get_factory(element);
longname = gst_element_factory_get_longname(factory);
klass = G_OBJECT_GET_CLASS(element);
@@ -800,6 +802,8 @@ purple_media_get_devices(GstElement *ele
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,
@@ -818,6 +822,7 @@ purple_media_get_devices(GstElement *ele
}
}
+ gst_object_unref(element);
return ret;
}
============================================================
--- libpurple/media.h bbb2dc85a1c2c66e024b7172db6100016297d3e1
+++ libpurple/media.h 359360edf6edcbcd4d69e7da23e83f2565a76870
@@ -287,11 +287,11 @@ void purple_media_got_accept(PurpleMedia
/**
* Enumerates a list of devices.
*
- * @param element The plugin from which to enumerate 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(GstElement *element);
+GList *purple_media_get_devices(const gchar *plugin);
/**
* Gets the device the plugin is currently set to.
============================================================
--- pidgin/gtkprefs.c 12dee598c148be73cae4fa2b7f2b8f8b9a0e57ba
+++ pidgin/gtkprefs.c fc0d1916618edaf87adbdb8b66a0d8a59b2639bc
@@ -2024,18 +2024,24 @@ static GList *
/* get a GList of pairs name / device */
static GList *
-get_device_items(const GstElement *element,
- const GList *devices)
+get_device_items(const gchar *plugin)
{
GList *ret = NULL;
+ GList *devices = purple_media_get_devices(plugin);
+ GstElement *element = gst_element_factory_make(plugin, NULL);
- for(; devices ; devices = devices->next) {
+ if (element == NULL)
+ return NULL;
+
+ for(; devices ; devices = g_list_delete_link(devices, devices)) {
gchar *name;
+ g_object_set(G_OBJECT(element), "device", devices->data, NULL);
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));
+ ret = g_list_append(ret, devices->data);
}
+ gst_object_unref(element);
return ret;
}
@@ -2122,20 +2128,9 @@ 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 = gst_element_factory_make(plugin, NULL);
- GList *video_items = NULL;
+ GList *video_items = get_device_items(plugin);
GList *list;
- if (video != NULL) {
- GList *video_devices = purple_media_get_devices(video);
- video_items = get_device_items(video, video_devices);
- for(; video_devices; video_devices = g_list_delete_link(
- video_devices, video_devices)) {
- g_free(video_devices->data);
- }
- gst_object_unref(video);
- }
-
if (video_items == NULL) {
video_items = g_list_prepend(video_items, g_strdup(""));
video_items = g_list_prepend(video_items, g_strdup("Default"));
@@ -2229,33 +2224,9 @@ media_page()
GtkSizeGroup *sg, *sg2;
const char *plugin = purple_prefs_get_string("/purple/media/video/plugin");
const char *device = purple_prefs_get_string("/purple/media/video/device");
+ GList *video_items = get_device_items(plugin);
+ GList *audio_items = get_device_items("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;
-
- if (video != NULL) {
- GList *video_devices = purple_media_get_devices(video);
- video_items = get_device_items(video, video_devices);
- for(; video_devices; video_devices = g_list_delete_link(
- video_devices, video_devices)) {
- g_free(video_devices->data);
- }
- gst_object_unref(video);
- }
-
- if (audio != NULL) {
- GList *audio_devices = purple_media_get_devices(audio);
- audio_items = get_device_items(audio, audio_devices);
- for(; audio_devices; audio_devices = g_list_delete_link(
- audio_devices, audio_devices)) {
- g_free(audio_devices->data);
- }
- gst_object_unref(audio);
- }
-
if (video_items == NULL) {
video_items = g_list_prepend(video_items, "");
video_items = g_list_prepend(video_items, "Default");
More information about the Commits
mailing list