changeset 26129:7acca8d51421

Limit the size and framerate of the video source.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 26 Feb 2009 06:08:51 +0000
parents 20c16e29f364
children 1ae8629f29dc
files libpurple/media.c
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Wed Feb 25 09:20:20 2009 +0000
+++ b/libpurple/media.c	Thu Feb 26 06:08:51 2009 +0000
@@ -1606,9 +1606,10 @@
 void
 purple_media_video_init_src(GstElement **sendbin)
 {
-	GstElement *src;
+	GstElement *src, *videoscale, *capsfilter;
 	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(
@@ -1618,14 +1619,23 @@
 
 	*sendbin = gst_bin_new("purplesendvideobin");
 	src = gst_element_factory_make(video_plugin, "purplevideosource");
-	gst_bin_add(GST_BIN(*sendbin), src);
+	videoscale = gst_element_factory_make("videoscale", NULL);
+	capsfilter = gst_element_factory_make("capsfilter", NULL);
+
+	/* It was recommended to set the size < 352x288 and framerate < 20 */
+	caps = gst_caps_from_string("video/x-raw-yuv , width=[250,350] , "
+			"height=[200,275] , framerate=[10/1,20/1]");
+	g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL);
+
+	gst_bin_add_many(GST_BIN(*sendbin), src, videoscale, capsfilter, NULL);
+	gst_element_link_many(src, videoscale, capsfilter, NULL);
 
 	if (!strcmp(video_plugin, "videotestsrc")) {
 		/* unless is-live is set to true it doesn't throttle videotestsrc */
 		g_object_set (G_OBJECT(src), "is-live", TRUE, NULL);
 	}
 
-	pad = gst_element_get_static_pad(src, "src");
+	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);