Mercurial > pidgin.yaz
changeset 31551:4ce69a55f2c6
Add a GstCapsFilter between every video source and the rest of the pipeline.
This will force the sources to have the same capaibilties as the
"pidgindefaultvideosrc" and should reduce CPU usage as well. Refs #13095.
committer: John Bailey <rekkanoryo@rekkanoryo.org>
author | jakub.adam@ktknet.cz |
---|---|
date | Fri, 07 Jan 2011 11:38:12 +0000 |
parents | ac2cf73dbab8 |
children | 43ab38a1f55c |
files | libpurple/mediamanager.c pidgin/gtkmedia.c |
diffstat | 2 files changed, 35 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/mediamanager.c Thu Jan 06 20:43:12 2011 +0000 +++ b/libpurple/mediamanager.c Fri Jan 07 11:38:12 2011 +0000 @@ -81,6 +81,7 @@ GList *output_windows; gulong next_output_window_id; GType backend_type; + GstCaps *video_caps; PurpleMediaElementInfo *video_src; PurpleMediaElementInfo *video_sink; @@ -191,6 +192,8 @@ g_list_delete_link(priv->elements, priv->elements)) { g_object_unref(priv->elements->data); } + if (priv->video_caps) + gst_caps_unref(priv->video_caps); parent_class->finalize(media); } #endif @@ -414,6 +417,20 @@ #endif #ifdef USE_GSTREAMER + +static GstCaps * +purple_media_manager_get_video_caps(PurpleMediaManager *manager) +{ +#ifdef USE_VV + if (manager->priv->video_caps == NULL) + manager->priv->video_caps = gst_caps_from_string("video/x-raw-yuv," + "width=[250,352], height=[200,288], framerate=[1/1,20/1]"); + return manager->priv->video_caps; +#else + return NULL; +#endif +} + GstElement * purple_media_manager_get_element(PurpleMediaManager *manager, PurpleMediaSessionType type, PurpleMedia *media, @@ -456,7 +473,21 @@ bin = gst_bin_new(id); tee = gst_element_factory_make("tee", "tee"); gst_bin_add_many(GST_BIN(bin), ret, tee, NULL); - gst_element_link(ret, tee); + + if (type & PURPLE_MEDIA_SEND_VIDEO) { + GstElement *videoscale; + GstElement *capsfilter; + + videoscale = gst_element_factory_make("videoscale", NULL); + capsfilter = gst_element_factory_make("capsfilter", "prpl_video_caps"); + + g_object_set(G_OBJECT(capsfilter), + "caps", purple_media_manager_get_video_caps(manager), NULL); + + gst_bin_add_many(GST_BIN(bin), videoscale, capsfilter, NULL); + gst_element_link_many(ret, videoscale, capsfilter, tee, NULL); + } else + gst_element_link(ret, tee); /* * This shouldn't be necessary, but it stops it from
--- a/pidgin/gtkmedia.c Thu Jan 06 20:43:12 2011 +0000 +++ b/pidgin/gtkmedia.c Fri Jan 07 11:38:12 2011 +0000 @@ -932,10 +932,9 @@ create_default_video_src(PurpleMedia *media, const gchar *session_id, const gchar *participant) { - GstElement *sendbin, *src, *videoscale, *capsfilter; + GstElement *sendbin, *src; GstPad *pad; GstPad *ghost; - GstCaps *caps; #ifdef _WIN32 /* autovideosrc doesn't pick ksvideosrc for some reason */ @@ -960,19 +959,10 @@ } sendbin = gst_bin_new("pidgindefaultvideosrc"); - 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,352] , " - "height=[200,288] , framerate=[1/1,20/1]"); - g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL); + gst_bin_add(GST_BIN(sendbin), src); - gst_bin_add_many(GST_BIN(sendbin), src, - videoscale, capsfilter, NULL); - gst_element_link_many(src, videoscale, capsfilter, NULL); - - pad = gst_element_get_static_pad(capsfilter, "src"); + pad = gst_element_get_static_pad(src, "src"); ghost = gst_ghost_pad_new("ghostsrc", pad); gst_object_unref(pad); gst_element_add_pad(sendbin, ghost);