changeset 26413:a198f064a42c

Use better choices for default elements and have fallbacks.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Fri, 03 Apr 2009 05:02:57 +0000
parents 86c5499f36e8
children a820c03b9d4e
files pidgin/gtkmedia.c
diffstat 1 files changed, 48 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkmedia.c	Fri Apr 03 04:40:36 2009 +0000
+++ b/pidgin/gtkmedia.c	Fri Apr 03 05:02:57 2009 +0000
@@ -957,13 +957,25 @@
 	GstPad *pad;
 	GstPad *ghost;
 	GstCaps *caps;
-	const gchar *video_plugin = purple_prefs_get_string(
-			"/purple/media/video/plugin");
-	const gchar *video_device = purple_prefs_get_string(
-			"/purple/media/video/device");
+
+	src = gst_element_factory_make("gconfvideosrc", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("autovideosrc", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("v4l2src", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("v4lsrc", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("ksvideosrc", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("dshowvideosrc", NULL);
+	if (src == NULL) {
+		purple_debug_error("gtkmedia", "Unable to find a suitable "
+				"element for the default video source.\n");
+		return NULL;
+	}
 
 	sendbin = gst_bin_new("pidgindefaultvideosrc");
-	src = gst_element_factory_make(video_plugin, "purplevideosource");
 	videoscale = gst_element_factory_make("videoscale", NULL);
 	capsfilter = gst_element_factory_make("capsfilter", NULL);
 
@@ -976,19 +988,11 @@
 			videoscale, capsfilter, NULL);
 	gst_element_link_many(src, videoscale, capsfilter, NULL);
 
-	if (!strcmp(video_plugin, "videotestsrc")) {
-		/* Set is-live to true to throttle videotestsrc */
-		g_object_set (G_OBJECT(src), "is-live", TRUE, NULL);
-	}
-
 	pad = gst_element_get_static_pad(capsfilter, "src");
 	ghost = gst_ghost_pad_new("ghostsrc", pad);
 	gst_object_unref(pad);
 	gst_element_add_pad(sendbin, ghost);
 
-	if (video_device != NULL && strcmp(video_device, ""))
-		g_object_set(G_OBJECT(src), "device", video_device, NULL);
-
 	return sendbin;
 }
 
@@ -996,7 +1000,13 @@
 create_default_video_sink(PurpleMedia *media,
 		const gchar *session_id, const gchar *participant)
 {
-	return gst_element_factory_make("autovideosink", NULL);
+	GstElement *sink = gst_element_factory_make("gconfvideosink", NULL);
+	if (sink == NULL)
+		sink = gst_element_factory_make("autovideosink", NULL);
+	if (sink == NULL)
+		purple_debug_error("gtkmedia", "Unable to find a suitable "
+				"element for the default video sink.\n");
+	return sink;
 }
 
 static GstElement *
@@ -1005,13 +1015,25 @@
 {
 	GstElement *bin, *src, *volume, *level;
 	GstPad *pad, *ghost;
-	const gchar *audio_device = purple_prefs_get_string(
-			"/purple/media/audio/device");
 	double input_volume = purple_prefs_get_int(
 			"/purple/media/audio/volume/input")/10.0;
 
+	src = gst_element_factory_make("gconfaudiosrc", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("autoaudiosrc", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("alsasrc", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("osssrc", NULL);
+	if (src == NULL)
+		src = gst_element_factory_make("dshowaudiosrc", NULL);
+	if (src == NULL) {
+		purple_debug_error("gtkmedia", "Unable to find a suitable "
+				"element for the default audio source.\n");
+		return NULL;
+	}
+
 	bin = gst_bin_new("pidgindefaultaudiosrc");
-	src = gst_element_factory_make("alsasrc", "asrc");
 	volume = gst_element_factory_make("volume", "purpleaudioinputvolume");
 	g_object_set(volume, "volume", input_volume, NULL);
 	level = gst_element_factory_make("level", "sendlevel");
@@ -1023,9 +1045,6 @@
 	gst_element_add_pad(bin, ghost);
 	g_object_set(G_OBJECT(level), "message", TRUE, NULL);
 
-	if (audio_device != NULL && strcmp(audio_device, ""))
-		g_object_set(G_OBJECT(src), "device", audio_device, NULL);
-
 	return bin;
 }
 
@@ -1038,8 +1057,16 @@
 	double output_volume = purple_prefs_get_int(
 			"/purple/media/audio/volume/output")/10.0;
 
+	sink = gst_element_factory_make("gconfaudiosink", NULL);
+	if (sink == NULL)
+		sink = gst_element_factory_make("autoaudiosink",NULL);
+	if (sink == NULL) {
+		purple_debug_error("gtkmedia", "Unable to find a suitable "
+				"element for the default audio sink.\n");
+		return NULL;
+	}
+
 	bin = gst_bin_new("pidginrecvaudiobin");
-	sink = gst_element_factory_make("alsasink", "asink");
 	volume = gst_element_factory_make("volume", "purpleaudiooutputvolume");
 	g_object_set(volume, "volume", output_volume, NULL);
 	level = gst_element_factory_make("level", "recvlevel");